How to tell if pc.onnegotiationneeded was fired because stream has been removed?
Asked Answered
P

1

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?

Pastelki answered 2/3, 2015 at 1:42 Comment(0)
V
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.

Vo answered 12/9, 2017 at 17:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.