Browse Source

ref(LargeVideo): move VideoContainer to separate file

VideoContainer is a separate being which implements the LargeContainer
and it's confusing to have it in the same file. This was encouraging to
access private parts of the VideoContainer directly(not through
the interface).
master
paweldomas 9 years ago
parent
commit
e0a05c5908

+ 3
- 1
conference.js View File

@@ -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
 

+ 2
- 380
modules/UI/videolayout/LargeVideo.js View File

@@ -1,388 +1,10 @@
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
-import FilmStrip from './FilmStrip';
8 4
 import Avatar from "../avatar/Avatar";
9 5
 import {createDeferred} from '../../util/helpers';
10
-
11
-const FADE_DURATION_MS = 300;
12
-
13
-export const VIDEO_CONTAINER_TYPE = "camera";
14
-
15
-/**
16
- * Get stream id.
17
- * @param {JitsiTrack?} stream
18
- */
19
-function getStreamOwnerId(stream) {
20
-    if (!stream) {
21
-        return;
22
-    }
23
-    if (stream.isLocal()) { // local stream doesn't have method "getParticipantId"
24
-        return APP.conference.getMyUserId();
25
-    } else {
26
-        return stream.getParticipantId();
27
-    }
28
-}
29
-
30
-/**
31
- * Returns an array of the video dimensions, so that it keeps it's aspect
32
- * ratio and fits available area with it's larger dimension. This method
33
- * ensures that whole video will be visible and can leave empty areas.
34
- *
35
- * @return an array with 2 elements, the video width and the video height
36
- */
37
-function getDesktopVideoSize(videoWidth,
38
-                             videoHeight,
39
-                             videoSpaceWidth,
40
-                             videoSpaceHeight) {
41
-
42
-    let aspectRatio = videoWidth / videoHeight;
43
-
44
-    let availableWidth = Math.max(videoWidth, videoSpaceWidth);
45
-    let availableHeight = Math.max(videoHeight, videoSpaceHeight);
46
-
47
-    videoSpaceHeight -= FilmStrip.getFilmStripHeight();
48
-
49
-    if (availableWidth / aspectRatio >= videoSpaceHeight) {
50
-        availableHeight = videoSpaceHeight;
51
-        availableWidth = availableHeight * aspectRatio;
52
-    }
53
-
54
-    if (availableHeight * aspectRatio >= videoSpaceWidth) {
55
-        availableWidth = videoSpaceWidth;
56
-        availableHeight = availableWidth / aspectRatio;
57
-    }
58
-
59
-    return [ availableWidth, availableHeight ];
60
-}
61
-
62
-
63
-/**
64
- * Returns an array of the video dimensions. It respects the
65
- * VIDEO_LAYOUT_FIT config, to fit the video to the screen, by hiding some parts
66
- * of it, or to fit it to the height or width.
67
- *
68
- * @param videoWidth the original video width
69
- * @param videoHeight the original video height
70
- * @param videoSpaceWidth the width of the video space
71
- * @param videoSpaceHeight the height of the video space
72
- * @return an array with 2 elements, the video width and the video height
73
- */
74
-function getCameraVideoSize(videoWidth,
75
-                            videoHeight,
76
-                            videoSpaceWidth,
77
-                            videoSpaceHeight) {
78
-
79
-    let aspectRatio = videoWidth / videoHeight;
80
-
81
-    let availableWidth = videoWidth;
82
-    let availableHeight = videoHeight;
83
-
84
-    if (interfaceConfig.VIDEO_LAYOUT_FIT == 'height') {
85
-        availableHeight = videoSpaceHeight;
86
-        availableWidth = availableHeight*aspectRatio;
87
-    }
88
-    else if (interfaceConfig.VIDEO_LAYOUT_FIT == 'width') {
89
-        availableWidth = videoSpaceWidth;
90
-        availableHeight = availableWidth/aspectRatio;
91
-    }
92
-    else if (interfaceConfig.VIDEO_LAYOUT_FIT == 'both') {
93
-        availableWidth = Math.max(videoWidth, videoSpaceWidth);
94
-        availableHeight = Math.max(videoHeight, videoSpaceHeight);
95
-
96
-        if (availableWidth / aspectRatio < videoSpaceHeight) {
97
-            availableHeight = videoSpaceHeight;
98
-            availableWidth = availableHeight * aspectRatio;
99
-        }
100
-
101
-        if (availableHeight * aspectRatio < videoSpaceWidth) {
102
-            availableWidth = videoSpaceWidth;
103
-            availableHeight = availableWidth / aspectRatio;
104
-        }
105
-    }
106
-
107
-
108
-    return [ availableWidth, availableHeight ];
109
-}
110
-
111
-/**
112
- * Returns an array of the video horizontal and vertical indents,
113
- * so that if fits its parent.
114
- *
115
- * @return an array with 2 elements, the horizontal indent and the vertical
116
- * indent
117
- */
118
-function getCameraVideoPosition(videoWidth,
119
-                                videoHeight,
120
-                                videoSpaceWidth,
121
-                                videoSpaceHeight) {
122
-    // Parent height isn't completely calculated when we position the video in
123
-    // full screen mode and this is why we use the screen height in this case.
124
-    // Need to think it further at some point and implement it properly.
125
-    if (UIUtil.isFullScreen()) {
126
-        videoSpaceHeight = window.innerHeight;
127
-    }
128
-
129
-    let horizontalIndent = (videoSpaceWidth - videoWidth) / 2;
130
-    let verticalIndent = (videoSpaceHeight - videoHeight) / 2;
131
-
132
-    return { horizontalIndent, verticalIndent };
133
-}
134
-
135
-/**
136
- * Returns an array of the video horizontal and vertical indents.
137
- * Centers horizontally and top aligns vertically.
138
- *
139
- * @return an array with 2 elements, the horizontal indent and the vertical
140
- * indent
141
- */
142
-function getDesktopVideoPosition(videoWidth,
143
-                                 videoHeight,
144
-                                 videoSpaceWidth,
145
-                                 videoSpaceHeight) {
146
-
147
-    let horizontalIndent = (videoSpaceWidth - videoWidth) / 2;
148
-
149
-    let verticalIndent = 0;// Top aligned
150
-
151
-    return { horizontalIndent, verticalIndent };
152
-}
153
-
154
-/**
155
- * Container for user video.
156
- */
157
-class VideoContainer extends LargeContainer {
158
-    // FIXME: With Temasys we have to re-select everytime
159
-    get $video () {
160
-        return $('#largeVideo');
161
-    }
162
-
163
-    get id () {
164
-        return getStreamOwnerId(this.stream);
165
-    }
166
-
167
-    constructor (onPlay, emitter) {
168
-        super();
169
-        this.stream = null;
170
-        this.videoType = null;
171
-        this.localFlipX = true;
172
-        this.emitter = emitter;
173
-
174
-        this.isVisible = false;
175
-
176
-        this.$avatar = $('#dominantSpeaker');
177
-        this.$wrapper = $('#largeVideoWrapper');
178
-
179
-        this.avatarHeight = $("#dominantSpeakerAvatar").height();
180
-
181
-        // This does not work with Temasys plugin - has to be a property to be
182
-        // copied between new <object> elements
183
-        //this.$video.on('play', onPlay);
184
-        this.$video[0].onplay = onPlay;
185
-    }
186
-
187
-    /**
188
-     * Get size of video element.
189
-     * @returns {{width, height}}
190
-     */
191
-    getStreamSize () {
192
-        let video = this.$video[0];
193
-        return {
194
-            width: video.videoWidth,
195
-            height: video.videoHeight
196
-        };
197
-    }
198
-
199
-    /**
200
-     * Calculate optimal video size for specified container size.
201
-     * @param {number} containerWidth container width
202
-     * @param {number} containerHeight container height
203
-     * @returns {{availableWidth, availableHeight}}
204
-     */
205
-    getVideoSize (containerWidth, containerHeight) {
206
-        let { width, height } = this.getStreamSize();
207
-        if (this.stream && this.isScreenSharing()) {
208
-            return getDesktopVideoSize( width,
209
-                                        height,
210
-                                        containerWidth,
211
-                                        containerHeight);
212
-        } else {
213
-            return getCameraVideoSize(  width,
214
-                                        height,
215
-                                        containerWidth,
216
-                                        containerHeight);
217
-        }
218
-    }
219
-
220
-    /**
221
-     * Calculate optimal video position (offset for top left corner)
222
-     * for specified video size and container size.
223
-     * @param {number} width video width
224
-     * @param {number} height video height
225
-     * @param {number} containerWidth container width
226
-     * @param {number} containerHeight container height
227
-     * @returns {{horizontalIndent, verticalIndent}}
228
-     */
229
-    getVideoPosition (width, height, containerWidth, containerHeight) {
230
-        if (this.stream && this.isScreenSharing()) {
231
-            return getDesktopVideoPosition( width,
232
-                                            height,
233
-                                            containerWidth,
234
-                                            containerHeight);
235
-        } else {
236
-            return getCameraVideoPosition(  width,
237
-                                            height,
238
-                                            containerWidth,
239
-                                            containerHeight);
240
-        }
241
-    }
242
-
243
-    resize (containerWidth, containerHeight, animate = false) {
244
-        let [width, height]
245
-            = this.getVideoSize(containerWidth, containerHeight);
246
-        let { horizontalIndent, verticalIndent }
247
-            = this.getVideoPosition(width, height,
248
-                                    containerWidth, containerHeight);
249
-
250
-        // update avatar position
251
-        let top = containerHeight / 2 - this.avatarHeight / 4 * 3;
252
-
253
-        this.$avatar.css('top', top);
254
-
255
-        this.$wrapper.animate({
256
-            width: width,
257
-            height: height,
258
-
259
-            top: verticalIndent,
260
-            bottom: verticalIndent,
261
-
262
-            left: horizontalIndent,
263
-            right: horizontalIndent
264
-        }, {
265
-            queue: false,
266
-            duration: animate ? 500 : 0
267
-        });
268
-    }
269
-
270
-    /**
271
-     * Update video stream.
272
-     * @param {JitsiTrack?} stream new stream
273
-     * @param {string} videoType video type
274
-     */
275
-    setStream (stream, videoType) {
276
-        // detach old stream
277
-        if (this.stream) {
278
-            this.stream.detach(this.$video[0]);
279
-        }
280
-
281
-        this.stream = stream;
282
-        this.videoType = videoType;
283
-
284
-        if (!stream) {
285
-            return;
286
-        }
287
-
288
-        stream.attach(this.$video[0]);
289
-        let flipX = stream.isLocal() && this.localFlipX;
290
-        this.$video.css({
291
-            transform: flipX ? 'scaleX(-1)' : 'none'
292
-        });
293
-    }
294
-
295
-    /**
296
-     * Changes the flipX state of the local video.
297
-     * @param val {boolean} true if flipped.
298
-     */
299
-    setLocalFlipX(val) {
300
-        this.localFlipX = val;
301
-        if(!this.$video || !this.stream || !this.stream.isLocal())
302
-            return;
303
-        this.$video.css({
304
-            transform: this.localFlipX ? 'scaleX(-1)' : 'none'
305
-        });
306
-    }
307
-
308
-    /**
309
-     * Check if current video stream is screen sharing.
310
-     * @returns {boolean}
311
-     */
312
-    isScreenSharing () {
313
-        return this.videoType === 'desktop';
314
-    }
315
-
316
-    /**
317
-     * Show or hide user avatar.
318
-     * @param {boolean} show
319
-     */
320
-    showAvatar (show) {
321
-        // TO FIX: Video background need to be black, so that we don't have a
322
-        // flickering effect when scrolling between videos and have the screen
323
-        // move to grey before going back to video. Avatars though can have the
324
-        // default background set.
325
-        // In order to fix this code we need to introduce video background or
326
-        // find a workaround for the video flickering.
327
-        $("#largeVideoContainer").css("background",
328
-            (show) ? interfaceConfig.DEFAULT_BACKGROUND : "#000");
329
-
330
-        this.$avatar.css("visibility", show ? "visible" : "hidden");
331
-
332
-        this.emitter.emit(UIEvents.LARGE_VIDEO_AVATAR_DISPLAYED, show);
333
-    }
334
-
335
-    // We are doing fadeOut/fadeIn animations on parent div which wraps
336
-    // largeVideo, because when Temasys plugin is in use it replaces
337
-    // <video> elements with plugin <object> tag. In Safari jQuery is
338
-    // unable to store values on this plugin object which breaks all
339
-    // animation effects performed on it directly.
340
-
341
-    show () {
342
-        // its already visible
343
-        if (this.isVisible) {
344
-            return Promise.resolve();
345
-        }
346
-
347
-        let $wrapper = this.$wrapper;
348
-        return new Promise((resolve) => {
349
-            this.$wrapper.css('visibility', 'visible').fadeTo(
350
-                FADE_DURATION_MS,
351
-                1,
352
-                () => {
353
-                    this.isVisible = true;
354
-                    resolve();
355
-                }
356
-            );
357
-        });
358
-    }
359
-
360
-    hide () {
361
-        // as the container is hidden/replaced by another container
362
-        // hide its avatar
363
-        this.showAvatar(false);
364
-
365
-        // its already hidden
366
-        if (!this.isVisible) {
367
-            return Promise.resolve();
368
-        }
369
-
370
-        return new Promise((resolve) => {
371
-            this.$wrapper.fadeTo(FADE_DURATION_MS, 0, () => {
372
-                this.$wrapper.css('visibility', 'hidden');
373
-                this.isVisible = false;
374
-                resolve();
375
-            });
376
-        });
377
-    }
378
-
379
-    /**
380
-     * @return {boolean} switch on dominant speaker event if on stage.
381
-     */
382
-    stayOnStage () {
383
-        return false;
384
-    }
385
-}
6
+import UIUtil from "../util/UIUtil";
7
+import {VideoContainer, VIDEO_CONTAINER_TYPE} from "./VideoContainer";
386 8
 
