瀏覽代碼

Add events for data chanel.

j8
hristoterezov 10 年之前
父節點
當前提交
bc2d72638b

+ 5
- 4
index.html 查看文件

22
     <script src="service/RTC/RTCBrowserType.js?v=1"></script>
22
     <script src="service/RTC/RTCBrowserType.js?v=1"></script>
23
     <script src="service/RTC/StreamEventTypes.js?v=2"></script>
23
     <script src="service/RTC/StreamEventTypes.js?v=2"></script>
24
     <script src="service/RTC/MediaStreamTypes.js?v=1"></script>
24
     <script src="service/RTC/MediaStreamTypes.js?v=1"></script>
25
+    <script src="service/RTC/RTCEvents.js?v=1"></script>
25
     <script src="service/xmpp/XMPPEvents.js?v=1"></script>
26
     <script src="service/xmpp/XMPPEvents.js?v=1"></script>
26
     <script src="service/connectionquality/CQEvents.js?v=1"></script>
27
     <script src="service/connectionquality/CQEvents.js?v=1"></script>
27
     <script src="service/UI/UIEvents.js?v=1"></script>
28
     <script src="service/UI/UIEvents.js?v=1"></script>
28
     <script src="service/desktopsharing/DesktopSharingEventTypes.js?v=1"></script>
29
     <script src="service/desktopsharing/DesktopSharingEventTypes.js?v=1"></script>
29
-    <script src="libs/modules/simulcast.bundle.js?v=5"></script>
30
     <script src="libs/modules/connectionquality.bundle.js?v=3"></script>
30
     <script src="libs/modules/connectionquality.bundle.js?v=3"></script>
31
-    <script src="libs/modules/UI.bundle.js?v=12"></script>
31
+    <script src="libs/modules/UI.bundle.js?v=13"></script>
32
     <script src="libs/modules/statistics.bundle.js?v=5"></script>
32
     <script src="libs/modules/statistics.bundle.js?v=5"></script>
33
-    <script src="libs/modules/RTC.bundle.js?v=7"></script>
33
+    <script src="libs/modules/RTC.bundle.js?v=8"></script>
34
+    <script src="libs/modules/simulcast.bundle.js?v=6"></script>
34
     <script src="libs/modules/desktopsharing.bundle.js?v=3"></script><!-- desktop sharing -->
35
     <script src="libs/modules/desktopsharing.bundle.js?v=3"></script><!-- desktop sharing -->
35
-    <script src="libs/modules/xmpp.bundle.js?v=7"></script>
36
+    <script src="libs/modules/xmpp.bundle.js?v=8"></script>
36
     <script src="libs/modules/keyboardshortcut.bundle.js?v=2"></script>
37
     <script src="libs/modules/keyboardshortcut.bundle.js?v=2"></script>
37
     <script src="app.js?v=30"></script><!-- application logic -->
38
     <script src="app.js?v=30"></script><!-- application logic -->
38
     <script src="libs/modules/API.bundle.js?v=2"></script>
39
     <script src="libs/modules/API.bundle.js?v=2"></script>

+ 18
- 17
libs/modules/RTC.bundle.js 查看文件

4
 // cache datachannels to avoid garbage collection
4
 // cache datachannels to avoid garbage collection
5
 // https://code.google.com/p/chromium/issues/detail?id=405545
5
 // https://code.google.com/p/chromium/issues/detail?id=405545
6
 var _dataChannels = [];
6
 var _dataChannels = [];
7
+var eventEmitter = null;
7
 
8
 
8
 
9
 
9
 
10
 
67
                     console.info(
68
                     console.info(
68
                         "Data channel new dominant speaker event: ",
69
                         "Data channel new dominant speaker event: ",
69
                         dominantSpeakerEndpoint);
70
                         dominantSpeakerEndpoint);
70
-                    $(document).trigger(
71
-                        'dominantspeakerchanged',
72
-                        [dominantSpeakerEndpoint]);
71
+                    eventEmitter.emit(RTC.DOMINANTSPEAKER_CHANGED, dominantSpeakerEndpoint);
73
                 }
72
                 }
74
                 else if ("InLastNChangeEvent" === colibriClass)
73
                 else if ("InLastNChangeEvent" === colibriClass)
75
                 {
74
                 {
92
                             newValue = new Boolean(newValue).valueOf();
91
                             newValue = new Boolean(newValue).valueOf();
93
                         }
92
                         }
94
                     }
93
                     }
95
-                    UI.onLastNChanged(oldValue, newValue);
94
+
95
+                    eventEmitter.emit(RTCEvents.LASTN_CHANGED, oldValue, newValue);
96
                 }
96
                 }
97
                 else if ("LastNEndpointsChangeEvent" === colibriClass)
97
                 else if ("LastNEndpointsChangeEvent" === colibriClass)
98
                 {
98
                 {
107
                     console.log(
107
                     console.log(
108
                         "Data channel new last-n event: ",
108
                         "Data channel new last-n event: ",
109
                         lastNEndpoints, endpointsEnteringLastN, obj);
109
                         lastNEndpoints, endpointsEnteringLastN, obj);
110
-                    $(document).trigger(
111
-                        'lastnchanged',
112
-                        [lastNEndpoints, endpointsEnteringLastN, stream]);
110
+                    eventEmitter.emit(RTCEvents.LASTN_ENDPOINT_CHANGED,
111
+                        lastNEndpoints, endpointsEnteringLastN, obj);
113
                 }
112
                 }
114
                 else if ("SimulcastLayersChangedEvent" === colibriClass)
113
                 else if ("SimulcastLayersChangedEvent" === colibriClass)
