Pārlūkot izejas kodu

do not use RTC/xmpp in UI module

j8
isymchych 9 gadus atpakaļ
vecāks
revīzija
6ded050b51

+ 61
- 17
app.js Parādīt failu

@@ -13,6 +13,7 @@ import "jQuery-Impromptu";
13 13
 import "autosize";
14 14
 window.toastr = require("toastr");
15 15
 
16
+import URLProcessor from "./modules/config/URLProcessor";
16 17
 import RoomnameGenerator from './modules/util/RoomnameGenerator';
17 18
 import CQEvents from './service/connectionquality/CQEvents';
18 19
 import UIEvents from './service/UI/UIEvents';
@@ -101,23 +102,23 @@ const APP = {
101 102
 };
102 103
 
103 104
 
104
-var ConnectionEvents = JitsiMeetJS.events.connection;
105
-var ConnectionErrors = JitsiMeetJS.errors.connection;
105
+const ConnectionEvents = JitsiMeetJS.events.connection;
106
+const ConnectionErrors = JitsiMeetJS.errors.connection;
106 107
 function connect() {
107
-    var connection = new JitsiMeetJS.JitsiConnection(null, null, {
108
+    let connection = new JitsiMeetJS.JitsiConnection(null, null, {
108 109
         hosts: config.hosts,
109 110
         bosh: config.bosh,
110 111
         clientNode: config.clientNode
111 112
     });
112 113
 
113 114
     return new Promise(function (resolve, reject) {
114
-        var handlers = {};
115
+        let handlers = {};
115 116
 
116
-        var unsubscribe = function () {
117
+        function unsubscribe () {
117 118
             Object.keys(handlers).forEach(function (event) {
118 119
                 connection.removeEventListener(event, handlers[event]);
119 120
             });
120
-        };
121
+        }
121 122
 
122 123
         handlers[ConnectionEvents.CONNECTION_ESTABLISHED] = function () {
123 124
             console.log('CONNECTED');
@@ -125,14 +126,14 @@ function connect() {
125 126
             resolve(connection);
126 127
         };
127 128
 
128
-        var listenForFailure = function (event) {
129
+        function listenForFailure (event) {
129 130
             handlers[event] = function (...args) {
130 131
                 console.error(`CONNECTION FAILED: ${event}`, ...args);
131 132
 
132 133
                 unsubscribe();
133 134
                 reject([event, ...args]);
134 135
             };
135
-        };
136
+        }
136 137
 
137 138
         listenForFailure(ConnectionEvents.CONNECTION_FAILED);
138 139
         listenForFailure(ConnectionErrors.PASSWORD_REQUIRED);
@@ -172,6 +173,13 @@ function initConference(localTracks, connection) {
172 173
         }
173 174
     });
174 175
 
176
+    APP.conference.listMembers = function () {
177
+        return room.getParticipants();
178
+    };
179
+    APP.conference.listMembersIds = function () {
180
+        return room.getParticipants().map(p => p.getId());
181
+    };
182
+
175 183
     function getDisplayName(id) {
176 184
         if (APP.conference.isLocalId(id)) {
177 185
             return APP.settings.getDisplayName();
@@ -187,17 +195,22 @@ function initConference(localTracks, connection) {
187 195
     room.on(ConferenceEvents.CONFERENCE_JOINED, function () {
188 196
         localTracks.forEach(function (track) {
189 197
             room.addTrack(track);
190
-            //APP.UI.addLocalStream(track);
198
+            APP.UI.addLocalStream(track);
191 199
         });
192 200
     });
193 201
 
194 202
 
195
-    room.on(ConferenceEvents.USER_JOINED, function (id) {
203
+    room.on(ConferenceEvents.USER_JOINED, function (id, user) {
204
+        if (APP.conference.isLocalId(id)) {
205
+            return;
206
+        }
207
+        console.error('USER %s connnected', id);
196 208
         // FIXME email???
197
-        //APP.UI.addUser(id);
209
+        APP.UI.addUser(id, user.getDisplayName());
198 210
     });
199
-    room.on(ConferenceEvents.USER_LEFT, function (id) {
200
-        APP.UI.removeUser(id);
211
+    room.on(ConferenceEvents.USER_LEFT, function (id, user) {
212
+        console.error('USER LEFT', id);
213
+        APP.UI.removeUser(id, user.getDisplayName());
201 214
     });
202 215
 
203 216
 
@@ -230,6 +243,26 @@ function initConference(localTracks, connection) {
230 243
     });
231 244
 
232 245
 
246
+    room.on(ConferenceEvents.TRACK_ADDED, function (track) {
247
+        if (!track.getParticipantId) { // skip local tracks
248
+            return;
249
+        }
250
+        console.error(
251
+            'REMOTE %s TRACK', track.getType(), track.getParticipantId()
252
+        );
253
+        APP.UI.addRemoteStream(track);
254
+    });
255
+    room.on(ConferenceEvents.TRACK_REMOVED, function (track) {
256
+        if (!track.getParticipantId) { // skip local tracks
257
+            return;
258
+        }
259
+
260
+        console.error(
261
+            'REMOTE %s TRACK REMOVED', track.getType(), track.getParticipantId()
262
+        );
263
+
264
+        // FIXME handle
265
+    });
233 266
     room.on(ConferenceEvents.TRACK_MUTE_CHANGED, function (track) {
234 267
         // FIXME handle mute
235 268
     });
@@ -421,10 +454,23 @@ function initConference(localTracks, connection) {
421 454
         // on SUBJECT_CHANGED UI.setSubject(topic);
422 455
     });
423 456
 
457
+    APP.UI.addListener(UIEvents.USER_KICKED, function (id) {
458
+        // FIXME handle
459
+        // APP.xmpp.eject(self.id);
460
+    });
461
+
462
+    APP.UI.addListener(UIEvents.SELECTED_ENDPOINT, function (id) {
463
+        room.selectParticipant(id);
464
+    });
465
+
424 466
     room.on(ConferenceEvents.DTMF_SUPPORT_CHANGED, function (isDTMFSupported) {
425 467
         APP.UI.updateDTMFSupport(isDTMFSupported);
426 468
     });
427 469
 
470
+    $(window).bind('beforeunload', function () {
471
+        room.leave();
472
+    });
473
+
428 474
     return new Promise(function (resolve, reject) {
429 475
         room.on(ConferenceEvents.CONFERENCE_JOINED, resolve);
430 476
 
@@ -456,6 +502,7 @@ function createLocalTracks () {
456 502
 }
457 503
 
458 504
 function init() {
505
+    APP.UI.start();
459 506
     JitsiMeetJS.setLogLevel(JitsiMeetJS.logLevels.TRACE);
460 507
     JitsiMeetJS.init().then(function () {
461 508
         return Promise.all([createLocalTracks(), connect()]);
@@ -463,8 +510,6 @@ function init() {
463 510
         console.log('initialized with %s local tracks', tracks.length);
464 511
         return initConference(tracks, connection);
465 512
     }).then(function () {
466
-        APP.UI.start();
467
-
468 513
         APP.UI.initConference();
469 514
 
470 515
         APP.UI.addListener(UIEvents.LANG_CHANGED, function (language) {
@@ -518,7 +563,6 @@ function obtainConfigAndInit() {
518 563
 $(document).ready(function () {
519 564
     console.log("(TIME) document ready:\t", window.performance.now());
520 565
 
521
-    var URLProcessor = require("./modules/config/URLProcessor");
522 566
     URLProcessor.setConfigParametersFromUrl();
523 567
     APP.init();
524 568
 
@@ -537,4 +581,4 @@ $(window).bind('beforeunload', function () {
537 581
     }
538 582
 });
539 583
 
540
-export default APP;
584
+module.exports = APP;

+ 1173
- 826
lib-jitsi-meet.js
Failā izmaiņas netiks attēlotas, jo tās ir par lielu
Parādīt failu


+ 22
- 22
modules/UI/UI.js Parādīt failu

@@ -1,31 +1,33 @@
1
-/* global Strophe, APP, $, config, interfaceConfig, toastr */
1
+/* global APP, $, config, interfaceConfig, toastr */
2 2
 /* jshint -W101 */
3 3
 var UI = {};
4 4
 
5
-var VideoLayout = require("./videolayout/VideoLayout");
6
-var AudioLevels = require("./audio_levels/AudioLevels");
5
+import AudioLevels from './audio_levels/AudioLevels';
6
+import Chat from "./side_pannels/chat/Chat";
7
+import Toolbar from "./toolbars/Toolbar";
8
+import ToolbarToggler from "./toolbars/ToolbarToggler";
9
+import BottomToolbar from "./toolbars/BottomToolbar";
10
+import ContactList from "./side_pannels/contactlist/ContactList";
11
+import Avatar from "./avatar/Avatar";
12
+import PanelToggler from "./side_pannels/SidePanelToggler";
13
+import UIUtil from "./util/UIUtil";
14
+import UIEvents from "../../service/UI/UIEvents";
15
+
16
+import VideoLayout from "./videolayout/VideoLayout";
17
+
7 18
 var Prezi = require("./prezi/Prezi");
8 19
 var Etherpad = require("./etherpad/Etherpad");
9
-var Chat = require("./side_pannels/chat/Chat");
10
-var Toolbar = require("./toolbars/Toolbar");
11
-var ToolbarToggler = require("./toolbars/ToolbarToggler");
12
-var BottomToolbar = require("./toolbars/BottomToolbar");
13
-var ContactList = require("./side_pannels/contactlist/ContactList");
14
-var Avatar = require("./avatar/Avatar");
15 20
 var EventEmitter = require("events");
16 21
 var SettingsMenu = require("./side_pannels/settings/SettingsMenu");
17 22
 var Settings = require("./../settings/Settings");
18
-var PanelToggler = require("./side_pannels/SidePanelToggler");
19 23
 UI.messageHandler = require("./util/MessageHandler");
20 24
 var messageHandler = UI.messageHandler;
21 25
 var Authentication  = require("./authentication/Authentication");
22
-var UIUtil = require("./util/UIUtil");
23 26
 var JitsiPopover = require("./util/JitsiPopover");
24 27
 var CQEvents = require("../../service/connectionquality/CQEvents");
25 28
 var DesktopSharingEventTypes
26 29
     = require("../../service/desktopsharing/DesktopSharingEventTypes");
27 30
 var StatisticsEvents = require("../../service/statistics/Events");
28
-var UIEvents = require("../../service/UI/UIEvents");
29 31
 var Feedback = require("./Feedback");
30 32
 
31 33
 var eventEmitter = new EventEmitter();
@@ -352,7 +354,7 @@ function initEtherpad(name) {
352 354
     Etherpad.init(name);
353 355
 }
354 356
 
355
-UI.addUser = function (jid, id, displayName) {
357
+UI.addUser = function (id, displayName) {
356 358
     messageHandler.notify(
357 359
         displayName,'notify.somebody', 'connected', 'notify.connected'
358 360
     );
@@ -362,16 +364,14 @@ UI.addUser = function (jid, id, displayName) {
362 364
         UIUtil.playSoundNotification('userJoined');
363 365
 
364 366
     // Configure avatar
365
-    UI.setUserAvatar(jid, id);
367
+    UI.setUserAvatar(id, displayName);
366 368
 
367 369
     // Add Peer's container
368
-    VideoLayout.ensurePeerContainerExists(jid);
370
+    VideoLayout.ensurePeerContainerExists(id);
369 371
 };
370 372
 
371
-UI.removeUser = function (jid) {
372
-    console.log('left.muc', jid);
373
-    var displayName = $('#participant_' + Strophe.getResourceFromJid(jid) +
374
-        '>.displayname').html();
373
+UI.removeUser = function (id, displayName) {
374
+    console.log('left.muc', id);
375 375
     messageHandler.notify(displayName,'notify.somebody',
376 376
         'disconnected',
377 377
         'notify.disconnected');
@@ -380,9 +380,9 @@ UI.removeUser = function (jid) {
380 380
         UIUtil.playSoundNotification('userLeft');
381 381
     }
382 382
 
383
-    ContactList.removeContact(jid);
383
+    ContactList.removeContact(id);
384 384
 
385
-    VideoLayout.participantLeft(jid);
385
+    VideoLayout.participantLeft(id);
386 386
 };
387 387
 
388 388
 function onMucPresenceStatus(jid, info) {
@@ -601,7 +601,7 @@ UI.handleLastNEndpoints = function (ids) {
601 601
 
602 602
 UI.setAudioLevel = function (id, lvl) {
603 603
     AudioLevels.updateAudioLevel(
604
-        id, lvl, VideoLayout.getLargeVideoResource()
604
+        id, lvl, VideoLayout.getLargeVideoId()
605 605
     );
606 606
 };
607 607
 

+ 1
- 2
modules/UI/audio_levels/AudioLevels.js Parādīt failu

@@ -248,8 +248,7 @@ const AudioLevels = {
248 248
 
249 249
         // Fill the shape.
250 250
         ASDrawContext.fill();
251
-    },
252
-
251
+    }
253 252
 };
254 253
 
255 254
 export default AudioLevels;

+ 5
- 2
modules/UI/prezi/Prezi.js Parādīt failu

@@ -1,5 +1,8 @@
1
-var UIUtil = require("../util/UIUtil");
2
-var VideoLayout = require("../videolayout/VideoLayout");
1
+/* global $, APP */
2
+/* jshint -W101 */
3
+import UIUtil from "../util/UIUtil";
4
+import VideoLayout from "../videolayout/VideoLayout";
5
+
3 6
 var messageHandler = require("../util/MessageHandler");
4 7
 var PreziPlayer = require("./PreziPlayer");
5 8
 

+ 6
- 2
modules/UI/util/UIUtil.js Parādīt failu

@@ -1,13 +1,15 @@
1 1
 /* global $, config, interfaceConfig */
2
+
3
+import PanelToggler from "../side_pannels/SidePanelToggler";
4
+
2 5
 /**
3 6
  * Created by hristo on 12/22/14.
4 7
  */
5
-var UIUtil = module.exports = {
8
+ var UIUtil = {
6 9
     /**
7 10
      * Returns the available video width.
8 11
      */
9 12
     getAvailableVideoWidth: function (isVisible) {
10
-        var PanelToggler = require("../side_pannels/SidePanelToggler");
11 13
         if(typeof isVisible === "undefined" || isVisible === null)
12 14
             isVisible = PanelToggler.isVisible();
13 15
         var rightPanelWidth
@@ -114,3 +116,5 @@ var UIUtil = module.exports = {
114 116
         $(selector).hide();
115 117
     }
116 118
 };
119
+
120
+export default UIUtil;

+ 8
- 8
modules/UI/videolayout/ConnectionIndicator.js Parādīt failu

@@ -1,13 +1,13 @@
1 1
 /* global APP, $ */
2 2
 /* jshint -W101 */
3
-var JitsiPopover = require("../util/JitsiPopover");
3
+import JitsiPopover from "../util/JitsiPopover";
4 4
 
5 5
 /**
6 6
  * Constructs new connection indicator.
7 7
  * @param videoContainer the video container associated with the indicator.
8 8
  * @constructor
9 9
  */
10
-function ConnectionIndicator(videoContainer, jid) {
10
+function ConnectionIndicator(videoContainer, id) {
11 11
     this.videoContainer = videoContainer;
12 12
     this.bandwidth = null;
13 13
     this.packetLoss = null;
@@ -16,7 +16,7 @@ function ConnectionIndicator(videoContainer, jid) {
16 16
     this.resolution = null;
17 17
     this.transport = [];
18 18
     this.popover = null;
19
-    this.jid = jid;
19
+    this.id = id;
20 20
     this.create();
21 21
 }
22 22
 
@@ -87,7 +87,7 @@ ConnectionIndicator.prototype.generateText = function () {
87 87
     }
88 88
 
89 89
     var resolutionValue = null;
90
-    if(this.resolution && this.jid) {
90
+    if(this.resolution && this.id) {
91 91
         var keys = Object.keys(this.resolution);
92 92
         for(var ssrc in this.resolution) {
93 93
             // skip resolutions for ssrc that don't have this info
@@ -99,7 +99,7 @@ ConnectionIndicator.prototype.generateText = function () {
99 99
         }
100 100
     }
101 101
 
102
-    if(this.jid === null) {
102
+    if(this.id === null) {
103 103
         resolution = "";
104 104
         if(this.resolution === null || !Object.keys(this.resolution) ||
105 105
             Object.keys(this.resolution).length === 0) {
@@ -144,8 +144,8 @@ ConnectionIndicator.prototype.generateText = function () {
144 144
     if(this.videoContainer.videoSpanId == "localVideoContainer") {
145 145
         result += "<div class=\"jitsipopover_showmore\" " +
146 146
             "onclick = \"APP.UI.connectionIndicatorShowMore('" +
147
-            // FIXME: we do not know local jid when this text is generated
148
-            //this.jid + "')\"  data-i18n='connectionindicator." +
147
+            // FIXME: we do not know local id when this text is generated
148
+            //this.id + "')\"  data-i18n='connectionindicator." +
149 149
             "local')\"  data-i18n='connectionindicator." +
150 150
                 (this.showMoreValue ? "less" : "more") + "'>" +
151 151
             translate("connectionindicator." + (this.showMoreValue ? "less" : "more")) +
@@ -385,4 +385,4 @@ ConnectionIndicator.prototype.hideIndicator = function () {
385 385
         this.popover.forceHide();
386 386
 };
387 387
 
388
-module.exports = ConnectionIndicator;
388
+export default ConnectionIndicator;

+ 75
- 80
modules/UI/videolayout/LargeVideo.js Parādīt failu

@@ -1,11 +1,11 @@
1
-/* global $, APP, Strophe, interfaceConfig */
1
+/* global $, APP, interfaceConfig */
2 2
 /* jshint -W101 */
3
-var Avatar = require("../avatar/Avatar");
3
+import Avatar from "../avatar/Avatar";
4
+import ToolbarToggler from "../toolbars/ToolbarToggler";
5
+import UIUtil from "../util/UIUtil";
6
+import UIEvents from "../../../service/UI/UIEvents";
7
+
4 8
 var RTCBrowserType = require("../../RTC/RTCBrowserType");
5
-var UIUtil = require("../util/UIUtil");
6
-var UIEvents = require("../../../service/UI/UIEvents");
7
-var xmpp = require("../../xmpp/xmpp");
8
-var ToolbarToggler = require("../toolbars/ToolbarToggler");
9 9
 
10 10
 // FIXME: With Temasys we have to re-select everytime
11 11
 //var video = $('#largeVideo');
@@ -37,22 +37,22 @@ var state = "video";
37 37
  * @param state the state.
38 38
  * @returns {JQuery|*|jQuery|HTMLElement} the container.
39 39
  */
40
-function getContainerByState(state)
41
-{
40
+function getContainerByState(state) {
42 41
     var selector = null;
43
-    switch (state)
44
-    {
45
-        case "video":
46
-            selector = "#largeVideoWrapper";
47
-            break;
48
-        case "etherpad":
49
-            selector = "#etherpad>iframe";
50
-            break;
51
-        case "prezi":
52
-            selector = "#presentation>iframe";
53
-            break;
42
+    switch (state) {
43
+    case "video":
44
+        selector = "#largeVideoWrapper";
45
+        break;
46
+    case "etherpad":
47
+        selector = "#etherpad>iframe";
48
+        break;
49
+    case "prezi":
50
+        selector = "#presentation>iframe";
51
+        break;
52
+    default:
53
+        return null;
54 54
     }
55
-    return (selector !== null)? $(selector) : null;
55
+    return $(selector);
56 56
 }
57 57
 
58 58
 /**
@@ -72,24 +72,25 @@ function positionVideo(video,
72 72
                        animate) {
73 73
     if (animate) {
74 74
         video.animate({
75
-                width: width,
76
-                height: height,
77
-                top: verticalIndent,
78
-                bottom: verticalIndent,
79
-                left: horizontalIndent,
80
-                right: horizontalIndent
81
-            },
82
-            {
83
-                queue: false,
84
-                duration: 500
85
-            });
75
+            width: width,
76
+            height: height,
77
+            top: verticalIndent,
78
+            bottom: verticalIndent,
79
+            left: horizontalIndent,
80
+            right: horizontalIndent
81
+        }, {
82
+            queue: false,
83
+            duration: 500
84
+        });
86 85
     } else {
87 86
         video.width(width);
88 87
         video.height(height);
89
-        video.css({  top: verticalIndent + 'px',
90
-            bottom: verticalIndent + 'px',
91
-            left: horizontalIndent + 'px',
92
-            right: horizontalIndent + 'px'});
88
+        video.css({
89
+            top:     verticalIndent,
90
+            bottom:  verticalIndent,
91
+            left:    horizontalIndent,
92
+            right:   horizontalIndent
93
+        });
93 94
     }
94 95
 
95 96
 }
@@ -237,16 +238,13 @@ function getCameraVideoSize(videoWidth,
237 238
 
238 239
 /**
239 240
  * Updates the src of the active speaker avatar
240
- * @param jid of the current active speaker
241 241
  */
242 242
 function updateActiveSpeakerAvatarSrc() {
243
-    var avatar = $("#activeSpeakerAvatar")[0];
244
-    var jid = currentSmallVideo.peerJid;
245
-    var url = Avatar.getActiveSpeakerUrl(jid);
246
-    if (avatar.src === url)
247
-        return;
248
-    if (jid) {
249
-        avatar.src = url;
243
+    let avatar = $("#activeSpeakerAvatar");
244
+    let id = currentSmallVideo.id;
245
+    let url = Avatar.getActiveSpeakerUrl(id);
246
+    if (id && avatar.attr('src') !== url) {
247
+        avatar.attr('src', url);
250 248
         currentSmallVideo.showAvatar();
251 249
     }
252 250
 }
@@ -263,13 +261,15 @@ function changeVideo(isVisible) {
263 261
     }
264 262
 
265 263
     updateActiveSpeakerAvatarSrc();
266
-    var largeVideoElement = $('#largeVideo')[0];
264
+    let largeVideoElement = $('#largeVideo');
267 265
 
268
-    APP.RTC.setVideoSrc(largeVideoElement, currentSmallVideo.getSrc());
266
+    currentSmallVideo.stream.attach(largeVideoElement);
269 267
 
270
-    var flipX = currentSmallVideo.flipX;
268
+    let flipX = currentSmallVideo.flipX;
271 269
 
272
-    largeVideoElement.style.transform = flipX ? "scaleX(-1)" : "none";
270
+    largeVideoElement.css({
271
+        transform: flipX ? "scaleX(-1)" : "none"
272
+    });
273 273
 
274 274
     LargeVideo.updateVideoSizeAndPosition(currentSmallVideo.getVideoType());
275 275
 
@@ -369,40 +369,35 @@ var LargeVideo = {
369 369
     /**
370 370
      * Returns <tt>true</tt> if the user is currently displayed on large video.
371 371
      */
372
-    isCurrentlyOnLarge: function (resourceJid) {
373
-        return currentSmallVideo && resourceJid &&
374
-            currentSmallVideo.getResourceJid() === resourceJid;
372
+    isCurrentlyOnLarge: function (id) {
373
+        return id && id === this.getId();
375 374
     },
376 375
     /**
377 376
      * Updates the large video with the given new video source.
378 377
      */
379
-    updateLargeVideo: function (resourceJid, forceUpdate) {
380
-        if(!isEnabled)
378
+    updateLargeVideo: function (id, forceUpdate) {
379
+        if(!isEnabled) {
381 380
             return;
382
-        var newSmallVideo = this.VideoLayout.getSmallVideo(resourceJid);
383
-        console.info('hover in ' + resourceJid + ', video: ', newSmallVideo);
381
+        }
382
+        let newSmallVideo = this.VideoLayout.getSmallVideo(id);
383
+        console.info(`hover in ${id} , video: `, newSmallVideo);
384 384
 
385 385
         if (!newSmallVideo) {
386
-            console.error("Small video not found for: " + resourceJid);
386
+            console.error("Small video not found for: " + id);
387 387
             return;
388 388
         }
389 389
 
390
-        if (!LargeVideo.isCurrentlyOnLarge(resourceJid) || forceUpdate) {
390
+        if (!LargeVideo.isCurrentlyOnLarge(id) || forceUpdate) {
391 391
             $('#activeSpeaker').css('visibility', 'hidden');
392 392
 
393
-            var oldSmallVideo = null;
394
-            if (currentSmallVideo) {
395
-                oldSmallVideo = currentSmallVideo;
396
-            }
393
+            let oldId = this.getId();
394
+
397 395
             currentSmallVideo = newSmallVideo;
398 396
 
399
-            var oldJid = null;
400
-            if (oldSmallVideo)
401
-                oldJid = oldSmallVideo.peerJid;
402
-            if (oldJid !== resourceJid) {
403
-                // we want the notification to trigger even if userJid is undefined,
397
+            if (oldId !== id) {
398
+                // we want the notification to trigger even if id is undefined,
404 399
                 // or null.
405
-                this.eventEmitter.emit(UIEvents.SELECTED_ENDPOINT, resourceJid);
400
+                this.eventEmitter.emit(UIEvents.SELECTED_ENDPOINT, id);
406 401
             }
407 402
             // We are doing fadeOut/fadeIn animations on parent div which wraps
408 403
             // largeVideo, because when Temasys plugin is in use it replaces
@@ -443,11 +438,10 @@ var LargeVideo = {
443 438
                 currentSmallVideo.enableDominantSpeaker(false);
444 439
         }
445 440
     },
446
-    onVideoTypeChanged: function (resourceJid, newVideoType) {
441
+    onVideoTypeChanged: function (id, newVideoType) {
447 442
         if (!isEnabled)
448 443
             return;
449
-        if (LargeVideo.isCurrentlyOnLarge(resourceJid))
450
-        {
444
+        if (LargeVideo.isCurrentlyOnLarge(id)) {
451 445
             LargeVideo.updateVideoSizeAndPosition(newVideoType);
452 446
 
453 447
             this.position(null, null, null, null, true);
@@ -562,22 +556,23 @@ var LargeVideo = {
562 556
         getVideoPosition = isDesktop ? getDesktopVideoPosition :
563 557
             getCameraVideoPosition;
564 558
     },
565
-    getResourceJid: function () {
566
-        return currentSmallVideo ? currentSmallVideo.getResourceJid() : null;
559
+    getId: function () {
560
+        return currentSmallVideo ? currentSmallVideo.id : null;
567 561
     },
568
-    updateAvatar: function (resourceJid) {
569
-        if(!isEnabled)
562
+    updateAvatar: function (id) {
563
+        if (!isEnabled) {
570 564
             return;
571
-        if (resourceJid === this.getResourceJid()) {
565
+        }
566
+        if (id === this.getId()) {
572 567
             updateActiveSpeakerAvatarSrc();
573 568
         }
574 569
     },
575
-    showAvatar: function (resourceJid, show) {
576
-        if (!isEnabled)
570
+    showAvatar: function (id, show) {
571
+        if (!isEnabled) {
577 572
             return;
578
-        if (this.getResourceJid() === resourceJid && state === "video") {
579
-            $("#largeVideoWrapper")
580
-                .css("visibility", show ? "hidden" : "visible");
573
+        }
574
+        if (this.getId() === id && state === "video") {
575
+            $("#largeVideoWrapper").css("visibility", show ? "hidden" : "visible");
581 576
             $('#activeSpeaker').css("visibility", show ? "visible" : "hidden");
582 577
             return true;
583 578
         }
@@ -721,4 +716,4 @@ var LargeVideo = {
721 716
     }
722 717
 };
723 718
 
724
-module.exports = LargeVideo;
719
+export default LargeVideo;

+ 21
- 33
modules/UI/videolayout/LocalVideo.js Parādīt failu

@@ -1,8 +1,9 @@
1 1
 /* global $, interfaceConfig, APP */
2
-var SmallVideo = require("./SmallVideo");
3
-var ConnectionIndicator = require("./ConnectionIndicator");
4
-var UIUtil = require("../util/UIUtil");
5
-var UIEvents = require("../../../service/UI/UIEvents");
2
+import ConnectionIndicator from "./ConnectionIndicator";
3
+import UIUtil from "../util/UIUtil";
4
+import UIEvents from "../../../service/UI/UIEvents";
5
+import SmallVideo from "./SmallVideo";
6
+
6 7
 var LargeVideo = require("./LargeVideo");
7 8
 var RTCBrowserType = require("../../RTC/RTCBrowserType");
8 9
 
@@ -13,7 +14,6 @@ function LocalVideo(VideoLayout, emitter) {
13 14
     this.VideoLayout = VideoLayout;
14 15
     this.flipX = true;
15 16
     this.isLocal = true;
16
-    this.peerJid = null;
17 17
     this.emitter = emitter;
18 18
 }
19 19
 
@@ -143,32 +143,25 @@ LocalVideo.prototype.createConnectionIndicator = function() {
143 143
     this.connectionIndicator = new ConnectionIndicator(this, null);
144 144
 };
145 145
 
146
-LocalVideo.prototype.changeVideo = function (stream, isMuted) {
147
-    var self = this;
146
+LocalVideo.prototype.changeVideo = function (stream) {
147
+    this.stream = stream;
148 148
 
149
-    function localVideoClick(event) {
149
+    let localVideoClick = (event) => {
150 150
         // FIXME: with Temasys plugin event arg is not an event, but
151 151
         // the clicked object itself, so we have to skip this call
152 152
         if (event.stopPropagation) {
153 153
             event.stopPropagation();
154 154
         }
155
-        self.VideoLayout.handleVideoThumbClicked(
156
-            true,
157
-            APP.xmpp.myResource());
158
-    }
155
+        this.VideoLayout.handleVideoThumbClicked(true, this.id);
156
+    };
159 157
 
160
-    var localVideoContainerSelector = $('#localVideoContainer');
158
+    let localVideoContainerSelector = $('#localVideoContainer');
161 159
     localVideoContainerSelector.off('click');
162 160
     localVideoContainerSelector.on('click', localVideoClick);
163 161
 
164
-    if(isMuted) {
165
-        APP.UI.setVideoMute(true);
166
-        return;
167
-    }
168 162
     this.flipX = stream.videoType != "screen";
169
-    var localVideo = document.createElement('video');
170
-    localVideo.id = 'localVideo_' +
171
-        APP.RTC.getStreamID(stream.getOriginalStream());
163
+    let localVideo = document.createElement('video');
164
+    localVideo.id = 'localVideo_' + stream.getId();
172 165
     if (!RTCBrowserType.isIExplorer()) {
173 166
         localVideo.autoplay = true;
174 167
         localVideo.volume = 0; // is it required if audio is separated ?
@@ -192,7 +185,10 @@ LocalVideo.prototype.changeVideo = function (stream, isMuted) {
192 185
     }
193 186
 
194 187
     // Attach WebRTC stream
195
-    APP.RTC.attachMediaStream(localVideoSelector, stream.getOriginalStream());
188
+    stream.attach(localVideoSelector);
189
+
190
+    // FIXME handle
191
+    return;
196 192
 
197 193
     // Add stream ended handler
198 194
     APP.RTC.addMediaStreamInactiveHandler(
@@ -201,20 +197,12 @@ LocalVideo.prototype.changeVideo = function (stream, isMuted) {
201 197
         // because <video> element is replaced with <object>
202 198
         localVideo = $('#' + localVideo.id)[0];
203 199
         localVideoContainer.removeChild(localVideo);
204
-        self.VideoLayout.updateRemovedVideo(APP.xmpp.myResource());
200
+        self.VideoLayout.updateRemovedVideo(self.id);
205 201
     });
206 202
 };
207 203
 
208
-LocalVideo.prototype.joined = function (jid) {
209
-    this.peerJid = jid;
210
-};
211
-
212
-LocalVideo.prototype.getResourceJid = function () {
213
-    var myResource = APP.xmpp.myResource();
214
-    if (!myResource) {
215
-        console.error("Requested local resource before we're in the MUC");
216
-    }
217
-    return myResource;
204
+LocalVideo.prototype.joined = function (id) {
205
+    this.id = id;
218 206
 };
219 207
 
220
-module.exports = LocalVideo;
208
+export default LocalVideo;

+ 51
- 62
modules/UI/videolayout/RemoteVideo.js Parādīt failu

@@ -1,24 +1,25 @@
1
-/* global $, APP, require, Strophe, interfaceConfig */
2
-var ConnectionIndicator = require("./ConnectionIndicator");
3
-var SmallVideo = require("./SmallVideo");
4
-var AudioLevels = require("../audio_levels/AudioLevels");
5
-var MediaStreamType = require("../../../service/RTC/MediaStreamTypes");
1
+/* global $, APP, interfaceConfig */
2
+
3
+import ConnectionIndicator from './ConnectionIndicator';
4
+
5
+import SmallVideo from "./SmallVideo";
6
+import AudioLevels from "../audio_levels/AudioLevels";
7
+import UIUtils from "../util/UIUtil";
8
+import UIEvents from '../../../service/UI/UIEvents';
9
+
6 10
 var RTCBrowserType = require("../../RTC/RTCBrowserType");
7
-var UIUtils = require("../util/UIUtil");
8
-var XMPPEvents = require("../../../service/xmpp/XMPPEvents");
9 11
 
10
-function RemoteVideo(peerJid, VideoLayout) {
11
-    this.peerJid = peerJid;
12
-    this.resourceJid = Strophe.getResourceFromJid(peerJid);
13
-    this.videoSpanId = 'participant_' + this.resourceJid;
12
+function RemoteVideo(id, VideoLayout, emitter) {
13
+    this.id = id;
14
+    this.emitter = emitter;
15
+    this.videoSpanId = `participant_${id}`;
14 16
     this.VideoLayout = VideoLayout;
15 17
     this.addRemoteVideoContainer();
16
-    this.connectionIndicator = new ConnectionIndicator(
17
-        this, this.peerJid);
18
+    this.connectionIndicator = new ConnectionIndicator(this, id);
18 19
     this.setDisplayName();
19 20
     var nickfield = document.createElement('span');
20 21
     nickfield.className = "nick";
21
-    nickfield.appendChild(document.createTextNode(this.resourceJid));
22
+    nickfield.appendChild(document.createTextNode(id));
22 23
     this.container.appendChild(nickfield);
23 24
     this.bindHoverHandler();
24 25
     this.flipX = false;
@@ -30,18 +31,19 @@ RemoteVideo.prototype.constructor = RemoteVideo;
30 31
 
31 32
 RemoteVideo.prototype.addRemoteVideoContainer = function() {
32 33
     this.container = RemoteVideo.createContainer(this.videoSpanId);
33
-    if (APP.xmpp.isModerator())
34
+    if (APP.conference.isModerator) {
34 35
         this.addRemoteVideoMenu();
35
-    AudioLevels.updateAudioLevelCanvas(this.peerJid, this.VideoLayout);
36
+    }
37
+    AudioLevels.updateAudioLevelCanvas(this.id, this.VideoLayout);
36 38
 
37 39
     return this.container;
38 40
 };
39 41
 
40 42
 /**
41
- * Adds the remote video menu element for the given <tt>jid</tt> in the
43
+ * Adds the remote video menu element for the given <tt>id</tt> in the
42 44
  * given <tt>parentElement</tt>.
43 45
  *
44
- * @param jid the jid indicating the video for which we're adding a menu.
46
+ * @param id the id indicating the video for which we're adding a menu.
45 47
  * @param parentElement the parent element where this menu will be added
46 48
  */
47 49
 
@@ -60,7 +62,7 @@ if (!interfaceConfig.filmStripOnly) {
60 62
 
61 63
         var popupmenuElement = document.createElement('ul');
62 64
         popupmenuElement.className = 'popupmenu';
63
-        popupmenuElement.id = 'remote_popupmenu_' + this.getResourceJid();
65
+        popupmenuElement.id = `remote_popupmenu_${this.id}`;
64 66
         spanElement.appendChild(popupmenuElement);
65 67
 
66 68
         var muteMenuItem = document.createElement('li');
@@ -88,7 +90,7 @@ if (!interfaceConfig.filmStripOnly) {
88 90
                 event.preventDefault();
89 91
             }
90 92
             var isMute = !!self.isMuted;
91
-            APP.xmpp.setMute(self.peerJid, !isMute);
93
+            self.emitter.emit(UIEvents.AUDIO_MUTED, !isMute);
92 94
 
93 95
             popupmenuElement.setAttribute('style', 'display:none;');
94 96
 
@@ -117,7 +119,7 @@ if (!interfaceConfig.filmStripOnly) {
117 119
             "data-i18n='videothumbnail.kick'>&nbsp;</div>";
118 120
         ejectLinkItem.innerHTML = ejectIndicator + ' ' + ejectText;
119 121
         ejectLinkItem.onclick = function(){
120
-            APP.xmpp.eject(self.peerJid);
122
+            self.emitter.emit(UIEvents.USER_KICKED, self.id);
121 123
             popupmenuElement.setAttribute('style', 'display:none;');
122 124
         };
123 125
 
@@ -157,36 +159,36 @@ RemoteVideo.prototype.removeRemoteStreamElement =
157 159
     select.remove();
158 160
 
159 161
     console.info((isVideo ? "Video" : "Audio") +
160
-                 " removed " + this.getResourceJid(), select);
162
+                 " removed " + this.id, select);
161 163
 
162 164
     if (isVideo)
163
-        this.VideoLayout.updateRemovedVideo(this.getResourceJid());
165
+        this.VideoLayout.updateRemovedVideo(this.id);
164 166
 };
165 167
 
166 168
 /**
167 169
  * Removes RemoteVideo from the page.
168 170
  */
169 171
 RemoteVideo.prototype.remove = function () {
170
-    console.log("Remove thumbnail", this.peerJid);
172
+    console.log("Remove thumbnail", this.id);
171 173
     this.removeConnectionIndicator();
172 174
     // Make sure that the large video is updated if are removing its
173 175
     // corresponding small video.
174
-    this.VideoLayout.updateRemovedVideo(this.getResourceJid());
176
+    this.VideoLayout.updateRemovedVideo(this.id);
175 177
     // Remove whole container
176
-    if (this.container.parentNode)
178
+    if (this.container.parentNode) {
177 179
         this.container.parentNode.removeChild(this.container);
180
+    }
178 181
 };
179 182
 
180 183
 RemoteVideo.prototype.waitForPlayback = function (sel, stream) {
181 184
 
182 185
     var webRtcStream = stream.getOriginalStream();
183
-    var isVideo = stream.isVideoStream();
186
+    var isVideo = stream.isVideoTrack();
184 187
     if (!isVideo || webRtcStream.id === 'mixedmslabel') {
185 188
         return;
186 189
     }
187 190
 
188 191
     var self = this;
189
-    var resourceJid = this.getResourceJid();
190 192
 
191 193
     // Register 'onplaying' listener to trigger 'videoactive' on VideoLayout
192 194
     // when video playback starts
@@ -198,7 +200,7 @@ RemoteVideo.prototype.waitForPlayback = function (sel, stream) {
198 200
         if (RTCBrowserType.isTemasysPluginUsed()) {
199 201
             sel = self.selectVideoElement();
200 202
         }
201
-        self.VideoLayout.videoactive(sel, resourceJid);
203
+        self.VideoLayout.videoactive(sel, self.id);
202 204
         sel[0].onplaying = null;
203 205
         if (RTCBrowserType.isTemasysPluginUsed()) {
204 206
             // 'currentTime' is used to check if the video has started
@@ -210,39 +212,33 @@ RemoteVideo.prototype.waitForPlayback = function (sel, stream) {
210 212
 };
211 213
 
212 214
 RemoteVideo.prototype.addRemoteStreamElement = function (stream) {
213
-    if (!this.container)
215
+    if (!this.container) {
214 216
         return;
217
+    }
215 218
 
216
-    var self = this;
217
-    var webRtcStream = stream.getOriginalStream();
218
-    var isVideo = stream.isVideoStream();
219
-    var streamElement = SmallVideo.createStreamElement(stream);
220
-    var newElementId = streamElement.id;
219
+    this.stream = stream;
220
+
221
+    let isVideo = stream.isVideoTrack();
222
+    let streamElement = SmallVideo.createStreamElement(stream);
223
+    let newElementId = streamElement.id;
221 224
 
222 225
     // Put new stream element always in front
223 226
     UIUtils.prependChild(this.container, streamElement);
224 227
 
225
-    var sel = $('#' + newElementId);
228
+    let sel = $(`#${newElementId}`);
226 229
     sel.hide();
227 230
 
228 231
     // If the container is currently visible we attach the stream.
229 232
     if (!isVideo || (this.container.offsetParent !== null && isVideo)) {
230 233
         this.waitForPlayback(sel, stream);
231 234
 
232
-        APP.RTC.attachMediaStream(sel, webRtcStream);
235
+        stream.attach(sel);
233 236
     }
234 237
 
235
-    APP.RTC.addMediaStreamInactiveHandler(
236
-        webRtcStream, function () {
237
-            console.log('stream ended', this);
238
-
239
-            self.removeRemoteStreamElement(webRtcStream, isVideo, newElementId);
240
-    });
241
-
242 238
     // Add click handler.
243
-    var onClickHandler = function (event) {
239
+    let onClickHandler = (event) => {
244 240
 
245
-        self.VideoLayout.handleVideoThumbClicked(false, self.getResourceJid());
241
+        this.VideoLayout.handleVideoThumbClicked(false, this.id);
246 242
 
247 243
         // On IE we need to populate this handler on video <object>
248 244
         // and it does not give event instance as an argument,
@@ -255,13 +251,14 @@ RemoteVideo.prototype.addRemoteStreamElement = function (stream) {
255 251
     };
256 252
     this.container.onclick = onClickHandler;
257 253
     // reselect
258
-    if (RTCBrowserType.isTemasysPluginUsed())
259
-        sel = $('#' + newElementId);
260
-    sel[0].onclick = onClickHandler;
254
+    if (RTCBrowserType.isTemasysPluginUsed()) {
255
+        sel = $(`#${newElementId}`);
256
+    }
257
+    sel.click(onClickHandler);
261 258
 },
262 259
 
263 260
 /**
264
- * Show/hide peer container for the given resourceJid.
261
+ * Show/hide peer container for the given id.
265 262
  */
266 263
 RemoteVideo.prototype.showPeerContainer = function (state) {
267 264
     if (!this.container)
@@ -294,7 +291,7 @@ RemoteVideo.prototype.showPeerContainer = function (state) {
294 291
 
295 292
     // We want to be able to pin a participant from the contact list, even
296 293
     // if he's not in the lastN set!
297
-    // ContactList.setClickable(resourceJid, !isHide);
294
+    // ContactList.setClickable(id, !isHide);
298 295
 
299 296
 };
300 297
 
@@ -311,12 +308,11 @@ RemoteVideo.prototype.hideConnectionIndicator = function () {
311 308
 /**
312 309
  * Updates the remote video menu.
313 310
  *
314
- * @param jid the jid indicating the video for which we're adding a menu.
311
+ * @param id the id indicating the video for which we're adding a menu.
315 312
  * @param isMuted indicates the current mute state
316 313
  */
317 314
 RemoteVideo.prototype.updateRemoteVideoMenu = function (isMuted) {
318
-    var muteMenuItem
319
-        = $('#remote_popupmenu_' + this.getResourceJid() + '>li>a.mutelink');
315
+    var muteMenuItem = $(`#remote_popupmenu_${this.id}>li>a.mutelink`);
320 316
 
321 317
     var mutedIndicator = "<i class='icon-mic-disabled'></i>";
322 318
 
@@ -423,13 +419,6 @@ RemoteVideo.prototype.removeRemoteVideoMenu = function() {
423 419
     }
424 420
 };
425 421
 
426
-RemoteVideo.prototype.getResourceJid = function () {
427
-    if (!this.resourceJid) {
428
-        console.error("Undefined resource jid");
429
-    }
430
-    return this.resourceJid;
431
-};
432
-
433 422
 RemoteVideo.createContainer = function (spanId) {
434 423
     var container = document.createElement('span');
435 424
     container.id = spanId;
@@ -439,4 +428,4 @@ RemoteVideo.createContainer = function (spanId) {
439 428
 };
440 429
 
441 430
 
442
-module.exports = RemoteVideo;
431
+export default RemoteVideo;

+ 25
- 24
modules/UI/videolayout/SmallVideo.js Parādīt failu

@@ -1,14 +1,16 @@
1 1
 /* global $, APP, require */
2 2
 /* jshint -W101 */
3
-var Avatar = require("../avatar/Avatar");
4
-var UIUtil = require("../util/UIUtil");
5
-var LargeVideo = require("./LargeVideo");
3
+import Avatar from "../avatar/Avatar";
4
+import UIUtil from "../util/UIUtil";
5
+import LargeVideo from "./LargeVideo";
6
+
6 7
 var RTCBrowserType = require("../../RTC/RTCBrowserType");
7 8
 var MediaStreamType = require("../../../service/RTC/MediaStreamTypes");
8 9
 
9 10
 function SmallVideo() {
10 11
     this.isMuted = false;
11 12
     this.hasAvatar = false;
13
+    this.stream = null;
12 14
 }
13 15
 
14 16
 function setVisibility(selector, show) {
@@ -106,9 +108,10 @@ SmallVideo.prototype.setPresenceStatus = function (statusMsg) {
106 108
  * Creates an audio or video element for a particular MediaStream.
107 109
  */
108 110
 SmallVideo.createStreamElement = function (stream) {
109
-    var isVideo = stream.isVideoStream();
111
+    let isVideo = stream.isVideoTrack();
110 112
 
111
-    var element = isVideo ? document.createElement('video')
113
+    let element = isVideo
114
+        ? document.createElement('video')
112 115
         : document.createElement('audio');
113 116
     if (isVideo) {
114 117
         element.setAttribute("muted", "true");
@@ -118,8 +121,7 @@ SmallVideo.createStreamElement = function (stream) {
118 121
         element.autoplay = true;
119 122
     }
120 123
 
121
-    element.id = (isVideo ? 'remoteVideo_' : 'remoteAudio_') +
122
-        APP.RTC.getStreamID(stream.getOriginalStream());
124
+    element.id = (isVideo ? 'remoteVideo_' : 'remoteAudio_') + stream.getId();
123 125
 
124 126
     element.onplay = function () {
125 127
         console.log("(TIME) Render " + (isVideo ? 'video' : 'audio') + ":\t",
@@ -145,7 +147,7 @@ SmallVideo.prototype.bindHoverHandler = function () {
145 147
             // If the video has been "pinned" by the user we want to
146 148
             // keep the display name on place.
147 149
             if (!LargeVideo.isLargeVideoVisible() ||
148
-                !LargeVideo.isCurrentlyOnLarge(self.getResourceJid()))
150
+                !LargeVideo.isCurrentlyOnLarge(self.id))
149 151
                 self.showDisplayName(false);
150 152
         }
151 153
     );
@@ -237,15 +239,14 @@ SmallVideo.prototype.showVideoIndicator = function(isMuted) {
237 239
 };
238 240
 
239 241
 SmallVideo.prototype.enableDominantSpeaker = function (isEnable) {
240
-    var resourceJid = this.getResourceJid();
241
-    var displayName = resourceJid;
242
+    var displayName = this.id;
242 243
     var nameSpan = $('#' + this.videoSpanId + '>span.displayname');
243 244
     if (nameSpan.length > 0)
244 245
         displayName = nameSpan.html();
245 246
 
246 247
     console.log("UI enable dominant speaker",
247 248
         displayName,
248
-        resourceJid,
249
+        this.id,
249 250
         isEnable);
250 251
 
251 252
 
@@ -316,6 +317,8 @@ SmallVideo.prototype.createModeratorIndicatorElement = function () {
316 317
 };
317 318
 
318 319
 SmallVideo.prototype.selectVideoElement = function () {
320
+    return $('#' + this.videoSpanId).find(videoElem);
321
+    // FIXME maybe move this to the library?
319 322
     var videoElem = APP.RTC.getVideoElementName();
320 323
     if (!RTCBrowserType.isTemasysPluginUsed()) {
321 324
         return $('#' + this.videoSpanId).find(videoElem);
@@ -367,32 +370,31 @@ SmallVideo.prototype.hasVideo = function () {
367 370
  */
368 371
 SmallVideo.prototype.showAvatar = function (show) {
369 372
     if (!this.hasAvatar) {
370
-        if (this.peerJid) {
373
+        if (this.id) {
371 374
             // Init avatar
372
-            this.avatarChanged(Avatar.getThumbUrl(this.peerJid));
375
+            this.avatarChanged(Avatar.getThumbUrl(this.id));
373 376
         } else {
374
-            console.error("Unable to init avatar - no peerjid", this);
377
+            console.error("Unable to init avatar - no id", this);
375 378
             return;
376 379
         }
377 380
     }
378 381
 
379
-    var resourceJid = this.getResourceJid();
380
-    var video = this.selectVideoElement();
382
+    let video = this.selectVideoElement();
381 383
 
382
-    var avatar = $('#avatar_' + resourceJid);
384
+    let avatar = $(`#avatar_${this.id}`);
383 385
 
384 386
     if (show === undefined || show === null) {
385 387
         if (!this.isLocal &&
386
-            !this.VideoLayout.isInLastN(resourceJid)) {
388
+            !this.VideoLayout.isInLastN(this.id)) {
387 389
             show = true;
388 390
         } else {
389 391
             // We want to show the avatar when the video is muted or not exists
390 392
             // that is when 'true' or 'null' is returned
391
-            show = APP.RTC.isVideoMuted(this.peerJid) !== false;
393
+            show = !this.stream || this.stream.isMuted();
392 394
         }
393 395
     }
394 396
 
395
-    if (LargeVideo.showAvatar(resourceJid, show)) {
397
+    if (LargeVideo.showAvatar(this.id, show)) {
396 398
         setVisibility(avatar, false);
397 399
         setVisibility(video, false);
398 400
     } else {
@@ -405,8 +407,7 @@ SmallVideo.prototype.showAvatar = function (show) {
405 407
 
406 408
 SmallVideo.prototype.avatarChanged = function (thumbUrl) {
407 409
     var thumbnail = $('#' + this.videoSpanId);
408
-    var resourceJid = this.getResourceJid();
409
-    var avatar = $('#avatar_' + resourceJid);
410
+    var avatar = $('#avatar_' + this.id);
410 411
     this.hasAvatar = true;
411 412
 
412 413
     // set the avatar in the thumbnail
@@ -415,7 +416,7 @@ SmallVideo.prototype.avatarChanged = function (thumbUrl) {
415 416
     } else {
416 417
         if (thumbnail && thumbnail.length > 0) {
417 418
             avatar = document.createElement('img');
418
-            avatar.id = 'avatar_' + resourceJid;
419
+            avatar.id = 'avatar_' + this.id;
419 420
             avatar.className = 'userAvatar';
420 421
             avatar.src = thumbUrl;
421 422
             thumbnail.append(avatar);
@@ -423,4 +424,4 @@ SmallVideo.prototype.avatarChanged = function (thumbUrl) {
423 424
     }
424 425
 };
425 426
 
426
-module.exports = SmallVideo;
427
+export default SmallVideo;

+ 246
- 270
modules/UI/videolayout/VideoLayout.js Parādīt failu

@@ -1,18 +1,18 @@
1
-/* global config, APP, $, Strophe, require, interfaceConfig */
1
+/* global config, APP, $, interfaceConfig */
2 2
 /* jshint -W101 */
3
-var AudioLevels = require("../audio_levels/AudioLevels");
4
-var ContactList = require("../side_pannels/contactlist/ContactList");
5
-var MediaStreamType = require("../../../service/RTC/MediaStreamTypes");
6
-var UIEvents = require("../../../service/UI/UIEvents");
7
-var UIUtil = require("../util/UIUtil");
8 3
 
9
-var RTC = require("../../RTC/RTC");
10
-var RTCBrowserType = require('../../RTC/RTCBrowserType');
4
+import AudioLevels from "../audio_levels/AudioLevels";
5
+import ContactList from "../side_pannels/contactlist/ContactList";
11 6
 
12
-var RemoteVideo = require("./RemoteVideo");
13
-var LargeVideo = require("./LargeVideo");
14
-var LocalVideo = require("./LocalVideo");
7
+import UIEvents from "../../../service/UI/UIEvents";
8
+import UIUtil from "../util/UIUtil";
15 9
 
10
+import RemoteVideo from "./RemoteVideo";
11
+import LargeVideo from "./LargeVideo";
12
+import LocalVideo from "./LocalVideo";
13
+
14
+var MediaStreamType = require("../../../service/RTC/MediaStreamTypes");
15
+var RTCBrowserType = require('../../RTC/RTCBrowserType');
16 16
 
17 17
 var remoteVideos = {};
18 18
 var remoteVideoTypes = {};
@@ -23,7 +23,7 @@ var lastNCount = config.channelLastN;
23 23
 var localLastNCount = config.channelLastN;
24 24
 var localLastNSet = [];
25 25
 var lastNEndpointsCache = [];
26
-var lastNPickupJid = null;
26
+var lastNPickupId = null;
27 27
 
28 28
 var eventEmitter = null;
29 29
 
@@ -33,8 +33,50 @@ var eventEmitter = null;
33 33
  */
34 34
 var focusedVideoResourceJid = null;
35 35
 
36
-var VideoLayout = (function (my) {
37
-    my.init = function (emitter) {
36
+/**
37
+ * On contact list item clicked.
38
+ */
39
+$(ContactList).bind('contactclicked', function(event, id) {
40
+    if (!id) {
41
+        return;
42
+    }
43
+
44
+    if (APP.conference.isLocalId(id)) {
45
+        $("#localVideoContainer").click();
46
+        return;
47
+    }
48
+
49
+    var remoteVideo = remoteVideos[id];
50
+    if (remoteVideo && remoteVideo.selectVideoElement().length) {
51
+        var videoThumb = remoteVideo.selectVideoElement()[0];
52
+        // It is not always the case that a videoThumb exists (if there is
53
+        // no actual video).
54
+        if (RTC.getVideoSrc(videoThumb)) {
55
+
56
+            // We have a video src, great! Let's update the large video
57
+            // now.
58
+            VideoLayout.handleVideoThumbClicked(false, id);
59
+        } else {
60
+
61
+            // If we don't have a video src for jid, there's absolutely
62
+            // no point in calling handleVideoThumbClicked; Quite
63
+            // simply, it won't work because it needs an src to attach
64
+            // to the large video.
65
+            //
66
+            // Instead, we trigger the pinned endpoint changed event to
67
+            // let the bridge adjust its lastN set for myjid and store
68
+            // the pinned user in the lastNPickupId variable to be
69
+            // picked up later by the lastN changed event handler.
70
+
71
+            lastNPickupId = id;
72
+            eventEmitter.emit(UIEvents.PINNED_ENDPOINT, id);
73
+        }
74
+    }
75
+});
76
+
77
+
78
+var VideoLayout = {
79
+    init (emitter) {
38 80
         eventEmitter = emitter;
39 81
         localVideoThumbnail = new LocalVideo(VideoLayout, emitter);
40 82
         if (interfaceConfig.filmStripOnly) {
@@ -45,19 +87,21 @@ var VideoLayout = (function (my) {
45 87
 
46 88
         VideoLayout.resizeLargeVideoContainer();
47 89
 
48
-    };
90
+    },
49 91
 
50
-    my.isInLastN = function(resource) {
92
+    isInLastN (resource) {
51 93
         return lastNCount < 0 || // lastN is disabled
52 94
              // lastNEndpoints cache not built yet
53 95
             (lastNCount > 0 && !lastNEndpointsCache.length) ||
54 96
             (lastNEndpointsCache &&
55 97
                 lastNEndpointsCache.indexOf(resource) !== -1);
56
-    };
98
+    },
57 99
 
58
-    my.changeLocalAudio = function(stream, isMuted) {
59
-        APP.RTC.attachMediaStream($('#localAudio'), stream.getOriginalStream());
60
-        var localAudio = document.getElementById('localAudio');
100
+    changeLocalAudio (stream) {
101
+        let localAudio = document.getElementById('localAudio');
102
+        stream.attach($(localAudio));
103
+
104
+        return; // FIXME maybe move this into the library?
61 105
         // Writing volume not allowed in IE
62 106
         if (!RTCBrowserType.isIExplorer()) {
63 107
             localAudio.autoplay = true;
@@ -73,39 +117,41 @@ var VideoLayout = (function (my) {
73 117
             // which will result in audio mute issues
74 118
             $('#localAudio').hide();
75 119
         }
76
-    };
120
+    },
77 121
 
78
-    my.changeLocalVideo = function(stream, isMuted) {
122
+    changeLocalVideo (stream) {
79 123
         // Set default display name.
80 124
         localVideoThumbnail.setDisplayName();
81 125
         localVideoThumbnail.createConnectionIndicator();
82 126
 
83
-        this.onVideoTypeChanged(APP.xmpp.myResource(), stream.videoType);
127
+        let localId = APP.conference.localId;
128
+        this.onVideoTypeChanged(localId, stream.getType());
84 129
 
85 130
         AudioLevels.updateAudioLevelCanvas(null, VideoLayout);
86 131
 
87
-        localVideoThumbnail.changeVideo(stream, isMuted);
132
+        localVideoThumbnail.changeVideo(stream);
88 133
 
89 134
         /* force update if we're currently being displayed */
90
-        if (LargeVideo.isCurrentlyOnLarge(APP.xmpp.myResource())) {
91
-            LargeVideo.updateLargeVideo(APP.xmpp.myResource(), true);
135
+        if (LargeVideo.isCurrentlyOnLarge(localId)) {
136
+            LargeVideo.updateLargeVideo(localId, true);
92 137
         }
93
-    };
138
+    },
94 139
 
95
-    my.mucJoined = function () {
96
-        var myResourceJid = APP.xmpp.myResource();
97
-        localVideoThumbnail.joined(APP.xmpp.myJid());
140
+    mucJoined () {
141
+        let id = APP.conference.localId;
142
+        localVideoThumbnail.joined(id);
98 143
 
99
-        if (!LargeVideo.getResourceJid())
100
-            LargeVideo.updateLargeVideo(myResourceJid, true);
101
-    };
144
+        if (!LargeVideo.id) {
145
+            LargeVideo.updateLargeVideo(id, true);
146
+        }
147
+    },
102 148
 
103 149
     /**
104 150
      * Adds or removes icons for not available camera and microphone.
105 151
      * @param resourceJid the jid of user
106 152
      * @param devices available devices
107 153
      */
108
-    my.setDeviceAvailabilityIcons = function (resourceJid, devices) {
154
+    setDeviceAvailabilityIcons (resourceJid, devices) {
109 155
         if(!devices)
110 156
             return;
111 157
 
@@ -115,31 +161,31 @@ var VideoLayout = (function (my) {
115 161
             if(remoteVideos[resourceJid])
116 162
                 remoteVideos[resourceJid].setDeviceAvailabilityIcons(devices);
117 163
         }
118
-    };
164
+    },
119 165
 
120 166
     /**
121 167
      * Checks if removed video is currently displayed and tries to display
122 168
      * another one instead.
123 169
      */
124
-    my.updateRemovedVideo = function(resourceJid) {
125
-        var newResourceJid;
170
+    updateRemovedVideo (id) {
171
+        let newId;
126 172
 
127
-        if (resourceJid === LargeVideo.getResourceJid()) {
173
+        if (id === LargeVideo.getId()) {
128 174
             // We'll show user's avatar if he is the dominant speaker or if
129 175
             // his video thumbnail is pinned
130
-            if (remoteVideos[resourceJid] &&
131
-                resourceJid === focusedVideoResourceJid ||
132
-                resourceJid === currentDominantSpeaker) {
133
-                newResourceJid = resourceJid;
176
+            if (remoteVideos[id] &&
177
+                id === focusedVideoResourceJid ||
178
+                id === currentDominantSpeaker) {
179
+                newId = id;
134 180
             } else {
135 181
                 // Otherwise select last visible video
136
-                newResourceJid = this.electLastVisibleVideo();
182
+                newId = this.electLastVisibleVideo();
137 183
             }
138
-            LargeVideo.updateLargeVideo(newResourceJid);
184
+            LargeVideo.updateLargeVideo(id);
139 185
         }
140
-    };
186
+    },
141 187
 
142
-    my.electLastVisibleVideo = function () {
188
+    electLastVisibleVideo () {
143 189
         // pick the last visible video in the row
144 190
         // if nobody else is left, this picks the local video
145 191
         var jid;
@@ -174,39 +220,36 @@ var VideoLayout = (function (my) {
174 220
 
175 221
         console.info("electLastVisibleVideo: " + jid);
176 222
         return jid;
177
-    };
223
+    },
178 224
 
179
-    my.onRemoteStreamAdded = function (stream) {
180
-        if (stream.peerjid) {
181
-            VideoLayout.ensurePeerContainerExists(stream.peerjid);
225
+    onRemoteStreamAdded (stream) {
226
+        let id = stream.getParticipantId();
227
+        VideoLayout.ensurePeerContainerExists(id);
182 228
 
183
-            var resourceJid = Strophe.getResourceFromJid(stream.peerjid);
184
-            remoteVideos[resourceJid].addRemoteStreamElement(stream);
185
-        }
186
-    };
229
+        remoteVideos[id].addRemoteStreamElement(stream);
230
+    },
187 231
 
188
-    my.getLargeVideoResource = function () {
189
-        return LargeVideo.getResourceJid();
190
-    };
232
+    getLargeVideoId () {
233
+        return LargeVideo.getId();
234
+    },
191 235
 
192 236
     /**
193 237
      * Return the type of the remote video.
194
-     * @param jid the jid for the remote video
238
+     * @param id the id for the remote video
195 239
      * @returns the video type video or screen.
196 240
      */
197
-    my.getRemoteVideoType = function (jid) {
198
-        return remoteVideoTypes[jid];
199
-    };
241
+    getRemoteVideoType (id) {
242
+        return remoteVideoTypes[id];
243
+    },
200 244
 
201 245
     /**
202 246
      * Called when large video update is finished
203 247
      * @param currentSmallVideo small video currently displayed on large video
204 248
      */
205
-    my.largeVideoUpdated = function (currentSmallVideo) {
249
+    largeVideoUpdated (currentSmallVideo) {
206 250
         // Makes sure that dominant speaker UI
207 251
         // is enabled only on current small video
208
-        localVideoThumbnail.enableDominantSpeaker(
209
-            localVideoThumbnail === currentSmallVideo);
252
+        localVideoThumbnail.enableDominantSpeaker(localVideoThumbnail === currentSmallVideo);
210 253
         Object.keys(remoteVideos).forEach(
211 254
             function (resourceJid) {
212 255
                 var remoteVideo = remoteVideos[resourceJid];
@@ -216,9 +259,9 @@ var VideoLayout = (function (my) {
216 259
                 }
217 260
             }
218 261
         );
219
-    };
262
+    },
220 263
 
221
-    my.handleVideoThumbClicked = function(noPinnedEndpointChangedEvent,
264
+    handleVideoThumbClicked (noPinnedEndpointChangedEvent,
222 265
                                           resourceJid) {
223 266
         if(focusedVideoResourceJid) {
224 267
             var oldSmallVideo
@@ -269,50 +312,46 @@ var VideoLayout = (function (my) {
269 312
                 el.volume = 1;
270 313
             });
271 314
         }
272
-    };
315
+    },
273 316
 
274 317
 
275 318
     /**
276
-     * Checks if container for participant identified by given peerJid exists
319
+     * Checks if container for participant identified by given id exists
277 320
      * in the document and creates it eventually.
278 321
      *
279
-     * @param peerJid peer Jid to check.
280
-     *
281 322
      * @return Returns <tt>true</tt> if the peer container exists,
282 323
      * <tt>false</tt> - otherwise
283 324
      */
284
-    my.ensurePeerContainerExists = function(peerJid) {
285
-        ContactList.ensureAddContact(peerJid);
286
-
287
-        var resourceJid = Strophe.getResourceFromJid(peerJid);
325
+    ensurePeerContainerExists (id) {
326
+        ContactList.ensureAddContact(id);
288 327
 
289
-        if (!remoteVideos[resourceJid]) {
328
+        if (remoteVideos[id]) {
329
+            return;
330
+        }
290 331
 
291
-            var remoteVideo = new RemoteVideo(peerJid, VideoLayout);
292
-            remoteVideos[resourceJid] = remoteVideo;
332
+        let remoteVideo = new RemoteVideo(id, VideoLayout, eventEmitter);
333
+        remoteVideos[id] = remoteVideo;
293 334
 
294
-            var videoType = remoteVideoTypes[resourceJid];
295
-            if (videoType) {
296
-                remoteVideo.setVideoType(videoType);
297
-            }
335
+        let videoType = remoteVideoTypes[id];
336
+        if (videoType) {
337
+            remoteVideo.setVideoType(videoType);
338
+        }
298 339
 
299
-            // In case this is not currently in the last n we don't show it.
300
-            if (localLastNCount &&
301
-                localLastNCount > 0 &&
302
-                $('#remoteVideos>span').length >= localLastNCount + 2) {
303
-                remoteVideo.showPeerContainer('hide');
304
-            }
305
-            else
306
-                VideoLayout.resizeThumbnails();
340
+        // In case this is not currently in the last n we don't show it.
341
+        if (localLastNCount && localLastNCount > 0 &&
342
+            $('#remoteVideos>span').length >= localLastNCount + 2) {
343
+            remoteVideo.showPeerContainer('hide');
344
+        } else {
345
+            VideoLayout.resizeThumbnails();
307 346
         }
308
-    };
347
+    },
309 348
 
310 349
 
311
-    my.inputDisplayNameHandler = function (name) {
350
+    inputDisplayNameHandler (name) {
312 351
         localVideoThumbnail.inputDisplayNameHandler(name);
313
-    };
352
+    },
314 353
 
315
-    my.videoactive = function (videoelem, resourceJid) {
354
+    videoactive (videoelem, resourceJid) {
316 355
 
317 356
         console.info(resourceJid + " video is now active");
318 357
 
@@ -330,61 +369,50 @@ var VideoLayout = (function (my) {
330 369
                 currentDominantSpeaker === resourceJid)) {
331 370
             LargeVideo.updateLargeVideo(resourceJid, true);
332 371
         }
333
-    };
372
+    },
334 373
 
335 374
     /**
336 375
      * Shows the presence status message for the given video.
337 376
      */
338
-    my.setPresenceStatus = function (resourceJid, statusMsg) {
377
+    setPresenceStatus (resourceJid, statusMsg) {
339 378
         remoteVideos[resourceJid].setPresenceStatus(statusMsg);
340
-    };
379
+    },
341 380
 
342 381
     /**
343 382
      * Shows a visual indicator for the moderator of the conference.
344 383
      */
345
-    my.showModeratorIndicator = function () {
346
-
347
-        var isModerator = APP.xmpp.isModerator();
384
+    showModeratorIndicator () {
385
+        let isModerator = APP.conference.isModerator;
348 386
         if (isModerator) {
349 387
             localVideoThumbnail.createModeratorIndicatorElement();
350 388
         }
351 389
 
352
-        var members = APP.xmpp.getMembers();
353
-
354
-        Object.keys(members).forEach(function (jid) {
355
-
356
-            var resourceJid = Strophe.getResourceFromJid(jid);
357
-            var member = members[jid];
358
-
359
-            if (member.isFocus) {
360
-                // Skip server side focus
361
-                return;
362
-            }
363
-
364
-            if (member.role === 'moderator') {
365
-                remoteVideos[resourceJid].removeRemoteVideoMenu();
366
-                remoteVideos[resourceJid].createModeratorIndicatorElement();
390
+        APP.conference.listMembers().forEach(function (member) {
391
+            let id = member.getId();
392
+            if (member.isModerator()) {
393
+                remoteVideos[id].removeRemoteVideoMenu();
394
+                remoteVideos[id].createModeratorIndicatorElement();
367 395
             } else if (isModerator) {
368 396
                 // We are moderator, but user is not - add menu
369
-                if ($('#remote_popupmenu_' + resourceJid).length <= 0) {
370
-                    remoteVideos[resourceJid].addRemoteVideoMenu();
397
+                if ($(`#remote_popupmenu_${id}`).length <= 0) {
398
+                    remoteVideos[id].addRemoteVideoMenu();
371 399
                 }
372 400
             }
373 401
         });
374
-    };
402
+    },
375 403
 
376 404
     /*
377 405
      * Shows or hides the audio muted indicator over the local thumbnail video.
378 406
      * @param {boolean} isMuted
379 407
      */
380
-    my.showLocalAudioIndicator = function(isMuted) {
408
+    showLocalAudioIndicator (isMuted) {
381 409
         localVideoThumbnail.showAudioIndicator(isMuted);
382
-    };
410
+    },
383 411
 
384 412
     /**
385 413
      * Resizes the large video container.
386 414
      */
387
-    my.resizeLargeVideoContainer = function () {
415
+    resizeLargeVideoContainer () {
388 416
         if(LargeVideo.isEnabled()) {
389 417
             LargeVideo.resize();
390 418
         } else {
@@ -392,12 +420,12 @@ var VideoLayout = (function (my) {
392 420
         }
393 421
         VideoLayout.resizeThumbnails();
394 422
         LargeVideo.position();
395
-    };
423
+    },
396 424
 
397 425
     /**
398 426
      * Resizes thumbnails.
399 427
      */
400
-    my.resizeThumbnails = function(animate) {
428
+    resizeThumbnails (animate) {
401 429
         var videoSpaceWidth = $('#remoteVideos').width();
402 430
 
403 431
         var thumbnailSize = VideoLayout.calculateThumbnailSize(videoSpaceWidth);
@@ -441,14 +469,14 @@ var VideoLayout = (function (my) {
441 469
 
442 470
             $(document).trigger("remotevideo.resized", [width, height]);
443 471
         }
444
-    };
472
+    },
445 473
 
446 474
     /**
447 475
      * Calculates the thumbnail size.
448 476
      *
449 477
      * @param videoSpaceWidth the width of the video space
450 478
      */
451
-    my.calculateThumbnailSize = function (videoSpaceWidth) {
479
+    calculateThumbnailSize (videoSpaceWidth) {
452 480
         // Calculate the available height, which is the inner window height
453 481
         // minus 39px for the header minus 2px for the delimiter lines on the
454 482
         // top and bottom of the large video, minus the 36px space inside the
@@ -478,7 +506,7 @@ var VideoLayout = (function (my) {
478 506
        }
479 507
 
480 508
        return [availableWidth, availableHeight];
481
-   };
509
+   },
482 510
 
483 511
     /**
484 512
      * Returns the corresponding resource jid to the given peer container
@@ -487,66 +515,21 @@ var VideoLayout = (function (my) {
487 515
      * @return the corresponding resource jid to the given peer container
488 516
      * DOM element
489 517
      */
490
-    my.getPeerContainerResourceJid = function (containerElement) {
518
+    getPeerContainerResourceJid (containerElement) {
491 519
         if (localVideoThumbnail.container === containerElement) {
492
-            return localVideoThumbnail.getResourceJid();
520
+            return localVideoThumbnail.getId();
493 521
         }
494 522
 
495 523
         var i = containerElement.id.indexOf('participant_');
496 524
 
497 525
         if (i >= 0)
498 526
             return containerElement.id.substring(i + 12);
499
-    };
500
-
501
-    /**
502
-     * On contact list item clicked.
503
-     */
504
-    $(ContactList).bind('contactclicked', function(event, jid) {
505
-        if (!jid) {
506
-            return;
507
-        }
508
-
509
-        if (jid === APP.xmpp.myJid()) {
510
-            $("#localVideoContainer").click();
511
-            return;
512
-        }
513
-
514
-        var resource = Strophe.getResourceFromJid(jid);
515
-        var remoteVideo = remoteVideos[resource];
516
-        if (remoteVideo && remoteVideo.selectVideoElement().length) {
517
-            var videoThumb = remoteVideo.selectVideoElement()[0];
518
-            // It is not always the case that a videoThumb exists (if there is
519
-            // no actual video).
520
-            if (RTC.getVideoSrc(videoThumb)) {
521
-
522
-                // We have a video src, great! Let's update the large video
523
-                // now.
524
-                VideoLayout.handleVideoThumbClicked(
525
-                    false,
526
-                    Strophe.getResourceFromJid(jid));
527
-            } else {
528
-
529
-                // If we don't have a video src for jid, there's absolutely
530
-                // no point in calling handleVideoThumbClicked; Quite
531
-                // simply, it won't work because it needs an src to attach
532
-                // to the large video.
533
-                //
534
-                // Instead, we trigger the pinned endpoint changed event to
535
-                // let the bridge adjust its lastN set for myjid and store
536
-                // the pinned user in the lastNPickupJid variable to be
537
-                // picked up later by the lastN changed event handler.
538
-
539
-                lastNPickupJid = jid;
540
-                eventEmitter.emit(UIEvents.PINNED_ENDPOINT,
541
-                    Strophe.getResourceFromJid(jid));
542
-            }
543
-        }
544
-    });
527
+    },
545 528
 
546 529
     /**
547 530
      * On audio muted event.
548 531
      */
549
-    my.onAudioMute = function (jid, isMuted) {
532
+    onAudioMute (jid, isMuted) {
550 533
         var resourceJid = Strophe.getResourceFromJid(jid);
551 534
         if (resourceJid === APP.xmpp.myResource()) {
552 535
             localVideoThumbnail.showAudioIndicator(isMuted);
@@ -557,12 +540,12 @@ var VideoLayout = (function (my) {
557 540
                 remoteVideos[resourceJid].updateRemoteVideoMenu(isMuted);
558 541
             }
559 542
         }
560
-    };
543
+    },
561 544
 
562 545
     /**
563 546
      * On video muted event.
564 547
      */
565
-    my.onVideoMute = function (jid, value) {
548
+    onVideoMute (jid, value) {
566 549
         if (jid !== APP.xmpp.myJid() &&
567 550
             !APP.RTC.muteRemoteVideoStream(jid, value))
568 551
             return;
@@ -582,12 +565,12 @@ var VideoLayout = (function (my) {
582 565
             else
583 566
                 el.hide();
584 567
         }
585
-    };
568
+    },
586 569
 
587 570
     /**
588 571
      * Display name changed.
589 572
      */
590
-    my.onDisplayNameChanged = function (id, displayName, status) {
573
+    onDisplayNameChanged (id, displayName, status) {
591 574
         if (id === 'localVideoContainer' ||
592 575
             APP.conference.isLocalId(id)) {
593 576
             localVideoThumbnail.setDisplayName(displayName);
@@ -595,39 +578,39 @@ var VideoLayout = (function (my) {
595 578
             VideoLayout.ensurePeerContainerExists(id);
596 579
             remoteVideos[id].setDisplayName(displayName, status);
597 580
         }
598
-    };
581
+    },
599 582
 
600 583
     /**
601 584
      * On dominant speaker changed event.
602 585
      */
603
-    my.onDominantSpeakerChanged = function (resourceJid) {
586
+    onDominantSpeakerChanged (id) {
604 587
         // We ignore local user events.
605
-        if (resourceJid === APP.xmpp.myResource())
588
+        if (APP.conference.isLocalId(id)) {
606 589
             return;
590
+        }
607 591
 
608
-        var remoteVideo = remoteVideos[resourceJid];
609
-        var members = APP.xmpp.getMembers();
610
-        // Update the current dominant speaker.
611
-        if (resourceJid !== currentDominantSpeaker) {
612
-            if (remoteVideo) {
613
-                remoteVideo.updateDominantSpeakerIndicator(true);
614
-                // let's remove the indications from the remote video if any
615
-                var oldSpeakerRemoteVideo
616
-                    = remoteVideos[currentDominantSpeaker];
617
-                if (oldSpeakerRemoteVideo) {
618
-                    oldSpeakerRemoteVideo.updateDominantSpeakerIndicator(false);
619
-                }
620
-            }
621
-            currentDominantSpeaker = resourceJid;
622
-        } else {
592
+        if (id === currentDominantSpeaker) {
623 593
             return;
624 594
         }
625 595
 
626
-        if (!remoteVideo)
596
+        let remoteVideo = remoteVideos[id];
597
+
598
+        if (!remoteVideo) {
627 599
             return;
600
+        }
601
+
602
+        // Update the current dominant speaker.
603
+        remoteVideo.updateDominantSpeakerIndicator(true);
604
+
605
+        // let's remove the indications from the remote video if any
606
+        let oldSpeakerRemoteVideo = remoteVideos[currentDominantSpeaker];
607
+        if (oldSpeakerRemoteVideo) {
608
+            oldSpeakerRemoteVideo.updateDominantSpeakerIndicator(false);
609
+        }
610
+        currentDominantSpeaker = id;
628 611
 
629 612
         // Obtain container for new dominant speaker.
630
-        var videoSel  = remoteVideo.selectVideoElement();
613
+        let videoSel = remoteVideo.selectVideoElement();
631 614
 
632 615
         // Local video will not have container found, but that's ok
633 616
         // since we don't want to switch to local video.
@@ -635,10 +618,10 @@ var VideoLayout = (function (my) {
635 618
             // Update the large video if the video source is already available,
636 619
             // otherwise wait for the "videoactive.jingle" event.
637 620
             if (videoSel[0].currentTime > 0) {
638
-                LargeVideo.updateLargeVideo(resourceJid);
621
+                LargeVideo.updateLargeVideo(id);
639 622
             }
640 623
         }
641
-    };
624
+    },
642 625
 
643 626
     /**
644 627
      * On last N change event.
@@ -647,7 +630,7 @@ var VideoLayout = (function (my) {
647 630
      * @param endpointsEnteringLastN the list currently entering last N
648 631
      * endpoints
649 632
      */
650
-    my.onLastNEndpointsChanged = function (lastNEndpoints, endpointsEnteringLastN) {
633
+    onLastNEndpointsChanged (lastNEndpoints, endpointsEnteringLastN) {
651 634
         if (lastNCount !== lastNEndpoints.length)
652 635
             lastNCount = lastNEndpoints.length;
653 636
 
@@ -727,7 +710,7 @@ var VideoLayout = (function (my) {
727 710
                 // displayed in the large video we have to switch to another
728 711
                 // user.
729 712
                 if (!updateLargeVideo &&
730
-                    resourceJid === LargeVideo.getResourceJid()) {
713
+                    resourceJid === LargeVideo.getId()) {
731 714
                     updateLargeVideo = true;
732 715
                 }
733 716
             }
@@ -751,9 +734,9 @@ var VideoLayout = (function (my) {
751 734
                     var sel = remoteVideo.selectVideoElement();
752 735
 
753 736
                     APP.RTC.attachMediaStream(sel, mediaStream.stream);
754
-                    if (lastNPickupJid == mediaStream.peerjid) {
755
-                        // Clean up the lastN pickup jid.
756
-                        lastNPickupJid = null;
737
+                    if (lastNPickupId == mediaStream.peerjid) {
738
+                        // Clean up the lastN pickup id.
739
+                        lastNPickupId = null;
757 740
 
758 741
                         // Don't fire the events again, they've already
759 742
                         // been fired in the contact list click handler.
@@ -789,14 +772,14 @@ var VideoLayout = (function (my) {
789 772
                 break;
790 773
             }
791 774
         }
792
-    };
775
+    },
793 776
 
794 777
     /**
795 778
      * Updates local stats
796 779
      * @param percent
797 780
      * @param object
798 781
      */
799
-    my.updateLocalConnectionStats = function (percent, object) {
782
+    updateLocalConnectionStats (percent, object) {
800 783
         var resolution = null;
801 784
         if (object.resolution !== null) {
802 785
             resolution = object.resolution;
@@ -814,7 +797,7 @@ var VideoLayout = (function (my) {
814 797
                     updateResolution(resolution[jid]);
815 798
             }
816 799
         }
817
-    };
800
+    },
818 801
 
819 802
     /**
820 803
      * Updates remote stats.
@@ -822,92 +805,90 @@ var VideoLayout = (function (my) {
822 805
      * @param percent the connection quality percent
823 806
      * @param object the stats data
824 807
      */
825
-    my.updateConnectionStats = function (jid, percent, object) {
808
+    updateConnectionStats (jid, percent, object) {
826 809
         var resourceJid = Strophe.getResourceFromJid(jid);
827 810
 
828 811
         if (remoteVideos[resourceJid])
829 812
             remoteVideos[resourceJid].updateStatsIndicator(percent, object);
830
-    };
813
+    },
831 814
 
832 815
     /**
833 816
      * Hides the connection indicator
834 817
      * @param jid
835 818
      */
836
-    my.hideConnectionIndicator = function (jid) {
819
+    hideConnectionIndicator (jid) {
837 820
         remoteVideos[Strophe.getResourceFromJid(jid)].hideConnectionIndicator();
838
-    };
821
+    },
839 822
 
840 823
     /**
841 824
      * Hides all the indicators
842 825
      */
843
-    my.hideStats = function () {
826
+    hideStats () {
844 827
         for(var video in remoteVideos) {
845 828
             remoteVideos[video].hideIndicator();
846 829
         }
847 830
         localVideoThumbnail.hideIndicator();
848
-    };
831
+    },
849 832
 
850
-    my.participantLeft = function (jid) {
833
+    participantLeft (id) {
851 834
         // Unlock large video
852
-        var resourceJid = Strophe.getResourceFromJid(jid);
853
-        if (focusedVideoResourceJid === resourceJid) {
835
+        if (focusedVideoResourceJid === id) {
854 836
             console.info("Focused video owner has left the conference");
855 837
             focusedVideoResourceJid = null;
856 838
         }
857 839
 
858
-        if (currentDominantSpeaker === resourceJid) {
840
+        if (currentDominantSpeaker === id) {
859 841
             console.info("Dominant speaker has left the conference");
860 842
             currentDominantSpeaker = null;
861 843
         }
862 844
 
863
-        var remoteVideo = remoteVideos[resourceJid];
845
+        var remoteVideo = remoteVideos[id];
864 846
         if (remoteVideo) {
865 847
             // Remove remote video
866
-            console.info("Removing remote video: " + resourceJid);
867
-            delete remoteVideos[resourceJid];
848
+            console.info("Removing remote video: " + id);
849
+            delete remoteVideos[id];
868 850
             remoteVideo.remove();
869 851
         } else {
870
-            console.warn("No remote video for " + resourceJid);
852
+            console.warn("No remote video for " + id);
871 853
         }
872 854
 
873 855
         VideoLayout.resizeThumbnails();
874
-    };
856
+    },
875 857
 
876
-    my.onVideoTypeChanged = function (resourceJid, newVideoType) {
877
-        if (remoteVideoTypes[resourceJid] === newVideoType) {
858
+    onVideoTypeChanged (id, newVideoType) {
859
+        if (remoteVideoTypes[id] === newVideoType) {
878 860
             return;
879 861
         }
880 862
 
881
-        console.info("Peer video type changed: ", resourceJid, newVideoType);
882
-        remoteVideoTypes[resourceJid] = newVideoType;
863
+        console.info("Peer video type changed: ", id, newVideoType);
864
+        remoteVideoTypes[id] = newVideoType;
883 865
 
884 866
         var smallVideo;
885
-        if (resourceJid === APP.xmpp.myResource()) {
867
+        if (APP.conference.isLocalId(id)) {
886 868
             if (!localVideoThumbnail) {
887 869
                 console.warn("Local video not ready yet");
888 870
                 return;
889 871
             }
890 872
             smallVideo = localVideoThumbnail;
891
-        } else if (remoteVideos[resourceJid]) {
892
-            smallVideo = remoteVideos[resourceJid];
873
+        } else if (remoteVideos[id]) {
874
+            smallVideo = remoteVideos[id];
893 875
         } else {
894 876
             return;
895 877
         }
896 878
 
897 879
         smallVideo.setVideoType(newVideoType);
898
-        LargeVideo.onVideoTypeChanged(resourceJid, newVideoType);
899
-
900
-    };
880
+        LargeVideo.onVideoTypeChanged(id, newVideoType);
881
+    },
901 882
 
902 883
     /**
903 884
      * Updates the video size and position.
904 885
      */
905
-    my.updateLargeVideoSize = function () {
886
+    updateLargeVideoSize () {
906 887
         LargeVideo.updateVideoSizeAndPosition();
907 888
         LargeVideo.position(null, null, null, null, true);
908
-    };
889
+    },
909 890
 
910
-    my.showMore = function (jid) {
891
+    showMore (jid) {
911 892
         if (jid === 'local') {
912 893
             localVideoThumbnail.connectionIndicator.showMore();
913 894
         } else {
@@ -918,15 +899,15 @@ var VideoLayout = (function (my) {
918 899
                 console.info("Error - no remote video for jid: " + jid);
919 900
             }
920 901
         }
921
-    };
902
+    },
922 903
 
923
-    my.addPreziContainer = function (id) {
904
+    addPreziContainer (id) {
924 905
         var container = RemoteVideo.createContainer(id);
925 906
         VideoLayout.resizeThumbnails();
926 907
         return container;
927
-    };
908
+    },
928 909
 
929
-    my.setLargeVideoVisible = function (isVisible) {
910
+    setLargeVideoVisible (isVisible) {
930 911
         LargeVideo.setLargeVideoVisible(isVisible);
931 912
         if(!isVisible && focusedVideoResourceJid) {
932 913
             var smallVideo = VideoLayout.getSmallVideo(focusedVideoResourceJid);
@@ -936,7 +917,7 @@ var VideoLayout = (function (my) {
936 917
             }
937 918
             focusedVideoResourceJid = null;
938 919
         }
939
-    };
920
+    },
940 921
 
941 922
     /**
942 923
      * Resizes the video area.
@@ -945,10 +926,10 @@ var VideoLayout = (function (my) {
945 926
      * @param callback a function to be called when the video space is
946 927
      * resized.
947 928
      */
948
-    my.resizeVideoArea = function(isSideBarVisible, callback) {
929
+    resizeVideoArea (isSideBarVisible, callback) {
949 930
         LargeVideo.resizeVideoAreaAnimated(isSideBarVisible, callback);
950 931
         VideoLayout.resizeThumbnails(true);
951
-    };
932
+    },
952 933
 
953 934
     /**
954 935
      * Resizes the #videospace html element
@@ -961,7 +942,7 @@ var VideoLayout = (function (my) {
961 942
      * @param completeFunction a function to be called when the video space
962 943
      * is resized.
963 944
      */
964
-    my.resizeVideoSpace = function (animate, isChatVisible, completeFunction) {
945
+    resizeVideoSpace (animate, isChatVisible, completeFunction) {
965 946
         var availableHeight = window.innerHeight;
966 947
         var availableWidth = UIUtil.getAvailableVideoWidth(isChatVisible);
967 948
 
@@ -983,19 +964,17 @@ var VideoLayout = (function (my) {
983 964
             $('#videospace').height(availableHeight);
984 965
         }
985 966
 
986
-    };
967
+    },
987 968
 
988
-    my.getSmallVideo = function (resourceJid) {
989
-        if(resourceJid == APP.xmpp.myResource()) {
969
+    getSmallVideo (id) {
970
+        if (APP.conference.isLocalId(id)) {
990 971
             return localVideoThumbnail;
991 972
         } else {
992
-            if(!remoteVideos[resourceJid])
993
-                return null;
994
-            return remoteVideos[resourceJid];
973
+            return remoteVideos[id];
995 974
         }
996
-    };
975
+    },
997 976
 
998
-    my.changeUserAvatar = function(id, thumbUrl) {
977
+    changeUserAvatar (id, thumbUrl) {
999 978
         var smallVideo = VideoLayout.getSmallVideo(id);
1000 979
         if (smallVideo) {
1001 980
             smallVideo.avatarChanged(thumbUrl);
@@ -1005,46 +984,43 @@ var VideoLayout = (function (my) {
1005 984
             );
1006 985
         }
1007 986
         LargeVideo.updateAvatar(id, thumbUrl);
1008
-    };
987
+    },
1009 988
 
1010
-    my.createEtherpadIframe = function(src, onloadHandler)
1011
-    {
989
+    createEtherpadIframe (src, onloadHandler) {
1012 990
         return LargeVideo.createEtherpadIframe(src, onloadHandler);
1013
-    };
991
+    },
1014 992
 
1015
-    my.setLargeVideoState = function (state) {
993
+    setLargeVideoState (state) {
1016 994
         LargeVideo.setState(state);
1017
-    };
995
+    },
1018 996
 
1019
-    my.getLargeVideoState = function () {
997
+    getLargeVideoState () {
1020 998
         return LargeVideo.getState();
1021
-    };
999
+    },
1022 1000
 
1023
-    my.setLargeVideoHover = function (inHandler, outHandler) {
1001
+    setLargeVideoHover (inHandler, outHandler) {
1024 1002
         LargeVideo.setHover(inHandler, outHandler);
1025
-    };
1003
+    },
1026 1004
 
1027 1005
     /**
1028 1006
      * Indicates that the video has been interrupted.
1029 1007
      */
1030
-    my.onVideoInterrupted = function () {
1008
+    onVideoInterrupted () {
1031 1009
         LargeVideo.enableVideoProblemFilter(true);
1032 1010
         var reconnectingKey = "connection.RECONNECTING";
1033 1011
         $('#videoConnectionMessage').attr("data-i18n", reconnectingKey);
1034 1012
         $('#videoConnectionMessage')
1035 1013
             .text(APP.translation.translateString(reconnectingKey));
1036 1014
         $('#videoConnectionMessage').css({display: "block"});
1037
-    };
1015
+    },
1038 1016
 
1039 1017
     /**
1040 1018
      * Indicates that the video has been restored.
1041 1019
      */
1042
-    my.onVideoRestored = function () {
1020
+    onVideoRestored () {
1043 1021
         LargeVideo.enableVideoProblemFilter(false);
1044 1022
         $('#videoConnectionMessage').css({display: "none"});
1045
-    };
1046
-
1047
-    return my;
1048
-}(VideoLayout || {}));
1023
+    }
1024
+};
1049 1025
 
1050
-module.exports = VideoLayout;
1026
+export default VideoLayout;

+ 1
- 0
service/UI/UIEvents.js Parādīt failu

@@ -25,6 +25,7 @@ export default {
25 25
     ETHERPAD_CLICKED: "UI.etherpad_clicked",
26 26
     ROOM_LOCK_CLICKED: "UI.room_lock_clicked",
27 27
     USER_INVITED: "UI.user_invited",
28
+    USER_KICKED: "UI.user_kicked",
28 29
     FULLSCREEN_TOGGLE: "UI.fullscreen_toggle",
29 30
     AUTH_CLICKED: "UI.auth_clicked",
30 31
     TOGGLE_CHAT: "UI.toggle_chat",

Notiek ielāde…
Atcelt
Saglabāt