Browse Source

do not use RTC/xmpp in UI module

j8
isymchych 9 years ago
parent
commit
6ded050b51

+ 61
- 17
app.js View File

13
 import "autosize";
13
 import "autosize";
14
 window.toastr = require("toastr");
14
 window.toastr = require("toastr");
15
 
15
 
16
+import URLProcessor from "./modules/config/URLProcessor";
16
 import RoomnameGenerator from './modules/util/RoomnameGenerator';
17
 import RoomnameGenerator from './modules/util/RoomnameGenerator';
17
 import CQEvents from './service/connectionquality/CQEvents';
18
 import CQEvents from './service/connectionquality/CQEvents';
18
 import UIEvents from './service/UI/UIEvents';
19
 import UIEvents from './service/UI/UIEvents';
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
 function connect() {
107
 function connect() {
107
-    var connection = new JitsiMeetJS.JitsiConnection(null, null, {
108
+    let connection = new JitsiMeetJS.JitsiConnection(null, null, {
108
         hosts: config.hosts,
109
         hosts: config.hosts,
109
         bosh: config.bosh,
110
         bosh: config.bosh,
110
         clientNode: config.clientNode
111
         clientNode: config.clientNode
111
     });
112
     });
112
 
113
 
113
     return new Promise(function (resolve, reject) {
114
     return new Promise(function (resolve, reject) {
114
-        var handlers = {};
115
+        let handlers = {};
115
 
116
 
116
-        var unsubscribe = function () {
117
+        function unsubscribe () {
117
             Object.keys(handlers).forEach(function (event) {
118
             Object.keys(handlers).forEach(function (event) {
118
                 connection.removeEventListener(event, handlers[event]);
119
                 connection.removeEventListener(event, handlers[event]);
119
             });
120
             });
120
-        };
121
+        }
121
 
122
 
122
         handlers[ConnectionEvents.CONNECTION_ESTABLISHED] = function () {
123
         handlers[ConnectionEvents.CONNECTION_ESTABLISHED] = function () {
123
             console.log('CONNECTED');
124
             console.log('CONNECTED');
125
             resolve(connection);
126
             resolve(connection);
126
         };
127
         };
127
 
128
 
128
-        var listenForFailure = function (event) {
129
+        function listenForFailure (event) {
129
             handlers[event] = function (...args) {
130
             handlers[event] = function (...args) {
130
                 console.error(`CONNECTION FAILED: ${event}`, ...args);
131
                 console.error(`CONNECTION FAILED: ${event}`, ...args);
131
 
132
 
132
                 unsubscribe();
133
                 unsubscribe();
133
                 reject([event, ...args]);
134
                 reject([event, ...args]);
134
             };
135
             };
135
-        };
136
+        }
136
 
137
 
137
         listenForFailure(ConnectionEvents.CONNECTION_FAILED);
138
         listenForFailure(ConnectionEvents.CONNECTION_FAILED);
138
         listenForFailure(ConnectionErrors.PASSWORD_REQUIRED);
139
         listenForFailure(ConnectionErrors.PASSWORD_REQUIRED);
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
     function getDisplayName(id) {
183
     function getDisplayName(id) {
176
         if (APP.conference.isLocalId(id)) {
184
         if (APP.conference.isLocalId(id)) {
177
             return APP.settings.getDisplayName();
185
             return APP.settings.getDisplayName();
187
     room.on(ConferenceEvents.CONFERENCE_JOINED, function () {
195
     room.on(ConferenceEvents.CONFERENCE_JOINED, function () {
188
         localTracks.forEach(function (track) {
196
         localTracks.forEach(function (track) {
189
             room.addTrack(track);
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
         // FIXME email???
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
     });
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
     room.on(ConferenceEvents.TRACK_MUTE_CHANGED, function (track) {
266
     room.on(ConferenceEvents.TRACK_MUTE_CHANGED, function (track) {
234
         // FIXME handle mute
267
         // FIXME handle mute
235
     });
268
     });
421
         // on SUBJECT_CHANGED UI.setSubject(topic);
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
     room.on(ConferenceEvents.DTMF_SUPPORT_CHANGED, function (isDTMFSupported) {
466
     room.on(ConferenceEvents.DTMF_SUPPORT_CHANGED, function (isDTMFSupported) {
425
         APP.UI.updateDTMFSupport(isDTMFSupported);
467
         APP.UI.updateDTMFSupport(isDTMFSupported);
426
     });
468
     });
427
 
469
 
470
+    $(window).bind('beforeunload', function () {
471
+        room.leave();
472
+    });
473
+
428
     return new Promise(function (resolve, reject) {
474
     return new Promise(function (resolve, reject) {
429
         room.on(ConferenceEvents.CONFERENCE_JOINED, resolve);
475
         room.on(ConferenceEvents.CONFERENCE_JOINED, resolve);
430
 
476
 
456
 }
502
 }
457
 
503
 
458
 function init() {
504
 function init() {
505
+    APP.UI.start();
459
     JitsiMeetJS.setLogLevel(JitsiMeetJS.logLevels.TRACE);
506
     JitsiMeetJS.setLogLevel(JitsiMeetJS.logLevels.TRACE);
460
     JitsiMeetJS.init().then(function () {
507
     JitsiMeetJS.init().then(function () {
461
         return Promise.all([createLocalTracks(), connect()]);
508
         return Promise.all([createLocalTracks(), connect()]);
463
         console.log('initialized with %s local tracks', tracks.length);
510
         console.log('initialized with %s local tracks', tracks.length);
464
         return initConference(tracks, connection);
511
         return initConference(tracks, connection);
465
     }).then(function () {
512
     }).then(function () {
466
-        APP.UI.start();
467
-
468
         APP.UI.initConference();
513
         APP.UI.initConference();
469
 
514
 
470
         APP.UI.addListener(UIEvents.LANG_CHANGED, function (language) {
515
         APP.UI.addListener(UIEvents.LANG_CHANGED, function (language) {
518
 $(document).ready(function () {
563
 $(document).ready(function () {
519
     console.log("(TIME) document ready:\t", window.performance.now());
564
     console.log("(TIME) document ready:\t", window.performance.now());
520
 
565
 
521
-    var URLProcessor = require("./modules/config/URLProcessor");
522
     URLProcessor.setConfigParametersFromUrl();
566
     URLProcessor.setConfigParametersFromUrl();
523
     APP.init();
567
     APP.init();
524
 
568
 
537
     }
581
     }
538
 });
582
 });
539
 
583
 
540
-export default APP;
584
+module.exports = APP;

+ 1173
- 826
lib-jitsi-meet.js
File diff suppressed because it is too large
View File


+ 22
- 22
modules/UI/UI.js View File

1
-/* global Strophe, APP, $, config, interfaceConfig, toastr */
1
+/* global APP, $, config, interfaceConfig, toastr */
2
 /* jshint -W101 */
2
 /* jshint -W101 */
3
 var UI = {};
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
 var Prezi = require("./prezi/Prezi");
18
 var Prezi = require("./prezi/Prezi");
8
 var Etherpad = require("./etherpad/Etherpad");
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
 var EventEmitter = require("events");
20
 var EventEmitter = require("events");
16
 var SettingsMenu = require("./side_pannels/settings/SettingsMenu");
21
 var SettingsMenu = require("./side_pannels/settings/SettingsMenu");
17
 var Settings = require("./../settings/Settings");
22
 var Settings = require("./../settings/Settings");
18
-var PanelToggler = require("./side_pannels/SidePanelToggler");
19
 UI.messageHandler = require("./util/MessageHandler");
23
 UI.messageHandler = require("./util/MessageHandler");
20
 var messageHandler = UI.messageHandler;
24
 var messageHandler = UI.messageHandler;
21
 var Authentication  = require("./authentication/Authentication");
25
 var Authentication  = require("./authentication/Authentication");
22
-var UIUtil = require("./util/UIUtil");
23
 var JitsiPopover = require("./util/JitsiPopover");
26
 var JitsiPopover = require("./util/JitsiPopover");
24
 var CQEvents = require("../../service/connectionquality/CQEvents");
27
 var CQEvents = require("../../service/connectionquality/CQEvents");
25
 var DesktopSharingEventTypes
28
 var DesktopSharingEventTypes
26
     = require("../../service/desktopsharing/DesktopSharingEventTypes");
29
     = require("../../service/desktopsharing/DesktopSharingEventTypes");
27
 var StatisticsEvents = require("../../service/statistics/Events");
30
 var StatisticsEvents = require("../../service/statistics/Events");
28
-var UIEvents = require("../../service/UI/UIEvents");
29
 var Feedback = require("./Feedback");
31
 var Feedback = require("./Feedback");
30
 
32
 
31
 var eventEmitter = new EventEmitter();
33
 var eventEmitter = new EventEmitter();
352
     Etherpad.init(name);
354
     Etherpad.init(name);
353
 }
355
 }
354
 
356
 
355
-UI.addUser = function (jid, id, displayName) {
357
+UI.addUser = function (id, displayName) {
356
     messageHandler.notify(
358
     messageHandler.notify(
357
         displayName,'notify.somebody', 'connected', 'notify.connected'
359
         displayName,'notify.somebody', 'connected', 'notify.connected'
358
     );
360
     );
362
         UIUtil.playSoundNotification('userJoined');
364
         UIUtil.playSoundNotification('userJoined');
363
 
365
 
364
     // Configure avatar
366
     // Configure avatar
365
-    UI.setUserAvatar(jid, id);
367
+    UI.setUserAvatar(id, displayName);
366
 
368
 
367
     // Add Peer's container
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
     messageHandler.notify(displayName,'notify.somebody',
375
     messageHandler.notify(displayName,'notify.somebody',
376
         'disconnected',
376
         'disconnected',
377
         'notify.disconnected');
377
         'notify.disconnected');
380
         UIUtil.playSoundNotification('userLeft');
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
 function onMucPresenceStatus(jid, info) {
388
 function onMucPresenceStatus(jid, info) {
601
 
601
 
602
 UI.setAudioLevel = function (id, lvl) {
602
 UI.setAudioLevel = function (id, lvl) {
603
     AudioLevels.updateAudioLevel(
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 View File

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

+ 5
- 2
modules/UI/prezi/Prezi.js View File

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
 var messageHandler = require("../util/MessageHandler");
6
 var messageHandler = require("../util/MessageHandler");
4
 var PreziPlayer = require("./PreziPlayer");
7
 var PreziPlayer = require("./PreziPlayer");
5
 
8
 

+ 6
- 2
modules/UI/util/UIUtil.js View File

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

+ 8
- 8
modules/UI/videolayout/ConnectionIndicator.js View File

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

+ 75
- 80
modules/UI/videolayout/LargeVideo.js View File

1
-/* global $, APP, Strophe, interfaceConfig */
1
+/* global $, APP, interfaceConfig */
2
 /* jshint -W101 */
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
 var RTCBrowserType = require("../../RTC/RTCBrowserType");
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
 // FIXME: With Temasys we have to re-select everytime
10
 // FIXME: With Temasys we have to re-select everytime
11
 //var video = $('#largeVideo');
11
 //var video = $('#largeVideo');
37
  * @param state the state.
37
  * @param state the state.
38
  * @returns {JQuery|*|jQuery|HTMLElement} the container.
38
  * @returns {JQuery|*|jQuery|HTMLElement} the container.
39
  */
39
  */
40
-function getContainerByState(state)
41
-{
40
+function getContainerByState(state) {
42
     var selector = null;
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
                        animate) {
72
                        animate) {
73
     if (animate) {
73
     if (animate) {
74
         video.animate({
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
     } else {
85
     } else {
87
         video.width(width);
86
         video.width(width);
88
         video.height(height);
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
 
238
 
238
 /**
239
 /**
239
  * Updates the src of the active speaker avatar
240
  * Updates the src of the active speaker avatar
240
- * @param jid of the current active speaker
241
  */
241
  */
242
 function updateActiveSpeakerAvatarSrc() {
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
         currentSmallVideo.showAvatar();
248
         currentSmallVideo.showAvatar();
251
     }
249
     }
252
 }
250
 }
263
     }
261
     }
264
 
262
 
265
     updateActiveSpeakerAvatarSrc();
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
     LargeVideo.updateVideoSizeAndPosition(currentSmallVideo.getVideoType());
274
     LargeVideo.updateVideoSizeAndPosition(currentSmallVideo.getVideoType());
275
 
275
 
369
     /**
369
     /**
370
      * Returns <tt>true</tt> if the user is currently displayed on large video.
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
      * Updates the large video with the given new video source.
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
             return;
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
         if (!newSmallVideo) {
385
         if (!newSmallVideo) {
386
-            console.error("Small video not found for: " + resourceJid);
386
+            console.error("Small video not found for: " + id);
387
             return;
387
             return;
388
         }
388
         }
389
 
389
 
390
-        if (!LargeVideo.isCurrentlyOnLarge(resourceJid) || forceUpdate) {
390
+        if (!LargeVideo.isCurrentlyOnLarge(id) || forceUpdate) {
391
             $('#activeSpeaker').css('visibility', 'hidden');
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
             currentSmallVideo = newSmallVideo;
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
                 // or null.
399
                 // or null.
405
-                this.eventEmitter.emit(UIEvents.SELECTED_ENDPOINT, resourceJid);
400
+                this.eventEmitter.emit(UIEvents.SELECTED_ENDPOINT, id);
406
             }
401
             }
407
             // We are doing fadeOut/fadeIn animations on parent div which wraps
402
             // We are doing fadeOut/fadeIn animations on parent div which wraps
408
             // largeVideo, because when Temasys plugin is in use it replaces
403
             // largeVideo, because when Temasys plugin is in use it replaces
443
                 currentSmallVideo.enableDominantSpeaker(false);
438
                 currentSmallVideo.enableDominantSpeaker(false);
444
         }
439
         }
445
     },
440
     },
446
-    onVideoTypeChanged: function (resourceJid, newVideoType) {
441
+    onVideoTypeChanged: function (id, newVideoType) {
447
         if (!isEnabled)
442
         if (!isEnabled)
448
             return;
443
             return;
449
-        if (LargeVideo.isCurrentlyOnLarge(resourceJid))
450
-        {
444
+        if (LargeVideo.isCurrentlyOnLarge(id)) {
451
             LargeVideo.updateVideoSizeAndPosition(newVideoType);
445
             LargeVideo.updateVideoSizeAndPosition(newVideoType);
452
 
446
 
453
             this.position(null, null, null, null, true);
447
             this.position(null, null, null, null, true);
562
         getVideoPosition = isDesktop ? getDesktopVideoPosition :
556
         getVideoPosition = isDesktop ? getDesktopVideoPosition :
563
             getCameraVideoPosition;
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
             return;
564
             return;
571
-        if (resourceJid === this.getResourceJid()) {
565
+        }
566
+        if (id === this.getId()) {
572
             updateActiveSpeakerAvatarSrc();
567
             updateActiveSpeakerAvatarSrc();
573
         }
568
         }
574
     },
569
     },
575
-    showAvatar: function (resourceJid, show) {
576
-        if (!isEnabled)
570
+    showAvatar: function (id, show) {
571
+        if (!isEnabled) {
577
             return;
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
             $('#activeSpeaker').css("visibility", show ? "visible" : "hidden");
576
             $('#activeSpeaker').css("visibility", show ? "visible" : "hidden");
582
             return true;
577
             return true;
583
         }
578
         }
721
     }
716
     }
722
 };
717
 };
723
 
718
 
724
-module.exports = LargeVideo;
719
+export default LargeVideo;

+ 21
- 33
modules/UI/videolayout/LocalVideo.js View File

1
 /* global $, interfaceConfig, APP */
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
 var LargeVideo = require("./LargeVideo");
7
 var LargeVideo = require("./LargeVideo");
7
 var RTCBrowserType = require("../../RTC/RTCBrowserType");
8
 var RTCBrowserType = require("../../RTC/RTCBrowserType");
8
 
9
 
13
     this.VideoLayout = VideoLayout;
14
     this.VideoLayout = VideoLayout;
14
     this.flipX = true;
15
     this.flipX = true;
15
     this.isLocal = true;
16
     this.isLocal = true;
16
-    this.peerJid = null;
17
     this.emitter = emitter;
17
     this.emitter = emitter;
18
 }
18
 }
19
 
19
 
143
     this.connectionIndicator = new ConnectionIndicator(this, null);
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
         // FIXME: with Temasys plugin event arg is not an event, but
150
         // FIXME: with Temasys plugin event arg is not an event, but
151
         // the clicked object itself, so we have to skip this call
151
         // the clicked object itself, so we have to skip this call
152
         if (event.stopPropagation) {
152
         if (event.stopPropagation) {
153
             event.stopPropagation();
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
     localVideoContainerSelector.off('click');
159
     localVideoContainerSelector.off('click');
162
     localVideoContainerSelector.on('click', localVideoClick);
160
     localVideoContainerSelector.on('click', localVideoClick);
163
 
161
 
164
-    if(isMuted) {
165
-        APP.UI.setVideoMute(true);
166
-        return;
167
-    }
168
     this.flipX = stream.videoType != "screen";
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
     if (!RTCBrowserType.isIExplorer()) {
165
     if (!RTCBrowserType.isIExplorer()) {
173
         localVideo.autoplay = true;
166
         localVideo.autoplay = true;
174
         localVideo.volume = 0; // is it required if audio is separated ?
167
         localVideo.volume = 0; // is it required if audio is separated ?
192
     }
185
     }
193
 
186
 
194
     // Attach WebRTC stream
187
     // Attach WebRTC stream
195
-    APP.RTC.attachMediaStream(localVideoSelector, stream.getOriginalStream());
188
+    stream.attach(localVideoSelector);
189
+
190
+    // FIXME handle
191
+    return;
196
 
192
 
197
     // Add stream ended handler
193
     // Add stream ended handler
198
     APP.RTC.addMediaStreamInactiveHandler(
194
     APP.RTC.addMediaStreamInactiveHandler(
201
         // because <video> element is replaced with <object>
197
         // because <video> element is replaced with <object>
202
         localVideo = $('#' + localVideo.id)[0];
198
         localVideo = $('#' + localVideo.id)[0];
203
         localVideoContainer.removeChild(localVideo);
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 View File

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
 var RTCBrowserType = require("../../RTC/RTCBrowserType");
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
     this.VideoLayout = VideoLayout;
16
     this.VideoLayout = VideoLayout;
15
     this.addRemoteVideoContainer();
17
     this.addRemoteVideoContainer();
16
-    this.connectionIndicator = new ConnectionIndicator(
17
-        this, this.peerJid);
18
+    this.connectionIndicator = new ConnectionIndicator(this, id);
18
     this.setDisplayName();
19
     this.setDisplayName();
19
     var nickfield = document.createElement('span');
20
     var nickfield = document.createElement('span');
20
     nickfield.className = "nick";
21
     nickfield.className = "nick";
21
-    nickfield.appendChild(document.createTextNode(this.resourceJid));
22
+    nickfield.appendChild(document.createTextNode(id));
22
     this.container.appendChild(nickfield);
23
     this.container.appendChild(nickfield);
23
     this.bindHoverHandler();
24
     this.bindHoverHandler();
24
     this.flipX = false;
25
     this.flipX = false;
30
 
31
 
31
 RemoteVideo.prototype.addRemoteVideoContainer = function() {
32
 RemoteVideo.prototype.addRemoteVideoContainer = function() {
32
     this.container = RemoteVideo.createContainer(this.videoSpanId);
33
     this.container = RemoteVideo.createContainer(this.videoSpanId);
33
-    if (APP.xmpp.isModerator())
34
+    if (APP.conference.isModerator) {
34
         this.addRemoteVideoMenu();
35
         this.addRemoteVideoMenu();
35
-    AudioLevels.updateAudioLevelCanvas(this.peerJid, this.VideoLayout);
36
+    }
37
+    AudioLevels.updateAudioLevelCanvas(this.id, this.VideoLayout);
36
 
38
 
37
     return this.container;
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
  * given <tt>parentElement</tt>.
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
  * @param parentElement the parent element where this menu will be added
47
  * @param parentElement the parent element where this menu will be added
46
  */
48
  */
47
 
49
 
60
 
62
 
61
         var popupmenuElement = document.createElement('ul');
63
         var popupmenuElement = document.createElement('ul');
62
         popupmenuElement.className = 'popupmenu';
64
         popupmenuElement.className = 'popupmenu';
63
-        popupmenuElement.id = 'remote_popupmenu_' + this.getResourceJid();
65
+        popupmenuElement.id = `remote_popupmenu_${this.id}`;
64
         spanElement.appendChild(popupmenuElement);
66
         spanElement.appendChild(popupmenuElement);
65
 
67
 
66
         var muteMenuItem = document.createElement('li');
68
         var muteMenuItem = document.createElement('li');
88
                 event.preventDefault();
90
                 event.preventDefault();
89
             }
91
             }
90
             var isMute = !!self.isMuted;
92
             var isMute = !!self.isMuted;
91
-            APP.xmpp.setMute(self.peerJid, !isMute);
93
+            self.emitter.emit(UIEvents.AUDIO_MUTED, !isMute);
92
 
94
 
93
             popupmenuElement.setAttribute('style', 'display:none;');
95
             popupmenuElement.setAttribute('style', 'display:none;');
94
 
96
 
117
             "data-i18n='videothumbnail.kick'>&nbsp;</div>";
119
             "data-i18n='videothumbnail.kick'>&nbsp;</div>";
118
         ejectLinkItem.innerHTML = ejectIndicator + ' ' + ejectText;
120
         ejectLinkItem.innerHTML = ejectIndicator + ' ' + ejectText;
119
         ejectLinkItem.onclick = function(){
121
         ejectLinkItem.onclick = function(){
120
-            APP.xmpp.eject(self.peerJid);
122
+            self.emitter.emit(UIEvents.USER_KICKED, self.id);
121
             popupmenuElement.setAttribute('style', 'display:none;');
123
             popupmenuElement.setAttribute('style', 'display:none;');
122
         };
124
         };
123
 
125
 
157
     select.remove();
159
     select.remove();
158
 
160
 
159
     console.info((isVideo ? "Video" : "Audio") +
161
     console.info((isVideo ? "Video" : "Audio") +
160
-                 " removed " + this.getResourceJid(), select);
162
+                 " removed " + this.id, select);
161
 
163
 
162
     if (isVideo)
164
     if (isVideo)
163
-        this.VideoLayout.updateRemovedVideo(this.getResourceJid());
165
+        this.VideoLayout.updateRemovedVideo(this.id);
164
 };
166
 };
165
 
167
 
166
 /**
168
 /**
167
  * Removes RemoteVideo from the page.
169
  * Removes RemoteVideo from the page.
168
  */
170
  */
169
 RemoteVideo.prototype.remove = function () {
171
 RemoteVideo.prototype.remove = function () {
170
-    console.log("Remove thumbnail", this.peerJid);
172
+    console.log("Remove thumbnail", this.id);
171
     this.removeConnectionIndicator();
173
     this.removeConnectionIndicator();
172
     // Make sure that the large video is updated if are removing its
174
     // Make sure that the large video is updated if are removing its
173
     // corresponding small video.
175
     // corresponding small video.
174
-    this.VideoLayout.updateRemovedVideo(this.getResourceJid());
176
+    this.VideoLayout.updateRemovedVideo(this.id);
175
     // Remove whole container
177
     // Remove whole container
176
-    if (this.container.parentNode)
178
+    if (this.container.parentNode) {
177
         this.container.parentNode.removeChild(this.container);
179
         this.container.parentNode.removeChild(this.container);
180
+    }
178
 };
181
 };
179
 
182
 
180
 RemoteVideo.prototype.waitForPlayback = function (sel, stream) {
183
 RemoteVideo.prototype.waitForPlayback = function (sel, stream) {
181
 
184
 
182
     var webRtcStream = stream.getOriginalStream();
185
     var webRtcStream = stream.getOriginalStream();
183
-    var isVideo = stream.isVideoStream();
186
+    var isVideo = stream.isVideoTrack();
184
     if (!isVideo || webRtcStream.id === 'mixedmslabel') {
187
     if (!isVideo || webRtcStream.id === 'mixedmslabel') {
185
         return;
188
         return;
186
     }
189
     }
187
 
190
 
188
     var self = this;
191
     var self = this;
189
-    var resourceJid = this.getResourceJid();
190
 
192
 
191
     // Register 'onplaying' listener to trigger 'videoactive' on VideoLayout
193
     // Register 'onplaying' listener to trigger 'videoactive' on VideoLayout
192
     // when video playback starts
194
     // when video playback starts
198
         if (RTCBrowserType.isTemasysPluginUsed()) {
200
         if (RTCBrowserType.isTemasysPluginUsed()) {
199
             sel = self.selectVideoElement();
201
             sel = self.selectVideoElement();
200
         }
202
         }
201
-        self.VideoLayout.videoactive(sel, resourceJid);
203
+        self.VideoLayout.videoactive(sel, self.id);
202
         sel[0].onplaying = null;
204
         sel[0].onplaying = null;
203
         if (RTCBrowserType.isTemasysPluginUsed()) {
205
         if (RTCBrowserType.isTemasysPluginUsed()) {
204
             // 'currentTime' is used to check if the video has started
206
             // 'currentTime' is used to check if the video has started
210
 };
212
 };
211
 
213
 
212
 RemoteVideo.prototype.addRemoteStreamElement = function (stream) {
214
 RemoteVideo.prototype.addRemoteStreamElement = function (stream) {
213
-    if (!this.container)
215
+    if (!this.container) {
214
         return;
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
     // Put new stream element always in front
225
     // Put new stream element always in front
223
     UIUtils.prependChild(this.container, streamElement);
226
     UIUtils.prependChild(this.container, streamElement);
224
 
227
 
225
-    var sel = $('#' + newElementId);
228
+    let sel = $(`#${newElementId}`);
226
     sel.hide();
229
     sel.hide();
227
 
230
 
228
     // If the container is currently visible we attach the stream.
231
     // If the container is currently visible we attach the stream.
229
     if (!isVideo || (this.container.offsetParent !== null && isVideo)) {
232
     if (!isVideo || (this.container.offsetParent !== null && isVideo)) {
230
         this.waitForPlayback(sel, stream);
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
     // Add click handler.
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
         // On IE we need to populate this handler on video <object>
243
         // On IE we need to populate this handler on video <object>
248
         // and it does not give event instance as an argument,
244
         // and it does not give event instance as an argument,
255
     };
251
     };
256
     this.container.onclick = onClickHandler;
252
     this.container.onclick = onClickHandler;
257
     // reselect
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
 RemoteVideo.prototype.showPeerContainer = function (state) {
263
 RemoteVideo.prototype.showPeerContainer = function (state) {
267
     if (!this.container)
264
     if (!this.container)
294
 
291
 
295
     // We want to be able to pin a participant from the contact list, even
292
     // We want to be able to pin a participant from the contact list, even
296
     // if he's not in the lastN set!
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
 /**
308
 /**
312
  * Updates the remote video menu.
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
  * @param isMuted indicates the current mute state
312
  * @param isMuted indicates the current mute state
316
  */
313
  */
317
 RemoteVideo.prototype.updateRemoteVideoMenu = function (isMuted) {
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
     var mutedIndicator = "<i class='icon-mic-disabled'></i>";
317
     var mutedIndicator = "<i class='icon-mic-disabled'></i>";
322
 
318
 
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
 RemoteVideo.createContainer = function (spanId) {
422
 RemoteVideo.createContainer = function (spanId) {
434
     var container = document.createElement('span');
423
     var container = document.createElement('span');
435
     container.id = spanId;
424
     container.id = spanId;
439
 };
428
 };
440
 
429
 
441
 
430
 
442
-module.exports = RemoteVideo;
431
+export default RemoteVideo;

+ 25
- 24
modules/UI/videolayout/SmallVideo.js View File

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

+ 246
- 270
modules/UI/videolayout/VideoLayout.js View File

1
-/* global config, APP, $, Strophe, require, interfaceConfig */
1
+/* global config, APP, $, interfaceConfig */
2
 /* jshint -W101 */
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
 var remoteVideos = {};
17
 var remoteVideos = {};
18
 var remoteVideoTypes = {};
18
 var remoteVideoTypes = {};
23
 var localLastNCount = config.channelLastN;
23
 var localLastNCount = config.channelLastN;
24
 var localLastNSet = [];
24
 var localLastNSet = [];
25
 var lastNEndpointsCache = [];
25
 var lastNEndpointsCache = [];
26
-var lastNPickupJid = null;
26
+var lastNPickupId = null;
27
 
27
 
28
 var eventEmitter = null;
28
 var eventEmitter = null;
29
 
29
 
33
  */
33
  */
34
 var focusedVideoResourceJid = null;
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
         eventEmitter = emitter;
80
         eventEmitter = emitter;
39
         localVideoThumbnail = new LocalVideo(VideoLayout, emitter);
81
         localVideoThumbnail = new LocalVideo(VideoLayout, emitter);
40
         if (interfaceConfig.filmStripOnly) {
82
         if (interfaceConfig.filmStripOnly) {
45
 
87
 
46
         VideoLayout.resizeLargeVideoContainer();
88
         VideoLayout.resizeLargeVideoContainer();
47
 
89
 
48
-    };
90
+    },
49
 
91
 
50
-    my.isInLastN = function(resource) {
92
+    isInLastN (resource) {
51
         return lastNCount < 0 || // lastN is disabled
93
         return lastNCount < 0 || // lastN is disabled
52
              // lastNEndpoints cache not built yet
94
              // lastNEndpoints cache not built yet
53
             (lastNCount > 0 && !lastNEndpointsCache.length) ||
95
             (lastNCount > 0 && !lastNEndpointsCache.length) ||
54
             (lastNEndpointsCache &&
96
             (lastNEndpointsCache &&
55
                 lastNEndpointsCache.indexOf(resource) !== -1);
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
         // Writing volume not allowed in IE
105
         // Writing volume not allowed in IE
62
         if (!RTCBrowserType.isIExplorer()) {
106
         if (!RTCBrowserType.isIExplorer()) {
63
             localAudio.autoplay = true;
107
             localAudio.autoplay = true;
73
             // which will result in audio mute issues
117
             // which will result in audio mute issues
74
             $('#localAudio').hide();
118
             $('#localAudio').hide();
75
         }
119
         }
76
-    };
120
+    },
77
 
121
 
78
-    my.changeLocalVideo = function(stream, isMuted) {
122
+    changeLocalVideo (stream) {
79
         // Set default display name.
123
         // Set default display name.
80
         localVideoThumbnail.setDisplayName();
124
         localVideoThumbnail.setDisplayName();
81
         localVideoThumbnail.createConnectionIndicator();
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
         AudioLevels.updateAudioLevelCanvas(null, VideoLayout);
130
         AudioLevels.updateAudioLevelCanvas(null, VideoLayout);
86
 
131
 
87
-        localVideoThumbnail.changeVideo(stream, isMuted);
132
+        localVideoThumbnail.changeVideo(stream);
88
 
133
 
89
         /* force update if we're currently being displayed */
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
      * Adds or removes icons for not available camera and microphone.
150
      * Adds or removes icons for not available camera and microphone.
105
      * @param resourceJid the jid of user
151
      * @param resourceJid the jid of user
106
      * @param devices available devices
152
      * @param devices available devices
107
      */
153
      */
108
-    my.setDeviceAvailabilityIcons = function (resourceJid, devices) {
154
+    setDeviceAvailabilityIcons (resourceJid, devices) {
109
         if(!devices)
155
         if(!devices)
110
             return;
156
             return;
111
 
157
 
115
             if(remoteVideos[resourceJid])
161
             if(remoteVideos[resourceJid])
116
                 remoteVideos[resourceJid].setDeviceAvailabilityIcons(devices);
162
                 remoteVideos[resourceJid].setDeviceAvailabilityIcons(devices);
117
         }
163
         }
118
-    };
164
+    },
119
 
165
 
120
     /**
166
     /**
121
      * Checks if removed video is currently displayed and tries to display
167
      * Checks if removed video is currently displayed and tries to display
122
      * another one instead.
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
             // We'll show user's avatar if he is the dominant speaker or if
174
             // We'll show user's avatar if he is the dominant speaker or if
129
             // his video thumbnail is pinned
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
             } else {
180
             } else {
135
                 // Otherwise select last visible video
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
         // pick the last visible video in the row
189
         // pick the last visible video in the row
144
         // if nobody else is left, this picks the local video
190
         // if nobody else is left, this picks the local video
145
         var jid;
191
         var jid;
174
 
220
 
175
         console.info("electLastVisibleVideo: " + jid);
221
         console.info("electLastVisibleVideo: " + jid);
176
         return jid;
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
      * Return the type of the remote video.
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
      * @returns the video type video or screen.
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
      * Called when large video update is finished
246
      * Called when large video update is finished
203
      * @param currentSmallVideo small video currently displayed on large video
247
      * @param currentSmallVideo small video currently displayed on large video
204
      */
248
      */
205
-    my.largeVideoUpdated = function (currentSmallVideo) {
249
+    largeVideoUpdated (currentSmallVideo) {
206
         // Makes sure that dominant speaker UI
250
         // Makes sure that dominant speaker UI
207
         // is enabled only on current small video
251
         // is enabled only on current small video
208
-        localVideoThumbnail.enableDominantSpeaker(
209
-            localVideoThumbnail === currentSmallVideo);
252
+        localVideoThumbnail.enableDominantSpeaker(localVideoThumbnail === currentSmallVideo);
210
         Object.keys(remoteVideos).forEach(
253
         Object.keys(remoteVideos).forEach(
211
             function (resourceJid) {
254
             function (resourceJid) {
212
                 var remoteVideo = remoteVideos[resourceJid];
255
                 var remoteVideo = remoteVideos[resourceJid];
216
                 }
259
                 }
217
             }
260
             }
218
         );
261
         );
219
-    };
262
+    },
220
 
263
 
221
-    my.handleVideoThumbClicked = function(noPinnedEndpointChangedEvent,
264
+    handleVideoThumbClicked (noPinnedEndpointChangedEvent,
222
                                           resourceJid) {
265
                                           resourceJid) {
223
         if(focusedVideoResourceJid) {
266
         if(focusedVideoResourceJid) {
224
             var oldSmallVideo
267
             var oldSmallVideo
269
                 el.volume = 1;
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
      * in the document and creates it eventually.
320
      * in the document and creates it eventually.
278
      *
321
      *
279
-     * @param peerJid peer Jid to check.
280
-     *
281
      * @return Returns <tt>true</tt> if the peer container exists,
322
      * @return Returns <tt>true</tt> if the peer container exists,
282
      * <tt>false</tt> - otherwise
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
         localVideoThumbnail.inputDisplayNameHandler(name);
351
         localVideoThumbnail.inputDisplayNameHandler(name);
313
-    };
352
+    },
314
 
353
 
315
-    my.videoactive = function (videoelem, resourceJid) {
354
+    videoactive (videoelem, resourceJid) {
316
 
355
 
317
         console.info(resourceJid + " video is now active");
356
         console.info(resourceJid + " video is now active");
318
 
357
 
330
                 currentDominantSpeaker === resourceJid)) {
369
                 currentDominantSpeaker === resourceJid)) {
331
             LargeVideo.updateLargeVideo(resourceJid, true);
370
             LargeVideo.updateLargeVideo(resourceJid, true);
332
         }
371
         }
333
-    };
372
+    },
334
 
373
 
335
     /**
374
     /**
336
      * Shows the presence status message for the given video.
375
      * Shows the presence status message for the given video.
337
      */
376
      */
338
-    my.setPresenceStatus = function (resourceJid, statusMsg) {
377
+    setPresenceStatus (resourceJid, statusMsg) {
339
         remoteVideos[resourceJid].setPresenceStatus(statusMsg);
378
         remoteVideos[resourceJid].setPresenceStatus(statusMsg);
340
-    };
379
+    },
341
 
380
 
342
     /**
381
     /**
343
      * Shows a visual indicator for the moderator of the conference.
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
         if (isModerator) {
386
         if (isModerator) {
349
             localVideoThumbnail.createModeratorIndicatorElement();
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
             } else if (isModerator) {
395
             } else if (isModerator) {
368
                 // We are moderator, but user is not - add menu
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
      * Shows or hides the audio muted indicator over the local thumbnail video.
405
      * Shows or hides the audio muted indicator over the local thumbnail video.
378
      * @param {boolean} isMuted
406
      * @param {boolean} isMuted
379
      */
407
      */
380
-    my.showLocalAudioIndicator = function(isMuted) {
408
+    showLocalAudioIndicator (isMuted) {
381
         localVideoThumbnail.showAudioIndicator(isMuted);
409
         localVideoThumbnail.showAudioIndicator(isMuted);
382
-    };
410
+    },
383
 
411
 
384
     /**
412
     /**
385
      * Resizes the large video container.
413
      * Resizes the large video container.
386
      */
414
      */
387
-    my.resizeLargeVideoContainer = function () {
415
+    resizeLargeVideoContainer () {
388
         if(LargeVideo.isEnabled()) {
416
         if(LargeVideo.isEnabled()) {
389
             LargeVideo.resize();
417
             LargeVideo.resize();
390
         } else {
418
         } else {
392
         }
420
         }
393
         VideoLayout.resizeThumbnails();
421
         VideoLayout.resizeThumbnails();
394
         LargeVideo.position();
422
         LargeVideo.position();
395
-    };
423
+    },
396
 
424
 
397
     /**
425
     /**
398
      * Resizes thumbnails.
426
      * Resizes thumbnails.
399
      */
427
      */
400
-    my.resizeThumbnails = function(animate) {
428
+    resizeThumbnails (animate) {
401
         var videoSpaceWidth = $('#remoteVideos').width();
429
         var videoSpaceWidth = $('#remoteVideos').width();
402
 
430
 
403
         var thumbnailSize = VideoLayout.calculateThumbnailSize(videoSpaceWidth);
431
         var thumbnailSize = VideoLayout.calculateThumbnailSize(videoSpaceWidth);
441
 
469
 
442
             $(document).trigger("remotevideo.resized", [width, height]);
470
             $(document).trigger("remotevideo.resized", [width, height]);
443
         }
471
         }
444
-    };
472
+    },
445
 
473
 
446
     /**
474
     /**
447
      * Calculates the thumbnail size.
475
      * Calculates the thumbnail size.
448
      *
476
      *
449
      * @param videoSpaceWidth the width of the video space
477
      * @param videoSpaceWidth the width of the video space
450
      */
478
      */
451
-    my.calculateThumbnailSize = function (videoSpaceWidth) {
479
+    calculateThumbnailSize (videoSpaceWidth) {
452
         // Calculate the available height, which is the inner window height
480
         // Calculate the available height, which is the inner window height
453
         // minus 39px for the header minus 2px for the delimiter lines on the
481
         // minus 39px for the header minus 2px for the delimiter lines on the
454
         // top and bottom of the large video, minus the 36px space inside the
482
         // top and bottom of the large video, minus the 36px space inside the
478
        }
506
        }
479
 
507
 
480
        return [availableWidth, availableHeight];
508
        return [availableWidth, availableHeight];
481
-   };
509
+   },
482
 
510
 
483
     /**
511
     /**
484
      * Returns the corresponding resource jid to the given peer container
512
      * Returns the corresponding resource jid to the given peer container
487
      * @return the corresponding resource jid to the given peer container
515
      * @return the corresponding resource jid to the given peer container
488
      * DOM element
516
      * DOM element
489
      */
517
      */
490
-    my.getPeerContainerResourceJid = function (containerElement) {
518
+    getPeerContainerResourceJid (containerElement) {
491
         if (localVideoThumbnail.container === containerElement) {
519
         if (localVideoThumbnail.container === containerElement) {
492
-            return localVideoThumbnail.getResourceJid();
520
+            return localVideoThumbnail.getId();
493
         }
521
         }
494
 
522
 
495
         var i = containerElement.id.indexOf('participant_');
523
         var i = containerElement.id.indexOf('participant_');
496
 
524
 
497
         if (i >= 0)
525
         if (i >= 0)
498
             return containerElement.id.substring(i + 12);
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
      * On audio muted event.
530
      * On audio muted event.
548
      */
531
      */
549
-    my.onAudioMute = function (jid, isMuted) {
532
+    onAudioMute (jid, isMuted) {
550
         var resourceJid = Strophe.getResourceFromJid(jid);
533
         var resourceJid = Strophe.getResourceFromJid(jid);
551
         if (resourceJid === APP.xmpp.myResource()) {
534
         if (resourceJid === APP.xmpp.myResource()) {
552
             localVideoThumbnail.showAudioIndicator(isMuted);
535
             localVideoThumbnail.showAudioIndicator(isMuted);
557
                 remoteVideos[resourceJid].updateRemoteVideoMenu(isMuted);
540
                 remoteVideos[resourceJid].updateRemoteVideoMenu(isMuted);
558
             }
541
             }
559
         }
542
         }
560
-    };
543
+    },
561
 
544
 
562
     /**
545
     /**
563
      * On video muted event.
546
      * On video muted event.
564
      */
547
      */
565
-    my.onVideoMute = function (jid, value) {
548
+    onVideoMute (jid, value) {
566
         if (jid !== APP.xmpp.myJid() &&
549
         if (jid !== APP.xmpp.myJid() &&
567
             !APP.RTC.muteRemoteVideoStream(jid, value))
550
             !APP.RTC.muteRemoteVideoStream(jid, value))
568
             return;
551
             return;
582
             else
565
             else
583
                 el.hide();
566
                 el.hide();
584
         }
567
         }
585
-    };
568
+    },
586
 
569
 
587
     /**
570
     /**
588
      * Display name changed.
571
      * Display name changed.
589
      */
572
      */
590
-    my.onDisplayNameChanged = function (id, displayName, status) {
573
+    onDisplayNameChanged (id, displayName, status) {
591
         if (id === 'localVideoContainer' ||
574
         if (id === 'localVideoContainer' ||
592
             APP.conference.isLocalId(id)) {
575
             APP.conference.isLocalId(id)) {
593
             localVideoThumbnail.setDisplayName(displayName);
576
             localVideoThumbnail.setDisplayName(displayName);
595
             VideoLayout.ensurePeerContainerExists(id);
578
             VideoLayout.ensurePeerContainerExists(id);
596
             remoteVideos[id].setDisplayName(displayName, status);
579
             remoteVideos[id].setDisplayName(displayName, status);
597
         }
580
         }
598
-    };
581
+    },
599
 
582
 
600
     /**
583
     /**
601
      * On dominant speaker changed event.
584
      * On dominant speaker changed event.
602
      */
585
      */
603
-    my.onDominantSpeakerChanged = function (resourceJid) {
586
+    onDominantSpeakerChanged (id) {
604
         // We ignore local user events.
587
         // We ignore local user events.
605
-        if (resourceJid === APP.xmpp.myResource())
588
+        if (APP.conference.isLocalId(id)) {
606
             return;
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
             return;
593
             return;
624
         }
594
         }
625
 
595
 
626
-        if (!remoteVideo)
596
+        let remoteVideo = remoteVideos[id];
597
+
598
+        if (!remoteVideo) {
627
             return;
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
         // Obtain container for new dominant speaker.
612
         // Obtain container for new dominant speaker.
630
-        var videoSel  = remoteVideo.selectVideoElement();
613
+        let videoSel = remoteVideo.selectVideoElement();
631
 
614
 
632
         // Local video will not have container found, but that's ok
615
         // Local video will not have container found, but that's ok
633
         // since we don't want to switch to local video.
616
         // since we don't want to switch to local video.
635
             // Update the large video if the video source is already available,
618
             // Update the large video if the video source is already available,
636
             // otherwise wait for the "videoactive.jingle" event.
619
             // otherwise wait for the "videoactive.jingle" event.
637
             if (videoSel[0].currentTime > 0) {
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
      * On last N change event.
627
      * On last N change event.
647
      * @param endpointsEnteringLastN the list currently entering last N
630
      * @param endpointsEnteringLastN the list currently entering last N
648
      * endpoints
631
      * endpoints
649
      */
632
      */
650
-    my.onLastNEndpointsChanged = function (lastNEndpoints, endpointsEnteringLastN) {
633
+    onLastNEndpointsChanged (lastNEndpoints, endpointsEnteringLastN) {
651
         if (lastNCount !== lastNEndpoints.length)
634
         if (lastNCount !== lastNEndpoints.length)
652
             lastNCount = lastNEndpoints.length;
635
             lastNCount = lastNEndpoints.length;
653
 
636
 
727
                 // displayed in the large video we have to switch to another
710
                 // displayed in the large video we have to switch to another
728
                 // user.
711
                 // user.
729
                 if (!updateLargeVideo &&
712
                 if (!updateLargeVideo &&
730
-                    resourceJid === LargeVideo.getResourceJid()) {
713
+                    resourceJid === LargeVideo.getId()) {
731
                     updateLargeVideo = true;
714
                     updateLargeVideo = true;
732
                 }
715
                 }
733
             }
716
             }
751
                     var sel = remoteVideo.selectVideoElement();
734
                     var sel = remoteVideo.selectVideoElement();
752
 
735
 
753
                     APP.RTC.attachMediaStream(sel, mediaStream.stream);
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
                         // Don't fire the events again, they've already
741
                         // Don't fire the events again, they've already
759
                         // been fired in the contact list click handler.
742
                         // been fired in the contact list click handler.
789
                 break;
772
                 break;
790
             }
773
             }
791
         }
774
         }
792
-    };
775
+    },
793
 
776
 
794
     /**
777
     /**
795
      * Updates local stats
778
      * Updates local stats
796
      * @param percent
779
      * @param percent
797
      * @param object
780
      * @param object
798
      */
781
      */
799
-    my.updateLocalConnectionStats = function (percent, object) {
782
+    updateLocalConnectionStats (percent, object) {
800
         var resolution = null;
783
         var resolution = null;
801
         if (object.resolution !== null) {
784
         if (object.resolution !== null) {
802
             resolution = object.resolution;
785
             resolution = object.resolution;
814
                     updateResolution(resolution[jid]);
797
                     updateResolution(resolution[jid]);
815
             }
798
             }
816
         }
799
         }
817
-    };
800
+    },
818
 
801
 
819
     /**
802
     /**
820
      * Updates remote stats.
803
      * Updates remote stats.
822
      * @param percent the connection quality percent
805
      * @param percent the connection quality percent
823
      * @param object the stats data
806
      * @param object the stats data
824
      */
807
      */
825
-    my.updateConnectionStats = function (jid, percent, object) {
808
+    updateConnectionStats (jid, percent, object) {
826
         var resourceJid = Strophe.getResourceFromJid(jid);
809
         var resourceJid = Strophe.getResourceFromJid(jid);
827
 
810
 
828
         if (remoteVideos[resourceJid])
811
         if (remoteVideos[resourceJid])
829
             remoteVideos[resourceJid].updateStatsIndicator(percent, object);
812
             remoteVideos[resourceJid].updateStatsIndicator(percent, object);
830
-    };
813
+    },
831
 
814
 
832
     /**
815
     /**
833
      * Hides the connection indicator
816
      * Hides the connection indicator
834
      * @param jid
817
      * @param jid
835
      */
818
      */
836
-    my.hideConnectionIndicator = function (jid) {
819
+    hideConnectionIndicator (jid) {
837
         remoteVideos[Strophe.getResourceFromJid(jid)].hideConnectionIndicator();
820
         remoteVideos[Strophe.getResourceFromJid(jid)].hideConnectionIndicator();
838
-    };
821
+    },
839
 
822
 
840
     /**
823
     /**
841
      * Hides all the indicators
824
      * Hides all the indicators
842
      */
825
      */
843
-    my.hideStats = function () {
826
+    hideStats () {
844
         for(var video in remoteVideos) {
827
         for(var video in remoteVideos) {
845
             remoteVideos[video].hideIndicator();
828
             remoteVideos[video].hideIndicator();
846
         }
829
         }
847
         localVideoThumbnail.hideIndicator();
830
         localVideoThumbnail.hideIndicator();
848
-    };
831
+    },
849
 
832
 
850
-    my.participantLeft = function (jid) {
833
+    participantLeft (id) {
851
         // Unlock large video
834
         // Unlock large video
852
-        var resourceJid = Strophe.getResourceFromJid(jid);
853
-        if (focusedVideoResourceJid === resourceJid) {
835
+        if (focusedVideoResourceJid === id) {
854
             console.info("Focused video owner has left the conference");
836
             console.info("Focused video owner has left the conference");
855
             focusedVideoResourceJid = null;
837
             focusedVideoResourceJid = null;
856
         }
838
         }
857
 
839
 
858
-        if (currentDominantSpeaker === resourceJid) {
840
+        if (currentDominantSpeaker === id) {
859
             console.info("Dominant speaker has left the conference");
841
             console.info("Dominant speaker has left the conference");
860
             currentDominantSpeaker = null;
842
             currentDominantSpeaker = null;
861
         }
843
         }
862
 
844
 
863
-        var remoteVideo = remoteVideos[resourceJid];
845
+        var remoteVideo = remoteVideos[id];
864
         if (remoteVideo) {
846
         if (remoteVideo) {
865
             // Remove remote video
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
             remoteVideo.remove();
850
             remoteVideo.remove();
869
         } else {
851
         } else {
870
-            console.warn("No remote video for " + resourceJid);
852
+            console.warn("No remote video for " + id);
871
         }
853
         }
872
 
854
 
873
         VideoLayout.resizeThumbnails();
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
             return;
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
         var smallVideo;
866
         var smallVideo;
885
-        if (resourceJid === APP.xmpp.myResource()) {
867
+        if (APP.conference.isLocalId(id)) {
886
             if (!localVideoThumbnail) {
868
             if (!localVideoThumbnail) {
887
                 console.warn("Local video not ready yet");
869
                 console.warn("Local video not ready yet");
888
                 return;
870
                 return;
889
             }
871
             }
890
             smallVideo = localVideoThumbnail;
872
             smallVideo = localVideoThumbnail;
891
-        } else if (remoteVideos[resourceJid]) {
892
-            smallVideo = remoteVideos[resourceJid];
873
+        } else if (remoteVideos[id]) {
874
+            smallVideo = remoteVideos[id];
893
         } else {
875
         } else {
894
             return;
876
             return;
895
         }
877
         }
896
 
878
 
897
         smallVideo.setVideoType(newVideoType);
879
         smallVideo.setVideoType(newVideoType);
898
-        LargeVideo.onVideoTypeChanged(resourceJid, newVideoType);
899
-
900
-    };
880
+        LargeVideo.onVideoTypeChanged(id, newVideoType);
881
+    },
901
 
882
 
902
     /**
883
     /**
903
      * Updates the video size and position.
884
      * Updates the video size and position.
904
      */
885
      */
905
-    my.updateLargeVideoSize = function () {
886
+    updateLargeVideoSize () {
906
         LargeVideo.updateVideoSizeAndPosition();
887
         LargeVideo.updateVideoSizeAndPosition();
907
         LargeVideo.position(null, null, null, null, true);
888
         LargeVideo.position(null, null, null, null, true);
908
-    };
889
+    },
909
 
890
 
910
-    my.showMore = function (jid) {
891
+    showMore (jid) {
911
         if (jid === 'local') {
892
         if (jid === 'local') {
912
             localVideoThumbnail.connectionIndicator.showMore();
893
             localVideoThumbnail.connectionIndicator.showMore();
913
         } else {
894
         } else {
918
                 console.info("Error - no remote video for jid: " + jid);
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
         var container = RemoteVideo.createContainer(id);
905
         var container = RemoteVideo.createContainer(id);
925
         VideoLayout.resizeThumbnails();
906
         VideoLayout.resizeThumbnails();
926
         return container;
907
         return container;
927
-    };
908
+    },
928
 
909
 
929
-    my.setLargeVideoVisible = function (isVisible) {
910
+    setLargeVideoVisible (isVisible) {
930
         LargeVideo.setLargeVideoVisible(isVisible);
911
         LargeVideo.setLargeVideoVisible(isVisible);
931
         if(!isVisible && focusedVideoResourceJid) {
912
         if(!isVisible && focusedVideoResourceJid) {
932
             var smallVideo = VideoLayout.getSmallVideo(focusedVideoResourceJid);
913
             var smallVideo = VideoLayout.getSmallVideo(focusedVideoResourceJid);
936
             }
917
             }
937
             focusedVideoResourceJid = null;
918
             focusedVideoResourceJid = null;
938
         }
919
         }
939
-    };
920
+    },
940
 
921
 
941
     /**
922
     /**
942
      * Resizes the video area.
923
      * Resizes the video area.
945
      * @param callback a function to be called when the video space is
926
      * @param callback a function to be called when the video space is
946
      * resized.
927
      * resized.
947
      */
928
      */
948
-    my.resizeVideoArea = function(isSideBarVisible, callback) {
929
+    resizeVideoArea (isSideBarVisible, callback) {
949
         LargeVideo.resizeVideoAreaAnimated(isSideBarVisible, callback);
930
         LargeVideo.resizeVideoAreaAnimated(isSideBarVisible, callback);
950
         VideoLayout.resizeThumbnails(true);
931
         VideoLayout.resizeThumbnails(true);
951
-    };
932
+    },
952
 
933
 
953
     /**
934
     /**
954
      * Resizes the #videospace html element
935
      * Resizes the #videospace html element
961
      * @param completeFunction a function to be called when the video space
942
      * @param completeFunction a function to be called when the video space
962
      * is resized.
943
      * is resized.
963
      */
944
      */
964
-    my.resizeVideoSpace = function (animate, isChatVisible, completeFunction) {
945
+    resizeVideoSpace (animate, isChatVisible, completeFunction) {
965
         var availableHeight = window.innerHeight;
946
         var availableHeight = window.innerHeight;
966
         var availableWidth = UIUtil.getAvailableVideoWidth(isChatVisible);
947
         var availableWidth = UIUtil.getAvailableVideoWidth(isChatVisible);
967
 
948
 
983
             $('#videospace').height(availableHeight);
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
             return localVideoThumbnail;
971
             return localVideoThumbnail;
991
         } else {
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
         var smallVideo = VideoLayout.getSmallVideo(id);
978
         var smallVideo = VideoLayout.getSmallVideo(id);
1000
         if (smallVideo) {
979
         if (smallVideo) {
1001
             smallVideo.avatarChanged(thumbUrl);
980
             smallVideo.avatarChanged(thumbUrl);
1005
             );
984
             );
1006
         }
985
         }
1007
         LargeVideo.updateAvatar(id, thumbUrl);
986
         LargeVideo.updateAvatar(id, thumbUrl);
1008
-    };
987
+    },
1009
 
988
 
1010
-    my.createEtherpadIframe = function(src, onloadHandler)
1011
-    {
989
+    createEtherpadIframe (src, onloadHandler) {
1012
         return LargeVideo.createEtherpadIframe(src, onloadHandler);
990
         return LargeVideo.createEtherpadIframe(src, onloadHandler);
1013
-    };
991
+    },
1014
 
992
 
1015
-    my.setLargeVideoState = function (state) {
993
+    setLargeVideoState (state) {
1016
         LargeVideo.setState(state);
994
         LargeVideo.setState(state);
1017
-    };
995
+    },
1018
 
996
 
1019
-    my.getLargeVideoState = function () {
997
+    getLargeVideoState () {
1020
         return LargeVideo.getState();
998
         return LargeVideo.getState();
1021
-    };
999
+    },
1022
 
1000
 
1023
-    my.setLargeVideoHover = function (inHandler, outHandler) {
1001
+    setLargeVideoHover (inHandler, outHandler) {
1024
         LargeVideo.setHover(inHandler, outHandler);
1002
         LargeVideo.setHover(inHandler, outHandler);
1025
-    };
1003
+    },
1026
 
1004
 
1027
     /**
1005
     /**
1028
      * Indicates that the video has been interrupted.
1006
      * Indicates that the video has been interrupted.
1029
      */
1007
      */
1030
-    my.onVideoInterrupted = function () {
1008
+    onVideoInterrupted () {
1031
         LargeVideo.enableVideoProblemFilter(true);
1009
         LargeVideo.enableVideoProblemFilter(true);
1032
         var reconnectingKey = "connection.RECONNECTING";
1010
         var reconnectingKey = "connection.RECONNECTING";
1033
         $('#videoConnectionMessage').attr("data-i18n", reconnectingKey);
1011
         $('#videoConnectionMessage').attr("data-i18n", reconnectingKey);
1034
         $('#videoConnectionMessage')
1012
         $('#videoConnectionMessage')
1035
             .text(APP.translation.translateString(reconnectingKey));
1013
             .text(APP.translation.translateString(reconnectingKey));
1036
         $('#videoConnectionMessage').css({display: "block"});
1014
         $('#videoConnectionMessage').css({display: "block"});
1037
-    };
1015
+    },
1038
 
1016
 
1039
     /**
1017
     /**
1040
      * Indicates that the video has been restored.
1018
      * Indicates that the video has been restored.
1041
      */
1019
      */
1042
-    my.onVideoRestored = function () {
1020
+    onVideoRestored () {
1043
         LargeVideo.enableVideoProblemFilter(false);
1021
         LargeVideo.enableVideoProblemFilter(false);
1044
         $('#videoConnectionMessage').css({display: "none"});
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 View File

25
     ETHERPAD_CLICKED: "UI.etherpad_clicked",
25
     ETHERPAD_CLICKED: "UI.etherpad_clicked",
26
     ROOM_LOCK_CLICKED: "UI.room_lock_clicked",
26
     ROOM_LOCK_CLICKED: "UI.room_lock_clicked",
27
     USER_INVITED: "UI.user_invited",
27
     USER_INVITED: "UI.user_invited",
28
+    USER_KICKED: "UI.user_kicked",
28
     FULLSCREEN_TOGGLE: "UI.fullscreen_toggle",
29
     FULLSCREEN_TOGGLE: "UI.fullscreen_toggle",
29
     AUTH_CLICKED: "UI.auth_clicked",
30
     AUTH_CLICKED: "UI.auth_clicked",
30
     TOGGLE_CHAT: "UI.toggle_chat",
31
     TOGGLE_CHAT: "UI.toggle_chat",

Loading…
Cancel
Save