Browse Source

Implements some conference events.

dev1
hristoterezov 10 years ago
parent
commit
036635dee6

+ 30
- 1
JitsiConference.js View File

1
 var RTC = require("./modules/RTC/RTC");
1
 var RTC = require("./modules/RTC/RTC");
2
 var XMPPEvents = require("./service/xmpp/XMPPEvents");
2
 var XMPPEvents = require("./service/xmpp/XMPPEvents");
3
 var StreamEventTypes = require("./service/RTC/StreamEventTypes");
3
 var StreamEventTypes = require("./service/RTC/StreamEventTypes");
4
+var RTCEvents = require("./service/RTC/RTCEvents");
4
 var EventEmitter = require("events");
5
 var EventEmitter = require("events");
5
 var JitsiConferenceEvents = require("./JitsiConferenceEvents");
6
 var JitsiConferenceEvents = require("./JitsiConferenceEvents");
6
 
7
 
182
 
183
 
183
 }
184
 }
184
 
185
 
186
+/**
187
+ * Setups the listeners needed for the conference.
188
+ * @param conference the conference
189
+ */
185
 function setupListeners(conference) {
190
 function setupListeners(conference) {
186
     conference.xmpp.addListener(XMPPEvents.CALL_INCOMING,
191
     conference.xmpp.addListener(XMPPEvents.CALL_INCOMING,
187
         conference.rtc.onIncommingCall.bind(conference.rtc));
192
         conference.rtc.onIncommingCall.bind(conference.rtc));
195
     })
200
     })
196
     conference.room.addListener(XMPPEvents.MUC_JOINED, function () {
201
     conference.room.addListener(XMPPEvents.MUC_JOINED, function () {
197
         conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_JOINED);
202
         conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_JOINED);
198
-    })
203
+    });
204
+    conference.room.addListener(XMPPEvents.MUC_JOINED, function () {
205
+        conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_LEFT);
206
+    });
207
+    conference.rtc.addListener(RTCEvents.DOMINANTSPEAKER_CHANGED, function (id) {
208
+        conference.eventEmitter.emit(JitsiConferenceEvents.ACTIVE_SPEAKER_CHANGED);
209
+    });
210
+
211
+    conference.rtc.addListener(RTCEvents.LASTN_CHANGED, function (oldValue, newValue) {
212
+        conference.eventEmitter.emit(JitsiConferenceEvents.IN_LAST_N_CHANGED, oldValue, newValue);
213
+    });
214
+
215
+    conference.rtc.addListener(RTCEvents.LASTN_ENDPOINT_CHANGED,
216
+        function (lastNEndpoints, endpointsEnteringLastN) {
217
+            conference.eventEmitter.emit(JitsiConferenceEvents.LAST_N_ENDPOINTS_CHANGED,
218
+                lastNEndpoints, endpointsEnteringLastN);
219
+        });
220
+
221
+    conference.room.addListener(XMPPEvents.MUC_MEMBER_JOINED,
222
+        function (jid, email, nick) {
223
+            conference.eventEmitter.emit(JitsiConferenceEvents.USER_JOINED, Strophe.getResourceFromJid(jid));
224
+        });
225
+    conference.room.addListener(XMPPEvents.MUC_MEMBER_LEFT,function (jid) {
226
+        conference.eventEmitter.emit(JitsiConferenceEvents.USER_LEFT, Strophe.getResourceFromJid(jid));
227
+    });
199
 }
228
 }
200
 
229
 
201
 
230
 

+ 5
- 1
JitsiConferenceEvents.js View File

42
     /**
42
     /**
43
      * The Last N set is changed.
43
      * The Last N set is changed.
44
      */
44
      */
45
-    LAST_N_CHANGED: "conference.lastNChanged",
45
+    LAST_N_ENDPOINTS_CHANGED: "conference.lastNEndpointsChanged",
46
+    /**
47
+     * You are included / excluded in somebody's last N set
48
+     */
49
+    IN_LAST_N_CHANGED: "conference.lastNEndpointsChanged",
46
     /**
50
     /**
47
      * A media track was muted.
51
      * A media track was muted.
48
      */
52
      */

+ 72
- 43
lib-jitsi-meet.js View File

2
 var RTC = require("./modules/RTC/RTC");
2
 var RTC = require("./modules/RTC/RTC");
3
 var XMPPEvents = require("./service/xmpp/XMPPEvents");
3
 var XMPPEvents = require("./service/xmpp/XMPPEvents");
4
 var StreamEventTypes = require("./service/RTC/StreamEventTypes");
4
 var StreamEventTypes = require("./service/RTC/StreamEventTypes");
