[webrtc-pc] Clarify unmute event must fire on receiver.track AFTER sRD(offer) succeeds (#2880)

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

== Clarify unmute event must fire on receiver.track AFTER sRD(offer) succeeds ==
This invariant lets apps use `getReceivers()` to discover receivers added by sRD and attach event handlers in time. [E.g](https://jsfiddle.net/jib1/dvh0f3ja/18/):
```js
await pc.setRemoteDescription(offer);
const [receiver] = pc.getReceivers();
receiver.track.onunmute = () => {
  console.log("unmute fired");
  video.srcObject = new MediaStream([receiver.track]);
}
```

The spec already guarantees this:
1. [sRD](https://w3c.github.io/webrtc-pc/#ref-for-dfn-receptive-1)'s success task sets _"transceiver.[[[Receptive]]](https://w3c.github.io/webrtc-pc/#dfn-receptive) to true,"_
2. [and](https://w3c.github.io/webrtc-pc/#ref-for-dfn-receptive-4) _"Whenever an [RTCRtpReceiver](https://w3c.github.io/webrtc-pc/#dom-rtcrtpreceiver) receives data on an RTP source whose corresponding [MediaStreamTrack](https://www.w3.org/TR/mediacapture-streams/#dom-mediastreamtrack) is muted, but not ended, and the [[[Receptive]]](https://w3c.github.io/webrtc-pc/#dfn-receptive) slot of the [RTCRtpTransceiver](https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver) object the [RTCRtpReceiver](https://w3c.github.io/webrtc-pc/#dom-rtcrtpreceiver) is a member of is true, it MUST queue a task to [set the muted state](https://w3c.github.io/webrtc-pc/#set-track-muted) of the corresponding [MediaStreamTrack](https://www.w3.org/TR/mediacapture-streams/#dom-mediastreamtrack) to false."_

IOW, since step 2 queues a task to fire the event, it happens AFTER the sRD success callback.

Unfortunately, none of the examples show this, and [crbug 1295295](crbug.com/1295295) undermines this (fiddle above doesn't work in Chrome).

Shall we add an example and a note?

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


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Monday, 12 June 2023 20:45:04 UTC