115
                 {
114
                 {
116
-                    $(document).trigger(
117
-                        'simulcastlayerschanged',
118
-                        [obj.endpointSimulcastLayers]);
115
+                    eventEmitter.emit(RTCEvents.SIMULCAST_LAYER_CHANGED,
116
+                        obj.endpointSimulcastLayers);
119
                 }
117
                 }
120
                 else if ("SimulcastLayersChangingEvent" === colibriClass)
118
                 else if ("SimulcastLayersChangingEvent" === colibriClass)
121
                 {
119
                 {
122
-                    $(document).trigger(
123
-                        'simulcastlayerschanging',
124
-                        [obj.endpointSimulcastLayers]);
120
+                    eventEmitter.emit(RTCEvents.SIMULCAST_LAYER_CHANGING,
121
+                        obj.endpointSimulcastLayers);
125
                 }
122
                 }
126
                 else if ("StartSimulcastLayerEvent" === colibriClass)
123
                 else if ("StartSimulcastLayerEvent" === colibriClass)
127
                 {
124
                 {
128
-                    $(document).trigger('startsimulcastlayer', obj.simulcastLayer);
125
+                    eventEmitter.emit(RTCEvents.SIMULCAST_START, obj.simulcastLayer);
129
                 }
126
                 }
130
                 else if ("StopSimulcastLayerEvent" === colibriClass)
127
                 else if ("StopSimulcastLayerEvent" === colibriClass)
131
                 {
128
                 {
132
-                    $(document).trigger('stopsimulcastlayer', obj.simulcastLayer);
129
+                    eventEmitter.emit(RTCEvents.SIMULCAST_STOP, obj.simulcastLayer);
133
                 }
130
                 }
134
                 else
131
                 else
135
                 {
132
                 {
152
      * Binds "ondatachannel" event listener to given PeerConnection instance.
149
      * Binds "ondatachannel" event listener to given PeerConnection instance.
153
      * @param peerConnection WebRTC peer connection instance.
150
      * @param peerConnection WebRTC peer connection instance.
154
      */
151
      */
155
-    bindDataChannelListener: function (peerConnection) {
152
+    init: function (peerConnection, emitter) {
156
         if(!config.openSctp)
153
         if(!config.openSctp)
157
             retrun;
154
             retrun;
158
 
155
 
159
         peerConnection.ondatachannel = this.onDataChannel;
156
         peerConnection.ondatachannel = this.onDataChannel;
157
+        eventEmitter = emitter;
160
 
158
 
161
         // Sample code for opening new data channel from Jitsi Meet to the bridge.
159
         // Sample code for opening new data channel from Jitsi Meet to the bridge.
162
         // Although it's not a requirement to open separate channels from both bridge
160
         // Although it's not a requirement to open separate channels from both bridge
407
     addStreamListener: function (listener, eventType) {
405
     addStreamListener: function (listener, eventType) {
408
         eventEmitter.on(eventType, listener);
406
         eventEmitter.on(eventType, listener);
409
     },
407
     },
408
+    addListener: function (type, listener) {
409
+        eventEmitter.on(type, listener);
410
+    },
410
     removeStreamListener: function (listener, eventType) {
411
     removeStreamListener: function (listener, eventType) {
411
         if(!(eventType instanceof StreamEventTypes))
412
         if(!(eventType instanceof StreamEventTypes))
412
             throw "Illegal argument";
413
             throw "Illegal argument";
510
             }
511
             }
511
         });
512
         });
512
         xmpp.addListener(XMPPEvents.CALL_INCOMING, function(event) {
513
         xmpp.addListener(XMPPEvents.CALL_INCOMING, function(event) {
513
-            DataChannels.bindDataChannelListener(event.peerconnection);
514
+            DataChannels.init(event.peerconnection, eventEmitter);
514
         });
515
         });
515
         this.rtcUtils = new RTCUtils(this);
516
         this.rtcUtils = new RTCUtils(this);
516
         this.rtcUtils.obtainAudioAndVideoPermissions();
517
         this.rtcUtils.obtainAudioAndVideoPermissions();

+ 52
- 35
libs/modules/UI.bundle.js 查看文件

80
     RTC.addStreamListener(function (stream) {
80
     RTC.addStreamListener(function (stream) {
81
         VideoLayout.onRemoteStreamAdded(stream);
81
         VideoLayout.onRemoteStreamAdded(stream);
82
     }, StreamEventTypes.EVENT_TYPE_REMOTE_CREATED);
82
     }, StreamEventTypes.EVENT_TYPE_REMOTE_CREATED);
83
-
83
+    RTC.addListener(RTCEvents.LASTN_CHANGED, onLastNChanged);
84
+    RTC.addListener(RTCEvents.DOMINANTSPEAKER_CHANGED, function (resourceJid) {
85
+        VideoLayout.onDominantSpeakerChanged(resourceJid);
86
+    });
87
+    RTC.addListener(RTCEvents.LASTN_ENDPOINT_CHANGED,
88
+        function (lastNEndpoints, endpointsEnteringLastN, stream) {
89
+            VideoLayout.onLastNEndpointsChanged(lastNEndpoints,
90
+                endpointsEnteringLastN, stream);
91
+        });
92
+    RTC.addListener(RTCEvents.SIMULCAST_LAYER_CHANGED,
93
+        function (endpointSimulcastLayers) {
94
+           VideoLayout.onSimulcastLayersChanged(endpointSimulcastLayers);
95
+        });
96
+    RTC.addListener(RTCEvents.SIMULCAST_LAYER_CHANGING,
97
+        function (endpointSimulcastLayers) {
98
+            VideoLayout.onSimulcastLayersChanging(endpointSimulcastLayers);
99
+        });
84
     VideoLayout.init();
100
     VideoLayout.init();
85
 
101
 
