Re: [webrtc-pc] When to fire events triggered by setRemoteDescription.

But what about this?

```
let processedStreams = new Set();
pc.setRemoteDescription() with "stream: { track1, track2 }"
pc.ontrack = e => {
  e.streams.forEach(stream => {
    if (!processedStreams.has(stream)) {
      // New remote stream!
      processStream(stream);
      processedStreams.add(stream);
    }
  });
}
```

This will fire ontrack twice, once for "track1" and once for "track2", both are added to "stream".
If defer all operations, not just their events firing, then when track1's event fires stream.getTracks() will only contain track1. Only in the second event is stream.getTracks() representing the complete picture. And we have no idea of knowing when the last stream has been added.

processStream() would not be able to look at stream.getTracks() without getting confusing results. Any application wanting to process remote streams and be able to use getTracks() would have to:
1. Add all new streams to a list.
2. After SRD has resolved, then handle the processing of all new streams.

What about POLA-violation "_That's not what the remote stream looks like!_" at processStream()? There was never a remote stream that only contained track1; the event describes details of the machinery, not the final result.

-- 
GitHub Notification of comment by henbos
Please view or discuss this issue at https://github.com/w3c/webrtc-pc/issues/1691#issuecomment-354347809 using your GitHub account

Received on Thursday, 28 December 2017 19:48:40 UTC