sipsorcery icon indicating copy to clipboard operation
sipsorcery copied to clipboard

Multiple Webrtc clients to same source

Open mateusz-osojca opened this issue 2 years ago • 3 comments

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?

mateusz-osojca avatar Aug 18 '22 10:08 mateusz-osojca

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

ChristopheI avatar Aug 18 '22 12:08 ChristopheI

Not really clients are on different machines. And I have multiple connections but Im wondering whether they all may be done to one VideoSource?

mateusz-osojca avatar Aug 18 '22 13:08 mateusz-osojca

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.

ChristopheI avatar Aug 23 '22 08:08 ChristopheI