Re: [webrtc-pc] Differences between pc.removeTrack(sender) and sender.replaceTrack(null) (#2024)

FWIW I think the spec is [super-clear](http://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-removetrack) how to implement `pc.removeTrack(sender)`. It's just counterintuitive, a misnomer. Unsure what note will solve that except *"No, really"*. I mean it takes a *sender*...

It's there mostly for [legacy reasons](https://blog.mozilla.org/webrtc/the-evolution-of-webrtc/) and best ignored IMHO. Might this be better covered under examples?  I think it's fair to say that (with `transceiver.direction == "sendrecv"` as a starting point):
```js
pc.removeTrack(transceiver.sender);
```
is a synchronous version of:
```js
transceiver.direction = "recvonly"; await transceiver.sender.replaceTrack(null); 
```
Or imagine we had a synchronous setter that threw on anything but `null`:
```js
transceiver.direction = "recvonly"; transceiver.sender.track = null; // null or TypeError 
```

This is possible because `sender.replaceTrack(null)` cannot fail, and *could have* been done synchronously, whereas `sender.replaceTrack(withTrack)` cannot.

> replaceTrack(null) could probably special-case to be synchronous, but it already returns a promise, so I think it would just be confusing.

It was like that before we fixed it in https://github.com/w3c/webrtc-pc/issues/1769.

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

Received on Wednesday, 13 March 2019 19:12:44 UTC