86
     statistics.addAudioLevelListener(function(jid, audioLevel)
102
     statistics.addAudioLevelListener(function(jid, audioLevel)
156
         VideoLayout.updateConnectionStats);
172
         VideoLayout.updateConnectionStats);
157
     connectionquality.addListener(CQEvents.STOP,
173
     connectionquality.addListener(CQEvents.STOP,
158
         VideoLayout.onStatsStop);
174
         VideoLayout.onStatsStop);
175
+    xmpp.addListener(XMPPEvents.AUTHENTICATION_REQUIRED, onAuthenticationRequired);
176
+
177
+
159
 }
178
 }
160
 
179
 
161
 function bindEvents()
180
 function bindEvents()
368
 
387
 
369
 };
388
 };
370
 
389
 
371
-UI.getSettings = function () {
372
-    return Settings.getSettings();
373
-};
374
-
375
-UI.toggleFilmStrip = function () {
376
-    return BottomToolbar.toggleFilmStrip();
377
-};
378
-
379
-UI.toggleChat = function () {
380
-    return BottomToolbar.toggleChat();
381
-};
382
-
383
-UI.toggleContactList = function () {
384
-    return BottomToolbar.toggleContactList();
385
-};
386
 
390
 
387
 function onLocalRoleChange(jid, info, pres, isModerator, isExternalAuthEnabled)
391
 function onLocalRoleChange(jid, info, pres, isModerator, isExternalAuthEnabled)
388
 {
392
 {
468
     }
472
     }
469
 }
473
 }
470
 
474
 
471
-UI.onAuthenticationRequired = function (intervalCallback) {
475
+function onAuthenticationRequired(intervalCallback) {
472
     Authentication.openAuthenticationDialog(
476
     Authentication.openAuthenticationDialog(
473
         roomName, intervalCallback, function () {
477
         roomName, intervalCallback, function () {
474
             Toolbar.authenticateClicked();
478
             Toolbar.authenticateClicked();
475
         });
479
         });
476
 };
480
 };
477
 
481
 
482
+
483
+function onLastNChanged(oldValue, newValue) {
484
+    if (config.muteLocalVideoIfNotInLastN) {
485
+        setVideoMute(!newValue, { 'byUser': false });
486
+    }
487
+}
488
+
489
+UI.getSettings = function () {
490
+    return Settings.getSettings();
491
+};
492
+
493
+UI.toggleFilmStrip = function () {
494
+    return BottomToolbar.toggleFilmStrip();
495
+};
496
+
497
+UI.toggleChat = function () {
498
+    return BottomToolbar.toggleChat();
499
+};
500
+
501
+UI.toggleContactList = function () {
502
+    return BottomToolbar.toggleContactList();
503
+};
504
+
478
 UI.setRecordingButtonState = function (state) {
505
 UI.setRecordingButtonState = function (state) {
479
     Toolbar.setRecordingButtonState(state);
506
     Toolbar.setRecordingButtonState(state);
480
 };
507
 };
677
 
704
 
678
 }
705
 }
679
 
706
 
680
-UI.onLastNChanged = function (oldValue, newValue) {
681
-    if (config.muteLocalVideoIfNotInLastN) {
682
-        setVideoMute(!newValue, { 'byUser': false });
683
-    }
684
-}
685
-
686
 UI.addListener = function (type, listener) {
707
 UI.addListener = function (type, listener) {
687
     eventEmitter.on(type, listener);
708
     eventEmitter.on(type, listener);
688
 }
709
 }
4805
 
4826
 
4806
 var localVideoSrc = null;
4827
 var localVideoSrc = null;
4807
 
4828
 
4808
-var defaultLocalDisplayName = "Me";
4809
-
4810
 function videoactive( videoelem) {
4829
 function videoactive( videoelem) {
4811
     if (videoelem.attr('id').indexOf('mixedmslabel') === -1) {
4830
     if (videoelem.attr('id').indexOf('mixedmslabel') === -1) {
4812
         // ignore mixedmslabela0 and v0
4831
         // ignore mixedmslabela0 and v0
6542
     /**
6561
     /**
6543
      * On dominant speaker changed event.
6562
      * On dominant speaker changed event.
6544
      */
6563
      */
6545
-    $(document).bind('dominantspeakerchanged', function (event, resourceJid) {
6564
+    my.onDominantSpeakerChanged = function (resourceJid) {
6546
         // We ignore local user events.
6565
         // We ignore local user events.
6547
         if (resourceJid
6566
         if (resourceJid
6548
                 === xmpp.myResource())
6567
                 === xmpp.myResource())
6581
             if (video.length && video[0].currentTime > 0)
6600
             if (video.length && video[0].currentTime > 0)
6582
                 VideoLayout.updateLargeVideo(RTC.getVideoSrc(video[0]), resourceJid);
6601
                 VideoLayout.updateLargeVideo(RTC.getVideoSrc(video[0]), resourceJid);
6583
         }
6602
         }
6584
-    });
6603
+    };
6585
 
6604
 
6586
     /**
6605
     /**
6587
      * On last N change event.
6606
      * On last N change event.
6588
      *
6607
      *
6589
-     * @param event the event that notified us
6590
      * @param lastNEndpoints the list of last N endpoints
6608
      * @param lastNEndpoints the list of last N endpoints
6591
      * @param endpointsEnteringLastN the list currently entering last N
6609
      * @param endpointsEnteringLastN the list currently entering last N
6592
      * endpoints
6610
      * endpoints
6593
      */
6611
      */
6594
-    $(document).bind('lastnchanged', function ( event,
6595
-                                                lastNEndpoints,
6612
+    my.onLastNEndpointsChanged = function ( lastNEndpoints,
6596
                                                 endpointsEnteringLastN,
6613
                                                 endpointsEnteringLastN,
6597
                                                 stream) {
6614
                                                 stream) {
6598
         if (lastNCount !== lastNEndpoints.length)
6615
         if (lastNCount !== lastNEndpoints.length)
6731
 
6748
 
6732
             }
6749
             }
6733
         }
6750
         }
6734
-    });
6751
+    };
6735
 