5
+var RTCEvents = require("./service/RTC/RTCEvents");
5
 var EventEmitter = require("events");
6
 var EventEmitter = require("events");
6
 var JitsiConferenceEvents = require("./JitsiConferenceEvents");
7
 var JitsiConferenceEvents = require("./JitsiConferenceEvents");
7
 
8
 
183
 
184
 
184
 }
185
 }
185
 
186
 
187
+/**
188
+ * Setups the listeners needed for the conference.
189
+ * @param conference the conference
190
+ */
186
 function setupListeners(conference) {
191
 function setupListeners(conference) {
187
     conference.xmpp.addListener(XMPPEvents.CALL_INCOMING,
192
     conference.xmpp.addListener(XMPPEvents.CALL_INCOMING,
188
         conference.rtc.onIncommingCall.bind(conference.rtc));
193
         conference.rtc.onIncommingCall.bind(conference.rtc));
196
     })
201
     })
197
     conference.room.addListener(XMPPEvents.MUC_JOINED, function () {
202
     conference.room.addListener(XMPPEvents.MUC_JOINED, function () {
198
         conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_JOINED);
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
 module.exports = JitsiConference;
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
  * Enumeration with the errors for the conference.
236
  * Enumeration with the errors for the conference.
208
  * @type {{string: string}}
237
  * @type {{string: string}}
272
     /**
301
     /**
273
      * The Last N set is changed.
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
      * A media track was muted.
310
      * A media track was muted.
278
      */
311
      */
513
  */
546
  */
514
 DataChannels.prototype.onDataChannel = function (event) {
547
 DataChannels.prototype.onDataChannel = function (event) {
515
     var dataChannel = event.channel;
548
     var dataChannel = event.channel;
549
+    var self = this;
516
 
550
 
517
     dataChannel.onopen = function () {
551
     dataChannel.onopen = function () {
518
         console.info("Data channel opened by the Videobridge!", dataChannel);
552
         console.info("Data channel opened by the Videobridge!", dataChannel);
523
         // Sends 12 bytes binary message to the bridge
557
         // Sends 12 bytes binary message to the bridge
524
         //dataChannel.send(new ArrayBuffer(12));
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
     dataChannel.onerror = function (error) {
563
     dataChannel.onerror = function (error) {
530
         console.error("Data Channel Error:", error, dataChannel);
564
         console.error("Data Channel Error:", error, dataChannel);
554
                 console.info(
588
                 console.info(
555
                     "Data channel new dominant speaker event: ",
589
                     "Data channel new dominant speaker event: ",
556
                     dominantSpeakerEndpoint);
590
                     dominantSpeakerEndpoint);
557
-                this.eventEmitter.emit(RTCEvents.DOMINANTSPEAKER_CHANGED, dominantSpeakerEndpoint);
591
+                self.eventEmitter.emit(RTCEvents.DOMINANTSPEAKER_CHANGED, dominantSpeakerEndpoint);
558
             }
592
             }
559
             else if ("InLastNChangeEvent" === colibriClass) {
593
             else if ("InLastNChangeEvent" === colibriClass) {
560
                 var oldValue = obj.oldValue;
594
                 var oldValue = obj.oldValue;
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
             else if ("LastNEndpointsChangeEvent" === colibriClass) {
616
             else if ("LastNEndpointsChangeEvent" === colibriClass) {
583
                 // The new/latest list of last-n endpoint IDs.
617
                 // The new/latest list of last-n endpoint IDs.
597
                 console.debug("Data channel JSON-formatted message: ", obj);
631
                 console.debug("Data channel JSON-formatted message: ", obj);
598
             }
632
             }
599
         }
633
         }
600
-    }.bind(this);
634
+    };
601
 
635
 
602
     dataChannel.onclose = function () {
636
     dataChannel.onclose = function () {
603
         console.info("The Data Channel closed", dataChannel);
637
         console.info("The Data Channel closed", dataChannel);
604
-        var idx = this._dataChannels.indexOf(dataChannel);
638
+        var idx = self._dataChannels.indexOf(dataChannel);
605
         if (idx > -1)
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
     this._dataChannels.push(dataChannel);
642
     this._dataChannels.push(dataChannel);
609
 };
643
 };
610
 
644
 
797
     this.muted = value;
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
 delete JitsiRemoteTrack.prototype.stop;
841
 delete JitsiRemoteTrack.prototype.stop;
801
 
842
 
802
 delete JitsiRemoteTrack.prototype.start;
843
 delete JitsiRemoteTrack.prototype.start;
846
     return this.type;
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
  * Returns the RTCMediaStream from the browser (?).
891
  * Returns the RTCMediaStream from the browser (?).
858
  */
892
  */
4347
     this.eventEmitter.removeListener(type, listener);
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
     this.eventEmitter.emit(XMPPEvents.REMOTE_STREAM_RECEIVED, data, sid, thessrc);
4385
     this.eventEmitter.emit(XMPPEvents.REMOTE_STREAM_RECEIVED, data, sid, thessrc);
4352
 }
4386
 }
4353
 
4387
 
4503
 var RTC = require("../RTC/RTC");
4537
 var RTC = require("../RTC/RTC");
4504
 
4538
 
4505
 // Jingle stuff
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
     this.initiator = null;
4542
     this.initiator = null;
4509
     this.responder = null;
4543
     this.responder = null;
4510
     this.peerjid = null;
4544
     this.peerjid = null;
4533
     this.localStreamsSSRC = null;
4567
     this.localStreamsSSRC = null;
4534
     this.ssrcOwners = {};
4568
     this.ssrcOwners = {};
4535
     this.ssrcVideoTypes = {};
4569
     this.ssrcVideoTypes = {};
4536
-    this.eventEmitter = eventEmitter;
4537
 
4570
 
4538
     /**
4571
     /**
4539
      * The indicator which determines whether the (local) video has been muted
4572
      * The indicator which determines whether the (local) video has been muted
4561
 JingleSessionPC.prototype.updateModifySourcesQueue = function() {
4594
 JingleSessionPC.prototype.updateModifySourcesQueue = function() {
4562
     var signalingState = this.peerconnection.signalingState;
4595
     var signalingState = this.peerconnection.signalingState;
4563
     var iceConnectionState = this.peerconnection.iceConnectionState;
4596
     var iceConnectionState = this.peerconnection.iceConnectionState;
4564
-    console.debug(signalingState + " + " + iceConnectionState);
4565
     if (signalingState === 'stable' && iceConnectionState === 'connected') {
4597
     if (signalingState === 'stable' && iceConnectionState === 'connected') {
4566
         this.modifySourcesQueue.resume();
4598
         this.modifySourcesQueue.resume();
4567
     } else {
4599
     } else {
4604
         $(document).trigger('remotestreamremoved.jingle', [event, self.sid]);
4636
         $(document).trigger('remotestreamremoved.jingle', [event, self.sid]);
4605
     };
4637
     };
4606
     this.peerconnection.onsignalingstatechange = function (event) {
4638
     this.peerconnection.onsignalingstatechange = function (event) {
4607
-        console.debug("signaling state11");
4608
         if (!(self && self.peerconnection)) return;
4639
         if (!(self && self.peerconnection)) return;
4609
-        console.debug("signaling state222");
4610
         self.updateModifySourcesQueue();
4640
         self.updateModifySourcesQueue();
4611
     };
4641
     };
4612
     /**
4642
     /**
4617
      * @param event the event containing information about the change
4647
      * @param event the event containing information about the change
4618
      */
4648
      */
4619
     this.peerconnection.oniceconnectionstatechange = function (event) {
4649
     this.peerconnection.oniceconnectionstatechange = function (event) {
4620
-        console.debug("ice state11");
4621
         if (!(self && self.peerconnection)) return;
4650
         if (!(self && self.peerconnection)) return;
4622
-        console.debug("ice state222");
4623
         self.updateModifySourcesQueue();
4651
         self.updateModifySourcesQueue();
4624
         switch (self.peerconnection.iceConnectionState) {
4652
         switch (self.peerconnection.iceConnectionState) {
4625
             case 'connected':
4653
             case 'connected':
4626
 
4654
 
4627
                 // Informs interested parties that the connection has been restored.
4655
                 // Informs interested parties that the connection has been restored.
4628
                 if (self.peerconnection.signalingState === 'stable' && self.isreconnect)
4656
                 if (self.peerconnection.signalingState === 'stable' && self.isreconnect)
4629
-                    self.eventEmitter.emit(XMPPEvents.CONNECTION_RESTORED);
4657
+                    self.room.eventEmitter.emit(XMPPEvents.CONNECTION_RESTORED);
4630
                 self.isreconnect = false;
4658
                 self.isreconnect = false;
4631
 
4659
 
4632
                 break;
4660
                 break;
4634
                 self.isreconnect = true;
4662
                 self.isreconnect = true;
4635
                 // Informs interested parties that the connection has been interrupted.
4663
                 // Informs interested parties that the connection has been interrupted.
4636
                 if (self.peerconnection.signalingState === 'stable')
4664
                 if (self.peerconnection.signalingState === 'stable')
4637
-                    self.eventEmitter.emit(XMPPEvents.CONNECTION_INTERRUPTED);
4665
+                    self.room.eventEmitter.emit(XMPPEvents.CONNECTION_INTERRUPTED);
4638
                 break;
4666
                 break;
4639
             case 'failed':
4667
             case 'failed':
4640
-                self.eventEmitter.emit(XMPPEvents.CONFERENCE_SETUP_FAILED);
4668
+                self.room.eventEmitter.emit(XMPPEvents.CONFERENCE_SETUP_FAILED);
4641
                 break;
4669
                 break;
4642
         }
4670
         }
4643
         onIceConnectionStateChange(self.sid, self);
4671
         onIceConnectionStateChange(self.sid, self);
4644
     };
4672
     };
4645
     this.peerconnection.onnegotiationneeded = function (event) {
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
     this.relayedStreams.forEach(function(stream) {
4677
     this.relayedStreams.forEach(function(stream) {
4765
         },
4793
         },
4766
         function (e) {
4794
         function (e) {
4767
             console.error('setLocalDescription failed', e);
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
         },
5017
         },
4990
         function (e) {
5018
         function (e) {
4991
             console.error('setLocalDescription failed', e);
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
     var cands = SDPUtil.find_lines(this.localSDP.raw, 'a=candidate:');
5023
     var cands = SDPUtil.find_lines(this.localSDP.raw, 'a=candidate:');
5187
         },
5215
         },
5188
         function (e) {
5216
         function (e) {
5189
             console.error('createAnswer failed', e);
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
         this.media_constraints
5220
         this.media_constraints
5193
     );
5221
     );
5253
         },
5281
         },
5254
         function (e) {
5282
         function (e) {
5255
             console.error('setLocalDescription failed', e);
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
     var cands = SDPUtil.find_lines(this.localSDP.raw, 'a=candidate:');
5287
     var cands = SDPUtil.find_lines(this.localSDP.raw, 'a=candidate:');
5844
 
5872
 
5845
 JingleSessionPC.onJingleFatalError = function (session, error)
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
 JingleSessionPC.prototype.setLocalDescription = function () {
5879
 JingleSessionPC.prototype.setLocalDescription = function () {
5889
 }
5917
 }
5890
 
5918
 
5891
 // an attempt to work around https://github.com/jitsi/jitmeet/issues/32
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
     console.log('sendkeyframe', pc.iceConnectionState);
5922
     console.log('sendkeyframe', pc.iceConnectionState);
5894
     if (pc.iceConnectionState !== 'connected') return; // safe...
5923
     if (pc.iceConnectionState !== 'connected') return; // safe...
5895
     var self = this;
5924
     var self = this;
5905
                         },
5934
                         },
5906
                         function (error) {
5935
                         function (error) {
5907
                             console.log('triggerKeyframe setLocalDescription failed', error);
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
                 function (error) {
5941
                 function (error) {
5913
                     console.log('triggerKeyframe createAnswer failed', error);
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
         }
5990
         }
5962
     }
5991
     }
5963
 
5992
 
5964
-    this.room.fireRemoteStreamEvent(data, this.sid, thessrc);
5993
+    this.room.remoteStreamAdded(data, this.sid, thessrc);
5965
 
5994
 
5966
     var isVideo = data.stream.getVideoTracks().length > 0;
5995
     var isVideo = data.stream.getVideoTracks().length > 0;
5967
     // an attempt to work around https://github.com/jitsi/jitmeet/issues/32
5996
     // an attempt to work around https://github.com/jitsi/jitmeet/issues/32
5970
         data.stream.getVideoTracks().length === 0 &&
5999
         data.stream.getVideoTracks().length === 0 &&
5971
         RTC.localVideo.getTracks().length > 0) {
6000
         RTC.localVideo.getTracks().length > 0) {
5972
         window.setTimeout(function () {
6001
         window.setTimeout(function () {
5973
-            sendKeyframe(self.peerconnection);
6002
+            self.sendKeyframe();
5974
         }, 3000);
6003
         }, 3000);
5975
     }
6004
     }
5976
 }
6005
 }
