sthustfo
sthustfo

Reputation: 1239

webrtc onaddstream event handler - differentiate between multiple video streams

In a scenario where an endpoint adds multiple video streams to a peer connection, the onaddstream event handler is invoked multiple times on the peer end.

Is there any means by which an application (on the peer end) can determine between the different video streams (within onaddstream handler)? By identifying the stream, each stream can be associated with a different video element.

Upvotes: 0

Views: 362

Answers (1)

elbecita
elbecita

Reputation: 2664

RTCPeerConnection has a couple of methods:

These methods return an array of MediaStream's associated with the remote/local end of the connection. Every MediaStream has an id, so you will be able to identify them.

There is also getStreamById, but it is deprecated, replaced by the two above.

Upvotes: 1

Related Questions