|
@@ -6,6 +6,8 @@ function TraceablePeerConnection(ice_config, constraints) {
|
6
|
6
|
this.stats = {};
|
7
|
7
|
this.statsinterval = null;
|
8
|
8
|
this.maxstats = 0; // limit to 300 values, i.e. 5 minutes; set to 0 to disable
|
|
9
|
+ var Interop = require('sdp-interop').Interop;
|
|
10
|
+ this.interop = new Interop();
|
9
|
11
|
|
10
|
12
|
// override as desired
|
11
|
13
|
this.trace = function (what, info) {
|
|
@@ -98,19 +100,39 @@ function TraceablePeerConnection(ice_config, constraints) {
|
98
|
100
|
};
|
99
|
101
|
|
100
|
102
|
dumpSDP = function(description) {
|
|
103
|
+ if (typeof description === 'undefined' || description == null) {
|
|
104
|
+ return '';
|
|
105
|
+ }
|
|
106
|
+
|
101
|
107
|
return 'type: ' + description.type + '\r\n' + description.sdp;
|
102
|
|
-}
|
|
108
|
+};
|
103
|
109
|
|
104
|
110
|
if (TraceablePeerConnection.prototype.__defineGetter__ !== undefined) {
|
105
|
111
|
TraceablePeerConnection.prototype.__defineGetter__('signalingState', function() { return this.peerconnection.signalingState; });
|
106
|
112
|
TraceablePeerConnection.prototype.__defineGetter__('iceConnectionState', function() { return this.peerconnection.iceConnectionState; });
|
107
|
113
|
TraceablePeerConnection.prototype.__defineGetter__('localDescription', function() {
|
108
|
|
- var publicLocalDescription = APP.simulcast.reverseTransformLocalDescription(this.peerconnection.localDescription);
|
109
|
|
- return publicLocalDescription;
|
|
114
|
+ this.trace('getLocalDescription::preTransform (Plan A)', dumpSDP(this.peerconnection.localDescription));
|
|
115
|
+ // if we're running on FF, transform to Plan B first.
|
|
116
|
+ var desc = this.peerconnection.localDescription;
|
|
117
|
+ if (navigator.mozGetUserMedia) {
|
|
118
|
+ desc = this.interop.toPlanB(desc);
|
|
119
|
+ } else {
|
|
120
|
+ desc = APP.simulcast.reverseTransformLocalDescription(this.peerconnection.localDescription);
|
|
121
|
+ }
|
|
122
|
+ this.trace('getLocalDescription::postTransform (Plan B)', dumpSDP(desc));
|
|
123
|
+ return desc;
|
110
|
124
|
});
|
111
|
125
|
TraceablePeerConnection.prototype.__defineGetter__('remoteDescription', function() {
|
112
|
|
- var publicRemoteDescription = APP.simulcast.reverseTransformRemoteDescription(this.peerconnection.remoteDescription);
|
113
|
|
- return publicRemoteDescription;
|
|
126
|
+ this.trace('getRemoteDescription::preTransform (Plan A)', dumpSDP(this.peerconnection.remoteDescription));
|
|
127
|
+ // if we're running on FF, transform to Plan B first.
|
|
128
|
+ var desc = this.peerconnection.remoteDescription;
|
|
129
|
+ if (navigator.mozGetUserMedia) {
|
|
130
|
+ desc = this.interop.toPlanB(desc);
|
|
131
|
+ } else {
|
|
132
|
+ desc = APP.simulcast.reverseTransformRemoteDescription(this.peerconnection.remoteDescription);
|
|
133
|
+ }
|
|
134
|
+ this.trace('getRemoteDescription::postTransform (Plan B)', dumpSDP(desc));
|
|
135
|
+ return desc;
|
114
|
136
|
});
|
115
|
137
|
}
|
116
|
138
|
|
|
@@ -148,9 +170,15 @@ TraceablePeerConnection.prototype.createDataChannel = function (label, opts) {
|
148
|
170
|
};
|
149
|
171
|
|
150
|
172
|
TraceablePeerConnection.prototype.setLocalDescription = function (description, successCallback, failureCallback) {
|
|
173
|
+ this.trace('setLocalDescription::preTransform (Plan B)', dumpSDP(description));
|
|
174
|
+ // if we're running on FF, transform to Plan A first.
|
|
175
|
+ if (navigator.mozGetUserMedia) {
|
|
176
|
+ description = this.interop.toPlanA(description);
|
|
177
|
+ } else {
|
|
178
|
+ description = APP.simulcast.transformLocalDescription(description);
|
|
179
|
+ }
|
|
180
|
+ this.trace('setLocalDescription::postTransform (Plan A)', dumpSDP(description));
|
151
|
181
|
var self = this;
|
152
|
|
- description = APP.simulcast.transformLocalDescription(description);
|
153
|
|
- this.trace('setLocalDescription', dumpSDP(description));
|
154
|
182
|
this.peerconnection.setLocalDescription(description,
|
155
|
183
|
function () {
|
156
|
184
|
self.trace('setLocalDescriptionOnSuccess');
|
|
@@ -169,9 +197,16 @@ TraceablePeerConnection.prototype.setLocalDescription = function (description, s
|
169
|
197
|
};
|
170
|
198
|
|
171
|
199
|
TraceablePeerConnection.prototype.setRemoteDescription = function (description, successCallback, failureCallback) {
|
|
200
|
+ this.trace('setRemoteDescription::preTransform (Plan B)', dumpSDP(description));
|
|
201
|
+ // if we're running on FF, transform to Plan A first.
|
|
202
|
+ if (navigator.mozGetUserMedia) {
|
|
203
|
+ description = this.interop.toPlanA(description);
|
|
204
|
+ }
|
|
205
|
+ else {
|
|
206
|
+ description = APP.simulcast.transformRemoteDescription(description);
|
|
207
|
+ }
|
|
208
|
+ this.trace('setRemoteDescription::postTransform (Plan A)', dumpSDP(description));
|
172
|
209
|
var self = this;
|
173
|
|
- description = APP.simulcast.transformRemoteDescription(description);
|
174
|
|
- this.trace('setRemoteDescription', dumpSDP(description));
|
175
|
210
|
this.peerconnection.setRemoteDescription(description,
|
176
|
211
|
function () {
|
177
|
212
|
self.trace('setRemoteDescriptionOnSuccess');
|
|
@@ -203,7 +238,12 @@ TraceablePeerConnection.prototype.createOffer = function (successCallback, failu
|
203
|
238
|
this.trace('createOffer', JSON.stringify(constraints, null, ' '));
|
204
|
239
|
this.peerconnection.createOffer(
|
205
|
240
|
function (offer) {
|
206
|
|
- self.trace('createOfferOnSuccess', dumpSDP(offer));
|
|
241
|
+ self.trace('createOfferOnSuccess::preTransform (Plan A)', dumpSDP(offer));
|
|
242
|
+ // if we're running on FF, transform to Plan B first.
|
|
243
|
+ if (navigator.mozGetUserMedia) {
|
|
244
|
+ offer = self.interop.toPlanB(offer);
|
|
245
|
+ }
|
|
246
|
+ self.trace('createOfferOnSuccess::postTransform (Plan B)', dumpSDP(offer));
|
207
|
247
|
successCallback(offer);
|
208
|
248
|
},
|
209
|
249
|
function(err) {
|
|
@@ -219,8 +259,14 @@ TraceablePeerConnection.prototype.createAnswer = function (successCallback, fail
|
219
|
259
|
this.trace('createAnswer', JSON.stringify(constraints, null, ' '));
|
220
|
260
|
this.peerconnection.createAnswer(
|
221
|
261
|
function (answer) {
|
222
|
|
- answer = APP.simulcast.transformAnswer(answer);
|
223
|
|
- self.trace('createAnswerOnSuccess', dumpSDP(answer));
|
|
262
|
+ self.trace('createAnswerOnSuccess::preTransfom (Plan A)', dumpSDP(answer));
|
|
263
|
+ // if we're running on FF, transform to Plan A first.
|
|
264
|
+ if (navigator.mozGetUserMedia) {
|
|
265
|
+ answer = self.interop.toPlanB(answer);
|
|
266
|
+ } else {
|
|
267
|
+ answer = APP.simulcast.transformAnswer(answer);
|
|
268
|
+ }
|
|
269
|
+ self.trace('createAnswerOnSuccess::postTransfom (Plan B)', dumpSDP(answer));
|
224
|
270
|
successCallback(answer);
|
225
|
271
|
},
|
226
|
272
|
function(err) {
|