8472
                     }
8501
                     }
8473
                     sess = new JingleSession(
8502
                     sess = new JingleSession(
8474
                         $(iq).attr('to'), $(iq).find('jingle').attr('sid'),
8503
                         $(iq).attr('to'), $(iq).find('jingle').attr('sid'),
8475
-                        this.connection, XMPP, eventEmitter);
8504
+                        this.connection, XMPP);
8476
                     // configure session
8505
                     // configure session
8477
 
8506
 
8478
                     var fromBareJid = Strophe.getBareJidFromJid(fromJid);
8507
                     var fromBareJid = Strophe.getBareJidFromJid(fromJid);

+ 9
- 8
modules/RTC/DataChannels.js View File

47
  */
47
  */
48
 DataChannels.prototype.onDataChannel = function (event) {
48
 DataChannels.prototype.onDataChannel = function (event) {
49
     var dataChannel = event.channel;
49
     var dataChannel = event.channel;
50
+    var self = this;
50
 
51
 
51
     dataChannel.onopen = function () {
52
     dataChannel.onopen = function () {
52
         console.info("Data channel opened by the Videobridge!", dataChannel);
53
         console.info("Data channel opened by the Videobridge!", dataChannel);
57
         // Sends 12 bytes binary message to the bridge
58
         // Sends 12 bytes binary message to the bridge
58
         //dataChannel.send(new ArrayBuffer(12));
59
         //dataChannel.send(new ArrayBuffer(12));
59
 
60
 
60
-        this.eventEmitter.emit(RTCEvents.DATA_CHANNEL_OPEN);
61
-    }.bind(this);
61
+        self.eventEmitter.emit(RTCEvents.DATA_CHANNEL_OPEN);
62
+    };
62
 
63
 
63
     dataChannel.onerror = function (error) {
64
     dataChannel.onerror = function (error) {
64
         console.error("Data Channel Error:", error, dataChannel);
65
         console.error("Data Channel Error:", error, dataChannel);
88
                 console.info(
89
                 console.info(
89
                     "Data channel new dominant speaker event: ",
90
                     "Data channel new dominant speaker event: ",
90
                     dominantSpeakerEndpoint);
91
                     dominantSpeakerEndpoint);
91
-                this.eventEmitter.emit(RTCEvents.DOMINANTSPEAKER_CHANGED, dominantSpeakerEndpoint);
92
+                self.eventEmitter.emit(RTCEvents.DOMINANTSPEAKER_CHANGED, dominantSpeakerEndpoint);
92
             }
93
             }
93
             else if ("InLastNChangeEvent" === colibriClass) {
94
             else if ("InLastNChangeEvent" === colibriClass) {
94
                 var oldValue = obj.oldValue;
95
                 var oldValue = obj.oldValue;
111
                     }
112
                     }
112
                 }
113
                 }