387 9
 /**
388 10
  * Manager for all Large containers.

+ 385
- 0
modules/UI/videolayout/VideoContainer.js View File

@@ -0,0 +1,385 @@
1
+/* global $, APP, interfaceConfig */
2
+/* jshint -W101 */
3
+
4
+import FilmStrip from './FilmStrip';
5
+import LargeContainer from './LargeContainer';
6
+import UIEvents from "../../../service/UI/UIEvents";
7
+import UIUtil from "../util/UIUtil";
8
+
9
+// FIXME should be 'video'
10
+export const VIDEO_CONTAINER_TYPE = "camera";
11
+
12
+const FADE_DURATION_MS = 300;
13
+
14
+/**
15
+ * Get stream id.
16
+ * @param {JitsiTrack?} stream
17
+ */
18
+function getStreamOwnerId(stream) {
19
+    if (!stream) {
20
+        return;
21
+    }
22
+    // local stream doesn't have method "getParticipantId"
23
+    if (stream.isLocal()) {
24
+        return APP.conference.getMyUserId();
25
+    } else {
26
+        return stream.getParticipantId();
27
+    }
28
+}
29
+
30
+/**
31
+ * Returns an array of the video dimensions, so that it keeps it's aspect
32
+ * ratio and fits available area with it's larger dimension. This method
33
+ * ensures that whole video will be visible and can leave empty areas.
34
+ *
35
+ * @return an array with 2 elements, the video width and the video height
36
+ */
37
+function getDesktopVideoSize(videoWidth,
38
+                             videoHeight,
39
+                             videoSpaceWidth,
40
+                             videoSpaceHeight) {
41
+
42
+    let aspectRatio = videoWidth / videoHeight;
43
+
44
+    let availableWidth = Math.max(videoWidth, videoSpaceWidth);
45
+    let availableHeight = Math.max(videoHeight, videoSpaceHeight);
46
+
47
+    videoSpaceHeight -= FilmStrip.getFilmStripHeight();
48
+
49
+    if (availableWidth / aspectRatio >= videoSpaceHeight) {
50
+        availableHeight = videoSpaceHeight;
51
+        availableWidth = availableHeight * aspectRatio;
52
+    }
53
+
54
+    if (availableHeight * aspectRatio >= videoSpaceWidth) {
55
+        availableWidth = videoSpaceWidth;
56
+        availableHeight = availableWidth / aspectRatio;
57
+    }
58
+
59
+    return [ availableWidth, availableHeight ];
60
+}
61
+
62
+
63
+/**
64
+ * Returns an array of the video dimensions. It respects the
65
+ * VIDEO_LAYOUT_FIT config, to fit the video to the screen, by hiding some parts
66
+ * of it, or to fit it to the height or width.
67
+ *
68
+ * @param videoWidth the original video width
69
+ * @param videoHeight the original video height
70
+ * @param videoSpaceWidth the width of the video space
71
+ * @param videoSpaceHeight the height of the video space
72
+ * @return an array with 2 elements, the video width and the video height
73
+ */
74
+function getCameraVideoSize(videoWidth,
75
+                            videoHeight,
76
+                            videoSpaceWidth,
77
+                            videoSpaceHeight) {
78
+
79
+    let aspectRatio = videoWidth / videoHeight;
80
+
81
+    let availableWidth = videoWidth;
82
+    let availableHeight = videoHeight;
83
+
84
+    if (interfaceConfig.VIDEO_LAYOUT_FIT == 'height') {
85
+        availableHeight = videoSpaceHeight;
86
+        availableWidth = availableHeight*aspectRatio;
87
+    }
88
+    else if (interfaceConfig.VIDEO_LAYOUT_FIT == 'width') {
89
+        availableWidth = videoSpaceWidth;
90
+        availableHeight = availableWidth/aspectRatio;
91
+    }
92
+    else if (interfaceConfig.VIDEO_LAYOUT_FIT == 'both') {
93
+        availableWidth = Math.max(videoWidth, videoSpaceWidth);
94
+        availableHeight = Math.max(videoHeight, videoSpaceHeight);
95
+
96
+        if (availableWidth / aspectRatio < videoSpaceHeight) {
97
+            availableHeight = videoSpaceHeight;
98
+            availableWidth = availableHeight * aspectRatio;
99
+        }
100
+
101
+        if (availableHeight * aspectRatio < videoSpaceWidth) {
102
+            availableWidth = videoSpaceWidth;
103
+            availableHeight = availableWidth / aspectRatio;
104
+        }
105
+    }
106
+
107
+
108
+    return [ availableWidth, availableHeight ];
109
+}
110
+
111
+/**
112
+ * Returns an array of the video horizontal and vertical indents,
113
+ * so that if fits its parent.
114
+ *
115
+ * @return an array with 2 elements, the horizontal indent and the vertical
116
+ * indent
117
+ */
118
+function getCameraVideoPosition(videoWidth,
119
+                                videoHeight,
120
+                                videoSpaceWidth,
121
+                                videoSpaceHeight) {
122
+    // Parent height isn't completely calculated when we position the video in
123
+    // full screen mode and this is why we use the screen height in this case.
124
+    // Need to think it further at some point and implement it properly.
125
+    if (UIUtil.isFullScreen()) {
126
+        videoSpaceHeight = window.innerHeight;
127
+    }
128
+
129
+    let horizontalIndent = (videoSpaceWidth - videoWidth) / 2;
130
+    let verticalIndent = (videoSpaceHeight - videoHeight) / 2;
131
+
132
+    return { horizontalIndent, verticalIndent };
133
+}
134
+
135
+/**
136
+ * Returns an array of the video horizontal and vertical indents.
137
+ * Centers horizontally and top aligns vertically.
138
+ *
139
+ * @return an array with 2 elements, the horizontal indent and the vertical
140
+ * indent
141
+ */
142
+function getDesktopVideoPosition(videoWidth,
143
+                                 videoHeight,
144
+                                 videoSpaceWidth,
145
+                                 videoSpaceHeight) {
146
+
147
+    let horizontalIndent = (videoSpaceWidth - videoWidth) / 2;
148
+
149
+    let verticalIndent = 0;// Top aligned
150
+
151
+    return { horizontalIndent, verticalIndent };
152
+}
153
+
154
+/**
155
+ * Container for user video.
156
+ */
157
+export class VideoContainer extends LargeContainer {
158
+    // FIXME: With Temasys we have to re-select everytime
159
+    get $video () {
160
+        return $('#largeVideo');
161
+    }
162
+
163
+    get id () {
164
+        return getStreamOwnerId(this.stream);
165
+    }
166
+
167
+    constructor (onPlay, emitter) {
168
+        super();
169
+        this.stream = null;
170
+        this.videoType = null;
171
+        this.localFlipX = true;
172
+        this.emitter = emitter;
173
+
174
+        this.isVisible = false;
175
+
176
+        this.$avatar = $('#dominantSpeaker');
177
+        this.$wrapper = $('#largeVideoWrapper');
178
+
179
+        this.avatarHeight = $("#dominantSpeakerAvatar").height();
180
+
181
+        // This does not work with Temasys plugin - has to be a property to be
182
+        // copied between new <object> elements
183
+        //this.$video.on('play', onPlay);
184
+        this.$video[0].onplay = onPlay;
185
+    }
186
+
187
+    /**
188
+     * Get size of video element.
189
+     * @returns {{width, height}}
190
+     */
191
+    getStreamSize () {
192
+        let video = this.$video[0];
193
+        return {
194
+            width: video.videoWidth,
195
+            height: video.videoHeight
196
+        };
197
+    }
198
+
199
+    /**
200
+     * Calculate optimal video size for specified container size.
201
+     * @param {number} containerWidth container width
202
+     * @param {number} containerHeight container height
203
+     * @returns {{availableWidth, availableHeight}}
204
+     */
205
+    getVideoSize (containerWidth, containerHeight) {
206
+        let { width, height } = this.getStreamSize();
207
+        if (this.stream && this.isScreenSharing()) {
208
+            return getDesktopVideoSize( width,
209
+                height,
210
+                containerWidth,
211
+                containerHeight);
212
+        } else {
213
+            return getCameraVideoSize(  width,
214
+                height,
215
+                containerWidth,
216
+                containerHeight);
217
+        }
218
+    }
219
+
220
+    /**
221
+     * Calculate optimal video position (offset for top left corner)
222
+     * for specified video size and container size.
223
+     * @param {number} width video width
224
+     * @param {number} height video height
225
+     * @param {number} containerWidth container width
226
+     * @param {number} containerHeight container height
227
+     * @returns {{horizontalIndent, verticalIndent}}
228
+     */
229
+    getVideoPosition (width, height, containerWidth, containerHeight) {
230
+        if (this.stream && this.isScreenSharing()) {
231
+            return getDesktopVideoPosition( width,
232
+                height,
233
+                containerWidth,
234
+                containerHeight);
235
+        } else {
236
+            return getCameraVideoPosition(  width,
237
+                height,
238
+                containerWidth,
239
+                containerHeight);
240
+        }
241
+    }
242
+
243
+    resize (containerWidth, containerHeight, animate = false) {
244
+        let [width, height]
245
+            = this.getVideoSize(containerWidth, containerHeight);
246
+        let { horizontalIndent, verticalIndent }
247
+            = this.getVideoPosition(width, height,
248
+            containerWidth, containerHeight);
249
+
250
+        // update avatar position
251
+        let top = containerHeight / 2 - this.avatarHeight / 4 * 3;
252
+
253
+        this.$avatar.css('top', top);
254
+
255
+        this.$wrapper.animate({
256
+            width: width,
257
+            height: height,
258
+
259
+            top: verticalIndent,
260
+            bottom: verticalIndent,
261
+
262
+            left: horizontalIndent,
263
+            right: horizontalIndent
264
+        }, {
265
+            queue: false,
266
+            duration: animate ? 500 : 0
267
+        });
268
+    }
269
+
270
+    /**
271
+     * Update video stream.
272
+     * @param {JitsiTrack?} stream new stream
273
+     * @param {string} videoType video type
274
+     */
275
+    setStream (stream, videoType) {
276
+        // detach old stream
277
+        if (this.stream) {
278
+            this.stream.detach(this.$video[0]);
279
+        }
280
+
281
+        this.stream = stream;
282
+        this.videoType = videoType;
283
+
284
+        if (!stream) {
285
+            return;
286
+        }
287
+
288
+        stream.attach(this.$video[0]);
289
+        let flipX = stream.isLocal() && this.localFlipX;
290
+        this.$video.css({
291
+            transform: flipX ? 'scaleX(-1)' : 'none'
292
+        });
293
+    }
294
+
295
+    /**
296
+     * Changes the flipX state of the local video.
297
+     * @param val {boolean} true if flipped.
298
+     */
299
+    setLocalFlipX(val) {
300
+        this.localFlipX = val;
301
+        if(!this.$video || !this.stream || !this.stream.isLocal())
302
+            return;
303
+        this.$video.css({
304
+            transform: this.localFlipX ? 'scaleX(-1)' : 'none'
305
+        });
306
+    }
307
+
308
+    /**
309
+     * Check if current video stream is screen sharing.
310
+     * @returns {boolean}
311
+     */
312
+    isScreenSharing () {
313
+        return this.videoType === 'desktop';
314
+    }
315
+
316
+    /**
317
+     * Show or hide user avatar.
318
+     * @param {boolean} show
319
+     */
320
+    showAvatar (show) {
321
+        // TO FIX: Video background need to be black, so that we don't have a
322
+        // flickering effect when scrolling between videos and have the screen
323
+        // move to grey before going back to video. Avatars though can have the
324
+        // default background set.
325
+        // In order to fix this code we need to introduce video background or
326
+        // find a workaround for the video flickering.
327
+        $("#largeVideoContainer").css("background",
328
+            (show) ? interfaceConfig.DEFAULT_BACKGROUND : "#000");
329
+
330
+        this.$avatar.css("visibility", show ? "visible" : "hidden");
331
+
332
+        this.emitter.emit(UIEvents.LARGE_VIDEO_AVATAR_DISPLAYED, show);
333
+    }
334
+
335
+    // We are doing fadeOut/fadeIn animations on parent div which wraps
336
+    // largeVideo, because when Temasys plugin is in use it replaces
337
+    // <video> elements with plugin <object> tag. In Safari jQuery is
338
+    // unable to store values on this plugin object which breaks all
339
+    // animation effects performed on it directly.
340
+
341
+    show () {
342
+        // its already visible
343
+        if (this.isVisible) {
344
+            return Promise.resolve();
345
+        }
346
+
347
+        let $wrapper = this.$wrapper;
348
+        return new Promise((resolve) => {
349
+            this.$wrapper.css('visibility', 'visible').fadeTo(
350
+                FADE_DURATION_MS,
351
+                1,
352
+                () => {
353
+                    this.isVisible = true;
354
+                    resolve();
355
+                }
356
+            );
357
+        });
358
+    }
359
+
360
+    hide () {
361
+        // as the container is hidden/replaced by another container
362
+        // hide its avatar
363
+        this.showAvatar(false);
364
+
365
+        // its already hidden
366
+        if (!this.isVisible) {
367
+            return Promise.resolve();
368
+        }
369
+
370
+        return new Promise((resolve) => {
371
+            this.$wrapper.fadeTo(FADE_DURATION_MS, 0, () => {
372
+                this.$wrapper.css('visibility', 'hidden');
373
+                this.isVisible = false;
374
+                resolve();
375
+            });
376
+        });
377
+    }
378
+
379
+    /**
380
+     * @return {boolean} switch on dominant speaker event if on stage.
381
+     */
382
+    stayOnStage () {
383
+        return false;
384
+    }
385
+}

+ 5
- 1
modules/UI/videolayout/VideoLayout.js View File

@@ -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 "./LargeVideo";
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
             }

Loading…
Cancel
Save