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