113
 
114
 
114
-                this.eventEmitter.emit(RTCEvents.LASTN_CHANGED, oldValue, newValue);
115
+                self.eventEmitter.emit(RTCEvents.LASTN_CHANGED, oldValue, newValue);
115
             }
116
             }
116
             else if ("LastNEndpointsChangeEvent" === colibriClass) {
117
             else if ("LastNEndpointsChangeEvent" === colibriClass) {
117
                 // The new/latest list of last-n endpoint IDs.
118
                 // The new/latest list of last-n endpoint IDs.
131
                 console.debug("Data channel JSON-formatted message: ", obj);
132
                 console.debug("Data channel JSON-formatted message: ", obj);
132
             }
133
             }
133
         }
134
         }
134
-    }.bind(this);
135
+    };
135
 
136
 
136
     dataChannel.onclose = function () {
137
     dataChannel.onclose = function () {
137
         console.info("The Data Channel closed", dataChannel);
138
         console.info("The Data Channel closed", dataChannel);
138
-        var idx = this._dataChannels.indexOf(dataChannel);
139
+        var idx = self._dataChannels.indexOf(dataChannel);
139
         if (idx > -1)
140
         if (idx > -1)
140
-            this._dataChannels = this._dataChannels.splice(idx, 1);
141
-    }.bind(this);
141
+            self._dataChannels = self._dataChannels.splice(idx, 1);
142
+    };
142
     this._dataChannels.push(dataChannel);
