Backed out changeset b490b5843f3c for M2 bustage

This commit is contained in:
Randell Jesup 2013-10-27 20:45:28 -04:00
parent d51413d11e
commit 981ced8cf7
3 changed files with 91 additions and 8 deletions

View File

@ -225,6 +225,10 @@ function RTCPeerConnection() {
// States
this._iceGatheringState = this._iceConnectionState = "new";
// Deprecated callbacks
this._ongatheringchange = null;
this._onicechange = null;
}
RTCPeerConnection.prototype = {
classDescription: "mozRTCPeerConnection",
@ -483,10 +487,29 @@ RTCPeerConnection.prototype = {
});
},
get onicechange() { return this._onicechange; },
get ongatheringchange() { return this._ongatheringchange; },
set onicechange(cb) {
this.deprecated("onicechange");
this._onicechange = cb;
},
set ongatheringchange(cb) {
this.deprecated("ongatheringchange");
this._ongatheringchange = cb;
},
deprecated: function(name) {
this.reportWarning(name + " is deprecated!", null, 0);
},
createOffer: function(onSuccess, onError, constraints) {
if (!constraints) {
constraints = {};
}
if (!onError) {
this.deprecated("calling createOffer without failureCallback");
}
this._mustValidateConstraints(constraints, "createOffer passed invalid constraints");
this._onCreateOfferSuccess = onSuccess;
this._onCreateOfferFailure = onError;
@ -499,6 +522,9 @@ RTCPeerConnection.prototype = {
},
_createAnswer: function(onSuccess, onError, constraints, provisional) {
if (!onError) {
this.deprecated("calling createAnswer without failureCallback");
}
this._onCreateAnswerSuccess = onSuccess;
this._onCreateAnswerFailure = onError;
@ -669,6 +695,16 @@ RTCPeerConnection.prototype = {
return this._getPC().getRemoteStreams();
},
// Backwards-compatible attributes
get localStreams() {
this.deprecated("localStreams");
return this.getLocalStreams();
},
get remoteStreams() {
this.deprecated("remoteStreams");
return this.getRemoteStreams();
},
get localDescription() {
this._checkClosed();
let sdp = this._getPC().localDescription;
@ -718,6 +754,35 @@ RTCPeerConnection.prototype = {
this.dispatchEvent(new this._win.Event("iceconnectionstatechange"));
},
get readyState() {
this.deprecated("readyState");
// checking for our local pc closed indication
// before invoking the pc methods.
if(this._closed) {
return "closed";
}
var state="undefined";
switch (this._getPC().readyState) {
case Ci.IPeerConnection.kNew:
state = "new";
break;
case Ci.IPeerConnection.kNegotiating:
state = "negotiating";
break;
case Ci.IPeerConnection.kActive:
state = "active";
break;
case Ci.IPeerConnection.kClosing:
state = "closing";
break;
case Ci.IPeerConnection.kClosed:
state = "closed";
break;
}
return state;
},
getStats: function(selector, onSuccess, onError) {
this._onGetStatsSuccess = onSuccess;
this._onGetStatsFailure = onError;
@ -994,13 +1059,13 @@ PeerConnectionObserver.prototype = {
IceGathering:
{ gathering: "gathering" },
IceWaiting:
{ connection: "new", gathering: "complete" },
{ connection: "new", gathering: "complete", legacy: "starting" },
IceChecking:
{ connection: "checking" },
{ connection: "checking", legacy: "checking" },
IceConnected:
{ connection: "connected", success: true },
{ connection: "connected", legacy: "connected", success: true },
IceFailed:
{ connection: "failed", success: false }
{ connection: "failed", legacy: "failed", success: false }
};
// These are all the allowed inputs.
@ -1011,6 +1076,12 @@ PeerConnectionObserver.prototype = {
}
if ("gathering" in transitions) {
this._dompc.changeIceGatheringState(transitions.gathering);
// Handle (old, deprecated) "ongatheringchange" callback
this.callCB(this._dompc.ongatheringchange, transitions.gathering);
}
// Handle deprecated "onicechange" callback
if ("legacy" in transitions) {
this.callCB(this._onicechange, transitions.legacy);
}
if ("success" in transitions) {
histogram.add(transitions.success);

View File

@ -1313,11 +1313,11 @@ PeerConnectionWrapper.prototype = {
* The media constraints of the remote peer connection object
*/
checkMediaStreams : function PCW_checkMediaStreams(constraintsRemote) {
is(this._pc.getLocalStreams().length, this.constraints.length,
is(this._pc.localStreams.length, this.constraints.length,
this + ' has ' + this.constraints.length + ' local streams');
// TODO: change this when multiple incoming streams are supported (bug 834835)
is(this._pc.getRemoteStreams().length, 1,
is(this._pc.remoteStreams.length, 1,
this + ' has ' + 1 + ' remote streams');
},

View File

@ -87,10 +87,10 @@ interface RTCDataChannel;
// moz-prefixed until sufficiently standardized.
interface mozRTCPeerConnection : EventTarget {
void createOffer (RTCSessionDescriptionCallback successCallback,
RTCPeerConnectionErrorCallback failureCallback,
RTCPeerConnectionErrorCallback? failureCallback, // for apprtc
optional MediaConstraints constraints);
void createAnswer (RTCSessionDescriptionCallback successCallback,
RTCPeerConnectionErrorCallback failureCallback,
RTCPeerConnectionErrorCallback? failureCallback, // for apprtc
optional MediaConstraints constraints);
void setLocalDescription (mozRTCSessionDescription description,
optional VoidFunction successCallback,
@ -124,6 +124,18 @@ interface mozRTCPeerConnection : EventTarget {
void getStats (MediaStreamTrack? selector,
RTCStatsCallback successCallback,
RTCPeerConnectionErrorCallback failureCallback);
};
// Mozilla extensions.
partial interface mozRTCPeerConnection {
// Deprecated callbacks (use causes warning)
attribute RTCPeerConnectionErrorCallback onicechange;
attribute RTCPeerConnectionErrorCallback ongatheringchange;
// Deprecated attributes (use causes warning)
readonly attribute object localStreams;
readonly attribute object remoteStreams;
readonly attribute DOMString readyState;
// Data channel.
RTCDataChannel createDataChannel (DOMString label,