Bug 1425618 - Part 2: Make offerToReceiveX: false unset the send bit on transceivers. r?jib draft
authorByron Campen [:bwc] <docfaraday@gmail.com>
Tue, 19 Dec 2017 11:52:39 -0600
changeset 714126 5a2f85552ce388edccfe9c74ce1f3157758e17f0
parent 714125 6a42d3e352f79e811823b2ff19066bb0a9bc752e
child 714136 ab30f91e677aece43bd5049ac0e3725a0793328e
push id93856
push userbcampen@mozilla.com
push dateThu, 21 Dec 2017 19:06:40 +0000
reviewersjib
bugs1425618
milestone59.0a1
Bug 1425618 - Part 2: Make offerToReceiveX: false unset the send bit on transceivers. r?jib MozReview-Commit-ID: 1arzHQBUziR
dom/media/PeerConnection.js
--- a/dom/media/PeerConnection.js
+++ b/dom/media/PeerConnection.js
@@ -826,31 +826,34 @@ class RTCPeerConnection {
   }
 
   // Handles offerToReceiveAudio/Video
   _ensureTransceiversForOfferToReceive(options) {
     if (options.offerToReceiveVideo) {
       this._ensureOfferToReceive("video");
     }
 
-    if (options.offerToReceiveVideo === false) {
-      this.logWarning("offerToReceiveVideo: false is ignored now. If you " +
-                      "want to disallow a recv track, use " +
-                      "RTCRtpTransceiver.direction");
-    }
-
     if (options.offerToReceiveAudio) {
       this._ensureOfferToReceive("audio");
     }
 
-    if (options.offerToReceiveAudio === false) {
-      this.logWarning("offerToReceiveAudio: false is ignored now. If you " +
-                      "want to disallow a recv track, use " +
-                      "RTCRtpTransceiver.direction");
-    }
+    this._transceivers
+      .filter(transceiver => {
+        return (options.offerToReceiveVideo === false &&
+                transceiver.receiver.track.kind == "video") ||
+               (options.offerToReceiveAudio === false &&
+                transceiver.receiver.track.kind == "audio");
+      })
+      .forEach(transceiver => {
+        if (transceiver.direction == "sendrecv") {
+          transceiver.setDirectionInternal("sendonly");
+        } else if (transceiver.direction == "recvonly") {
+          transceiver.setDirectionInternal("inactive");
+        }
+      });
   }
 
   async _createOffer(options) {
     this._checkClosed();
     let origin = Cu.getWebIDLCallerPrincipal().origin;
     return this._chain(async () => {
       let haveAssertion;
       if (this._localIdp.enabled) {