8

I am dealing with a RTCPeerConnection (pc) which has an event handler named onnegotiationneeded.

The "onnegotiationneeded" is triggered when a complete media stream is added or removed with pc.addStream or pc.removeStream.

Is it possible to tell inside the onnegotiationneeded function if it has been executed because the stream was added or removed? Because from reading the docs I couldn't find a state for that.

At the moment I am switching a flag when I do pc.addStream or pc.removeStream. This flag helps me to tell within onnegotiationneeded if it has been triggered by a stream remove or not.

But I was wondering if there is already such a property given by the browser's (Chrome 40 or Firefox 36) API?

Benny Code
  • 51,456
  • 28
  • 233
  • 198

1 Answers1

0

The MDN documentation for the onnegotiationneeded handler states:

This should be set to a function you provide which is passed a single parameter: an Event object containing the negotiationneeded event. There's no additional information provided in the event; anything you need, you can get by examining the properties of the RTCPeerConnection.

So basically, you cannot do it by the callback alone. But you may be able to use it with the onstreamadded or onstreamremoved handler

You may find a comfortable solution for keeping track of added tracks and streams here.

Andrew Myers
  • 2,754
  • 5
  • 32
  • 40
nasskalte.juni
  • 433
  • 3
  • 14