6752
 
6736
-    $(document).bind('simulcastlayerschanging', function (event, endpointSimulcastLayers) {
6753
+    my.onSimulcastLayersChanging = function (endpointSimulcastLayers) {
6737
         endpointSimulcastLayers.forEach(function (esl) {
6754
         endpointSimulcastLayers.forEach(function (esl) {
6738
 
6755
 
6739
             var resource = esl.endpoint;
6756
             var resource = esl.endpoint;
6782
                 console.error('Could not find a stream or a session.', sid, electedStream);
6799
                 console.error('Could not find a stream or a session.', sid, electedStream);
6783
             }
6800
             }
6784
         });
6801
         });
6785
-    });
6802
+    };
6786
 
6803
 
6787
     /**
6804
     /**
6788
      * On simulcast layers changed event.
6805
      * On simulcast layers changed event.
6789
      */
6806
      */
6790
-    $(document).bind('simulcastlayerschanged', function (event, endpointSimulcastLayers) {
6807
+    my.onSimulcastLayersChanged = function (endpointSimulcastLayers) {
6791
         endpointSimulcastLayers.forEach(function (esl) {
6808
         endpointSimulcastLayers.forEach(function (esl) {
6792
 
6809
 
6793
             var resource = esl.endpoint;
6810
             var resource = esl.endpoint;
6873
                 console.error('Could not find a stream or a sid.', sid, electedStream);
6890
                 console.error('Could not find a stream or a sid.', sid, electedStream);
6874
             }
6891
             }
6875
         });
6892
         });
6876
-    });
6893
+    };
6877
 
6894
 
