Bug 1437832 - Part 2: Use the same C++ logic for replaceTrack, removeTrack, and addTrack (when on a pre-existing transceiver). r+jib r=jib a=lizzard
authorByron Campen [:bwc] <docfaraday@gmail.com>
Tue, 13 Feb 2018 13:25:19 -0600
changeset 454918 f42de8d75322bc3bb4ca40f5b0f4262c4ae2ebc0
parent 454917 0a2d9531ca7fedec93aa98783f64cb082a9f54f4
child 454919 9f0b85bbc92d2cf70d6559220535d8aa115fce72
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjib, lizzard
bugs1437832
milestone59.0
Bug 1437832 - Part 2: Use the same C++ logic for replaceTrack, removeTrack, and addTrack (when on a pre-existing transceiver). r+jib r=jib a=lizzard MozReview-Commit-ID: KQSlagkmAZ
dom/media/PeerConnection.js
--- a/dom/media/PeerConnection.js
+++ b/dom/media/PeerConnection.js
@@ -1198,19 +1198,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();
@@ -1373,18 +1370,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;
@@ -1962,17 +1958,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.
@@ -2036,16 +2032,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));
   }