Bug 1437832 - Part 2: Use the same C++ logic for replaceTrack, removeTrack, and addTrack (when on a pre-existing transceiver). r+jib r=jib
authorByron Campen [:bwc] <docfaraday@gmail.com>
Tue, 13 Feb 2018 13:25:19 -0600
changeset 403768 57b2226d05e8516cc46cf14c4d362d254f0570f6
parent 403767 ec7939040da763bbfe29824cc615ee0168596af1
child 403769 2040187280ad289759fbfd5e61fedb43a8c46a2a
push id33444
push userapavel@mozilla.com
push dateThu, 15 Feb 2018 09:59:25 +0000
treeherdermozilla-central@026401920e32 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjib
bugs1437832
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1437832 - Part 2: Use the same C++ logic for replaceTrack, removeTrack, and addTrack (when on a pre-existing transceiver). r+jib r=jib MozReview-Commit-ID: KQSlagkmAZ
dom/media/PeerConnection.js
--- 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));
   }