Просмотр исходного кода

Merge pull request #911 from jitsi/small_videolayout_refactoring

Small videolayout refactoring
j8
Дамян Минков 9 лет назад
Родитель
Сommit
586ea2ae0d

+ 3
- 1
conference.js Просмотреть файл

@@ -39,7 +39,7 @@ let connectionIsInterrupted = false;
39 39
  */
40 40
 let DSExternalInstallationInProgress = false;
41 41
 
42
-import {VIDEO_CONTAINER_TYPE} from "./modules/UI/videolayout/LargeVideo";
42
+import {VIDEO_CONTAINER_TYPE} from "./modules/UI/videolayout/VideoContainer";
43 43
 
44 44
 /**
45 45
  * Known custom conference commands.
@@ -1424,6 +1424,8 @@ export default {
1424 1424
 
1425 1425
         APP.UI.addListener(UIEvents.PINNED_ENDPOINT, (smallVideo, isPinned) => {
1426 1426
             var smallVideoId = smallVideo.getId();
1427
+            // FIXME why VIDEO_CONTAINER_TYPE instead of checking if
1428
+            // the participant is on the large video ?
1427 1429
             if (smallVideo.getVideoType() === VIDEO_CONTAINER_TYPE
1428 1430
                 && !APP.conference.isLocalId(smallVideoId)) {
1429 1431
 

+ 310
- 0
modules/UI/videolayout/LargeVideoManager.js Просмотреть файл

@@ -0,0 +1,310 @@
1
+/* global $, APP, interfaceConfig */
2
+/* jshint -W101 */
3
+
4
+import Avatar from "../avatar/Avatar";
5
+import {createDeferred} from '../../util/helpers';
6
+import UIUtil from "../util/UIUtil";
7
+import {VideoContainer, VIDEO_CONTAINER_TYPE} from "./VideoContainer";
8
+
9
+/**
10
+ * Manager for all Large containers.
11
+ */
12
+export default class LargeVideoManager {
13
+    constructor (emitter) {
14
+        this.containers = {};
15
+
16
+        this.state = VIDEO_CONTAINER_TYPE;
17
+        this.videoContainer = new VideoContainer(
18
+            () => this.resizeContainer(VIDEO_CONTAINER_TYPE), emitter);
19
+        this.addContainer(VIDEO_CONTAINER_TYPE, this.videoContainer);
20
+
21
+        // use the same video container to handle and desktop tracks
22
+        this.addContainer("desktop", this.videoContainer);
23
+
24
+        this.width = 0;
25
+        this.height = 0;
26
+
27
+        this.$container = $('#largeVideoContainer');
28
+
29
+        this.$container.css({
30
+            display: 'inline-block'
31
+        });
32
+
33
+        if (interfaceConfig.SHOW_JITSI_WATERMARK) {
34
+            let leftWatermarkDiv
35
+                = this.$container.find("div.watermark.leftwatermark");
36
+
37
+            leftWatermarkDiv.css({display: 'block'});
38
+
39
+            UIUtil.setLinkHref(
40
+                leftWatermarkDiv.parent(),
41
+                interfaceConfig.JITSI_WATERMARK_LINK);
42
+        }
43
+
44
+        if (interfaceConfig.SHOW_BRAND_WATERMARK) {
45
+            let rightWatermarkDiv
46
+                = this.$container.find("div.watermark.rightwatermark");
47
+
48
+            rightWatermarkDiv.css({
49
+                display: 'block',
50
+                backgroundImage: 'url(images/rightwatermark.png)'
51
+            });
52
+
53
+            UIUtil.setLinkHref(
54
+                rightWatermarkDiv.parent(),
55
+                interfaceConfig.BRAND_WATERMARK_LINK);
56
+        }
57
+
58
+        if (interfaceConfig.SHOW_POWERED_BY) {
59
+            this.$container.children("a.poweredby").css({display: 'block'});
60
+        }
61
+
62
+        this.$container.hover(
63
+            e => this.onHoverIn(e),
64
+            e => this.onHoverOut(e)
65
+        );
66
+    }
67
+
68
+    onHoverIn (e) {
69
+        if (!this.state) {
70
+            return;
71
+        }
72
+        let container = this.getContainer(this.state);
73
+        container.onHoverIn(e);
74
+    }
75
+
76
+    onHoverOut (e) {
77
+        if (!this.state) {
78
+            return;
79
+        }
80
+        let container = this.getContainer(this.state);
81
+        container.onHoverOut(e);
82
+    }
83
+
84
+    get id () {
85
+        let container = this.getContainer(this.state);
86
+        return container.id;
87
+    }
88
+
89
+    scheduleLargeVideoUpdate () {
90
+        if (this.updateInProcess || !this.newStreamData) {
91
+            return;
92
+        }
93
+
94
+        this.updateInProcess = true;
95
+
96
+        let container = this.getContainer(this.state);
97
+
98
+        // Include hide()/fadeOut only if we're switching between users
99
+        let preUpdate;
100
+        if (this.newStreamData.id != this.id) {
101
+            preUpdate = container.hide();
102
+        } else {
103
+            preUpdate = Promise.resolve();
104
+        }
105
+
106
+        preUpdate.then(() => {
107
+            let {id, stream, videoType, resolve} = this.newStreamData;
108
+            this.newStreamData = null;
109
+
110
+            console.info("hover in %s", id);
111
+            this.state = videoType;
112
+            let container = this.getContainer(this.state);
113
+            container.setStream(stream, videoType);
114
+
115
+            // change the avatar url on large
116
+            this.updateAvatar(Avatar.getAvatarUrl(id));
117
+
118
+            // If we the continer is VIDEO_CONTAINER_TYPE, we need to check
119
+            // its stream whether exist and is muted to set isVideoMuted
120
+            // in rest of the cases it is false
121
+            let isVideoMuted = false;
122
+            if (videoType == VIDEO_CONTAINER_TYPE)
123
+                isVideoMuted = stream ? stream.isMuted() : true;
124
+
125
+            // show the avatar on large if needed
126
+            container.showAvatar(isVideoMuted);
127
+
128
+            let promise;
129
+
130
+            // do not show stream if video is muted
131
+            // but we still should show watermark
132
+            if (isVideoMuted) {
133
+                this.showWatermark(true);
134
+                promise = Promise.resolve();
135
+            } else {
136
+                promise = container.show();
137
+            }
138
+
139
+            // resolve updateLargeVideo promise after everything is done
140
+            promise.then(resolve);
141
+
142
+            return promise;
143
+        }).then(() => {
144
+            // after everything is done check again if there are any pending
145
+            // new streams.
146
+            this.updateInProcess = false;
147
+            this.scheduleLargeVideoUpdate();
148
+        });
149
+    }
150
+
151
+    /**
152
+     * Update large video.
153
+     * Switches to large video even if previously other container was visible.
154
+     * @param userID the userID of the participant associated with the stream
155
+     * @param {JitsiTrack?} stream new stream
156
+     * @param {string?} videoType new video type
157
+     * @returns {Promise}
158
+     */
159
+    updateLargeVideo (userID, stream, videoType) {
160
+        if (this.newStreamData) {
161
+            this.newStreamData.reject();
162
+        }
163
+
164
+        this.newStreamData = createDeferred();
165
+        this.newStreamData.id = userID;
166
+        this.newStreamData.stream = stream;
167
+        this.newStreamData.videoType = videoType;
168
+
169
+        this.scheduleLargeVideoUpdate();
170
+
171
+        return this.newStreamData.promise;
172
+    }
173
+
174
+    /**
175
+     * Update container size.
176
+     */
177
+    updateContainerSize () {
178
+        this.width = UIUtil.getAvailableVideoWidth();
179
+        this.height = window.innerHeight;
180
+    }
181
+
182
+    /**
183
+     * Resize Large container of specified type.
184
+     * @param {string} type type of container which should be resized.
185
+     * @param {boolean} [animate=false] if resize process should be animated.
186
+     */
187
+    resizeContainer (type, animate = false) {
188
+        let container = this.getContainer(type);
189
+        container.resize(this.width, this.height, animate);
190
+    }
191
+
192
+    /**
193
+     * Resize all Large containers.
194
+     * @param {boolean} animate if resize process should be animated.
195
+     */
196
+    resize (animate) {
197
+        // resize all containers
198
+        Object.keys(this.containers)
199
+            .forEach(type => this.resizeContainer(type, animate));
200
+
201
+        this.$container.animate({
202
+            width: this.width,
203
+            height: this.height
204
+        }, {
205
+            queue: false,
206
+            duration: animate ? 500 : 0
207
+        });
208
+    }
209
+
210
+    /**
211
+     * Enables/disables the filter indicating a video problem to the user.
212
+     *
213
+     * @param enable <tt>true</tt> to enable, <tt>false</tt> to disable
214
+     */
215
+    enableVideoProblemFilter (enable) {
216
+        let container = this.getContainer(this.state);
217
+        container.$video.toggleClass("videoProblemFilter", enable);
218
+    }
219
+
220
+    /**
221
+     * Updates the src of the dominant speaker avatar
222
+     */
223
+    updateAvatar (avatarUrl) {
224
+        $("#dominantSpeakerAvatar").attr('src', avatarUrl);
225
+    }
226
+
227
+    /**
228
+     * Show or hide watermark.
229
+     * @param {boolean} show
230
+     */
231
+    showWatermark (show) {
232
+        $('.watermark').css('visibility', show ? 'visible' : 'hidden');
233
+    }
234
+
235
+    /**
236
+     * Add container of specified type.
237
+     * @param {string} type container type
238
+     * @param {LargeContainer} container container to add.
239
+     */
240
+    addContainer (type, container) {
241
+        if (this.containers[type]) {
242
+            throw new Error(`container of type ${type} already exist`);
243
+        }
244
+
245
+        this.containers[type] = container;
246
+        this.resizeContainer(type);
247
+    }
248
+
249
+    /**
250
+     * Get Large container of specified type.
251
+     * @param {string} type container type.
252
+     * @returns {LargeContainer}
253
+     */
254
+    getContainer (type) {
255
+        let container = this.containers[type];
256
+
257
+        if (!container) {
258
+            throw new Error(`container of type ${type} doesn't exist`);
259
+        }
260
+
261
+        return container;
262
+    }
263
+
264
+    /**
265
+     * Remove Large container of specified type.
266
+     * @param {string} type container type.
267
+     */
268
+    removeContainer (type) {
269
+        if (!this.containers[type]) {
270
+            throw new Error(`container of type ${type} doesn't exist`);
271
+        }
272
+
273
+        delete this.containers[type];
274
+    }
275
+
276
+    /**
277
+     * Show Large container of specified type.
278
+     * Does nothing if such container is already visible.
279
+     * @param {string} type container type.
280
+     * @returns {Promise}
281
+     */
282
+    showContainer (type) {
283
+        if (this.state === type) {
284
+            return Promise.resolve();
285
+        }
286
+
287
+        let oldContainer = this.containers[this.state];
288
+        if (this.state === VIDEO_CONTAINER_TYPE) {
289
+            this.showWatermark(false);
290
+        }
291
+        oldContainer.hide();
292
+
293
+        this.state = type;
294
+        let container = this.getContainer(type);
295
+
296
+        return container.show().then(() => {
297
+            if (type === VIDEO_CONTAINER_TYPE) {
298
+                this.showWatermark(true);
299
+            }
300
+        });
301
+    }
302
+
303
+    /**
304
+     * Changes the flipX state of the local video.
305
+     * @param val {boolean} true if flipped.
306
+     */
307
+    onLocalFlipXChange(val) {
308
+        this.videoContainer.setLocalFlipX(val);
309
+    }
310
+}

