W3C home > Mailing lists > Public > public-webrtc-logs@w3.org > March 2019

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

From: Jan-Ivar Bruaroey via GitHub <sysbot+gh@w3.org>
Date: Wed, 13 Mar 2019 19:12:42 +0000
To: public-webrtc-logs@w3.org
Message-ID: <issue_comment.created-472565431-1552504360-sysbot+gh@w3.org>
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):
is a synchronous version of:
transceiver.direction = "recvonly"; await transceiver.sender.replaceTrack(null); 
Or imagine we had a synchronous setter that threw on anything but `null`:
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

This archive was generated by hypermail 2.4.0 : Saturday, 6 May 2023 21:19:46 UTC