|
@@ -10,7 +10,7 @@ var RTCBrowserType = require("../RTC/RTCBrowserType");
|
10
|
10
|
var SSRCReplacement = require("./LocalSSRCReplacement");
|
11
|
11
|
|
12
|
12
|
// Jingle stuff
|
13
|
|
-function JingleSession(me, sid, connection, service, eventEmitter) {
|
|
13
|
+function JingleSessionPC(me, sid, connection, service, eventEmitter) {
|
14
|
14
|
this.me = me;
|
15
|
15
|
this.sid = sid;
|
16
|
16
|
this.connection = connection;
|
|
@@ -66,7 +66,7 @@ function JingleSession(me, sid, connection, service, eventEmitter) {
|
66
|
66
|
this.modifySourcesQueue.pause();
|
67
|
67
|
}
|
68
|
68
|
|
69
|
|
-JingleSession.prototype.updateModifySourcesQueue = function() {
|
|
69
|
+JingleSessionPC.prototype.updateModifySourcesQueue = function() {
|
70
|
70
|
var signalingState = this.peerconnection.signalingState;
|
71
|
71
|
var iceConnectionState = this.peerconnection.iceConnectionState;
|
72
|
72
|
if (signalingState === 'stable' && iceConnectionState === 'connected') {
|
|
@@ -76,7 +76,7 @@ JingleSession.prototype.updateModifySourcesQueue = function() {
|
76
|
76
|
}
|
77
|
77
|
};
|
78
|
78
|
|
79
|
|
-JingleSession.prototype.initiate = function (peerjid, isInitiator) {
|
|
79
|
+JingleSessionPC.prototype.initiate = function (peerjid, isInitiator) {
|
80
|
80
|
var self = this;
|
81
|
81
|
if (this.state !== null) {
|
82
|
82
|
console.error('attempt to initiate on session ' + this.sid +
|
|
@@ -211,7 +211,7 @@ function onIceConnectionStateChange(sid, session) {
|
211
|
211
|
}
|
212
|
212
|
}
|
213
|
213
|
|
214
|
|
-JingleSession.prototype.accept = function () {
|
|
214
|
+JingleSessionPC.prototype.accept = function () {
|
215
|
215
|
this.state = 'active';
|
216
|
216
|
|
217
|
217
|
var pranswer = this.peerconnection.localDescription;
|
|
@@ -268,7 +268,7 @@ JingleSession.prototype.accept = function () {
|
268
|
268
|
reason: $(stanza).find('error :first')[0].tagName
|
269
|
269
|
}:{};
|
270
|
270
|
error.source = 'answer';
|
271
|
|
- JingleSession.onJingleError(self.sid, error);
|
|
271
|
+ JingleSessionPC.onJingleError(self.sid, error);
|
272
|
272
|
},
|
273
|
273
|
10000);
|
274
|
274
|
},
|
|
@@ -279,7 +279,7 @@ JingleSession.prototype.accept = function () {
|
279
|
279
|
);
|
280
|
280
|
};
|
281
|
281
|
|
282
|
|
-JingleSession.prototype.terminate = function (reason) {
|
|
282
|
+JingleSessionPC.prototype.terminate = function (reason) {
|
283
|
283
|
this.state = 'ended';
|
284
|
284
|
this.reason = reason;
|
285
|
285
|
this.peerconnection.close();
|
|
@@ -289,11 +289,11 @@ JingleSession.prototype.terminate = function (reason) {
|
289
|
289
|
}
|
290
|
290
|
};
|
291
|
291
|
|
292
|
|
-JingleSession.prototype.active = function () {
|
|
292
|
+JingleSessionPC.prototype.active = function () {
|
293
|
293
|
return this.state == 'active';
|
294
|
294
|
};
|
295
|
295
|
|
296
|
|
-JingleSession.prototype.sendIceCandidate = function (candidate) {
|
|
296
|
+JingleSessionPC.prototype.sendIceCandidate = function (candidate) {
|
297
|
297
|
var self = this;
|
298
|
298
|
if (candidate && !this.lasticecandidate) {
|
299
|
299
|
var ice = SDPUtil.iceparams(this.localSDP.media[candidate.sdpMLineIndex], this.localSDP.session);
|
|
@@ -365,7 +365,7 @@ JingleSession.prototype.sendIceCandidate = function (candidate) {
|
365
|
365
|
reason: $(stanza).find('error :first')[0].tagName,
|
366
|
366
|
}:{};
|
367
|
367
|
error.source = 'offer';
|
368
|
|
- JingleSession.onJingleError(self.sid, error);
|
|
368
|
+ JingleSessionPC.onJingleError(self.sid, error);
|
369
|
369
|
},
|
370
|
370
|
10000);
|
371
|
371
|
}
|
|
@@ -381,7 +381,7 @@ JingleSession.prototype.sendIceCandidate = function (candidate) {
|
381
|
381
|
}
|
382
|
382
|
};
|
383
|
383
|
|
384
|
|
-JingleSession.prototype.sendIceCandidates = function (candidates) {
|
|
384
|
+JingleSessionPC.prototype.sendIceCandidates = function (candidates) {
|
385
|
385
|
console.log('sendIceCandidates', candidates);
|
386
|
386
|
var cand = $iq({to: this.peerjid, type: 'set'})
|
387
|
387
|
.c('jingle', {xmlns: 'urn:xmpp:jingle:1',
|
|
@@ -430,13 +430,13 @@ JingleSession.prototype.sendIceCandidates = function (candidates) {
|
430
|
430
|
reason: $(stanza).find('error :first')[0].tagName,
|
431
|
431
|
}:{};
|
432
|
432
|
error.source = 'transportinfo';
|
433
|
|
- JingleSession.onJingleError(this.sid, error);
|
|
433
|
+ JingleSessionPC.onJingleError(this.sid, error);
|
434
|
434
|
},
|
435
|
435
|
10000);
|
436
|
436
|
};
|
437
|
437
|
|
438
|
438
|
|
439
|
|
-JingleSession.prototype.sendOffer = function () {
|
|
439
|
+JingleSessionPC.prototype.sendOffer = function () {
|
440
|
440
|
//console.log('sendOffer...');
|
441
|
441
|
var self = this;
|
442
|
442
|
this.peerconnection.createOffer(function (sdp) {
|
|
@@ -450,7 +450,7 @@ JingleSession.prototype.sendOffer = function () {
|
450
|
450
|
};
|
451
|
451
|
|
452
|
452
|
// FIXME createdOffer is never used in jitsi-meet
|
453
|
|
-JingleSession.prototype.createdOffer = function (sdp) {
|
|
453
|
+JingleSessionPC.prototype.createdOffer = function (sdp) {
|
454
|
454
|
//console.log('createdOffer', sdp);
|
455
|
455
|
var self = this;
|
456
|
456
|
this.localSDP = new SDP(sdp.sdp);
|
|
@@ -483,7 +483,7 @@ JingleSession.prototype.createdOffer = function (sdp) {
|
483
|
483
|
reason: $(stanza).find('error :first')[0].tagName,
|
484
|
484
|
}:{};
|
485
|
485
|
error.source = 'offer';
|
486
|
|
- JingleSession.onJingleError(self.sid, error);
|
|
486
|
+ JingleSessionPC.onJingleError(self.sid, error);
|
487
|
487
|
},
|
488
|
488
|
10000);
|
489
|
489
|
}
|
|
@@ -513,7 +513,7 @@ JingleSession.prototype.createdOffer = function (sdp) {
|
513
|
513
|
}
|
514
|
514
|
};
|
515
|
515
|
|
516
|
|
-JingleSession.prototype.readSsrcInfo = function (contents) {
|
|
516
|
+JingleSessionPC.prototype.readSsrcInfo = function (contents) {
|
517
|
517
|
var self = this;
|
518
|
518
|
$(contents).each(function (idx, content) {
|
519
|
519
|
var name = $(content).attr('name');
|
|
@@ -531,11 +531,11 @@ JingleSession.prototype.readSsrcInfo = function (contents) {
|
531
|
531
|
});
|
532
|
532
|
};
|
533
|
533
|
|
534
|
|
-JingleSession.prototype.getSsrcOwner = function (ssrc) {
|
|
534
|
+JingleSessionPC.prototype.getSsrcOwner = function (ssrc) {
|
535
|
535
|
return this.ssrcOwners[ssrc];
|
536
|
536
|
};
|
537
|
537
|
|
538
|
|
-JingleSession.prototype.setRemoteDescription = function (elem, desctype) {
|
|
538
|
+JingleSessionPC.prototype.setRemoteDescription = function (elem, desctype) {
|
539
|
539
|
//console.log('setting remote description... ', desctype);
|
540
|
540
|
this.remoteSDP = new SDP('');
|
541
|
541
|
this.remoteSDP.fromJingle(elem);
|
|
@@ -575,12 +575,12 @@ JingleSession.prototype.setRemoteDescription = function (elem, desctype) {
|
575
|
575
|
},
|
576
|
576
|
function (e) {
|
577
|
577
|
console.error('setRemoteDescription error', e);
|
578
|
|
- JingleSession.onJingleFatalError(self, e);
|
|
578
|
+ JingleSessionPC.onJingleFatalError(self, e);
|
579
|
579
|
}
|
580
|
580
|
);
|
581
|
581
|
};
|
582
|
582
|
|
583
|
|
-JingleSession.prototype.addIceCandidate = function (elem) {
|
|
583
|
+JingleSessionPC.prototype.addIceCandidate = function (elem) {
|
584
|
584
|
var self = this;
|
585
|
585
|
if (this.peerconnection.signalingState == 'closed') {
|
586
|
586
|
return;
|
|
@@ -688,7 +688,7 @@ JingleSession.prototype.addIceCandidate = function (elem) {
|
688
|
688
|
});
|
689
|
689
|
};
|
690
|
690
|
|
691
|
|
-JingleSession.prototype.sendAnswer = function (provisional) {
|
|
691
|
+JingleSessionPC.prototype.sendAnswer = function (provisional) {
|
692
|
692
|
//console.log('createAnswer', provisional);
|
693
|
693
|
var self = this;
|
694
|
694
|
this.peerconnection.createAnswer(
|
|
@@ -703,7 +703,7 @@ JingleSession.prototype.sendAnswer = function (provisional) {
|
703
|
703
|
);
|
704
|
704
|
};
|
705
|
705
|
|
706
|
|
-JingleSession.prototype.createdAnswer = function (sdp, provisional) {
|
|
706
|
+JingleSessionPC.prototype.createdAnswer = function (sdp, provisional) {
|
707
|
707
|
//console.log('createAnswer callback');
|
708
|
708
|
var self = this;
|
709
|
709
|
this.localSDP = new SDP(sdp.sdp);
|
|
@@ -747,7 +747,7 @@ JingleSession.prototype.createdAnswer = function (sdp, provisional) {
|
747
|
747
|
reason: $(stanza).find('error :first')[0].tagName,
|
748
|
748
|
}:{};
|
749
|
749
|
error.source = 'answer';
|
750
|
|
- JingleSession.onJingleError(self.sid, error);
|
|
750
|
+ JingleSessionPC.onJingleError(self.sid, error);
|
751
|
751
|
},
|
752
|
752
|
10000);
|
753
|
753
|
}
|
|
@@ -777,7 +777,7 @@ JingleSession.prototype.createdAnswer = function (sdp, provisional) {
|
777
|
777
|
}
|
778
|
778
|
};
|
779
|
779
|
|
780
|
|
-JingleSession.prototype.sendTerminate = function (reason, text) {
|
|
780
|
+JingleSessionPC.prototype.sendTerminate = function (reason, text) {
|
781
|
781
|
var self = this,
|
782
|
782
|
term = $iq({to: this.peerjid,
|
783
|
783
|
type: 'set'})
|
|
@@ -815,7 +815,7 @@ JingleSession.prototype.sendTerminate = function (reason, text) {
|
815
|
815
|
}
|
816
|
816
|
};
|
817
|
817
|
|
818
|
|
-JingleSession.prototype.addSource = function (elem, fromJid) {
|
|
818
|
+JingleSessionPC.prototype.addSource = function (elem, fromJid) {
|
819
|
819
|
|
820
|
820
|
var self = this;
|
821
|
821
|
// FIXME: dirty waiting
|
|
@@ -897,7 +897,7 @@ JingleSession.prototype.addSource = function (elem, fromJid) {
|
897
|
897
|
});
|
898
|
898
|
};
|
899
|
899
|
|
900
|
|
-JingleSession.prototype.removeSource = function (elem, fromJid) {
|
|
900
|
+JingleSessionPC.prototype.removeSource = function (elem, fromJid) {
|
901
|
901
|
|
902
|
902
|
var self = this;
|
903
|
903
|
// FIXME: dirty waiting
|
|
@@ -968,7 +968,7 @@ JingleSession.prototype.removeSource = function (elem, fromJid) {
|
968
|
968
|
});
|
969
|
969
|
};
|
970
|
970
|
|
971
|
|
-JingleSession.prototype._modifySources = function (successCallback, queueCallback) {
|
|
971
|
+JingleSessionPC.prototype._modifySources = function (successCallback, queueCallback) {
|
972
|
972
|
var self = this;
|
973
|
973
|
|
974
|
974
|
if (this.peerconnection.signalingState == 'closed') return;
|
|
@@ -1074,7 +1074,7 @@ JingleSession.prototype._modifySources = function (successCallback, queueCallbac
|
1074
|
1074
|
* @param oldStream old video stream of this session.
|
1075
|
1075
|
* @param success_callback callback executed after successful stream switch.
|
1076
|
1076
|
*/
|
1077
|
|
-JingleSession.prototype.switchStreams = function (new_stream, oldStream, success_callback, isAudio) {
|
|
1077
|
+JingleSessionPC.prototype.switchStreams = function (new_stream, oldStream, success_callback, isAudio) {
|
1078
|
1078
|
|
1079
|
1079
|
var self = this;
|
1080
|
1080
|
|
|
@@ -1112,7 +1112,7 @@ JingleSession.prototype.switchStreams = function (new_stream, oldStream, success
|
1112
|
1112
|
* @param old_sdp SDP object for old description.
|
1113
|
1113
|
* @param new_sdp SDP object for new description.
|
1114
|
1114
|
*/
|
1115
|
|
-JingleSession.prototype.notifyMySSRCUpdate = function (old_sdp, new_sdp) {
|
|
1115
|
+JingleSessionPC.prototype.notifyMySSRCUpdate = function (old_sdp, new_sdp) {
|
1116
|
1116
|
|
1117
|
1117
|
if (!(this.peerconnection.signalingState == 'stable' &&
|
1118
|
1118
|
this.peerconnection.iceConnectionState == 'connected')){
|
|
@@ -1197,7 +1197,7 @@ JingleSession.prototype.notifyMySSRCUpdate = function (old_sdp, new_sdp) {
|
1197
|
1197
|
* specifies whether the method was initiated in response to a user command (in
|
1198
|
1198
|
* contrast to an automatic decision made by the application logic)
|
1199
|
1199
|
*/
|
1200
|
|
-JingleSession.prototype.setVideoMute = function (mute, callback, options) {
|
|
1200
|
+JingleSessionPC.prototype.setVideoMute = function (mute, callback, options) {
|
1201
|
1201
|
var byUser;
|
1202
|
1202
|
|
1203
|
1203
|
if (options) {
|
|
@@ -1237,11 +1237,11 @@ JingleSession.prototype.setVideoMute = function (mute, callback, options) {
|
1237
|
1237
|
});
|
1238
|
1238
|
};
|
1239
|
1239
|
|
1240
|
|
-JingleSession.prototype.hardMuteVideo = function (muted) {
|
|
1240
|
+JingleSessionPC.prototype.hardMuteVideo = function (muted) {
|
1241
|
1241
|
this.pendingop = muted ? 'mute' : 'unmute';
|
1242
|
1242
|
};
|
1243
|
1243
|
|
1244
|
|
-JingleSession.prototype.sendMute = function (muted, content) {
|
|
1244
|
+JingleSessionPC.prototype.sendMute = function (muted, content) {
|
1245
|
1245
|
var info = $iq({to: this.peerjid,
|
1246
|
1246
|
type: 'set'})
|
1247
|
1247
|
.c('jingle', {xmlns: 'urn:xmpp:jingle:1',
|
|
@@ -1256,7 +1256,7 @@ JingleSession.prototype.sendMute = function (muted, content) {
|
1256
|
1256
|
this.connection.send(info);
|
1257
|
1257
|
};
|
1258
|
1258
|
|
1259
|
|
-JingleSession.prototype.sendRinging = function () {
|
|
1259
|
+JingleSessionPC.prototype.sendRinging = function () {
|
1260
|
1260
|
var info = $iq({to: this.peerjid,
|
1261
|
1261
|
type: 'set'})
|
1262
|
1262
|
.c('jingle', {xmlns: 'urn:xmpp:jingle:1',
|
|
@@ -1267,7 +1267,7 @@ JingleSession.prototype.sendRinging = function () {
|
1267
|
1267
|
this.connection.send(info);
|
1268
|
1268
|
};
|
1269
|
1269
|
|
1270
|
|
-JingleSession.prototype.getStats = function (interval) {
|
|
1270
|
+JingleSessionPC.prototype.getStats = function (interval) {
|
1271
|
1271
|
var self = this;
|
1272
|
1272
|
var recv = {audio: 0, video: 0};
|
1273
|
1273
|
var lost = {audio: 0, video: 0};
|
|
@@ -1313,12 +1313,12 @@ JingleSession.prototype.getStats = function (interval) {
|
1313
|
1313
|
return this.statsinterval;
|
1314
|
1314
|
};
|
1315
|
1315
|
|
1316
|
|
-JingleSession.onJingleError = function (session, error)
|
|
1316
|
+JingleSessionPC.onJingleError = function (session, error)
|
1317
|
1317
|
{
|
1318
|
1318
|
console.error("Jingle error", error);
|
1319
|
1319
|
}
|
1320
|
1320
|
|
1321
|
|
-JingleSession.onJingleFatalError = function (session, error)
|
|
1321
|
+JingleSessionPC.onJingleFatalError = function (session, error)
|
1322
|
1322
|
{
|
1323
|
1323
|
this.service.sessionTerminated = true;
|
1324
|
1324
|
this.connection.emuc.doLeave();
|
|
@@ -1326,7 +1326,7 @@ JingleSession.onJingleFatalError = function (session, error)
|
1326
|
1326
|
this.eventEmitter.emit(XMPPEvents.JINGLE_FATAL_ERROR, session, error);
|
1327
|
1327
|
}
|
1328
|
1328
|
|
1329
|
|
-JingleSession.prototype.setLocalDescription = function () {
|
|
1329
|
+JingleSessionPC.prototype.setLocalDescription = function () {
|
1330
|
1330
|
var self = this;
|
1331
|
1331
|
var newssrcs = [];
|
1332
|
1332
|
var session = transform.parse(this.peerconnection.localDescription.sdp);
|
|
@@ -1401,7 +1401,7 @@ function sendKeyframe(pc) {
|
1401
|
1401
|
}
|
1402
|
1402
|
|
1403
|
1403
|
|
1404
|
|
-JingleSession.prototype.remoteStreamAdded = function (data, times) {
|
|
1404
|
+JingleSessionPC.prototype.remoteStreamAdded = function (data, times) {
|
1405
|
1405
|
var self = this;
|
1406
|
1406
|
var thessrc;
|
1407
|
1407
|
var streamId = APP.RTC.getStreamID(data.stream);
|
|
@@ -1453,4 +1453,4 @@ JingleSession.prototype.remoteStreamAdded = function (data, times) {
|
1453
|
1453
|
}
|
1454
|
1454
|
}
|
1455
|
1455
|
|
1456
|
|
-module.exports = JingleSession;
|
|
1456
|
+module.exports = JingleSessionPC;
|