143
     this._dataChannels.push(dataChannel);
143
 };
144
 };
144
 
145
 

+ 7
- 0
modules/RTC/JitsiRemoteTrack.js View File

24
     this.muted = value;
24
     this.muted = value;
25
 };
25
 };
26
 
26
 
27
+/**
28
+ * @returns {JitsiParticipant} to which this track belongs, or null if it is a local track.
29
+ */
30
+JitsiRemoteTrack.prototype.getParitcipantId = function() {
31
+    return Strophe.getResourceFromJid(this.peerjid);
32
+};
33
+
27
 delete JitsiRemoteTrack.prototype.stop;
34
 delete JitsiRemoteTrack.prototype.stop;
28
 
35
 
29
 delete JitsiRemoteTrack.prototype.start;
36
 delete JitsiRemoteTrack.prototype.start;

+ 0
- 7
modules/RTC/JitsiTrack.js View File

40
     return this.type;
40
     return this.type;
41
 };
41
 };
42
 
42
 
43
-/**
44
- * @returns {JitsiParticipant} to which this track belongs, or null if it is a local track.
45
- */
46
-JitsiTrack.prototype.getParitcipant = function() {
47
-
48
-};
49
-
50
 /**
43
 /**
51
  * Returns the RTCMediaStream from the browser (?).
44
  * Returns the RTCMediaStream from the browser (?).
52
  */
