Re: [webrtc-pc] When is negotiation complete? (#2495)

**Proposal A:** `negotiationcomplete` event from SRD(answer) _only_ if renegotiation is not needed.
```js
const transceiver = pc.addTransceiver("video");
await new Promise(r => pc.onnegotiationcomplete = r);
assert_equals(transceiver.currentDirection, "sendonly", "negotiates to sendonly");
```

A downside is subsequent actions might delay this event.

**Proposal B:** Expose a `negotiationneeded` boolean attribute.
```js
const transceiver = pc.addTransceiver("video");
while (pc.negotiationneeded) await state(pc, "stable");
assert_equals(transceiver.currentDirection, "sendonly", "negotiates to sendonly");
```

Complication: once set, we MUST fire `negotiationneeded` event, to meet JS expectations.

**Proposal C:** Expose a `negotiationcomplete` promise attribute.
```js
const transceiver = pc.addTransceiver("video");
await pc.negotiationcomplete;
assert_equals(transceiver.currentDirection, "sendonly", "negotiates to sendonly");
```

Its fulfillment would not be delayed by subsequent actions, besting **_proposal A_**
(browsers would replace this attribute with a new promise each time a train leaves the station).

Think of it as _the promise addTransceiver etc. should have returned_.

**Proposal D:** The Road.

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

Received on Monday, 23 March 2020 00:58:01 UTC