Sfoglia il codice sorgente

Implements some conference events.

dev1
hristoterezov 10 anni fa
parent
commit
036635dee6

+ 30
- 1
JitsiConference.js Vedi File

@@ -1,6 +1,7 @@
1 1
 var RTC = require("./modules/RTC/RTC");
2 2
 var XMPPEvents = require("./service/xmpp/XMPPEvents");
3 3
 var StreamEventTypes = require("./service/RTC/StreamEventTypes");
4
+var RTCEvents = require("./service/RTC/RTCEvents");
4 5
 var EventEmitter = require("events");
5 6
 var JitsiConferenceEvents = require("./JitsiConferenceEvents");
6 7
 
@@ -182,6 +183,10 @@ JitsiConference.prototype.getParticipantById = function(id) {
182 183
 
183 184
 }
184 185
 
186
+/**
187
+ * Setups the listeners needed for the conference.
188
+ * @param conference the conference
189
+ */
185 190
 function setupListeners(conference) {
186 191
     conference.xmpp.addListener(XMPPEvents.CALL_INCOMING,
187 192
         conference.rtc.onIncommingCall.bind(conference.rtc));
@@ -195,7 +200,31 @@ function setupListeners(conference) {
195 200
     })
196 201
     conference.room.addListener(XMPPEvents.MUC_JOINED, function () {
197 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 Vedi File

@@ -42,7 +42,11 @@ var JitsiConferenceEvents = {
42 42
     /**
43 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 51
      * A media track was muted.
48 52
      */

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

@@ -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);

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

@@ -47,6 +47,7 @@ function DataChannels(peerConnection, emitter) {
47 47
  */
48 48
 DataChannels.prototype.onDataChannel = function (event) {
49 49
     var dataChannel = event.channel;
50
+    var self = this;
50 51
 
51 52
     dataChannel.onopen = function () {
52 53
         console.info("Data channel opened by the Videobridge!", dataChannel);
@@ -57,8 +58,8 @@ DataChannels.prototype.onDataChannel = function (event) {
57 58
         // Sends 12 bytes binary message to the bridge
58 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 64
     dataChannel.onerror = function (error) {
64 65
         console.error("Data Channel Error:", error, dataChannel);
@@ -88,7 +89,7 @@ DataChannels.prototype.onDataChannel = function (event) {
88 89
                 console.info(
89 90
                     "Data channel new dominant speaker event: ",
90 91
                     dominantSpeakerEndpoint);
91
-                this.eventEmitter.emit(RTCEvents.DOMINANTSPEAKER_CHANGED, dominantSpeakerEndpoint);
92
+                self.eventEmitter.emit(RTCEvents.DOMINANTSPEAKER_CHANGED, dominantSpeakerEndpoint);
92 93
             }
93 94
             else if ("InLastNChangeEvent" === colibriClass) {
94 95
                 var oldValue = obj.oldValue;
@@ -111,7 +112,7 @@ DataChannels.prototype.onDataChannel = function (event) {
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 117
             else if ("LastNEndpointsChangeEvent" === colibriClass) {
117 118
                 // The new/latest list of last-n endpoint IDs.
@@ -131,14 +132,14 @@ DataChannels.prototype.onDataChannel = function (event) {
131 132
                 console.debug("Data channel JSON-formatted message: ", obj);
132 133
             }
133 134
         }
134
-    }.bind(this);
135
+    };
135 136
 
136 137
     dataChannel.onclose = function () {
137 138
         console.info("The Data Channel closed", dataChannel);
138
-        var idx = this._dataChannels.indexOf(dataChannel);
139
+        var idx = self._dataChannels.indexOf(dataChannel);
139 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 143
     this._dataChannels.push(dataChannel);
143 144
 };
144 145
 

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

@@ -24,6 +24,13 @@ JitsiRemoteTrack.prototype._setMute = function (value) {
24 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 34
 delete JitsiRemoteTrack.prototype.stop;
28 35
 
29 36
 delete JitsiRemoteTrack.prototype.start;

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

@@ -40,13 +40,6 @@ JitsiTrack.prototype.getType = function() {
40 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 44
  * Returns the RTCMediaStream from the browser (?).
52 45
  */

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

@@ -566,7 +566,7 @@ ChatRoom.prototype.removeListener = function (type, listener) {
566 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 570
     this.eventEmitter.emit(XMPPEvents.REMOTE_STREAM_RECEIVED, data, sid, thessrc);
571 571
 }
572 572
 

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

@@ -12,8 +12,8 @@ var SSRCReplacement = require("./LocalSSRCReplacement");
12 12
 var RTC = require("../RTC/RTC");
13 13
 
14 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 17
     this.initiator = null;
18 18
     this.responder = null;
19 19
     this.peerjid = null;
@@ -42,7 +42,6 @@ function JingleSessionPC(me, sid, connection, service, eventEmitter) {
42 42
     this.localStreamsSSRC = null;
43 43
     this.ssrcOwners = {};
44 44
     this.ssrcVideoTypes = {};
45
-    this.eventEmitter = eventEmitter;
46 45
 
47 46
     /**
48 47
      * The indicator which determines whether the (local) video has been muted
@@ -70,7 +69,6 @@ JingleSessionPC.prototype.setAnswer = function(answer) {
70 69
 JingleSessionPC.prototype.updateModifySourcesQueue = function() {
71 70
     var signalingState = this.peerconnection.signalingState;
72 71
     var iceConnectionState = this.peerconnection.iceConnectionState;
73
-    console.debug(signalingState + " + " + iceConnectionState);
74 72
     if (signalingState === 'stable' && iceConnectionState === 'connected') {
75 73
         this.modifySourcesQueue.resume();
76 74
     } else {
@@ -113,9 +111,7 @@ JingleSessionPC.prototype.doInitialize = function () {
113 111
         $(document).trigger('remotestreamremoved.jingle', [event, self.sid]);
114 112
     };
115 113
     this.peerconnection.onsignalingstatechange = function (event) {
116
-        console.debug("signaling state11");
117 114
         if (!(self && self.peerconnection)) return;
118
-        console.debug("signaling state222");
119 115
         self.updateModifySourcesQueue();
120 116
     };
121 117
     /**
@@ -126,16 +122,14 @@ JingleSessionPC.prototype.doInitialize = function () {
126 122
      * @param event the event containing information about the change
127 123
      */
128 124
     this.peerconnection.oniceconnectionstatechange = function (event) {
129
-        console.debug("ice state11");
130 125
         if (!(self && self.peerconnection)) return;
131
-        console.debug("ice state222");
132 126
         self.updateModifySourcesQueue();
133 127
         switch (self.peerconnection.iceConnectionState) {
134 128
             case 'connected':
135 129
 
136 130
                 // Informs interested parties that the connection has been restored.
137 131
                 if (self.peerconnection.signalingState === 'stable' && self.isreconnect)
138
-                    self.eventEmitter.emit(XMPPEvents.CONNECTION_RESTORED);
132
+                    self.room.eventEmitter.emit(XMPPEvents.CONNECTION_RESTORED);
139 133
                 self.isreconnect = false;
140 134
 
141 135
                 break;
@@ -143,16 +137,16 @@ JingleSessionPC.prototype.doInitialize = function () {
143 137
                 self.isreconnect = true;
144 138
                 // Informs interested parties that the connection has been interrupted.
145 139
                 if (self.peerconnection.signalingState === 'stable')
146
-                    self.eventEmitter.emit(XMPPEvents.CONNECTION_INTERRUPTED);
140
+                    self.room.eventEmitter.emit(XMPPEvents.CONNECTION_INTERRUPTED);
147 141
                 break;
148 142
             case 'failed':
149
-                self.eventEmitter.emit(XMPPEvents.CONFERENCE_SETUP_FAILED);
143
+                self.room.eventEmitter.emit(XMPPEvents.CONFERENCE_SETUP_FAILED);
150 144
                 break;
151 145
         }
152 146
         onIceConnectionStateChange(self.sid, self);
153 147
     };
154 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 152
     this.relayedStreams.forEach(function(stream) {
@@ -274,7 +268,7 @@ JingleSessionPC.prototype.accept = function () {
274 268
         },
275 269
         function (e) {
276 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,7 +492,7 @@ JingleSessionPC.prototype.createdOffer = function (sdp) {
498 492
         },
499 493
         function (e) {
500 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 498
     var cands = SDPUtil.find_lines(this.localSDP.raw, 'a=candidate:');
@@ -696,7 +690,7 @@ JingleSessionPC.prototype.sendAnswer = function (provisional) {
696 690
         },
697 691
         function (e) {
698 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 695
         this.media_constraints
702 696
     );
@@ -762,7 +756,7 @@ JingleSessionPC.prototype.createdAnswer = function (sdp, provisional) {
762 756
         },
763 757
         function (e) {
764 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 762
     var cands = SDPUtil.find_lines(this.localSDP.raw, 'a=candidate:');
@@ -1353,8 +1347,8 @@ JingleSessionPC.onJingleError = function (session, error)
1353 1347
 
1354 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 1354
 JingleSessionPC.prototype.setLocalDescription = function () {
@@ -1398,7 +1392,8 @@ JingleSessionPC.prototype.setLocalDescription = function () {
1398 1392
 }
1399 1393
 
1400 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 1397
     console.log('sendkeyframe', pc.iceConnectionState);
1403 1398
     if (pc.iceConnectionState !== 'connected') return; // safe...
1404 1399
     var self = this;
@@ -1414,13 +1409,13 @@ function sendKeyframe(pc) {
1414 1409
                         },
1415 1410
                         function (error) {
1416 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 1416
                 function (error) {
1422 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,7 +1465,7 @@ JingleSessionPC.prototype.remoteStreamAdded = function (data, times) {
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 1470
     var isVideo = data.stream.getVideoTracks().length > 0;
1476 1471
     // an attempt to work around https://github.com/jitsi/jitmeet/issues/32
@@ -1479,7 +1474,7 @@ JingleSessionPC.prototype.remoteStreamAdded = function (data, times) {
1479 1474
         data.stream.getVideoTracks().length === 0 &&
1480 1475
         RTC.localVideo.getTracks().length > 0) {
1481 1476
         window.setTimeout(function () {
1482
-            sendKeyframe(self.peerconnection);
1477
+            self.sendKeyframe();
1483 1478
         }, 3000);
1484 1479
     }
1485 1480
 }

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

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

Loading…
Annulla
Salva