According to this article, re-negotiation is implemented in firefox v38 and we can add remove streams from same peerconnections without creating new ones, but I am unable to find any working demos to support that claim, and when I tried it, two users chating in video mode, I changing one of their stream to audio
, I get the error:
NotSupportedError: removeStream not yet implemented
this tells the same, but this tells renegotiation events are supported, but isn't removeStream
key part of renegotiation? I am using firefox version 39 in windows 7. I am confused, renegotiation is not yet supported in firefox, right?
Renegotiation is a process allows you modify pre-created peer connections when you want to: append additional streams. remove existing streams. modify SDP for peers direction or something else.
onnegotiationneeded. The RTCPeerConnection interface's onnegotiationneeded property is an EventListener which specifies a function which is called to handle the negotiationneeded event when it occurs on an RTCPeerConnection instance. This event is fired when a change has occurred which requires session negotiation.
When a user starts a WebRTC call to another user, a special description is created called an offer. This description includes all the information about the caller's proposed configuration for the call. The recipient then responds with an answer, which is a description of their end of the call.
Renegotiation is supported in Firefox.
Firefox just never implemented removeStream
because the spec had changed to addTrack
and removeTrack
by the time renegotiation was implemented (some are suggesting that its removal was too hasty, so it may come back). addStream
still works for backwards compatibility, because Firefox already supported it.
Note that removeTrack
confusingly takes the RTCRtpSender returned from addTrack
so the API is not a drop-in.
A polyfill would look something like this:
mozRTCPeerConnection.prototype.removeStream = function(stream) {
this.getSenders().forEach(sender =>
stream.getTracks().includes(sender.track) && this.removeTrack(sender));
}
The move to tracks was done to give users more flexibility, since tracks may belong to multiple streams, and not all tracks in a stream need be sent over a PeerConnection (or the same PeerConnection).
See this answer to a different question for a renegotiation example that works in Firefox.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With