6878
     /**
6895
     /**
6879
      * Updates local stats
6896
      * Updates local stats

+ 16
- 18
libs/modules/simulcast.bundle.js 查看文件

1103
         }
1103
         }
1104
 
1104
 
1105
     }
1105
     }
1106
+    RTC.addListener(RTCEvents.SIMULCAST_LAYER_CHANGED,
1107
+        function (endpointSimulcastLayers) {
1108
+            endpointSimulcastLayers.forEach(function (esl) {
1109
+                var ssrc = esl.simulcastLayer.primarySSRC;
1110
+                simulcast._setReceivingVideoStream(esl.endpoint, ssrc);
1111
+            });
1112
+        });
1113
+    RTC.addListener(RTCEvents.SIMULCAST_START, function (simulcastLayer) {
1114
+        var ssrc = simulcastLayer.primarySSRC;
1115
+        simulcast._setLocalVideoStreamEnabled(ssrc, true);
1116
+    });
1117
+    RTC.addListener(RTCEvents.SIMULCAST_STOP, function (simulcastLayer) {
1118
+        var ssrc = simulcastLayer.primarySSRC;
1119
+        simulcast._setLocalVideoStreamEnabled(ssrc, false);
1120
+    });
1121
+
1106
 }
1122
 }
1107
 
1123
 
1108
 /**
1124
 /**
1237
     }
1253
     }
1238
 };
1254
 };
1239
 
1255
 
1240
-$(document).bind('simulcastlayerschanged', function (event, endpointSimulcastLayers) {
1241
-    endpointSimulcastLayers.forEach(function (esl) {
1242
-        var ssrc = esl.simulcastLayer.primarySSRC;
1243
-        simulcast._setReceivingVideoStream(esl.endpoint, ssrc);
1244
-    });
1245
-});
1246
-
1247
-$(document).bind('startsimulcastlayer', function (event, simulcastLayer) {
1248
-    var ssrc = simulcastLayer.primarySSRC;
1249
-    simulcast._setLocalVideoStreamEnabled(ssrc, true);
1250
-});
1251
-
1252
-$(document).bind('stopsimulcastlayer', function (event, simulcastLayer) {
1253
-    var ssrc = simulcastLayer.primarySSRC;
1254
-    simulcast._setLocalVideoStreamEnabled(ssrc, false);
1255
-});
1256
-
1257
-
1258
 var simulcast = new SimulcastManager();
1256
 var simulcast = new SimulcastManager();
1259
 
1257
 
1260
 module.exports = simulcast;
1258
 module.exports = simulcast;

+ 11
- 6
libs/modules/xmpp.bundle.js 查看文件

2831
 // service discovery.
2831
 // service discovery.
2832
 var sipGatewayEnabled = config.hosts.call_control !== undefined;
2832
 var sipGatewayEnabled = config.hosts.call_control !== undefined;
2833
 
2833
 
2834
+var eventEmitter = null;
2835
+
2834
 var Moderator = {
2836
 var Moderator = {
2835
     isModerator: function () {
2837
     isModerator: function () {
2836
         return connection && connection.emuc.isModerator();
2838
         return connection && connection.emuc.isModerator();
2853
         connection = con;
2855
         connection = con;
2854
     },
2856
     },
2855
 
2857
 
2856
-    init: function (xmpp) {
2858
+    init: function (xmpp, emitter) {
2857
         this.xmppService = xmpp;
2859
         this.xmppService = xmpp;
2860
+        eventEmitter = emitter;
2858
     },
2861
     },
2859
 
2862
 
2860
     onMucLeft: function (jid) {
2863
     onMucLeft: function (jid) {
3013
 
3016
 
3014
                         self.xmppService.promptLogin();
3017
                         self.xmppService.promptLogin();
3015
                     } else {
3018
                     } else {
3016
-                        // External authentication mode
3017
-                        UI.onAuthenticationRequired(function () {
3018
-                            Moderator.allocateConferenceFocus(
3019
-                                roomName, callback);
3020
-                        });
3019
+
3020
+                        eventEmitter.emit(XMPPEvents.AUTHENTICATION_REQUIRED, // External authentication mode
3021
+                            function () {
3022
+                                Moderator.allocateConferenceFocus(
3023
+                                    roomName, callback);
3024
+                            });
3025
+
3021
                     }
3026
                     }
3022
                     return;
3027
                     return;
3023
                 }
3028
                 }

+ 14
- 16
modules/RTC/DataChannels.js 查看文件

3
 // cache datachannels to avoid garbage collection
3
 // cache datachannels to avoid garbage collection
4
 // https://code.google.com/p/chromium/issues/detail?id=405545
4
 // https://code.google.com/p/chromium/issues/detail?id=405545
5
 var _dataChannels = [];
5
 var _dataChannels = [];
6
+var eventEmitter = null;
6
 
7
 
7
 
8
 
8
 
9
 
66
                     console.info(
67
                     console.info(
67
                         "Data channel new dominant speaker event: ",
68
                         "Data channel new dominant speaker event: ",
68
                         dominantSpeakerEndpoint);
69
                         dominantSpeakerEndpoint);
69
-                    $(document).trigger(
70
-                        'dominantspeakerchanged',
71
-                        [dominantSpeakerEndpoint]);
70
+                    eventEmitter.emit(RTC.DOMINANTSPEAKER_CHANGED, dominantSpeakerEndpoint);
72
                 }
71
                 }
73
                 else if ("InLastNChangeEvent" === colibriClass)
72
                 else if ("InLastNChangeEvent" === colibriClass)
74
                 {
73
                 {
91
                             newValue = new Boolean(newValue).valueOf();
90
                             newValue = new Boolean(newValue).valueOf();
92
                         }
91
                         }
93
                     }
92
                     }
94
-                    UI.onLastNChanged(oldValue, newValue);
93
+
94
+                    eventEmitter.emit(RTCEvents.LASTN_CHANGED, oldValue, newValue);
95
                 }
95
                 }
96
                 else if ("LastNEndpointsChangeEvent" === colibriClass)
96
                 else if ("LastNEndpointsChangeEvent" === colibriClass)
97
                 {
97
                 {
106
                     console.log(
106
                     console.log(
107
                         "Data channel new last-n event: ",
107
                         "Data channel new last-n event: ",
108
                         lastNEndpoints, endpointsEnteringLastN, obj);
108
                         lastNEndpoints, endpointsEnteringLastN, obj);
109
-                    $(document).trigger(
110
-                        'lastnchanged',
111
-                        [lastNEndpoints, endpointsEnteringLastN, stream]);
109
+                    eventEmitter.emit(RTCEvents.LASTN_ENDPOINT_CHANGED,
110
+                        lastNEndpoints, endpointsEnteringLastN, obj);
112
                 }
111
                 }
113
                 else if ("SimulcastLayersChangedEvent" === colibriClass)
112
                 else if ("SimulcastLayersChangedEvent" === colibriClass)
114
                 {
113
                 {
115
-                    $(document).trigger(
116
-                        'simulcastlayerschanged',
117
-                        [obj.endpointSimulcastLayers]);
114
+                    eventEmitter.emit(RTCEvents.SIMULCAST_LAYER_CHANGED,
115
+                        obj.endpointSimulcastLayers);
118
                 }
116
                 }
119
                 else if ("SimulcastLayersChangingEvent" === colibriClass)
117
                 else if ("SimulcastLayersChangingEvent" === colibriClass)
120
                 {
118
                 {
121
-                    $(document).trigger(
122
-                        'simulcastlayerschanging',
123
-                        [obj.endpointSimulcastLayers]);
119
+                    eventEmitter.emit(RTCEvents.SIMULCAST_LAYER_CHANGING,
120
+                        obj.endpointSimulcastLayers);
124
                 }
121
                 }
125
                 else if ("StartSimulcastLayerEvent" === colibriClass)
122
                 else if ("StartSimulcastLayerEvent" === colibriClass)
126
                 {
123
                 {
127
-                    $(document).trigger('startsimulcastlayer', obj.simulcastLayer);
124
+                    eventEmitter.emit(RTCEvents.SIMULCAST_START, obj.simulcastLayer);
128
                 }
125
                 }
129
                 else if ("StopSimulcastLayerEvent" === colibriClass)
126
                 else if ("StopSimulcastLayerEvent" === colibriClass)
130
                 {
127
                 {
131
-                    $(document).trigger('stopsimulcastlayer', obj.simulcastLayer);
128
+                    eventEmitter.emit(RTCEvents.SIMULCAST_STOP, obj.simulcastLayer);
132
                 }
129
                 }
133
                 else
130
                 else
134
                 {
131
                 {
151
      * Binds "ondatachannel" event listener to given PeerConnection instance.
148
      * Binds "ondatachannel" event listener to given PeerConnection instance.
152
      * @param peerConnection WebRTC peer connection instance.
149
      * @param peerConnection WebRTC peer connection instance.
153
      */
150
      */
