Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebRTC: Renegotiation in firefox

Tags:

firefox

webrtc

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?

like image 300
mido Avatar asked Jul 10 '15 10:07

mido


People also ask

What is renegotiation WebRTC?

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.

What is Onnegotiationneeded?

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.

What is WebRTC offer?

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.


1 Answers

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.

like image 112
jib Avatar answered Sep 17 '22 21:09

jib