|
@@ -2,6 +2,7 @@
|
2
|
2
|
var RTC = require("./modules/RTC/RTC");
|
3
|
3
|
var XMPPEvents = require("./service/xmpp/XMPPEvents");
|
4
|
4
|
var StreamEventTypes = require("./service/RTC/StreamEventTypes");
|
|
5
|
+var RTCEvents = require("./service/RTC/RTCEvents");
|
5
|
6
|
var EventEmitter = require("events");
|
6
|
7
|
var JitsiConferenceEvents = require("./JitsiConferenceEvents");
|
7
|
8
|
|
|
@@ -183,6 +184,10 @@ JitsiConference.prototype.getParticipantById = function(id) {
|
183
|
184
|
|
184
|
185
|
}
|
185
|
186
|
|
|
187
|
+/**
|
|
188
|
+ * Setups the listeners needed for the conference.
|
|
189
|
+ * @param conference the conference
|
|
190
|
+ */
|
186
|
191
|
function setupListeners(conference) {
|
187
|
192
|
conference.xmpp.addListener(XMPPEvents.CALL_INCOMING,
|
188
|
193
|
conference.rtc.onIncommingCall.bind(conference.rtc));
|
|
@@ -196,13 +201,37 @@ function setupListeners(conference) {
|
196
|
201
|
})
|
197
|
202
|
conference.room.addListener(XMPPEvents.MUC_JOINED, function () {
|
198
|
203
|
conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_JOINED);
|
199
|
|
- })
|
|
204
|
+ });
|
|
205
|
+ conference.room.addListener(XMPPEvents.MUC_JOINED, function () {
|
|
206
|
+ conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_LEFT);
|
|
207
|
+ });
|
|
208
|
+ conference.rtc.addListener(RTCEvents.DOMINANTSPEAKER_CHANGED, function (id) {
|
|
209
|
+ conference.eventEmitter.emit(JitsiConferenceEvents.ACTIVE_SPEAKER_CHANGED);
|
|
210
|
+ });
|
|
211
|
+
|
|
212
|
+ conference.rtc.addListener(RTCEvents.LASTN_CHANGED, function (oldValue, newValue) {
|
|
213
|
+ conference.eventEmitter.emit(JitsiConferenceEvents.IN_LAST_N_CHANGED, oldValue, newValue);
|
|
214
|
+ });
|
|
215
|
+
|
|
216
|
+ conference.rtc.addListener(RTCEvents.LASTN_ENDPOINT_CHANGED,
|
|
217
|
+ function (lastNEndpoints, endpointsEnteringLastN) {
|
|
218
|
+ conference.eventEmitter.emit(JitsiConferenceEvents.LAST_N_ENDPOINTS_CHANGED,
|
|
219
|
+ lastNEndpoints, endpointsEnteringLastN);
|
|
220
|
+ });
|
|
221
|
+
|
|
222
|
+ conference.room.addListener(XMPPEvents.MUC_MEMBER_JOINED,
|
|
223
|
+ function (jid, email, nick) {
|
|
224
|
+ conference.eventEmitter.emit(JitsiConferenceEvents.USER_JOINED, Strophe.getResourceFromJid(jid));
|
|
225
|
+ });
|
|
226
|
+ conference.room.addListener(XMPPEvents.MUC_MEMBER_LEFT,function (jid) {
|
|
227
|
+ conference.eventEmitter.emit(JitsiConferenceEvents.USER_LEFT, Strophe.getResourceFromJid(jid));
|
|
228
|
+ });
|
200
|
229
|
}
|
201
|
230
|
|
202
|
231
|
|
203
|
232
|
module.exports = JitsiConference;
|
204
|
233
|
|
205
|
|
-},{"./JitsiConferenceEvents":3,"./modules/RTC/RTC":12,"./service/RTC/StreamEventTypes":72,"./service/xmpp/XMPPEvents":75,"events":76}],2:[function(require,module,exports){
|
|
234
|
+},{"./JitsiConferenceEvents":3,"./modules/RTC/RTC":12,"./service/RTC/RTCEvents":70,"./service/RTC/StreamEventTypes":72,"./service/xmpp/XMPPEvents":75,"events":76}],2:[function(require,module,exports){
|
206
|
235
|
/**
|
207
|
236
|
* Enumeration with the errors for the conference.
|
208
|
237
|
* @type {{string: string}}
|
|
@@ -272,7 +301,11 @@ var JitsiConferenceEvents = {
|
272
|
301
|
/**
|
273
|
302
|
* The Last N set is changed.
|
274
|
303
|
*/
|
275
|
|
- LAST_N_CHANGED: "conference.lastNChanged",
|
|
304
|
+ LAST_N_ENDPOINTS_CHANGED: "conference.lastNEndpointsChanged",
|
|
305
|
+ /**
|
|
306
|
+ * You are included / excluded in somebody's last N set
|
|
307
|
+ */
|
|
308
|
+ IN_LAST_N_CHANGED: "conference.lastNEndpointsChanged",
|
276
|
309
|
/**
|
277
|
310
|
* A media track was muted.
|
278
|
311
|
*/
|
|
@@ -513,6 +546,7 @@ function DataChannels(peerConnection, emitter) {
|
513
|
546
|
*/
|
514
|
547
|
DataChannels.prototype.onDataChannel = function (event) {
|
515
|
548
|
var dataChannel = event.channel;
|
|
549
|
+ var self = this;
|
516
|
550
|
|
517
|
551
|
dataChannel.onopen = function () {
|
518
|
552
|
console.info("Data channel opened by the Videobridge!", dataChannel);
|
|
@@ -523,8 +557,8 @@ DataChannels.prototype.onDataChannel = function (event) {
|
523
|
557
|
// Sends 12 bytes binary message to the bridge
|
524
|
558
|
//dataChannel.send(new ArrayBuffer(12));
|
525
|
559
|
|
526
|
|
- this.eventEmitter.emit(RTCEvents.DATA_CHANNEL_OPEN);
|
527
|
|
- }.bind(this);
|
|
560
|
+ self.eventEmitter.emit(RTCEvents.DATA_CHANNEL_OPEN);
|
|
561
|
+ };
|
528
|
562
|
|
529
|
563
|
dataChannel.onerror = function (error) {
|
530
|
564
|
console.error("Data Channel Error:", error, dataChannel);
|
|
@@ -554,7 +588,7 @@ DataChannels.prototype.onDataChannel = function (event) {
|
554
|
588
|
console.info(
|
555
|
589
|
"Data channel new dominant speaker event: ",
|
556
|
590
|
dominantSpeakerEndpoint);
|
557
|
|
- this.eventEmitter.emit(RTCEvents.DOMINANTSPEAKER_CHANGED, dominantSpeakerEndpoint);
|
|
591
|
+ self.eventEmitter.emit(RTCEvents.DOMINANTSPEAKER_CHANGED, dominantSpeakerEndpoint);
|
558
|
592
|
}
|
559
|
593
|
else if ("InLastNChangeEvent" === colibriClass) {
|
560
|
594
|
var oldValue = obj.oldValue;
|
|
@@ -577,7 +611,7 @@ DataChannels.prototype.onDataChannel = function (event) {
|
577
|
611
|
}
|
578
|
612
|
}
|
579
|
613
|
|
580
|
|
- this.eventEmitter.emit(RTCEvents.LASTN_CHANGED, oldValue, newValue);
|
|
614
|
+ self.eventEmitter.emit(RTCEvents.LASTN_CHANGED, oldValue, newValue);
|
581
|
615
|
}
|
582
|
616
|
else if ("LastNEndpointsChangeEvent" === colibriClass) {
|
583
|
617
|
// The new/latest list of last-n endpoint IDs.
|
|
@@ -597,14 +631,14 @@ DataChannels.prototype.onDataChannel = function (event) {
|
597
|
631
|
console.debug("Data channel JSON-formatted message: ", obj);
|
598
|
632
|
}
|
599
|
633
|
}
|
600
|
|
- }.bind(this);
|
|
634
|
+ };
|
601
|
635
|
|
602
|
636
|
dataChannel.onclose = function () {
|
603
|
637
|
console.info("The Data Channel closed", dataChannel);
|
604
|
|
- var idx = this._dataChannels.indexOf(dataChannel);
|
|
638
|
+ var idx = self._dataChannels.indexOf(dataChannel);
|
605
|
639
|
if (idx > -1)
|
606
|
|
- this._dataChannels = this._dataChannels.splice(idx, 1);
|
607
|
|
- }.bind(this);
|
|
640
|
+ self._dataChannels = self._dataChannels.splice(idx, 1);
|
|
641
|
+ };
|
608
|
642
|
this._dataChannels.push(dataChannel);
|
609
|
643
|
};
|
610
|
644
|
|
|
@@ -797,6 +831,13 @@ JitsiRemoteTrack.prototype._setMute = function (value) {
|
797
|
831
|
this.muted = value;
|
798
|
832
|
};
|
799
|
833
|
|
|
834
|
+/**
|
|
835
|
+ * @returns {JitsiParticipant} to which this track belongs, or null if it is a local track.
|
|
836
|
+ */
|
|
837
|
+JitsiRemoteTrack.prototype.getParitcipantId = function() {
|
|
838
|
+ return Strophe.getResourceFromJid(this.peerjid);
|
|
839
|
+};
|
|
840
|
+
|
800
|
841
|
delete JitsiRemoteTrack.prototype.stop;
|
801
|
842
|
|
802
|
843
|
delete JitsiRemoteTrack.prototype.start;
|
|
@@ -846,13 +887,6 @@ JitsiTrack.prototype.getType = function() {
|
846
|
887
|
return this.type;
|
847
|
888
|
};
|
848
|
889
|
|
849
|
|
-/**
|
850
|
|
- * @returns {JitsiParticipant} to which this track belongs, or null if it is a local track.
|
851
|
|
- */
|
852
|
|
-JitsiTrack.prototype.getParitcipant = function() {
|
853
|
|
-
|
854
|
|
-};
|
855
|
|
-
|
856
|
890
|
/**
|
857
|
891
|
* Returns the RTCMediaStream from the browser (?).
|
858
|
892
|
*/
|
|
@@ -4347,7 +4381,7 @@ ChatRoom.prototype.removeListener = function (type, listener) {
|
4347
|
4381
|
this.eventEmitter.removeListener(type, listener);
|
4348
|
4382
|
};
|
4349
|
4383
|
|
4350
|
|
-ChatRoom.prototype.fireRemoteStreamEvent = function(data, sid, thessrc) {
|
|
4384
|
+ChatRoom.prototype.remoteStreamAdded = function(data, sid, thessrc) {
|
4351
|
4385
|
this.eventEmitter.emit(XMPPEvents.REMOTE_STREAM_RECEIVED, data, sid, thessrc);
|
4352
|
4386
|
}
|
4353
|
4387
|
|
|
@@ -4503,8 +4537,8 @@ var SSRCReplacement = require("./LocalSSRCReplacement");
|
4503
|
4537
|
var RTC = require("../RTC/RTC");
|
4504
|
4538
|
|
4505
|
4539
|
// Jingle stuff
|
4506
|
|
-function JingleSessionPC(me, sid, connection, service, eventEmitter) {
|
4507
|
|
- JingleSession.call(this, me, sid, connection, service, eventEmitter);
|
|
4540
|
+function JingleSessionPC(me, sid, connection, service) {
|
|
4541
|
+ JingleSession.call(this, me, sid, connection, service);
|
4508
|
4542
|
this.initiator = null;
|
4509
|
4543
|
this.responder = null;
|
4510
|
4544
|
this.peerjid = null;
|
|
@@ -4533,7 +4567,6 @@ function JingleSessionPC(me, sid, connection, service, eventEmitter) {
|
4533
|
4567
|
this.localStreamsSSRC = null;
|
4534
|
4568
|
this.ssrcOwners = {};
|
4535
|
4569
|
this.ssrcVideoTypes = {};
|
4536
|
|
- this.eventEmitter = eventEmitter;
|
4537
|
4570
|
|
4538
|
4571
|
/**
|
4539
|
4572
|
* The indicator which determines whether the (local) video has been muted
|
|
@@ -4561,7 +4594,6 @@ JingleSessionPC.prototype.setAnswer = function(answer) {
|
4561
|
4594
|
JingleSessionPC.prototype.updateModifySourcesQueue = function() {
|
4562
|
4595
|
var signalingState = this.peerconnection.signalingState;
|
4563
|
4596
|
var iceConnectionState = this.peerconnection.iceConnectionState;
|
4564
|
|
- console.debug(signalingState + " + " + iceConnectionState);
|
4565
|
4597
|
if (signalingState === 'stable' && iceConnectionState === 'connected') {
|
4566
|
4598
|
this.modifySourcesQueue.resume();
|
4567
|
4599
|
} else {
|
|
@@ -4604,9 +4636,7 @@ JingleSessionPC.prototype.doInitialize = function () {
|
4604
|
4636
|
$(document).trigger('remotestreamremoved.jingle', [event, self.sid]);
|
4605
|
4637
|
};
|
4606
|
4638
|
this.peerconnection.onsignalingstatechange = function (event) {
|
4607
|
|
- console.debug("signaling state11");
|
4608
|
4639
|
if (!(self && self.peerconnection)) return;
|
4609
|
|
- console.debug("signaling state222");
|
4610
|
4640
|
self.updateModifySourcesQueue();
|
4611
|
4641
|
};
|
4612
|
4642
|
/**
|
|
@@ -4617,16 +4647,14 @@ JingleSessionPC.prototype.doInitialize = function () {
|
4617
|
4647
|
* @param event the event containing information about the change
|
4618
|
4648
|
*/
|
4619
|
4649
|
this.peerconnection.oniceconnectionstatechange = function (event) {
|
4620
|
|
- console.debug("ice state11");
|
4621
|
4650
|
if (!(self && self.peerconnection)) return;
|
4622
|
|
- console.debug("ice state222");
|
4623
|
4651
|
self.updateModifySourcesQueue();
|
4624
|
4652
|
switch (self.peerconnection.iceConnectionState) {
|
4625
|
4653
|
case 'connected':
|
4626
|
4654
|
|
4627
|
4655
|
// Informs interested parties that the connection has been restored.
|
4628
|
4656
|
if (self.peerconnection.signalingState === 'stable' && self.isreconnect)
|
4629
|
|
- self.eventEmitter.emit(XMPPEvents.CONNECTION_RESTORED);
|
|
4657
|
+ self.room.eventEmitter.emit(XMPPEvents.CONNECTION_RESTORED);
|
4630
|
4658
|
self.isreconnect = false;
|
4631
|
4659
|
|
4632
|
4660
|
break;
|
|
@@ -4634,16 +4662,16 @@ JingleSessionPC.prototype.doInitialize = function () {
|
4634
|
4662
|
self.isreconnect = true;
|
4635
|
4663
|
// Informs interested parties that the connection has been interrupted.
|
4636
|
4664
|
if (self.peerconnection.signalingState === 'stable')
|
4637
|
|
- self.eventEmitter.emit(XMPPEvents.CONNECTION_INTERRUPTED);
|
|
4665
|
+ self.room.eventEmitter.emit(XMPPEvents.CONNECTION_INTERRUPTED);
|
4638
|
4666
|
break;
|
4639
|
4667
|
case 'failed':
|
4640
|
|
- self.eventEmitter.emit(XMPPEvents.CONFERENCE_SETUP_FAILED);
|
|
4668
|
+ self.room.eventEmitter.emit(XMPPEvents.CONFERENCE_SETUP_FAILED);
|
4641
|
4669
|
break;
|
4642
|
4670
|
}
|
4643
|
4671
|
onIceConnectionStateChange(self.sid, self);
|
4644
|
4672
|
};
|
4645
|
4673
|
this.peerconnection.onnegotiationneeded = function (event) {
|
4646
|
|
- self.eventEmitter.emit(XMPPEvents.PEERCONNECTION_READY, self);
|
|
4674
|
+ self.room.eventEmitter.emit(XMPPEvents.PEERCONNECTION_READY, self);
|
4647
|
4675
|
};
|
4648
|
4676
|
|
4649
|
4677
|
this.relayedStreams.forEach(function(stream) {
|
|
@@ -4765,7 +4793,7 @@ JingleSessionPC.prototype.accept = function () {
|
4765
|
4793
|
},
|
4766
|
4794
|
function (e) {
|
4767
|
4795
|
console.error('setLocalDescription failed', e);
|
4768
|
|
- self.eventEmitter.emit(XMPPEvents.CONFERENCE_SETUP_FAILED);
|
|
4796
|
+ self.room.eventEmitter.emit(XMPPEvents.CONFERENCE_SETUP_FAILED);
|
4769
|
4797
|
}
|
4770
|
4798
|
);
|
4771
|
4799
|
};
|
|
@@ -4989,7 +5017,7 @@ JingleSessionPC.prototype.createdOffer = function (sdp) {
|
4989
|
5017
|
},
|
4990
|
5018
|
function (e) {
|
4991
|
5019
|
console.error('setLocalDescription failed', e);
|
4992
|
|
- self.eventEmitter.emit(XMPPEvents.CONFERENCE_SETUP_FAILED);
|
|
5020
|
+ self.room.eventEmitter.emit(XMPPEvents.CONFERENCE_SETUP_FAILED);
|
4993
|
5021
|
}
|
4994
|
5022
|
);
|
4995
|
5023
|
var cands = SDPUtil.find_lines(this.localSDP.raw, 'a=candidate:');
|
|
@@ -5187,7 +5215,7 @@ JingleSessionPC.prototype.sendAnswer = function (provisional) {
|
5187
|
5215
|
},
|
5188
|
5216
|
function (e) {
|
5189
|
5217
|
console.error('createAnswer failed', e);
|
5190
|
|
- self.eventEmitter.emit(XMPPEvents.CONFERENCE_SETUP_FAILED);
|
|
5218
|
+ self.room.eventEmitter.emit(XMPPEvents.CONFERENCE_SETUP_FAILED);
|
5191
|
5219
|
},
|
5192
|
5220
|
this.media_constraints
|
5193
|
5221
|
);
|
|
@@ -5253,7 +5281,7 @@ JingleSessionPC.prototype.createdAnswer = function (sdp, provisional) {
|
5253
|
5281
|
},
|
5254
|
5282
|
function (e) {
|
5255
|
5283
|
console.error('setLocalDescription failed', e);
|
5256
|
|
- self.eventEmitter.emit(XMPPEvents.CONFERENCE_SETUP_FAILED);
|
|
5284
|
+ self.room.eventEmitter.emit(XMPPEvents.CONFERENCE_SETUP_FAILED);
|
5257
|
5285
|
}
|
5258
|
5286
|
);
|
5259
|
5287
|
var cands = SDPUtil.find_lines(this.localSDP.raw, 'a=candidate:');
|
|
@@ -5844,8 +5872,8 @@ JingleSessionPC.onJingleError = function (session, error)
|
5844
|
5872
|
|
5845
|
5873
|
JingleSessionPC.onJingleFatalError = function (session, error)
|
5846
|
5874
|
{
|
5847
|
|
- this.eventEmitter.emit(XMPPEvents.CONFERENCE_SETUP_FAILED);
|
5848
|
|
- this.eventEmitter.emit(XMPPEvents.JINGLE_FATAL_ERROR, session, error);
|
|
5875
|
+ this.room.eventEmitter.emit(XMPPEvents.CONFERENCE_SETUP_FAILED);
|
|
5876
|
+ this.room.eventEmitter.emit(XMPPEvents.JINGLE_FATAL_ERROR, session, error);
|
5849
|
5877
|
}
|
5850
|
5878
|
|
5851
|
5879
|
JingleSessionPC.prototype.setLocalDescription = function () {
|
|
@@ -5889,7 +5917,8 @@ JingleSessionPC.prototype.setLocalDescription = function () {
|
5889
|
5917
|
}
|
5890
|
5918
|
|
5891
|
5919
|
// an attempt to work around https://github.com/jitsi/jitmeet/issues/32
|
5892
|
|
-function sendKeyframe(pc) {
|
|
5920
|
+JingleSessionPC.prototype.sendKeyframe = function () {
|
|
5921
|
+ var pc = this.peerconnection;
|
5893
|
5922
|
console.log('sendkeyframe', pc.iceConnectionState);
|
5894
|
5923
|
if (pc.iceConnectionState !== 'connected') return; // safe...
|
5895
|
5924
|
var self = this;
|
|
@@ -5905,13 +5934,13 @@ function sendKeyframe(pc) {
|
5905
|
5934
|
},
|
5906
|
5935
|
function (error) {
|
5907
|
5936
|
console.log('triggerKeyframe setLocalDescription failed', error);
|
5908
|
|
- eventEmitter.emit(XMPPEvents.SET_LOCAL_DESCRIPTION_ERROR);
|
|
5937
|
+ self.room.eventEmitter.emit(XMPPEvents.SET_LOCAL_DESCRIPTION_ERROR);
|
5909
|
5938
|
}
|
5910
|
5939
|
);
|
5911
|
5940
|
},
|
5912
|
5941
|
function (error) {
|
5913
|
5942
|
console.log('triggerKeyframe createAnswer failed', error);
|
5914
|
|
- eventEmitter.emit(XMPPEvents.CREATE_ANSWER_ERROR);
|
|
5943
|
+ self.room.eventEmitter.emit(XMPPEvents.CREATE_ANSWER_ERROR);
|
5915
|
5944
|
}
|
5916
|
5945
|
);
|
5917
|
5946
|
},
|
|
@@ -5961,7 +5990,7 @@ JingleSessionPC.prototype.remoteStreamAdded = function (data, times) {
|
5961
|
5990
|
}
|
5962
|
5991
|
}
|
5963
|
5992
|
|
5964
|
|
- this.room.fireRemoteStreamEvent(data, this.sid, thessrc);
|
|
5993
|
+ this.room.remoteStreamAdded(data, this.sid, thessrc);
|
5965
|
5994
|
|
5966
|
5995
|
var isVideo = data.stream.getVideoTracks().length > 0;
|
5967
|
5996
|
// an attempt to work around https://github.com/jitsi/jitmeet/issues/32
|
|
@@ -5970,7 +5999,7 @@ JingleSessionPC.prototype.remoteStreamAdded = function (data, times) {
|
5970
|
5999
|
data.stream.getVideoTracks().length === 0 &&
|
5971
|
6000
|
RTC.localVideo.getTracks().length > 0) {
|
5972
|
6001
|
window.setTimeout(function () {
|
5973
|
|
- sendKeyframe(self.peerconnection);
|
|
6002
|
+ self.sendKeyframe();
|
5974
|
6003
|
}, 3000);
|
5975
|
6004
|
}
|
5976
|
6005
|
}
|
|
@@ -8472,7 +8501,7 @@ module.exports = function(XMPP, eventEmitter) {
|
8472
|
8501
|
}
|
8473
|
8502
|
sess = new JingleSession(
|
8474
|
8503
|
$(iq).attr('to'), $(iq).find('jingle').attr('sid'),
|
8475
|
|
- this.connection, XMPP, eventEmitter);
|
|
8504
|
+ this.connection, XMPP);
|
8476
|
8505
|
// configure session
|
8477
|
8506
|
|
8478
|
8507
|
var fromBareJid = Strophe.getBareJidFromJid(fromJid);
|