Bug 1230184 - add media.peerconnection.simulcast pref. r=bwc

This commit is contained in:
Jan-Ivar Bruaroey 2015-12-31 10:32:26 -06:00
parent 4675430c2d
commit 156906a3ab
2 changed files with 66 additions and 55 deletions

View File

@ -1039,7 +1039,9 @@ RTCPeerConnection.prototype = {
},
_setParameters: function(sender, parameters) {
if (!Services.prefs.getBoolPref("media.peerconnection.simulcast")) {
return;
}
// validate parameters input
var encodings = parameters.encodings || [];
@ -1058,6 +1060,9 @@ RTCPeerConnection.prototype = {
},
_getParameters: function(sender) {
if (!Services.prefs.getBoolPref("media.peerconnection.simulcast")) {
return;
}
return this._impl.getParameters(sender.track);
},

View File

@ -6,64 +6,68 @@
<body>
<pre id="test">
<script type="application/javascript;version=1.8">
createHTML({
bug: "1230184",
title: "Set parameters on sender",
visible: true
});
createHTML({
bug: "1230184",
title: "Set parameters on sender",
visible: true
});
function parameterstest(wrapper) {
var pc = wrapper._pc;
ok(pc.getSenders().length > 0, "have senders");
var sender = pc.getSenders()[0];
function parameterstest(wrapper) {
var pc = wrapper._pc;
ok(pc.getSenders().length > 0, "have senders");
var sender = pc.getSenders()[0];
var testParameters = (params, errorName, errorMsg) => {
var compareParameters = (a, b) => {
var compareEncoding = (a, b) => {
is(a.rid, b.rid || "", "same rid");
is(a.maxBitrate, b.maxBitrate, "same maxBitrate");
};
is(a.encodings.length, (b.encodings || []).length, "same encodings");
a.encodings.forEach((en, i) => compareEncoding(en, b.encodings[i]));
var testParameters = (params, errorName, errorMsg) => {
var compareParameters = (a, b) => {
var compareEncoding = (a, b) => {
is(a.rid, b.rid || "", "same rid");
is(a.maxBitrate, b.maxBitrate, "same maxBitrate");
};
try {
sender.setParameters(params);
compareParameters(sender.getParameters(), params);
is(null, errorName || null, "is success expected");
} catch (e) {
is(e.name, errorName, "correct error name");
is(e.message, errorMsg, "correct error message");
}
is(a.encodings.length, (b.encodings || []).length, "same encodings");
a.encodings.forEach((en, i) => compareEncoding(en, b.encodings[i]));
};
try {
sender.setParameters(params);
compareParameters(sender.getParameters(), params);
is(null, errorName || null, "is success expected");
} catch (e) {
is(e.name, errorName, "correct error name");
is(e.message, errorMsg, "correct error message");
}
};
testParameters({
encodings: [
{ rid: "foo", maxBitrate: 40000 },
{ rid: "bar", maxBitrate: 10000 },
]
});
testParameters({
encodings: [
{ maxBitrate: 10000 },
]
});
testParameters({
encodings: [
{ maxBitrate: 40000 },
{ rid: "bar", maxBitrate: 10000 },
]
}, "TypeError", "Missing rid");
testParameters({
encodings: [
{ rid: "foo", maxBitrate: 40000 },
{ rid: "bar", maxBitrate: 10000 },
{ rid: "bar", maxBitrate: 20000 },
]
}, "TypeError", "Duplicate rid");
testParameters({});
}
testParameters({
encodings: [
{ rid: "foo", maxBitrate: 40000 },
{ rid: "bar", maxBitrate: 10000 },
]
});
testParameters({
encodings: [
{ maxBitrate: 10000 },
]
});
testParameters({
encodings: [
{ maxBitrate: 40000 },
{ rid: "bar", maxBitrate: 10000 },
]
}, "TypeError", "Missing rid");
testParameters({
encodings: [
{ rid: "foo", maxBitrate: 40000 },
{ rid: "bar", maxBitrate: 10000 },
{ rid: "bar", maxBitrate: 20000 },
]
}, "TypeError", "Duplicate rid");
testParameters({});
}
var pushPrefs = (...p) => new Promise(r => SpecialPowers.pushPrefEnv({set: p}, r));
runNetworkTest(() =>
pushPrefs(['media.peerconnection.simulcast', true]).then(() => {
runNetworkTest(function () {
test = new PeerConnectionTest();
test.setMediaConstraints([{video: true}], [{video: true}]);
test.chain.removeAfter("PC_REMOTE_WAIT_FOR_MEDIA_FLOW");
@ -75,8 +79,10 @@
}
]);
test.run();
});
return test.run();
})
.catch(e => ok(false, "unexpected failure: " + e)));
</script>
</pre>
</body>