Reputation: 7912
In my application I heavily use renegotiation to add and remove local streams. Unfortunately, the use of renegotiation may drastically increase the number of race conditions when offers and answers are exchanged.
Let's consider the following scenario :
create a local offer without any local stream -- success setLocalDescription(offer) -- success user grant access to the video which causes renegotiation -- success create a local offer with local stream -- success setLocalDescription(offer) -- failed
The error thrown is :
Failed to set local offer sdp: Failed to push down transport description: Failed to set local identity.
If the statusSignal is "have-local-offer" I cannot call setLocalDescription?
What should be the right way to handle this situation?
I was thinking to delay the second offer ( containing the new local stream ) until the first answer/offer handshake is completed. This is not an optimal solution, but it should work. What do you think ?
Upvotes: 1
Views: 686
Reputation: 4793
I know from another question that it is not handy to attach the negotiation event handler directly as this wil trigger it twice (I don't know if that is in your case). What I tried was attaching the handler after I have successfully sent and received the SDP data. Then I caused negotiations by adding and removing streams and that works perfect. Also make sure that when you receive an SDP object you create a new RTCSessionDescription(<receivedObject>)
and then append that to pc.remoteDescription
.
Upvotes: 1