154
-    bindDataChannelListener: function (peerConnection) {
151
+    init: function (peerConnection, emitter) {
155
         if(!config.openSctp)
152
         if(!config.openSctp)
156
             retrun;
153
             retrun;
157
 
154
 
158
         peerConnection.ondatachannel = this.onDataChannel;
155
         peerConnection.ondatachannel = this.onDataChannel;
156
+        eventEmitter = emitter;
159
 
157
 
160
         // Sample code for opening new data channel from Jitsi Meet to the bridge.
158
         // Sample code for opening new data channel from Jitsi Meet to the bridge.
161
         // Although it's not a requirement to open separate channels from both bridge
159
         // Although it's not a requirement to open separate channels from both bridge

+ 4
- 1
modules/RTC/RTC.js 查看文件

18
     addStreamListener: function (listener, eventType) {
18
     addStreamListener: function (listener, eventType) {
19
         eventEmitter.on(eventType, listener);
19
         eventEmitter.on(eventType, listener);
20
     },
20
     },
21
+    addListener: function (type, listener) {
22
+        eventEmitter.on(type, listener);
23
+    },
21
     removeStreamListener: function (listener, eventType) {
24
     removeStreamListener: function (listener, eventType) {
22
         if(!(eventType instanceof StreamEventTypes))
25
         if(!(eventType instanceof StreamEventTypes))
23
             throw "Illegal argument";
26
             throw "Illegal argument";
121
             }
124
             }
122
         });
125
         });
123
         xmpp.addListener(XMPPEvents.CALL_INCOMING, function(event) {
126
         xmpp.addListener(XMPPEvents.CALL_INCOMING, function(event) {
124
-            DataChannels.bindDataChannelListener(event.peerconnection);
127
+            DataChannels.init(event.peerconnection, eventEmitter);
125
         });
128
         });
126
         this.rtcUtils = new RTCUtils(this);
129
         this.rtcUtils = new RTCUtils(this);
127
         this.rtcUtils.obtainAudioAndVideoPermissions();
130
         this.rtcUtils.obtainAudioAndVideoPermissions();

+ 44
- 23
modules/UI/UI.js 查看文件

79
     RTC.addStreamListener(function (stream) {
79
     RTC.addStreamListener(function (stream) {
80
         VideoLayout.onRemoteStreamAdded(stream);
80
         VideoLayout.onRemoteStreamAdded(stream);
81
     }, StreamEventTypes.EVENT_TYPE_REMOTE_CREATED);
81
     }, StreamEventTypes.EVENT_TYPE_REMOTE_CREATED);
82
-
82
+    RTC.addListener(RTCEvents.LASTN_CHANGED, onLastNChanged);
83
+    RTC.addListener(RTCEvents.DOMINANTSPEAKER_CHANGED, function (resourceJid) {
84
+        VideoLayout.onDominantSpeakerChanged(resourceJid);
85
+    });
86
+    RTC.addListener(RTCEvents.LASTN_ENDPOINT_CHANGED,
87
+        function (lastNEndpoints, endpointsEnteringLastN, stream) {
88
+            VideoLayout.onLastNEndpointsChanged(lastNEndpoints,
89
+                endpointsEnteringLastN, stream);
90
+        });
91
+    RTC.addListener(RTCEvents.SIMULCAST_LAYER_CHANGED,
92
+        function (endpointSimulcastLayers) {
93
+           VideoLayout.onSimulcastLayersChanged(endpointSimulcastLayers);
94
+        });
95
+    RTC.addListener(RTCEvents.SIMULCAST_LAYER_CHANGING,
96
+        function (endpointSimulcastLayers) {
97
+            VideoLayout.onSimulcastLayersChanging(endpointSimulcastLayers);
98
+        });
83
     VideoLayout.init();
99
     VideoLayout.init();
84
 
100
 
85
     statistics.addAudioLevelListener(function(jid, audioLevel)
101
     statistics.addAudioLevelListener(function(jid, audioLevel)
155
         VideoLayout.updateConnectionStats);
171
         VideoLayout.updateConnectionStats);
156
     connectionquality.addListener(CQEvents.STOP,
172
     connectionquality.addListener(CQEvents.STOP,
157
         VideoLayout.onStatsStop);
173
         VideoLayout.onStatsStop);
174
+    xmpp.addListener(XMPPEvents.AUTHENTICATION_REQUIRED, onAuthenticationRequired);
175
+
176
+
158
 }
177
 }
159
 
178
 
160
 function bindEvents()
179
 function bindEvents()
367
 
386
 
368
 };
387
 };
369
 
388
 
370
-UI.getSettings = function () {
371
-    return Settings.getSettings();
372
-};
373
-
374
-UI.toggleFilmStrip = function () {
375
-    return BottomToolbar.toggleFilmStrip();
376
-};
377
-
378
-UI.toggleChat = function () {
379
-    return BottomToolbar.toggleChat();
380
-};
381
-
382
-UI.toggleContactList = function () {
383
-    return BottomToolbar.toggleContactList();
384
-};
385
 
389
 
386
 function onLocalRoleChange(jid, info, pres, isModerator, isExternalAuthEnabled)
390
 function onLocalRoleChange(jid, info, pres, isModerator, isExternalAuthEnabled)
387
 {
391
 {
467
     }
471
     }
468
 }
472
 }
469
 
473
 
470
-UI.onAuthenticationRequired = function (intervalCallback) {
474
+function onAuthenticationRequired(intervalCallback) {
471
     Authentication.openAuthenticationDialog(
475
     Authentication.openAuthenticationDialog(
472
         roomName, intervalCallback, function () {
476
         roomName, intervalCallback, function () {
473
             Toolbar.authenticateClicked();
477
             Toolbar.authenticateClicked();
474
         });
478
         });
475
 };
479
 };
476
 
480
 
481
+
482
+function onLastNChanged(oldValue, newValue) {
483
+    if (config.muteLocalVideoIfNotInLastN) {
484
+        setVideoMute(!newValue, { 'byUser': false });
485
+    }
486
+}
487
+
488
+UI.getSettings = function () {
489
+    return Settings.getSettings();
490
+};
491
+
492
+UI.toggleFilmStrip = function () {
493
+    return BottomToolbar.toggleFilmStrip();
494
+};
495
+
496
+UI.toggleChat = function () {
497
+    return BottomToolbar.toggleChat();
498
+};
499
+
500
+UI.toggleContactList = function () {
501
+    return BottomToolbar.toggleContactList();
502
+};
503
+
477
 UI.setRecordingButtonState = function (state) {
504
 UI.setRecordingButtonState = function (state) {
478
     Toolbar.setRecordingButtonState(state);
505
     Toolbar.setRecordingButtonState(state);
479
 };
506
 };
