mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1063808 - Support old constraint-like RTCOfferOptions for a bit. r=smaug, r=abr
This commit is contained in:
parent
50002ee8ff
commit
8fc9788c04
@ -555,7 +555,46 @@ RTCPeerConnection.prototype = {
|
||||
},
|
||||
|
||||
createOffer: function(onSuccess, onError, options) {
|
||||
options = options || {};
|
||||
|
||||
// TODO: Remove old constraint-like RTCOptions support soon (Bug 1064223).
|
||||
function convertLegacyOptions(o) {
|
||||
if (!(o.mandatory || o.optional) ||
|
||||
Object.keys(o).length != ((o.mandatory && o.optional)? 2 : 1)) {
|
||||
return false;
|
||||
}
|
||||
let old = o.mandatory || {};
|
||||
if (o.mandatory) {
|
||||
delete o.mandatory;
|
||||
}
|
||||
if (o.optional) {
|
||||
o.optional.forEach(one => {
|
||||
// The old spec had optional as an array of objects w/1 attribute each.
|
||||
// Assumes our JS-webidl bindings only populate passed-in properties.
|
||||
let key = Object.keys(one)[0];
|
||||
if (key && old[key] === undefined) {
|
||||
old[key] = one[key];
|
||||
}
|
||||
});
|
||||
delete o.optional;
|
||||
}
|
||||
o.offerToReceiveAudio = old.OfferToReceiveAudio;
|
||||
o.offerToReceiveVideo = old.OfferToReceiveVideo;
|
||||
o.mozDontOfferDataChannel = old.MozDontOfferDataChannel;
|
||||
o.mozBundleOnly = old.MozBundleOnly;
|
||||
Object.keys(o).forEach(k => {
|
||||
if (o[k] === undefined) {
|
||||
delete o[k];
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
if (options && convertLegacyOptions(options)) {
|
||||
this.logWarning(
|
||||
"Mandatory/optional in createOffer options is deprecated! Use " +
|
||||
JSON.stringify(options) + " instead (note the case difference)!",
|
||||
null, 0);
|
||||
}
|
||||
this._queueOrRun({
|
||||
func: this._createOffer,
|
||||
args: [onSuccess, onError, options],
|
||||
|
@ -2141,7 +2141,18 @@ PeerConnectionWrapper.prototype = {
|
||||
if (!options) {
|
||||
return 0;
|
||||
}
|
||||
if (options.offerToReceiveAudio) {
|
||||
|
||||
var offerToReceiveAudio = options.offerToReceiveAudio;
|
||||
|
||||
// TODO: Remove tests of old constraint-like RTCOptions soon (Bug 1064223).
|
||||
if (options.mandatory && options.mandatory.OfferToReceiveAudio !== undefined) {
|
||||
offerToReceiveAudio = options.mandatory.OfferToReceiveAudio;
|
||||
} else if (options.optional && options.optional[0] &&
|
||||
options.optional[0].OfferToReceiveAudio !== undefined) {
|
||||
offerToReceiveAudio = options.optional[0].OfferToReceiveAudio;
|
||||
}
|
||||
|
||||
if (offerToReceiveAudio) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
@ -2179,7 +2190,18 @@ PeerConnectionWrapper.prototype = {
|
||||
if (!options) {
|
||||
return 0;
|
||||
}
|
||||
if (options.offerToReceiveVideo) {
|
||||
|
||||
var offerToReceiveVideo = options.offerToReceiveVideo;
|
||||
|
||||
// TODO: Remove tests of old constraint-like RTCOptions soon (Bug 1064223).
|
||||
if (options.mandatory && options.mandatory.OfferToReceiveVideo !== undefined) {
|
||||
offerToReceiveVideo = options.mandatory.OfferToReceiveVideo;
|
||||
} else if (options.optional && options.optional[0] &&
|
||||
options.optional[0].OfferToReceiveVideo !== undefined) {
|
||||
offerToReceiveVideo = options.optional[0].OfferToReceiveVideo;
|
||||
}
|
||||
|
||||
if (offerToReceiveVideo) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
|
@ -18,7 +18,10 @@
|
||||
|
||||
runNetworkTest(function() {
|
||||
var test = new PeerConnectionTest();
|
||||
test.setOfferOptions({ offerToReceiveAudio: true });
|
||||
|
||||
// TODO: Stop using old constraint-like RTCOptions soon (Bug 1064223).
|
||||
// Watch out for case-difference when fixing: { offerToReceiveAudio: true }
|
||||
test.setOfferOptions({ mandatory: { OfferToReceiveAudio: true } });
|
||||
test.run();
|
||||
});
|
||||
</script>
|
||||
|
@ -18,7 +18,9 @@
|
||||
|
||||
runNetworkTest(function() {
|
||||
var test = new PeerConnectionTest();
|
||||
test.setOfferOptions({ offerToReceiveVideo: true });
|
||||
// TODO: Stop using old constraint-like RTCOptions soon (Bug 1064223).
|
||||
// Watch out for case-difference when fixing: { offerToReceiveVideo: true }
|
||||
test.setOfferOptions({ optional: [{ OfferToReceiveAudio: true }] });
|
||||
test.run();
|
||||
});
|
||||
</script>
|
||||
|
@ -55,8 +55,19 @@ dictionary RTCDataChannelInit {
|
||||
dictionary RTCOfferOptions {
|
||||
long offerToReceiveVideo;
|
||||
long offerToReceiveAudio;
|
||||
boolean MozDontOfferDataChannel;
|
||||
boolean MozBundleOnly;
|
||||
boolean mozDontOfferDataChannel;
|
||||
boolean mozBundleOnly;
|
||||
|
||||
// TODO: Remove old constraint-like RTCOptions support soon (Bug 1064223).
|
||||
DeprecatedRTCOfferOptionsSet mandatory;
|
||||
sequence<DeprecatedRTCOfferOptionsSet> _optional;
|
||||
};
|
||||
|
||||
dictionary DeprecatedRTCOfferOptionsSet {
|
||||
boolean OfferToReceiveAudio; // Note the uppercase 'O'
|
||||
boolean OfferToReceiveVideo; // Note the uppercase 'O'
|
||||
boolean MozDontOfferDataChannel; // Note the uppercase 'M'
|
||||
boolean MozBundleOnly; // Note the uppercase 'M'
|
||||
};
|
||||
|
||||
interface RTCDataChannel;
|
||||
|
Loading…
Reference in New Issue
Block a user