Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I re-use an "offer" in WebRTC for mulitple connections?

I'm starting to learn WebRTC and have a working prototype using copy/paste here: https://github.com/aerik/webrtc (the prototype is meant to be run in two browser windows, unlike many other examples that run both sides in one window)

I understand that WebRTC is peer-to-peer and a I need a connection for every set of peers. However, I'm starting to think about signalling (no code yet) and I'm wondering about the "offer". In my prototype I see that clicking "create offer" multiple times results in the same string. So, if have client A, and connect to client B and C, it looks like I will send the same "offer" to both of them. If that's correct, it makes the first step of signalling easy - client A will always have the same offer, and I just have to gather responses from connected peers.

Is this a correct understanding?

like image 923
Aerik Avatar asked Dec 09 '15 22:12

Aerik


1 Answers

It is not, a peer connection will generate different origin values for different offers (o= in the SDP).

Same peer connection offers will contain same <sess-id> but different <sess-version>.

Different peer connections will produce different <sess-id>

You can check it with the following snippet in Chrome:

var a = new webkitRTCPeerConnection({});
a.createOffer().then(offer => $('#11').text(offer.sdp));
a.createOffer().then(offer => $('#12').text(offer.sdp));
var b = new webkitRTCPeerConnection({});
b.createOffer().then(offer => $('#21').text(offer.sdp));
b.createOffer().then(offer => $('#22').text(offer.sdp));
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
First PC, first offer: <span id="11"></span><br/>
First PC, second offer: <span id="12"></span><br/>
Second PC, first offer: <span id="21"></span><br/>
Second PC, second offer: <span id="22"></span><br/>

You can find more info about the SDP in https://datatracker.ietf.org/doc/html/rfc4566#page-11

like image 172
Javier Conde Avatar answered Nov 08 '22 15:11

Javier Conde