Bug 1425618 - Part 2: Make offerToReceiveX: false unset the send bit on transceivers. r?jib
MozReview-Commit-ID: 1arzHQBUziR
--- 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) {