676
 
703
 
677
 }
704
 }
678
 
705
 
679
-UI.onLastNChanged = function (oldValue, newValue) {
680
-    if (config.muteLocalVideoIfNotInLastN) {
681
-        setVideoMute(!newValue, { 'byUser': false });
682
-    }
683
-}
684
-
685
 UI.addListener = function (type, listener) {
706
 UI.addListener = function (type, listener) {
686
     eventEmitter.on(type, listener);
707
     eventEmitter.on(type, listener);
687
 }
708
 }

+ 8
- 14
modules/UI/videolayout/VideoLayout.js 查看文件

36
 
36
 
37
 var localVideoSrc = null;
37
 var localVideoSrc = null;
38
 
38
 
39
-var defaultLocalDisplayName = "Me";
40
-
41
 function videoactive( videoelem) {
39
 function videoactive( videoelem) {
42
     if (videoelem.attr('id').indexOf('mixedmslabel') === -1) {
40
     if (videoelem.attr('id').indexOf('mixedmslabel') === -1) {
43
         // ignore mixedmslabela0 and v0
41
         // ignore mixedmslabela0 and v0
1773
     /**
1771
     /**
1774
      * On dominant speaker changed event.
1772
      * On dominant speaker changed event.
1775
      */
1773
      */
1776
-    $(document).bind('dominantspeakerchanged', function (event, resourceJid) {
1774
+    my.onDominantSpeakerChanged = function (resourceJid) {
1777
         // We ignore local user events.
1775
         // We ignore local user events.
1778
         if (resourceJid
1776
         if (resourceJid
1779
                 === xmpp.myResource())
1777
                 === xmpp.myResource())
1812
             if (video.length && video[0].currentTime > 0)
1810
             if (video.length && video[0].currentTime > 0)
1813
                 VideoLayout.updateLargeVideo(RTC.getVideoSrc(video[0]), resourceJid);
1811
                 VideoLayout.updateLargeVideo(RTC.getVideoSrc(video[0]), resourceJid);
1814
         }
1812
         }
1815
-    });
1813
+    };
1816
 
1814
 
1817
     /**
1815
     /**
1818
      * On last N change event.
1816
      * On last N change event.
1819
      *
1817
      *
1820
-     * @param event the event that notified us
1821
      * @param lastNEndpoints the list of last N endpoints
1818
      * @param lastNEndpoints the list of last N endpoints
1822
      * @param endpointsEnteringLastN the list currently entering last N
1819
      * @param endpointsEnteringLastN the list currently entering last N
1823
      * endpoints
1820
      * endpoints
1824
      */
1821
      */
1825
-    $(document).bind('lastnchanged', function ( event,
1826
-                                                lastNEndpoints,
1822
+    my.onLastNEndpointsChanged = function ( lastNEndpoints,
1827
                                                 endpointsEnteringLastN,
1823
                                                 endpointsEnteringLastN,
1828
                                                 stream) {
1824
                                                 stream) {
1829
         if (lastNCount !== lastNEndpoints.length)
1825
         if (lastNCount !== lastNEndpoints.length)
1962
 
1958
 
1963
             }
1959
             }
1964
         }
1960
         }
1965
-    });
1961
+    };
1966
 
1962
 
1967
-    $(document).bind('simulcastlayerschanging', function (event, endpointSimulcastLayers) {
1963
+    my.onSimulcastLayersChanging = function (endpointSimulcastLayers) {
1968
         endpointSimulcastLayers.forEach(function (esl) {
1964
         endpointSimulcastLayers.forEach(function (esl) {
1969
 
1965
 
1970
             var resource = esl.endpoint;
1966
             var resource = esl.endpoint;
1992
 
1988
 
1993
                 console.info([esl, primarySSRC, msid, sid, electedStream]);
1989
                 console.info([esl, primarySSRC, msid, sid, electedStream]);
1994
 
1990
 
1995
-                var msidParts = msid.split(' ');
1996
-
1997
                 var preload = (Strophe.getResourceFromJid(xmpp.getJidFromSSRC(primarySSRC)) == largeVideoState.userResourceJid);
1991
                 var preload = (Strophe.getResourceFromJid(xmpp.getJidFromSSRC(primarySSRC)) == largeVideoState.userResourceJid);
1998
 
1992
 
1999
                 if (preload) {
1993
                 if (preload) {
2013
                 console.error('Could not find a stream or a session.', sid, electedStream);
2007
                 console.error('Could not find a stream or a session.', sid, electedStream);
2014
             }
2008
             }
2015
         });
2009
         });
2016
-    });
2010
+    };
2017
 
2011
 
2018
     /**
2012
     /**
2019
      * On simulcast layers changed event.
2013
      * On simulcast layers changed event.
2020
      */
2014
      */
2021
-    $(document).bind('simulcastlayerschanged', function (event, endpointSimulcastLayers) {
2015
+    my.onSimulcastLayersChanged = function (endpointSimulcastLayers) {
2022
         endpointSimulcastLayers.forEach(function (esl) {
2016
         endpointSimulcastLayers.forEach(function (esl) {
2023
 
2017
 
2024
             var resource = esl.endpoint;
2018
             var resource = esl.endpoint;
2104
                 console.error('Could not find a stream or a sid.', sid, electedStream);
2098
                 console.error('Could not find a stream or a sid.', sid, electedStream);
2105
             }
2099
             }
2106
         });
2100
         });
2107
-    });
2101
+    };
2108
 
2102
 
2109
     /**
2103
     /**
2110
      * Updates local stats
2104
      * Updates local stats

+ 16
- 18
modules/simulcast/simulcast.js 查看文件

46
         }
46
         }
47
 
47
 
48
     }
48
     }
49
+    RTC.addListener(RTCEvents.SIMULCAST_LAYER_CHANGED,
50
+        function (endpointSimulcastLayers) {
51
+            endpointSimulcastLayers.forEach(function (esl) {
52
+                var ssrc = esl.simulcastLayer.primarySSRC;
53
+                simulcast._setReceivingVideoStream(esl.endpoint, ssrc);
54
+            });
55
+        });
56
+    RTC.addListener(RTCEvents.SIMULCAST_START, function (simulcastLayer) {
57
+        var ssrc = simulcastLayer.primarySSRC;
58
+        simulcast._setLocalVideoStreamEnabled(ssrc, true);
59
+    });
60
+    RTC.addListener(RTCEvents.SIMULCAST_STOP, function (simulcastLayer) {
61
+        var ssrc = simulcastLayer.primarySSRC;
62
+        simulcast._setLocalVideoStreamEnabled(ssrc, false);
63
+    });
64
+
49
 }
65
 }
50
 
66
 
51
 /**
67
 /**
180
     }
196
     }
181
 };
197
 };
182
 
198
 
183
-$(document).bind('simulcastlayerschanged', function (event, endpointSimulcastLayers) {
184
-    endpointSimulcastLayers.forEach(function (esl) {
185
-        var ssrc = esl.simulcastLayer.primarySSRC;
186
-        simulcast._setReceivingVideoStream(esl.endpoint, ssrc);
187
-    });
188
-});
189
-
190
-$(document).bind('startsimulcastlayer', function (event, simulcastLayer) {
191
-    var ssrc = simulcastLayer.primarySSRC;
192
-    simulcast._setLocalVideoStreamEnabled(ssrc, true);
193
-});
194
-
195
-$(document).bind('stopsimulcastlayer', function (event, simulcastLayer) {
196
-    var ssrc = simulcastLayer.primarySSRC;
197
-    simulcast._setLocalVideoStreamEnabled(ssrc, false);
198
-});
199
-
200
-
201
 var simulcast = new SimulcastManager();
199
 var simulcast = new SimulcastManager();
202
 
200
 
203
 module.exports = simulcast;
201
 module.exports = simulcast;

+ 11
- 6
modules/xmpp/moderator.js 查看文件

30
 // service discovery.
30
 // service discovery.
31
 var sipGatewayEnabled = config.hosts.call_control !== undefined;
31
 var sipGatewayEnabled = config.hosts.call_control !== undefined;
32
 
32
 
33
+var eventEmitter = null;
34
+
33
 var Moderator = {
35
 var Moderator = {
34
     isModerator: function () {
36
     isModerator: function () {
35
         return connection && connection.emuc.isModerator();
37
         return connection && connection.emuc.isModerator();
52
         connection = con;
54
         connection = con;
53
     },
55
     },
54
 
56
 
55
-    init: function (xmpp) {
57
+    init: function (xmpp, emitter) {
56
         this.xmppService = xmpp;
58
         this.xmppService = xmpp;
59
+        eventEmitter = emitter;
57
     },
60
     },
58
 
61
 
59
     onMucLeft: function (jid) {
62
     onMucLeft: function (jid) {
212
 
215
 
213
                         self.xmppService.promptLogin();
216
                         self.xmppService.promptLogin();
214
                     } else {
217
                     } else {
215
-                        // External authentication mode
216
-                        UI.onAuthenticationRequired(function () {
217
-                            Moderator.allocateConferenceFocus(
218
-                                roomName, callback);
219
-                        });
218
+
219
+                        eventEmitter.emit(XMPPEvents.AUTHENTICATION_REQUIRED, // External authentication mode
220
+                            function () {
221
+                                Moderator.allocateConferenceFocus(
222
+                                    roomName, callback);
223
+                            });
224
+
220
                     }
225
                     }
221
                     return;
226
                     return;
222
                 }
227
                 }

+ 9
- 0
service/RTC/RTCEvents.js 查看文件

1
+var RTCEvents = {
2
+    LASTN_CHANGED: "rtc.lastn_changed",
3
+    DOMINANTSPEAKER_CHANGED: "rtc.dominantspeaker_changed",
4
+    LASTN_ENDPOINT_CHANGED: "rtc.lastn_endpoint_changed",
5
+    SIMULCAST_LAYER_CHANGED: "rtc.simulcast_layer_changed",
6
+    SIMULCAST_LAYER_CHANGING: "rtc.simulcast_layer_changing",
7
+    SIMULCAST_START: "rtc.simlcast_start",
8
+    SIMULCAST_STOP: "rtc.simlcast_stop"
9
+}

+ 1
- 0
service/xmpp/XMPPEvents.js 查看文件

19
     MESSAGE_RECEIVED: "xmpp.message_received",
19
     MESSAGE_RECEIVED: "xmpp.message_received",
20
     SENDING_CHAT_MESSAGE: "xmpp.sending_chat_message",
20
     SENDING_CHAT_MESSAGE: "xmpp.sending_chat_message",
21
     PASSWORD_REQUIRED: "xmpp.password_required",
21
     PASSWORD_REQUIRED: "xmpp.password_required",
22
+    AUTHENTICATION_REQUIRED: "xmpp.authentication_required",
22
     CHAT_ERROR_RECEIVED: "xmpp.chat_error_received",
23
     CHAT_ERROR_RECEIVED: "xmpp.chat_error_received",
23
     ETHERPAD: "xmpp.etherpad"
24
     ETHERPAD: "xmpp.etherpad"
24
 };
25
 };

Loading…
取消
儲存