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

六月ゝ 毕业季﹏ 提交于 2021-02-18 21:11:51

问题


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?


回答1:


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(function (offer) { $('#11').text(offer.sdp); });
a.createOffer(function (offer) { $('#12').text(offer.sdp); });
var b = new webkitRTCPeerConnection({});
b.createOffer(function (offer) { $('#21').text(offer.sdp); });
b.createOffer(function (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 http://tools.ietf.org/html/rfc4566#page-11



来源:https://stackoverflow.com/questions/34190152/can-i-re-use-an-offer-in-webrtc-for-mulitple-connections

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!