+ 4
- 5
modules/UI/videolayout/RemoteVideo.js Просмотреть файл

@@ -19,7 +19,6 @@ function RemoteVideo(id, VideoLayout, emitter) {
19 19
     this.setDisplayName();
20 20
     this.flipX = false;
21 21
     this.isLocal = false;
22
-    this.isMuted = false;
23 22
 }
24 23
 
25 24
 RemoteVideo.prototype = Object.create(SmallVideo.prototype);
@@ -61,7 +60,7 @@ RemoteVideo.prototype._initPopupMenu = function (popupMenuElement) {
61 60
     this.popover.show = function () {
62 61
         // update content by forcing it, to finish even if popover
63 62
         // is not visible
64
-        this.updateRemoteVideoMenu(this.isMuted, true);
63
+        this.updateRemoteVideoMenu(this.isAudioMuted, true);
65 64
         // call the original show, passing its actual this
66 65
         origShowFunc.call(this.popover);
67 66
     }.bind(this);
@@ -97,7 +96,7 @@ RemoteVideo.prototype._generatePopupContent = function () {
97 96
 
98 97
     muteLinkItem.id = "mutelink_" + this.id;
99 98
 
100
-    if (this.isMuted) {
99
+    if (this.isAudioMuted) {
101 100
         muteLinkItem.innerHTML = mutedHTML;
102 101
         muteLinkItem.className = 'mutelink disabled';
103 102
     }
@@ -109,7 +108,7 @@ RemoteVideo.prototype._generatePopupContent = function () {
109 108
     // Delegate event to the document.
110 109
     $(document).on("click", "#mutelink_" + this.id, function(){
111 110
 
112
-        if (this.isMuted)
111
+        if (this.isAudioMuted)
113 112
             return;
114 113
 
115 114
         this.emitter.emit(UIEvents.REMOTE_AUDIO_MUTED, this.id);
@@ -153,7 +152,7 @@ RemoteVideo.prototype._generatePopupContent = function () {
153 152
  */
154 153
 RemoteVideo.prototype.updateRemoteVideoMenu = function (isMuted, force) {
155 154
 
156
-    this.isMuted = isMuted;
155
+    this.isAudioMuted = isMuted;
157 156
 
158 157
     // generate content, translate it and add it to document only if
159 158
     // popover is visible or we force to do so.

+ 5
- 5
modules/UI/videolayout/SmallVideo.js Просмотреть файл

@@ -7,7 +7,7 @@ import UIEvents from "../../../service/UI/UIEvents";
7 7
 const RTCUIHelper = JitsiMeetJS.util.RTCUIHelper;
8 8
 
9 9
 function SmallVideo(VideoLayout) {
10
-    this.isMuted = false;
10
+    this.isAudioMuted = false;
11 11
     this.hasAvatar = false;
12 12
     this.isVideoMuted = false;
13 13
     this.videoStream = null;
@@ -204,7 +204,7 @@ SmallVideo.prototype.showAudioIndicator = function(isMuted) {
204 204
     else {
205 205
         audioMutedIndicator.show();
206 206
     }
207
-    this.isMuted = isMuted;
207
+    this.isAudioMuted = isMuted;
208 208
 };
209 209
 
210 210
 /**
@@ -222,7 +222,7 @@ SmallVideo.prototype.getAudioMutedIndicator = function () {
222 222
 
223 223
     audioMutedSpan = document.createElement('span');
224 224
     audioMutedSpan.className = 'audioMuted toolbar-icon';
225
-    
225
+
226 226
     UIUtil.setTooltip(audioMutedSpan,
227 227
         "videothumbnail.mute",
228 228
         "top");
@@ -277,11 +277,11 @@ SmallVideo.prototype.getVideoMutedIndicator = function () {
277 277
 
278 278
     var mutedIndicator = document.createElement('i');
279 279
     mutedIndicator.className = 'icon-camera-disabled';
280
-    
280
+
281 281
     UIUtil.setTooltip(mutedIndicator,
282 282
         "videothumbnail.videomute",
283 283
         "top");
284
-    
284
+
285 285
     videoMutedSpan.appendChild(mutedIndicator);
286 286
 
287 287
     return $('#' + this.videoSpanId + ' .videoMuted');

modules/UI/videolayout/LargeVideo.js → modules/UI/videolayout/VideoContainer.js Просмотреть файл

@@ -1,17 +1,16 @@
1 1
 /* global $, APP, interfaceConfig */
2 2
 /* jshint -W101 */
3 3
 
4
-import UIUtil from "../util/UIUtil";
5
-import UIEvents from "../../../service/UI/UIEvents";
6
-import LargeContainer from './LargeContainer';
7 4
 import FilmStrip from './FilmStrip';
8
-import Avatar from "../avatar/Avatar";
9
-import {createDeferred} from '../../util/helpers';
10
-
11
-const FADE_DURATION_MS = 300;
5
+import LargeContainer from './LargeContainer';
6
+import UIEvents from "../../../service/UI/UIEvents";
7
+import UIUtil from "../util/UIUtil";
12 8
 
9
+// FIXME should be 'video'
13 10
 export const VIDEO_CONTAINER_TYPE = "camera";
14 11
 
12
+const FADE_DURATION_MS = 300;
13
+
15 14
 /**
16 15
  * Get stream id.
17 16
  * @param {JitsiTrack?} stream
@@ -20,7 +19,8 @@ function getStreamOwnerId(stream) {
20 19
     if (!stream) {
21 20
         return;
22 21
     }
23
-    if (stream.isLocal()) { // local stream doesn't have method "getParticipantId"
22
+    // local stream doesn't have method "getParticipantId"
23
+    if (stream.isLocal()) {
24 24
         return APP.conference.getMyUserId();
25 25
     } else {
26 26
         return stream.getParticipantId();
@@ -154,7 +154,7 @@ function getDesktopVideoPosition(videoWidth,
154 154
 /**
155 155
  * Container for user video.
156 156
  */
157
-class VideoContainer extends LargeContainer {
157
+export class VideoContainer extends LargeContainer {
158 158
     // FIXME: With Temasys we have to re-select everytime
159 159
     get $video () {
160 160
         return $('#largeVideo');
@@ -206,14 +206,14 @@ class VideoContainer extends LargeContainer {
206 206
         let { width, height } = this.getStreamSize();
207 207
         if (this.stream && this.isScreenSharing()) {
208 208
             return getDesktopVideoSize( width,
209
-                                        height,
210
-                                        containerWidth,
211
-                                        containerHeight);
209
+                height,
210
+                containerWidth,
211
+                containerHeight);
212 212
         } else {
213 213
             return getCameraVideoSize(  width,
214
-                                        height,
215
-                                        containerWidth,
216
-                                        containerHeight);
214
+                height,
215
+                containerWidth,
216
+                containerHeight);
217 217
         }
218 218
     }
219 219
 
@@ -229,14 +229,14 @@ class VideoContainer extends LargeContainer {
229 229
     getVideoPosition (width, height, containerWidth, containerHeight) {
230 230
         if (this.stream && this.isScreenSharing()) {
231 231
             return getDesktopVideoPosition( width,
232
-                                            height,
233
-                                            containerWidth,
234
-                                            containerHeight);
232
+                height,
233
+                containerWidth,
234
+                containerHeight);
235 235
         } else {
236 236
             return getCameraVideoPosition(  width,
237
-                                            height,
238
-                                            containerWidth,
239
-                                            containerHeight);
237
+                height,
238
+                containerWidth,
239
+                containerHeight);
240 240
         }
241 241
     }
242 242
 
@@ -245,7 +245,7 @@ class VideoContainer extends LargeContainer {
245 245
             = this.getVideoSize(containerWidth, containerHeight);
246 246
         let { horizontalIndent, verticalIndent }
247 247
             = this.getVideoPosition(width, height,
248
-                                    containerWidth, containerHeight);
248
+            containerWidth, containerHeight);
249 249
 
250 250
         // update avatar position
251 251
         let top = containerHeight / 2 - this.avatarHeight / 4 * 3;
@@ -383,306 +383,3 @@ class VideoContainer extends LargeContainer {
383 383
         return false;
384 384
     }
385 385
 }
386
-
387
-/**
388
- * Manager for all Large containers.
389
- */
390
-export default class LargeVideoManager {
391
-    constructor (emitter) {
392
-        this.containers = {};
393
-
394
-        this.state = VIDEO_CONTAINER_TYPE;
395
-        this.videoContainer = new VideoContainer(
396
-            () => this.resizeContainer(VIDEO_CONTAINER_TYPE), emitter);
397
-        this.addContainer(VIDEO_CONTAINER_TYPE, this.videoContainer);
398
-
399
-        // use the same video container to handle and desktop tracks
400
-        this.addContainer("desktop", this.videoContainer);
401
-
402
-        this.width = 0;
403
-        this.height = 0;
404
-
405
-        this.$container = $('#largeVideoContainer');
406
-
407
-        this.$container.css({
408
-            display: 'inline-block'
409
-        });
410
-
411
-        if (interfaceConfig.SHOW_JITSI_WATERMARK) {
412
-            let leftWatermarkDiv
413
-                = this.$container.find("div.watermark.leftwatermark");
414
-
415
-            leftWatermarkDiv.css({display: 'block'});
416
-
417
-            UIUtil.setLinkHref(
418
-                leftWatermarkDiv.parent(),
419
-                interfaceConfig.JITSI_WATERMARK_LINK);
420
-        }
421
-
422
-        if (interfaceConfig.SHOW_BRAND_WATERMARK) {
423
-            let rightWatermarkDiv
424
-                = this.$container.find("div.watermark.rightwatermark");
425
-
426
-            rightWatermarkDiv.css({
427
-                display: 'block',
428
-                backgroundImage: 'url(images/rightwatermark.png)'
429
-            });
430
-
431
-            UIUtil.setLinkHref(
432
-                rightWatermarkDiv.parent(),
433
-                interfaceConfig.BRAND_WATERMARK_LINK);
434
-        }
435
-
436
-        if (interfaceConfig.SHOW_POWERED_BY) {
437
-            this.$container.children("a.poweredby").css({display: 'block'});
438
-        }
439
-
440
-        this.$container.hover(
441
-            e => this.onHoverIn(e),
442
-            e => this.onHoverOut(e)
443
-        );
444
-    }
445
-
446
-    onHoverIn (e) {
447
-        if (!this.state) {
448
-            return;
449
-        }
450
-        let container = this.getContainer(this.state);
451
-        container.onHoverIn(e);
452
-    }
453
-
454
-    onHoverOut (e) {
455
-        if (!this.state) {
456
-            return;
457
-        }
458
-        let container = this.getContainer(this.state);
459
-        container.onHoverOut(e);
460
-    }
461
-
462
-    get id () {
463
-        let container = this.getContainer(this.state);
464
-        return container.id;
465
-    }
466
-
467
-    scheduleLargeVideoUpdate () {
468
-        if (this.updateInProcess || !this.newStreamData) {
469
-            return;
470
-        }
471
-
472
-        this.updateInProcess = true;
473
-
474
-        let container = this.getContainer(this.state);
475
-
476
-        // Include hide()/fadeOut only if we're switching between users
477
-        let preUpdate;
478
-        if (this.newStreamData.id != this.id) {
479
-            preUpdate = container.hide();
480
-        } else {
481
-            preUpdate = Promise.resolve();
482
-        }
483
-
484
-        preUpdate.then(() => {
485
-            let {id, stream, videoType, resolve} = this.newStreamData;
486
-            this.newStreamData = null;
487
-
488
-            console.info("hover in %s", id);
489
-            this.state = videoType;
490
-            let container = this.getContainer(this.state);
491
-            container.setStream(stream, videoType);
492
-
493
-            // change the avatar url on large
494
-            this.updateAvatar(Avatar.getAvatarUrl(id));
495
-
496
-            // If we the continer is VIDEO_CONTAINER_TYPE, we need to check
497
-            // its stream whether exist and is muted to set isVideoMuted
498
-            // in rest of the cases it is false
499
-            let isVideoMuted = false;
500
-            if (videoType == VIDEO_CONTAINER_TYPE)
501
-                isVideoMuted = stream ? stream.isMuted() : true;
502
-
503
-            // show the avatar on large if needed
504
-            container.showAvatar(isVideoMuted);
505
-
506
-            let promise;
507
-
508
-            // do not show stream if video is muted
509
-            // but we still should show watermark
510
-            if (isVideoMuted) {
511
-                this.showWatermark(true);
512
-                promise = Promise.resolve();
513
-            } else {
514
-                promise = container.show();
515
-            }
516
-
517
-            // resolve updateLargeVideo promise after everything is done
518
-            promise.then(resolve);
519
-
520
-            return promise;
521
-        }).then(() => {
522
-            // after everything is done check again if there are any pending
523
-            // new streams.
524
-            this.updateInProcess = false;
525
-            this.scheduleLargeVideoUpdate();
526
-        });
527
-    }
528
-
529
-    /**
530
-     * Update large video.
531
-     * Switches to large video even if previously other container was visible.
532
-     * @param userID the userID of the participant associated with the stream
533
-     * @param {JitsiTrack?} stream new stream
534
-     * @param {string?} videoType new video type
535
-     * @returns {Promise}
536
-     */
537
-    updateLargeVideo (userID, stream, videoType) {
538
-        if (this.newStreamData) {
539
-            this.newStreamData.reject();
540
-        }
541
-
542
-        this.newStreamData = createDeferred();
543
-        this.newStreamData.id = userID;
544
-        this.newStreamData.stream = stream;
545
-        this.newStreamData.videoType = videoType;
546
-
547
-        this.scheduleLargeVideoUpdate();
548
-
549
-        return this.newStreamData.promise;
550
-    }
551
-
552
-    /**
553
-     * Update container size.
554
-     */
555
-    updateContainerSize () {
556
-        this.width = UIUtil.getAvailableVideoWidth();
557
-        this.height = window.innerHeight;
558
-    }
559
-
560
-    /**
561
-     * Resize Large container of specified type.
562
-     * @param {string} type type of container which should be resized.
563
-     * @param {boolean} [animate=false] if resize process should be animated.
564
-     */
565
-    resizeContainer (type, animate = false) {
566
-        let container = this.getContainer(type);
567
-        container.resize(this.width, this.height, animate);
568
-    }
569
-
570
-    /**
571
-     * Resize all Large containers.
572
-     * @param {boolean} animate if resize process should be animated.
573
-     */
574
-    resize (animate) {
575
-        // resize all containers
576
-        Object.keys(this.containers)
577
-            .forEach(type => this.resizeContainer(type, animate));
578
-
579
-        this.$container.animate({
580
-            width: this.width,
581
-            height: this.height
582
-        }, {
583
-            queue: false,
584
-            duration: animate ? 500 : 0
585
-        });
586
-    }
587
-
588
-    /**
589
-     * Enables/disables the filter indicating a video problem to the user.
590
-     *
591
-     * @param enable <tt>true</tt> to enable, <tt>false</tt> to disable
592
-     */
593
-    enableVideoProblemFilter (enable) {
594
-        let container = this.getContainer(this.state);
595
-        container.$video.toggleClass("videoProblemFilter", enable);
596
-    }
597
-
598
-    /**
599
-     * Updates the src of the dominant speaker avatar
600
-     */
601
-    updateAvatar (avatarUrl) {
602
-        $("#dominantSpeakerAvatar").attr('src', avatarUrl);
603
-    }
604
-
605
-    /**
606
-     * Show or hide watermark.
607
-     * @param {boolean} show
608
-     */
609
-    showWatermark (show) {
610
-        $('.watermark').css('visibility', show ? 'visible' : 'hidden');
611
-    }
612
-
613
-    /**
614
-     * Add container of specified type.
615
-     * @param {string} type container type
616
-     * @param {LargeContainer} container container to add.
617
-     */
618
-    addContainer (type, container) {
619
-        if (this.containers[type]) {
620
-            throw new Error(`container of type ${type} already exist`);
621
-        }
622
-
623
-        this.containers[type] = container;
624
-        this.resizeContainer(type);
625
-    }
626
-
627
-    /**
628
-     * Get Large container of specified type.
629
-     * @param {string} type container type.
630
-     * @returns {LargeContainer}
631
-     */
632
-    getContainer (type) {
633
-        let container = this.containers[type];
634
-
635
-        if (!container) {
636
-            throw new Error(`container of type ${type} doesn't exist`);
637
-        }
638
-
639
-        return container;
640
-    }
641
-
642
-    /**
643
-     * Remove Large container of specified type.
644
-     * @param {string} type container type.
645
-     */
646
-    removeContainer (type) {
647
-        if (!this.containers[type]) {
648
-            throw new Error(`container of type ${type} doesn't exist`);
649
-        }
650
-
651
-        delete this.containers[type];
652
-    }
653
-
654
-    /**
655
-     * Show Large container of specified type.
656
-     * Does nothing if such container is already visible.
657
-     * @param {string} type container type.
658
-     * @returns {Promise}
659
-     */
660
-    showContainer (type) {
661
-        if (this.state === type) {
662
-            return Promise.resolve();
663
-        }
664
-
665
-        let oldContainer = this.containers[this.state];
666
-        if (this.state === VIDEO_CONTAINER_TYPE) {
667
-            this.showWatermark(false);
668
-        }
669
-        oldContainer.hide();
670
-
671
-        this.state = type;
672
-        let container = this.getContainer(type);
673
-
674
-        return container.show().then(() => {
675
-            if (type === VIDEO_CONTAINER_TYPE) {
676
-                this.showWatermark(true);
677
-            }
678
-        });
679
-    }
680
-
681
-    /**
682
-     * Changes the flipX state of the local video.
683
-     * @param val {boolean} true if flipped.
684
-     */
685
-    onLocalFlipXChange(val) {
686
-        this.videoContainer.setLocalFlipX(val);
687
-    }
688
-}

+ 5
- 1
modules/UI/videolayout/VideoLayout.js Просмотреть файл

@@ -8,7 +8,8 @@ import UIEvents from "../../../service/UI/UIEvents";
8 8
 import UIUtil from "../util/UIUtil";
9 9
 
10 10
 import RemoteVideo from "./RemoteVideo";
11
-import LargeVideoManager, {VIDEO_CONTAINER_TYPE} from "./LargeVideo";
11
+import LargeVideoManager  from "./LargeVideoManager";
12
+import {VIDEO_CONTAINER_TYPE} from "./VideoContainer";
12 13
 import {SHARED_VIDEO_CONTAINER_TYPE} from '../shared_video/SharedVideo';
13 14
 import LocalVideo from "./LocalVideo";
14 15
 
@@ -102,6 +103,7 @@ var VideoLayout = {
102 103
             });
103 104
         localVideoThumbnail = new LocalVideo(VideoLayout, emitter);
104 105
         // sets default video type of local video
106
+        // FIXME container type is totally different thing from the video type
105 107
         localVideoThumbnail.setVideoType(VIDEO_CONTAINER_TYPE);
106 108
         // if we do not resize the thumbs here, if there is no video device
107 109
         // the local video thumb maybe one pixel
@@ -397,6 +399,7 @@ var VideoLayout = {
397 399
         let videoType = VideoLayout.getRemoteVideoType(id);
398 400
         if (!videoType) {
399 401
             // make video type the default one (camera)
402
+            // FIXME container type is not a video type
400 403
             videoType = VIDEO_CONTAINER_TYPE;
401 404
         }
402 405
         remoteVideo.setVideoType(videoType);
@@ -996,6 +999,7 @@ var VideoLayout = {
996 999
 
997 1000
         if (!isOnLarge || forceUpdate) {
998 1001
             let videoType = this.getRemoteVideoType(id);
1002
+            // FIXME video type is not the same thing as container type
999 1003
             if (id !== currentId && videoType === VIDEO_CONTAINER_TYPE) {
1000 1004
                 eventEmitter.emit(UIEvents.SELECTED_ENDPOINT, id);
1001 1005
             }

Загрузка…
Отмена
Сохранить