45
  */

+ 1
- 1
modules/xmpp/ChatRoom.js View File

566
     this.eventEmitter.removeListener(type, listener);
566
     this.eventEmitter.removeListener(type, listener);
567
 };
567
 };
568
 
568
 
569
-ChatRoom.prototype.fireRemoteStreamEvent = function(data, sid, thessrc) {
569
+ChatRoom.prototype.remoteStreamAdded = function(data, sid, thessrc) {
570
     this.eventEmitter.emit(XMPPEvents.REMOTE_STREAM_RECEIVED, data, sid, thessrc);
570
     this.eventEmitter.emit(XMPPEvents.REMOTE_STREAM_RECEIVED, data, sid, thessrc);
571
 }
571
 }
572
 
572
 

+ 18
- 23
modules/xmpp/JingleSessionPC.js View File

12
 var RTC = require("../RTC/RTC");
12
 var RTC = require("../RTC/RTC");
13
 
13
 
14
 // Jingle stuff
14
 // Jingle stuff
15
-function JingleSessionPC(me, sid, connection, service, eventEmitter) {
16
-    JingleSession.call(this, me, sid, connection, service, eventEmitter);
15
+function JingleSessionPC(me, sid, connection, service) {
16
+    JingleSession.call(this, me, sid, connection, service);
17
     this.initiator = null;
17
     this.initiator = null;
18
     this.responder = null;
18
     this.responder = null;
19
     this.peerjid = null;
19
     this.peerjid = null;
42
     this.localStreamsSSRC = null;
42
     this.localStreamsSSRC = null;
43
     this.ssrcOwners = {};
43
     this.ssrcOwners = {};
44
     this.ssrcVideoTypes = {};
44
     this.ssrcVideoTypes = {};
45
-    this.eventEmitter = eventEmitter;
46
 
45
 
47
     /**
46
     /**
48
      * The indicator which determines whether the (local) video has been muted
47
      * The indicator which determines whether the (local) video has been muted
70
 JingleSessionPC.prototype.updateModifySourcesQueue = function() {
69
 JingleSessionPC.prototype.updateModifySourcesQueue = function() {
71
     var signalingState = this.peerconnection.signalingState;
70
     var signalingState = this.peerconnection.signalingState;
72
     var iceConnectionState = this.peerconnection.iceConnectionState;
71
     var iceConnectionState = this.peerconnection.iceConnectionState;
73
-    console.debug(signalingState + " + " + iceConnectionState);
74
     if (signalingState === 'stable' && iceConnectionState === 'connected') {
72
     if (signalingState === 'stable' && iceConnectionState === 'connected') {
75
         this.modifySourcesQueue.resume();
73
         this.modifySourcesQueue.resume();
76
     } else {
74
     } else {
113
         $(document).trigger('remotestreamremoved.jingle', [event, self.sid]);
111
         $(document).trigger('remotestreamremoved.jingle', [event, self.sid]);
114
     };
112
     };
115
     this.peerconnection.onsignalingstatechange = function (event) {
113
     this.peerconnection.onsignalingstatechange = function (event) {
116
-        console.debug("signaling state11");
117
         if (!(self && self.peerconnection)) return;
114
         if (!(self && self.peerconnection)) return;
118
-        console.debug("signaling state222");
119
         self.updateModifySourcesQueue();
115
         self.updateModifySourcesQueue();
120
     };
116
     };
121
     /**
117
     /**
126
      * @param event the event containing information about the change
122
      * @param event the event containing information about the change
127
      */
123
      */
128
     this.peerconnection.oniceconnectionstatechange = function (event) {
124
     this.peerconnection.oniceconnectionstatechange = function (event) {
129
-        console.debug("ice state11");
130
         if (!(self && self.peerconnection)) return;
125
         if (!(self && self.peerconnection)) return;
131
-        console.debug("ice state222");
132
         self.updateModifySourcesQueue();
126
         self.updateModifySourcesQueue();
133
         switch (self.peerconnection.iceConnectionState) {
127
         switch (self.peerconnection.iceConnectionState) {
134
             case 'connected':
128
             case 'connected':
135
 
129
 
136
                 // Informs interested parties that the connection has been restored.
130
                 // Informs interested parties that the connection has been restored.
137
                 if (self.peerconnection.signalingState === 'stable' && self.isreconnect)
131
                 if (self.peerconnection.signalingState === 'stable' && self.isreconnect)
138
-                    self.eventEmitter.emit(XMPPEvents.CONNECTION_RESTORED);
132
+                    self.room.eventEmitter.emit(XMPPEvents.CONNECTION_RESTORED);
139
                 self.isreconnect = false;
133
                 self.isreconnect = false;
140
 
134
 
141
                 break;
135
                 break;
143
                 self.isreconnect = true;
137
                 self.isreconnect = true;
144
                 // Informs interested parties that the connection has been interrupted.
138
                 // Informs interested parties that the connection has been interrupted.
145
                 if (self.peerconnection.signalingState === 'stable')
139
                 if (self.peerconnection.signalingState === 'stable')
146
-                    self.eventEmitter.emit(XMPPEvents.CONNECTION_INTERRUPTED);
140
+                    self.room.eventEmitter.emit(XMPPEvents.CONNECTION_INTERRUPTED);
147
                 break;
141
                 break;
148
             case 'failed':
142
             case 'failed':
149
-                self.eventEmitter.emit(XMPPEvents.CONFERENCE_SETUP_FAILED);
143
+                self.room.eventEmitter.emit(XMPPEvents.CONFERENCE_SETUP_FAILED);
150
                 break;
144
                 break;
151
         }
145
         }
152
         onIceConnectionStateChange(self.sid, self);
146
         onIceConnectionStateChange(self.sid, self);
153
     };
147
     };
154
     this.peerconnection.onnegotiationneeded = function (event) {
148
     this.peerconnection.onnegotiationneeded = function (event) {
155
-        self.eventEmitter.emit(XMPPEvents.PEERCONNECTION_READY, self);
149
+        self.room.eventEmitter.emit(XMPPEvents.PEERCONNECTION_READY, self);
156
     };
150
     };
157
 
151
 
158
     this.relayedStreams.forEach(function(stream) {
152
     this.relayedStreams.forEach(function(stream) {
274
         },
268
         },
275
         function (e) {
269
         function (e) {
276
             console.error('setLocalDescription failed', e);
270
             console.error('setLocalDescription failed', e);
277
-            self.eventEmitter.emit(XMPPEvents.CONFERENCE_SETUP_FAILED);
271
+            self.room.eventEmitter.emit(XMPPEvents.CONFERENCE_SETUP_FAILED);
278
         }
272
         }
279
     );
273
     );
280
 };
274
 };
