问题
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