[webrtc-pc] How to handle removing and re-adding remote streams/tracks - possible ID collisions?

henbos has just created a new issue for https://github.com/w3c/webrtc-pc:

== How to handle removing and re-adding remote streams/tracks - possible ID collisions? ==
Let's say you do this... (see code snippet) Will we end up with the same stream and track objects as after the first SRD call or will we end up with new stream and track objects that have the same ID as the original ones?
```
var initialTrack;
pc.ontrack = function(e) {
  console.log(e.track.id);
  initialTrack = e.track;
}
pc.setRemoteDescription() such that stream x with track y is added
pc.setRemoteDescription() such that stream x with track y is removed
pc.ontrack = function(e) {
  console.log(e.track.id);
  console.log(e.track == initialTrack);
}
pc.setRemoteDescription() such that stream x with track y is added
```
Should the log be "y y true" or "y y false"?

The processing of the addition/removal of remote tracks says "For each MSID in msids, unless a MediaStream object has previously been created with that id for this connection, create a MediaStream object with that id." This would suggest we reuse streams, but the context here is adding and removing streams from the pc, it's unclear if this should apply to streams created in the past that no longer are part of the pc.

As for the tracks, step 8.2. of setting a session description describes trying to reuse existing inactive transceivers but if it doesn't find a transceiver, creating a new transceiver means creating a new track with the given ID. Are transceivers guaranteed to be reused such that we get no ID collision?

In any case with multiple RTCPeerConnection objects we could end up with streams and tracks that have colliding IDs with streams and tracks created by other PCs. I suspect this could lead to behavior where multiple stream/track objects behave as if they are the same by APIs looking at their IDs but they could have different states.

Please view or discuss this issue at https://github.com/w3c/webrtc-pc/issues/1562 using your GitHub account

Received on Monday, 28 August 2017 14:23:32 UTC