498
         },
492
         },
499
         function (e) {
493
         function (e) {
500
             console.error('setLocalDescription failed', e);
494
             console.error('setLocalDescription failed', e);
501
-            self.eventEmitter.emit(XMPPEvents.CONFERENCE_SETUP_FAILED);
495
+            self.room.eventEmitter.emit(XMPPEvents.CONFERENCE_SETUP_FAILED);
502
         }
496
         }
503
     );
497
     );
504
     var cands = SDPUtil.find_lines(this.localSDP.raw, 'a=candidate:');
498
     var cands = SDPUtil.find_lines(this.localSDP.raw, 'a=candidate:');
696
         },
690
         },
697
         function (e) {
691
         function (e) {
698
             console.error('createAnswer failed', e);
692
             console.error('createAnswer failed', e);
699
-            self.eventEmitter.emit(XMPPEvents.CONFERENCE_SETUP_FAILED);
693
+            self.room.eventEmitter.emit(XMPPEvents.CONFERENCE_SETUP_FAILED);
700
         },
694
         },
701
         this.media_constraints
695
         this.media_constraints
702
     );
696
     );
762
         },
756
         },
763
         function (e) {
757
         function (e) {
764
             console.error('setLocalDescription failed', e);
758
             console.error('setLocalDescription failed', e);
765
-            self.eventEmitter.emit(XMPPEvents.CONFERENCE_SETUP_FAILED);
759
+            self.room.eventEmitter.emit(XMPPEvents.CONFERENCE_SETUP_FAILED);
766
         }
760
         }
767
     );
761
     );
768
     var cands = SDPUtil.find_lines(this.localSDP.raw, 'a=candidate:');
762
     var cands = SDPUtil.find_lines(this.localSDP.raw, 'a=candidate:');
