How To Exchange Streams From Two Peerconnections With Offer/answer
Solution 1:
I think the problem is in step 3 where you have the offerer initiating when the answerer adds a video. In a real remote call, how would the offerer even know to do that?
As I understand it, when the answerer needs to renegotiate then the roles are effectively reversed, because for the purposes of renegotiation: the renegotiator acts as the offerer, while the non-renegotiator acts as the answerer.
In other words: the response to pc.onnegotiationneeded
is always:
createOffer()
,- then
setLocalDescription(description)
- then send
pc.localDescription
to the other side
regardless of side.
I'm not an authority on SDP, so I don't know for sure that this is the right approach, but the examples in the spec at least suggest to me that the steps above are right, and I got it working this way.
I've tested this out in this Firefox jsfiddle and it seems to work. Instructions for using the fiddle:
- There is no server (since it's a fiddle), so press the
Offer
button and copy the offer. - Paste the offer to the same spot in the same fiddle in another tab or on another machine.
- Press ENTER, then copy the answer you get and paste it back in the first fiddle.
- You are now connected with two data-channels: one for chat and another for signaling.
- Now press
addTrack
on either end and video should show up on the other end. - Press
addTrack
in the other direction, and you should have video going both ways.
Can this produce glare? I'm sure, and there may be better ways of handling this, but this seems to work for me.
Post a Comment for "How To Exchange Streams From Two Peerconnections With Offer/answer"