Bug 1319542 - Update RTCDataChannelInit to spec, and remove support for old deprecated values.
MozReview-Commit-ID: 12JbUVuSEYg
--- a/dom/media/PeerConnection.js
+++ b/dom/media/PeerConnection.js
@@ -1185,69 +1185,46 @@ RTCPeerConnection.prototype = {
return this._chain(() => new this._win.Promise((resolve, reject) => {
this._onGetStatsSuccess = resolve;
this._onGetStatsFailure = reject;
this._impl.getStats(selector);
}));
});
},
- createDataChannel: function(label, dict) {
+ createDataChannel: function(label, {
+ maxRetransmits, ordered, negotiated,
+ id = 0xFFFF,
+ maxRetransmitTime,
+ maxPacketLifeTime = maxRetransmitTime,
+ protocol,
+ } = {}) {
this._checkClosed();
- if (dict == undefined) {
- dict = {};
- }
- if (dict.maxRetransmitNum != undefined) {
- dict.maxRetransmits = dict.maxRetransmitNum;
- this.logWarning("Deprecated RTCDataChannelInit dictionary entry maxRetransmitNum used!");
- }
- if (dict.outOfOrderAllowed != undefined) {
- dict.ordered = !dict.outOfOrderAllowed; // the meaning is swapped with
- // the name change
- this.logWarning("Deprecated RTCDataChannelInit dictionary entry outOfOrderAllowed used!");
+
+ if (maxRetransmitTime !== undefined) {
+ this.logWarning("Use maxPacketLifeTime instead of deprecated maxRetransmitTime which will stop working soon in createDataChannel!");
}
-
- if (dict.preset != undefined) {
- dict.negotiated = dict.preset;
- this.logWarning("Deprecated RTCDataChannelInit dictionary entry preset used!");
- }
- if (dict.stream != undefined) {
- dict.id = dict.stream;
- this.logWarning("Deprecated RTCDataChannelInit dictionary entry stream used!");
- }
-
- if (dict.maxRetransmitTime !== null && dict.maxRetransmits !== null) {
+ if (maxPacketLifeTime !== undefined && maxRetransmits !== undefined) {
throw new this._win.DOMException(
- "Both maxRetransmitTime and maxRetransmits cannot be provided",
+ "Both maxPacketLifeTime and maxRetransmits cannot be provided",
"InvalidParameterError");
}
- let protocol;
- if (dict.protocol == undefined) {
- protocol = "";
- } else {
- protocol = dict.protocol;
- }
-
// Must determine the type where we still know if entries are undefined.
let type;
- if (dict.maxRetransmitTime != undefined) {
+ if (maxPacketLifeTime) {
type = Ci.IPeerConnection.kDataChannelPartialReliableTimed;
- } else if (dict.maxRetransmits != undefined) {
+ } else if (maxRetransmits) {
type = Ci.IPeerConnection.kDataChannelPartialReliableRexmit;
} else {
type = Ci.IPeerConnection.kDataChannelReliable;
}
-
// Synchronous since it doesn't block.
- let channel = this._impl.createDataChannel(
- label, protocol, type, !dict.ordered, dict.maxRetransmitTime,
- dict.maxRetransmits, dict.negotiated ? true : false,
- dict.id != undefined ? dict.id : 0xFFFF
- );
- return channel;
+ return this._impl.createDataChannel(label, protocol, type, ordered,
+ maxPacketLifeTime, maxRetransmits,
+ negotiated, id);
}
};
// This is a separate object because we don't want to expose it to DOM.
function PeerConnectionObserver() {
this._dompc = null;
}
PeerConnectionObserver.prototype = {
--- a/dom/webidl/PeerConnectionImpl.webidl
+++ b/dom/webidl/PeerConnectionImpl.webidl
@@ -96,12 +96,12 @@ interface PeerConnectionImpl {
attribute DOMString id;
attribute DOMString peerIdentity;
readonly attribute boolean privacyRequested;
/* Data channels */
[Throws]
DataChannel createDataChannel(DOMString label, DOMString protocol,
- unsigned short type, boolean outOfOrderAllowed,
+ unsigned short type, boolean ordered,
unsigned short maxTime, unsigned short maxNum,
boolean externalNegotiated, unsigned short stream);
};
--- a/dom/webidl/RTCPeerConnection.webidl
+++ b/dom/webidl/RTCPeerConnection.webidl
@@ -33,28 +33,25 @@ enum RTCIceConnectionState {
"connected",
"completed",
"failed",
"disconnected",
"closed"
};
dictionary RTCDataChannelInit {
- boolean ordered = true;
- unsigned short? maxRetransmitTime = null;
- unsigned short? maxRetransmits = null;
- DOMString protocol = "";
- boolean negotiated = false; // spec currently says 'true'; we disagree
- unsigned short? id = null;
+ boolean ordered = true;
+ unsigned short maxPacketLifeTime;
+ unsigned short maxRetransmits;
+ DOMString protocol = "";
+ boolean negotiated = false;
+ unsigned short id;
- // these are deprecated due to renaming in the spec, but still supported for Fx22
- boolean outOfOrderAllowed; // now ordered, and the default changes to keep behavior the same
- unsigned short maxRetransmitNum; // now maxRetransmits
- boolean preset; // now negotiated
- unsigned short stream; // now id
+ // These are deprecated due to renaming in the spec, but still supported for Fx53
+ unsigned short maxRetransmitTime;
};
dictionary RTCOfferAnswerOptions {
// boolean voiceActivityDetection = true; // TODO: support this (Bug 1184712)
};
dictionary RTCAnswerOptions : RTCOfferAnswerOptions {
};
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
@@ -1332,39 +1332,39 @@ PeerConnectionImpl::InitializeDataChanne
#endif
return NS_ERROR_FAILURE;
}
already_AddRefed<nsDOMDataChannel>
PeerConnectionImpl::CreateDataChannel(const nsAString& aLabel,
const nsAString& aProtocol,
uint16_t aType,
- bool outOfOrderAllowed,
+ bool ordered,
uint16_t aMaxTime,
uint16_t aMaxNum,
bool aExternalNegotiated,
uint16_t aStream,
ErrorResult &rv)
{
#if !defined(MOZILLA_EXTERNAL_LINKAGE)
RefPtr<nsDOMDataChannel> result;
- rv = CreateDataChannel(aLabel, aProtocol, aType, outOfOrderAllowed,
+ rv = CreateDataChannel(aLabel, aProtocol, aType, ordered,
aMaxTime, aMaxNum, aExternalNegotiated,
aStream, getter_AddRefs(result));
return result.forget();
#else
return nullptr;
#endif
}
NS_IMETHODIMP
PeerConnectionImpl::CreateDataChannel(const nsAString& aLabel,
const nsAString& aProtocol,
uint16_t aType,
- bool outOfOrderAllowed,
+ bool ordered,
uint16_t aMaxTime,
uint16_t aMaxNum,
bool aExternalNegotiated,
uint16_t aStream,
nsDOMDataChannel** aRetval)
{
PC_AUTO_ENTER_API_CALL(false);
MOZ_ASSERT(aRetval);
@@ -1375,17 +1375,17 @@ PeerConnectionImpl::CreateDataChannel(co
static_cast<DataChannelConnection::Type>(aType);
nsresult rv = EnsureDataConnection(WEBRTC_DATACHANNEL_STREAMS_DEFAULT);
if (NS_FAILED(rv)) {
return rv;
}
dataChannel = mDataConnection->Open(
NS_ConvertUTF16toUTF8(aLabel), NS_ConvertUTF16toUTF8(aProtocol), theType,
- !outOfOrderAllowed,
+ ordered,
aType == DataChannelConnection::PARTIAL_RELIABLE_REXMIT ? aMaxNum :
(aType == DataChannelConnection::PARTIAL_RELIABLE_TIMED ? aMaxTime : 0),
nullptr, nullptr, aExternalNegotiated, aStream
);
NS_ENSURE_TRUE(dataChannel,NS_ERROR_FAILURE);
CSFLogDebug(logTag, "%s: making DOMDataChannel", __FUNCTION__);