mediasoup-client: Peer to Peer

So I’ve been observing that the basic unit of exchange between the server and the client are sdps - I’ve seen that they are printed out to the console everytime we add or remove a producer or a consumer.

Would it be possible that in a 2 peer scenario, we generate and exchange those sdps so that two mediasoup-client instances talk directly to each other instead of passing through mediasoup?

Thanks.

Really? Where do you see that in mediasoup?

1 Like

Mediasoup does set and read SDPs in the browser under the hood, but it doesn’t transmit them over the network between client and server. You will not find SDPs in the docs anywhere.
If you want to switch between SFU/P2P on the fly you need to build additional logic for that in your app and mediasoup-client is not needed in the case of P2P connection, you can just send SDPs.

2 Likes

That’s where I observed them. And I might be totally off because of inadequate knowledge, I would love to be corrected. Here is where I’m coming from.

Webrtc uses the PeerConnection object to connect to a remote endpoint, the remote end point can be either another browser or an SFU or an MCU or whatever. The only thing that ensures a connection between the two is an offer and an answer.

In my knowledge mediasoup internally negotiates an SDP with the server whenever a new consumer or a new producer is added, that’s why anytime i enableShare or enable/disable microphone there’s an offer and an answer SDP exchanged. And it makes sense because even in a P2P connection if either one of the endpoints adds a new stream or a track ‘onnegotiationneeded’ is fired.

So I was just wondering if all of this is in place, should it be possible to make it peer to peer.

Thanks.

Okay. So you mean to say that the SDP that is passed to setRemoteDescription does not originate from the SFU, instead its generated locally and set. Well in that case how does it generate the SDP, since an SDP describes the data that is to be sent/received plus the codecs that are being used.

So for instance if I’m talking with 3 peers via the SFU and one of them adds a stream, how would my endpoint know the codecs and the bitrate and all of those parameters that I’m supposed to be receiving so that my end can generate an appropriate SDP for setRemoteDescription.

Thanks.

This is simpler: do not use mediasoup for one-to-one calls (unless you don’t mind the audio/video goes through a server).