Skip to content
This repository has been archived by the owner on Mar 22, 2022. It is now read-only.

Share MediaSender track between more than one Transceiver #336

Closed
CabbageWarrior opened this issue May 12, 2020 · 3 comments
Closed

Share MediaSender track between more than one Transceiver #336

CabbageWarrior opened this issue May 12, 2020 · 3 comments
Labels
breaking change This change breaks the current API and requires migration enhancement New feature or request

Comments

@CabbageWarrior
Copy link

Describe the problem
In a Unity project, I'm trying to create a multi-peer scenario using a Mesh architecture (at the moment, this is a project requirement), so I have a peer connection for each couple of users. I'm sure I will have very few users per "room", so this is not actually a problem.
The problem is that I need to use the same media source for more than one PeerConnection, but I noticed that a MediaSender (eg. WebcamSource and MicrophoneSource) cannot be shared between more than one Transceiver.

Describe the solution you'd like
I'd like to know how I can use the same media source for more than one PeerConnection.

I thought that using an extra layer between the media source and the Transceiver that "duplicates" the data to send, something as a "CloneVideoSender" or "CloneAudioSender", could be an idea, but maybe there are better solutions I haven't considered yet.
Another idea could be to split the device (webcam or mic) capture logic from the Track logic and use the device capture to populate a new custom media sender type so that more media senders can read the output data from the device.

Describe alternatives you've considered
About the webcam, in order to be shared with more than one other peer, I considered rendering the webcam image in a dedicated MediaPlayer (not visible from the local user's camera) and then create N SceneVideoSender objects (one per PeerConnection) with their own cameras to capture the webcam image on the media player and share it with the others.

Unfortunately, about the microphone, I don't have any idea about how to share it more than one time. This is a problem because the voice chat is a mandatory requirement of the application.

The very last chance is to move the voice chat to a different service instead of the WebRTC component, with the risk to lose the sync between the video shared with WebRTC and the audio.


I hope I have written in an understandable way and that I have not left out important things in my analysis before writing this message.

I thank you as always for your help and for your work, and I wish you a good day!
Riccardo

@djee-ms
Copy link
Member

djee-ms commented May 12, 2020

Hi @CabbageWarrior,

Yes what you need is what the Google API offers, separate track source (frame producer, audio or video) from track (bridge between track source and a peer connection). This is something I was considering. On one hand it opens up the scenario you describe. On the other hand it complexifies our API a bit more. But really there's no clean solution other than that one to share a webcam/microphone.

@djee-ms djee-ms added breaking change This change breaks the current API and requires migration enhancement New feature or request labels May 12, 2020
@CabbageWarrior
Copy link
Author

You don't know how happy I am to have had a good idea! xD
I look forward to the next updates on this, for when there will be, and thank you again for the excellent work! ❤️

@djee-ms
Copy link
Member

djee-ms commented Jun 16, 2020

This is merged to master.

@djee-ms djee-ms closed this as completed Jun 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
breaking change This change breaks the current API and requires migration enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants