Explorar el Código

Add events for data chanel.

j8
hristoterezov hace 10 años
padre
commit
bc2d72638b

+ 5
- 4
index.html Ver fichero

@@ -22,17 +22,18 @@
22 22
     <script src="service/RTC/RTCBrowserType.js?v=1"></script>
23 23
     <script src="service/RTC/StreamEventTypes.js?v=2"></script>
24 24
     <script src="service/RTC/MediaStreamTypes.js?v=1"></script>
25
+    <script src="service/RTC/RTCEvents.js?v=1"></script>
25 26
     <script src="service/xmpp/XMPPEvents.js?v=1"></script>
26 27
     <script src="service/connectionquality/CQEvents.js?v=1"></script>
27 28
     <script src="service/UI/UIEvents.js?v=1"></script>
28 29
     <script src="service/desktopsharing/DesktopSharingEventTypes.js?v=1"></script>
29
-    <script src="libs/modules/simulcast.bundle.js?v=5"></script>
30 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 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 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 37
     <script src="libs/modules/keyboardshortcut.bundle.js?v=2"></script>
37 38
     <script src="app.js?v=30"></script><!-- application logic -->
38 39
     <script src="libs/modules/API.bundle.js?v=2"></script>

+ 18
- 17
libs/modules/RTC.bundle.js Ver fichero

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

+ 52
- 35
libs/modules/UI.bundle.js Ver fichero

@@ -80,7 +80,23 @@ function registerListeners() {
80 80
     RTC.addStreamListener(function (stream) {
81 81
         VideoLayout.onRemoteStreamAdded(stream);
82 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 100
     VideoLayout.init();
85 101
 
86 102
     statistics.addAudioLevelListener(function(jid, audioLevel)
@@ -156,6 +172,9 @@ function registerListeners() {
156 172
         VideoLayout.updateConnectionStats);
157 173
     connectionquality.addListener(CQEvents.STOP,
158 174
         VideoLayout.onStatsStop);
175
+    xmpp.addListener(XMPPEvents.AUTHENTICATION_REQUIRED, onAuthenticationRequired);
176
+
177
+
159 178
 }
160 179
 
161 180
 function bindEvents()
@@ -368,21 +387,6 @@ function onMucLeft(jid) {
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 391
 function onLocalRoleChange(jid, info, pres, isModerator, isExternalAuthEnabled)
388 392
 {
@@ -468,13 +472,36 @@ function onMucRoleChanged(role, displayName) {
468 472
     }
469 473
 }
470 474
 
471
-UI.onAuthenticationRequired = function (intervalCallback) {
475
+function onAuthenticationRequired(intervalCallback) {
472 476
     Authentication.openAuthenticationDialog(
473 477
         roomName, intervalCallback, function () {
474 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 505
 UI.setRecordingButtonState = function (state) {
479 506
     Toolbar.setRecordingButtonState(state);
480 507
 };
@@ -677,12 +704,6 @@ UI.setAudioMuted = function (mute) {
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 707
 UI.addListener = function (type, listener) {
687 708
     eventEmitter.on(type, listener);
688 709
 }
@@ -4805,8 +4826,6 @@ var currentVideoHeight = null;
4805 4826
 
4806 4827
 var localVideoSrc = null;
4807 4828
 
4808
-var defaultLocalDisplayName = "Me";
4809
-
4810 4829
 function videoactive( videoelem) {
4811 4830
     if (videoelem.attr('id').indexOf('mixedmslabel') === -1) {
4812 4831
         // ignore mixedmslabela0 and v0
@@ -6542,7 +6561,7 @@ var VideoLayout = (function (my) {
6542 6561
     /**
6543 6562
      * On dominant speaker changed event.
6544 6563
      */
6545
-    $(document).bind('dominantspeakerchanged', function (event, resourceJid) {
6564
+    my.onDominantSpeakerChanged = function (resourceJid) {
6546 6565
         // We ignore local user events.
6547 6566
         if (resourceJid
6548 6567
                 === xmpp.myResource())
@@ -6581,18 +6600,16 @@ var VideoLayout = (function (my) {
6581 6600
             if (video.length && video[0].currentTime > 0)
6582 6601
                 VideoLayout.updateLargeVideo(RTC.getVideoSrc(video[0]), resourceJid);
6583 6602
         }
6584
-    });
6603
+    };
6585 6604
 
6586 6605
     /**
6587 6606
      * On last N change event.
6588 6607
      *
6589
-     * @param event the event that notified us
6590 6608
      * @param lastNEndpoints the list of last N endpoints
6591 6609
      * @param endpointsEnteringLastN the list currently entering last N
6592 6610
      * endpoints
6593 6611
      */
6594
-    $(document).bind('lastnchanged', function ( event,
6595
-                                                lastNEndpoints,
6612
+    my.onLastNEndpointsChanged = function ( lastNEndpoints,
6596 6613
                                                 endpointsEnteringLastN,
6597 6614
                                                 stream) {
6598 6615
         if (lastNCount !== lastNEndpoints.length)
@@ -6731,9 +6748,9 @@ var VideoLayout = (function (my) {
6731 6748
 
6732 6749
             }
6733 6750
         }
6734
-    });
6751
+    };
6735 6752
 
6736
-    $(document).bind('simulcastlayerschanging', function (event, endpointSimulcastLayers) {
6753
+    my.onSimulcastLayersChanging = function (endpointSimulcastLayers) {
6737 6754
         endpointSimulcastLayers.forEach(function (esl) {
6738 6755
 
6739 6756
             var resource = esl.endpoint;
@@ -6782,12 +6799,12 @@ var VideoLayout = (function (my) {
6782 6799
                 console.error('Could not find a stream or a session.', sid, electedStream);
6783 6800
             }
6784 6801
         });
6785
-    });
6802
+    };
6786 6803
 
6787 6804
     /**
6788 6805
      * On simulcast layers changed event.
6789 6806
      */
6790
-    $(document).bind('simulcastlayerschanged', function (event, endpointSimulcastLayers) {
6807
+    my.onSimulcastLayersChanged = function (endpointSimulcastLayers) {
6791 6808
         endpointSimulcastLayers.forEach(function (esl) {
6792 6809
 
6793 6810
             var resource = esl.endpoint;
@@ -6873,7 +6890,7 @@ var VideoLayout = (function (my) {
6873 6890
                 console.error('Could not find a stream or a sid.', sid, electedStream);
6874 6891
             }
6875 6892
         });
6876
-    });
6893
+    };
6877 6894
 
6878 6895
     /**
6879 6896
      * Updates local stats

+ 16
- 18
libs/modules/simulcast.bundle.js Ver fichero

@@ -1103,6 +1103,22 @@ function SimulcastManager() {
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,24 +1253,6 @@ SimulcastManager.prototype.resetSender = function() {
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 1256
 var simulcast = new SimulcastManager();
1259 1257
 
1260 1258
 module.exports = simulcast;

+ 11
- 6
libs/modules/xmpp.bundle.js Ver fichero

@@ -2831,6 +2831,8 @@ var externalAuthEnabled = false;
2831 2831
 // service discovery.
2832 2832
 var sipGatewayEnabled = config.hosts.call_control !== undefined;
2833 2833
 
2834
+var eventEmitter = null;
2835
+
2834 2836
 var Moderator = {
2835 2837
     isModerator: function () {
2836 2838
         return connection && connection.emuc.isModerator();
@@ -2853,8 +2855,9 @@ var Moderator = {
2853 2855
         connection = con;
2854 2856
     },
2855 2857
 
2856
-    init: function (xmpp) {
2858
+    init: function (xmpp, emitter) {
2857 2859
         this.xmppService = xmpp;
2860
+        eventEmitter = emitter;
2858 2861
     },
2859 2862
 
2860 2863
     onMucLeft: function (jid) {
@@ -3013,11 +3016,13 @@ var Moderator = {
3013 3016
 
3014 3017
                         self.xmppService.promptLogin();
3015 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 3027
                     return;
3023 3028
                 }

+ 14
- 16
modules/RTC/DataChannels.js Ver fichero

@@ -3,6 +3,7 @@
3 3
 // cache datachannels to avoid garbage collection
4 4
 // https://code.google.com/p/chromium/issues/detail?id=405545
5 5
 var _dataChannels = [];
6
+var eventEmitter = null;
6 7
 
7 8
 
8 9
 
@@ -66,9 +67,7 @@ var DataChannels =
66 67
                     console.info(
67 68
                         "Data channel new dominant speaker event: ",
68 69
                         dominantSpeakerEndpoint);
69
-                    $(document).trigger(
70
-                        'dominantspeakerchanged',
71
-                        [dominantSpeakerEndpoint]);
70
+                    eventEmitter.emit(RTC.DOMINANTSPEAKER_CHANGED, dominantSpeakerEndpoint);
72 71
                 }
73 72
                 else if ("InLastNChangeEvent" === colibriClass)
74 73
                 {
@@ -91,7 +90,8 @@ var DataChannels =
91 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 96
                 else if ("LastNEndpointsChangeEvent" === colibriClass)
97 97
                 {
@@ -106,29 +106,26 @@ var DataChannels =
106 106
                     console.log(
107 107
                         "Data channel new last-n event: ",
108 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 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 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 122
                 else if ("StartSimulcastLayerEvent" === colibriClass)
126 123
                 {
127
-                    $(document).trigger('startsimulcastlayer', obj.simulcastLayer);
124
+                    eventEmitter.emit(RTCEvents.SIMULCAST_START, obj.simulcastLayer);
128 125
                 }
129 126
                 else if ("StopSimulcastLayerEvent" === colibriClass)
130 127
                 {
131
-                    $(document).trigger('stopsimulcastlayer', obj.simulcastLayer);
128
+                    eventEmitter.emit(RTCEvents.SIMULCAST_STOP, obj.simulcastLayer);
132 129
                 }
133 130
                 else
134 131
                 {
@@ -151,11 +148,12 @@ var DataChannels =
151 148
      * Binds "ondatachannel" event listener to given PeerConnection instance.
152 149
      * @param peerConnection WebRTC peer connection instance.
153 150
      */
154
-    bindDataChannelListener: function (peerConnection) {
151
+    init: function (peerConnection, emitter) {
155 152
         if(!config.openSctp)
156 153
             retrun;
157 154
 
158 155
         peerConnection.ondatachannel = this.onDataChannel;
156
+        eventEmitter = emitter;
159 157
 
160 158
         // Sample code for opening new data channel from Jitsi Meet to the bridge.
161 159
         // Although it's not a requirement to open separate channels from both bridge

+ 4
- 1
modules/RTC/RTC.js Ver fichero

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

+ 44
- 23
modules/UI/UI.js Ver fichero

@@ -79,7 +79,23 @@ function registerListeners() {
79 79
     RTC.addStreamListener(function (stream) {
80 80
         VideoLayout.onRemoteStreamAdded(stream);
81 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 99
     VideoLayout.init();
84 100
 
85 101
     statistics.addAudioLevelListener(function(jid, audioLevel)
@@ -155,6 +171,9 @@ function registerListeners() {
155 171
         VideoLayout.updateConnectionStats);
156 172
     connectionquality.addListener(CQEvents.STOP,
157 173
         VideoLayout.onStatsStop);
174
+    xmpp.addListener(XMPPEvents.AUTHENTICATION_REQUIRED, onAuthenticationRequired);
175
+
176
+
158 177
 }
159 178
 
160 179
 function bindEvents()
@@ -367,21 +386,6 @@ function onMucLeft(jid) {
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 390
 function onLocalRoleChange(jid, info, pres, isModerator, isExternalAuthEnabled)
387 391
 {
@@ -467,13 +471,36 @@ function onMucRoleChanged(role, displayName) {
467 471
     }
468 472
 }
469 473
 
470
-UI.onAuthenticationRequired = function (intervalCallback) {
474
+function onAuthenticationRequired(intervalCallback) {
471 475
     Authentication.openAuthenticationDialog(
472 476
         roomName, intervalCallback, function () {
473 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 504
 UI.setRecordingButtonState = function (state) {
478 505
     Toolbar.setRecordingButtonState(state);
479 506
 };
@@ -676,12 +703,6 @@ UI.setAudioMuted = function (mute) {
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 706
 UI.addListener = function (type, listener) {
686 707
     eventEmitter.on(type, listener);
687 708
 }

+ 8
- 14
modules/UI/videolayout/VideoLayout.js Ver fichero

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

+ 16
- 18
modules/simulcast/simulcast.js Ver fichero

@@ -46,6 +46,22 @@ function SimulcastManager() {
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,24 +196,6 @@ SimulcastManager.prototype.resetSender = function() {
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 199
 var simulcast = new SimulcastManager();
202 200
 
203 201
 module.exports = simulcast;

+ 11
- 6
modules/xmpp/moderator.js Ver fichero

@@ -30,6 +30,8 @@ var externalAuthEnabled = false;
30 30
 // service discovery.
31 31
 var sipGatewayEnabled = config.hosts.call_control !== undefined;
32 32
 
33
+var eventEmitter = null;
34
+
33 35
 var Moderator = {
34 36
     isModerator: function () {
35 37
         return connection && connection.emuc.isModerator();
@@ -52,8 +54,9 @@ var Moderator = {
52 54
         connection = con;
53 55
     },
54 56
 
55
-    init: function (xmpp) {
57
+    init: function (xmpp, emitter) {
56 58
         this.xmppService = xmpp;
59
+        eventEmitter = emitter;
57 60
     },
58 61
 
59 62
     onMucLeft: function (jid) {
@@ -212,11 +215,13 @@ var Moderator = {
212 215
 
213 216
                         self.xmppService.promptLogin();
214 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 226
                     return;
222 227
                 }

+ 9
- 0
service/RTC/RTCEvents.js Ver fichero

@@ -0,0 +1,9 @@
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 Ver fichero

@@ -19,6 +19,7 @@ var XMPPEvents = {
19 19
     MESSAGE_RECEIVED: "xmpp.message_received",
20 20
     SENDING_CHAT_MESSAGE: "xmpp.sending_chat_message",
21 21
     PASSWORD_REQUIRED: "xmpp.password_required",
22
+    AUTHENTICATION_REQUIRED: "xmpp.authentication_required",
22 23
     CHAT_ERROR_RECEIVED: "xmpp.chat_error_received",
23 24
     ETHERPAD: "xmpp.etherpad"
24 25
 };

Loading…
Cancelar
Guardar