Bug 1437832 - Part 2: Use the same C++ logic for replaceTrack, removeTrack, and addTrack (when on a pre-existing transceiver). r+jib
MozReview-Commit-ID: KQSlagkmAZ
--- a/dom/media/PeerConnection.js
+++ b/dom/media/PeerConnection.js
@@ -1196,19 +1196,16 @@ class RTCPeerConnection {
let transceiver =
this._transceivers.find(transceiver => transceiver.sender == sender);
// If the transceiver was removed due to rollback, let it slide.
if (!transceiver || !sender.track) {
return;
}
- // TODO(bug 1401983): Move to TransceiverImpl?
- this._impl.removeTrack(sender.track);
-
sender.setTrack(null);
if (transceiver.direction == "sendrecv") {
transceiver.setDirectionInternal("recvonly");
} else if (transceiver.direction == "sendonly") {
transceiver.setDirectionInternal("inactive");
}
transceiver.sync();
@@ -1371,18 +1368,17 @@ class RTCPeerConnection {
_insertDTMF(transceiverImpl, tones, duration, interToneGap) {
return this._impl.insertDTMF(transceiverImpl, tones, duration, interToneGap);
}
_getDTMFToneBuffer(sender) {
return this._impl.getDTMFToneBuffer(sender.__DOM_IMPL__);
}
- _replaceTrack(transceiverImpl, withTrack) {
- this._checkClosed();
+ _replaceTrackNoRenegotiation(transceiverImpl, withTrack) {
this._impl.replaceTrackNoRenegotiation(transceiverImpl, withTrack);
}
close() {
if (this._closed) {
return;
}
this._closed = true;
@@ -1960,17 +1956,17 @@ class RTCRtpSender {
throw new this._pc._win.DOMException(
"Cannot replaceTrack with a different kind!",
"TypeError");
}
// Updates the track on the MediaPipeline; this is needed whether or not
// we've associated this transceiver, the spec language notwithstanding.
// Synchronous, and will throw on failure.
- this._pc._replaceTrack(this._transceiverImpl, withTrack);
+ this._pc._replaceTrackNoRenegotiation(this._transceiverImpl, withTrack);
let setTrack = () => {
this.track = withTrack;
this._transceiver.sync();
};
// Spec is a little weird here; we only queue if the transceiver was
// associated, otherwise we update the track synchronously.
@@ -2034,16 +2030,17 @@ class RTCRtpSender {
this._streams = streams;
}
getStreams() {
return this._streams;
}
setTrack(track) {
+ this._pc._replaceTrackNoRenegotiation(this._transceiverImpl, track);
this.track = track;
}
getStats() {
return this._pc._async(
async () => this._pc._getStats(this.track));
}