[webrtc-pc] Changing RTCRtpTransceiver direction from recvonly to sendrecv on the answerer side doesn't fire negotiationneeded event (#2919)

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

== Changing RTCRtpTransceiver direction from recvonly to sendrecv on the answerer side doesn't fire negotiationneeded event ==
5.3.3 in [checking if negotiation is needed](https://www.w3.org/TR/webrtc/#dfn-check-if-negotiation-is-needed) says:

> If description is of type "[answer](https://www.w3.org/TR/webrtc/#dom-rtcsdptype-answer)", and the direction of the [associated](https://www.w3.org/TR/webrtc/#dfn-associated) m= section in the description does not match transceiver.[[[Direction]]](https://www.w3.org/TR/webrtc/#dfn-direction) intersected with the offered direction (as described in [[RFC8829](https://www.w3.org/TR/webrtc/#bib-rfc8829)] ([section 5.3.1.](https://datatracker.ietf.org/doc/html/rfc8829#section-5.3.1))), return true.

This means that if offerer offered sendonly, answerer answered with recvonly and then the answerer changed its transceiver's direction to sendrecv, negotiationneeded event won't be fired.

The intersection of transceiver direction with the offered direction is recvonly (sendrecv x sendonly = recvonly) and the direction in the answer is also recvonly so there is no change.

Currently, browsers do the opposite thing i.e. they fire negotiationneeded event when the described situation occurs.

What's the expected behaviour? 

Code:

```js
pc1 = new RTCPeerConnection();
pc2 = new RTCPeerConnection();

pc1.onnegotiationneeded = _ => console.log("onnegotiationneeded1");
pc2.onnegotiationneeded = _ => console.log("onnegotiationneeded2");
tr = pc1.addTransceiver("audio", {direction: "sendonly"});
offer = await pc1.createOffer();
await pc1.setLocalDescription(offer);
await pc2.setRemoteDescription(offer);
answer = await pc2.createAnswer();
await pc2.setLocalDescription(answer);
await pc1.setRemoteDescription(answer);

console.log("changing pc2 tr direction");
pc2.getTransceivers()[0].direction = "sendrecv";
```

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


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

Received on Monday, 1 January 2024 21:03:50 UTC