1353
 
1347
 
1354
 JingleSessionPC.onJingleFatalError = function (session, error)
1348
 JingleSessionPC.onJingleFatalError = function (session, error)
1355
 {
1349
 {
1356
-    this.eventEmitter.emit(XMPPEvents.CONFERENCE_SETUP_FAILED);
1357
-    this.eventEmitter.emit(XMPPEvents.JINGLE_FATAL_ERROR, session, error);
1350
+    this.room.eventEmitter.emit(XMPPEvents.CONFERENCE_SETUP_FAILED);
1351
+    this.room.eventEmitter.emit(XMPPEvents.JINGLE_FATAL_ERROR, session, error);
1358
 }
1352
 }
1359
 
1353
 
1360
 JingleSessionPC.prototype.setLocalDescription = function () {
1354
 JingleSessionPC.prototype.setLocalDescription = function () {
1398
 }
1392
 }
1399
 
1393
 
1400
 // an attempt to work around https://github.com/jitsi/jitmeet/issues/32
1394
 // an attempt to work around https://github.com/jitsi/jitmeet/issues/32
1401
-function sendKeyframe(pc) {
1395
+JingleSessionPC.prototype.sendKeyframe = function () {
1396
+    var pc = this.peerconnection;
1402
     console.log('sendkeyframe', pc.iceConnectionState);
1397
     console.log('sendkeyframe', pc.iceConnectionState);
1403
     if (pc.iceConnectionState !== 'connected') return; // safe...
1398
     if (pc.iceConnectionState !== 'connected') return; // safe...
1404
     var self = this;
1399
     var self = this;
1414
                         },
1409
                         },
1415
                         function (error) {
1410
                         function (error) {
1416
                             console.log('triggerKeyframe setLocalDescription failed', error);
1411
                             console.log('triggerKeyframe setLocalDescription failed', error);
1417
-                            eventEmitter.emit(XMPPEvents.SET_LOCAL_DESCRIPTION_ERROR);
1412
+                            self.room.eventEmitter.emit(XMPPEvents.SET_LOCAL_DESCRIPTION_ERROR);
1418
                         }
1413
                         }
1419
                     );
1414
                     );
1420
                 },
1415
                 },
1421
                 function (error) {
1416
                 function (error) {
1422
                     console.log('triggerKeyframe createAnswer failed', error);
1417
                     console.log('triggerKeyframe createAnswer failed', error);
1423
-                    eventEmitter.emit(XMPPEvents.CREATE_ANSWER_ERROR);
1418
+                    self.room.eventEmitter.emit(XMPPEvents.CREATE_ANSWER_ERROR);
1424
                 }
1419
                 }
1425
             );
1420
             );
1426
         },
1421
         },
1470
         }
1465
         }
1471
     }
1466
     }
1472
 
1467
 
1473
-    this.room.fireRemoteStreamEvent(data, this.sid, thessrc);
1468
+    this.room.remoteStreamAdded(data, this.sid, thessrc);
1474
 
1469
 
1475
     var isVideo = data.stream.getVideoTracks().length > 0;
1470
     var isVideo = data.stream.getVideoTracks().length > 0;
1476
     // an attempt to work around https://github.com/jitsi/jitmeet/issues/32
1471
     // an attempt to work around https://github.com/jitsi/jitmeet/issues/32
1479
         data.stream.getVideoTracks().length === 0 &&
1474
         data.stream.getVideoTracks().length === 0 &&
1480
         RTC.localVideo.getTracks().length > 0) {
1475
         RTC.localVideo.getTracks().length > 0) {
1481
         window.setTimeout(function () {
1476
         window.setTimeout(function () {
1482
-            sendKeyframe(self.peerconnection);
1477
+            self.sendKeyframe();
1483
         }, 3000);
1478
         }, 3000);
1484
     }
1479
     }
1485
 }
1480
 }

+ 1
- 1
modules/xmpp/strophe.jingle.js View File

101
                     }
101
                     }
102
                     sess = new JingleSession(
102
                     sess = new JingleSession(
103
                         $(iq).attr('to'), $(iq).find('jingle').attr('sid'),
103
                         $(iq).attr('to'), $(iq).find('jingle').attr('sid'),
104
-                        this.connection, XMPP, eventEmitter);
104
+                        this.connection, XMPP);
105
                     // configure session
105
                     // configure session
106
 
106
 
107
                     var fromBareJid = Strophe.getBareJidFromJid(fromJid);
107
                     var fromBareJid = Strophe.getBareJidFromJid(fromJid);

Loading…
Cancel
Save