sipsorcery
sipsorcery copied to clipboard
Multiple Webrtc clients to same source
I have rather question than the issue. I have the scenario where I have one server instance serving the video with multiple clients who may want to get it. Should all the clients consume same instance of IVideoSource implementation or basically I should create as many VideoSource instance (working exactly same way) as many clients are connected?
Clients are on the same PC/device ? If yes, you can create one connection to the server with only one implementation. Then dispatch the video stream to all clients
Not really clients are on different machines. And I have multiple connections but Im wondering whether they all may be done to one VideoSource?
Theoretically, you can only create one VideoSource.
Then when event OnVideoSourceEncodedSample is raised, you will send video to each client using the PeerConnection created for each of them:
private void VideoSource_OnVideoSourceEncodedSample(uint durationRtpUnits, byte[] sample)
{
PeerConnection_Remote1?.SendVideo(durationRtpUnits, sample);
PeerConnection_Remote2?.SendVideo(durationRtpUnits, sample);
etc ...
}
All this it's based on the fact that there is no bandwidth issues with your clients. In real, you have to deal with them.