Browse Source

fix(video-label): Display based on video dimensions in LargeVideoManager

In its current implementation, the VideoStatusLabel shows HD based on peer
connection stats. These stats will be available on temasys browsers soon but
will remain unavailable on Firefox, which does not collect height/width stats.
To support VideoStatusLabel showing cross-browser, move the high-definition
detection out of stat sniffing and instead check the video element itself using
an interval in LargeVideoManager. (An interval was used because the temasys
video object does not support the onresize event.) Also, add a cleanup path from
conference.web to LargeVideoManager to remove the interval.
j8
Leonard Kim 8 years ago
parent
commit
a88409bbfa

+ 3
- 1
config.js View File

76
     'During that time service will not be available. ' +
76
     'During that time service will not be available. ' +
77
     'Apologise for inconvenience.',*/
77
     'Apologise for inconvenience.',*/
78
     disableThirdPartyRequests: false,
78
     disableThirdPartyRequests: false,
79
-    minHDHeight: 540,
79
+    // The minumum value a video's height or width can be, whichever is
80
+    // smaller, to be considered high-definition.
81
+    minHDSize: 540,
80
     // If true - all users without token will be considered guests and all users
82
     // If true - all users without token will be considered guests and all users
81
     // with token will be considered non-guests. Only guests will be allowed to
83
     // with token will be considered non-guests. Only guests will be allowed to
82
     // edit their profile.
84
     // edit their profile.

+ 9
- 0
modules/UI/UI.js View File

367
     callee && UI.showRingOverlay();
367
     callee && UI.showRingOverlay();
368
 };
368
 };
369
 
369
 
370
+/**
371
+ * Invokes cleanup of any deferred execution within relevant UI modules.
372
+ *
373
+ * @returns {void}
374
+ */
375
+UI.stopDaemons = () => {
376
+    VideoLayout.resetLargeVideo();
377
+};
378
+
370
 /**
379
 /**
371
  * Setup some UI event listeners.
380
  * Setup some UI event listeners.
372
  */
381
  */

+ 1
- 36
modules/UI/videolayout/ConnectionIndicator.js View File

1
-/* global $, APP, config */
1
+/* global $, APP */
2
 /* jshint -W101 */
2
 /* jshint -W101 */
3
-import {
4
-    setLargeVideoHDStatus
5
-} from '../../../react/features/base/conference';
6
 
3
 
7
 import JitsiPopover from "../util/JitsiPopover";
4
 import JitsiPopover from "../util/JitsiPopover";
8
-import VideoLayout from "./VideoLayout";
9
 import UIUtil from "../util/UIUtil";
5
 import UIUtil from "../util/UIUtil";
10
 
6
 
11
 /**
7
 /**
38
     this.bitrate = null;
34
     this.bitrate = null;
39
     this.showMoreValue = false;
35
     this.showMoreValue = false;
40
     this.resolution = null;
36
     this.resolution = null;
41
-    this.isResolutionHD = null;
42
     this.transport = [];
37
     this.transport = [];
43
     this.framerate = null;
38
     this.framerate = null;
44
     this.popover = null;
39
     this.popover = null;
405
     let width = qualityToWidth.find(x => percent >= x.percent);
400
     let width = qualityToWidth.find(x => percent >= x.percent);
406
     this.fullIcon.style.width = width.width;
401
     this.fullIcon.style.width = width.width;
407
 
402
 
408
-    if (object && typeof object.isResolutionHD === 'boolean') {
409
-        this.isResolutionHD = object.isResolutionHD;
410
-    }
411
-    this.updateResolutionIndicator();
412
     this.updatePopoverData();
403
     this.updatePopoverData();
413
 };
404
 };
414
 
405
 
418
  */
409
  */
419
 ConnectionIndicator.prototype.updateResolution = function (resolution) {
410
 ConnectionIndicator.prototype.updateResolution = function (resolution) {
420
     this.resolution = resolution;
411
     this.resolution = resolution;
421
-    this.updateResolutionIndicator();
422
     this.updatePopoverData();
412
     this.updatePopoverData();
423
 };
413
 };
424
 
414
 
461
         this.popover.forceHide();
451
         this.popover.forceHide();
462
 };
452
 };
463
 
453
 
464
-/**
465
- * Updates the resolution indicator.
466
- */
467
-ConnectionIndicator.prototype.updateResolutionIndicator = function () {
468
-
469
-    if (this.id !== null
470
-        && VideoLayout.isCurrentlyOnLarge(this.id)) {
471
-
472
-        let showResolutionLabel = false;
473
-
474
-        if (this.isResolutionHD !== null)
475
-            showResolutionLabel = this.isResolutionHD;
476
-        else if (this.resolution !== null) {
477
-            let resolutions = this.resolution || {};
478
-            Object.keys(resolutions).map(function (ssrc) {
479
-                    const { height } = resolutions[ssrc];
480
-                    if (height >= config.minHDHeight)
481
-                        showResolutionLabel = true;
482
-                });
483
-        }
484
-
485
-        APP.store.dispatch(setLargeVideoHDStatus(showResolutionLabel));
486
-    }
487
-};
488
-
489
 /**
454
 /**
490
  * Adds a hover listener to the popover.
455
  * Adds a hover listener to the popover.
491
  */
456
  */

+ 45
- 1
modules/UI/videolayout/LargeVideoManager.js View File

1
-/* global $, APP, JitsiMeetJS */
1
+/* global $, APP, config, JitsiMeetJS */
2
 const logger = require("jitsi-meet-logger").getLogger(__filename);
2
 const logger = require("jitsi-meet-logger").getLogger(__filename);
3
 
3
 
4
+import { setLargeVideoHDStatus } from '../../../react/features/base/conference';
5
+
4
 import Avatar from "../avatar/Avatar";
6
 import Avatar from "../avatar/Avatar";
5
 import {createDeferred} from '../../util/helpers';
7
 import {createDeferred} from '../../util/helpers';
6
 import UIEvents from "../../../service/UI/UIEvents";
8
 import UIEvents from "../../../service/UI/UIEvents";
12
 const ParticipantConnectionStatus
14
 const ParticipantConnectionStatus
13
     = JitsiMeetJS.constants.participantConnectionStatus;
15
     = JitsiMeetJS.constants.participantConnectionStatus;
14
 const DESKTOP_CONTAINER_TYPE = 'desktop';
16
 const DESKTOP_CONTAINER_TYPE = 'desktop';
17
+/**
18
+ * The time interval in milliseconds to check the video resolution of the video
19
+ * being displayed.
20
+ *
21
+ * @type {number}
22
+ */
23
+const VIDEO_RESOLUTION_POLL_INTERVAL = 2000;
15
 
24
 
16
 /**
25
 /**
17
  * Manager for all Large containers.
26
  * Manager for all Large containers.
49
             e => this.onHoverIn(e),
58
             e => this.onHoverIn(e),
50
             e => this.onHoverOut(e)
59
             e => this.onHoverOut(e)
51
         );
60
         );
61
+
62
+        // TODO Use the onresize event when temasys video objects support it.
63
+        /**
64
+         * The interval for checking if the displayed video resolution is or is
65
+         * not high-definition.
66
+         *
67
+         * @private
68
+         * @type {timeoutId}
69
+         */
70
+        this._updateVideoResolutionInterval = window.setInterval(
71
+            () => this._updateVideoResolutionStatus(),
72
+            VIDEO_RESOLUTION_POLL_INTERVAL);
73
+    }
74
+
75
+    /**
76
+     * Stops any polling intervals on the instance.
77
+     *
78
+     * @returns {void}
79
+     */
80
+    destroy() {
81
+        window.clearInterval(this._updateVideoResolutionInterval);
52
     }
82
     }
53
 
83
 
54
     onHoverIn (e) {
84
     onHoverIn (e) {
517
     onLocalFlipXChange(val) {
547
     onLocalFlipXChange(val) {
518
         this.videoContainer.setLocalFlipX(val);
548
         this.videoContainer.setLocalFlipX(val);
519
     }
549
     }
550
+
551
+    /**
552
+     * Dispatches an action to update the known resolution state of the
553
+     * large video.
554
+     *
555
+     * @private
556
+     * @returns {void}
557
+     */
558
+    _updateVideoResolutionStatus() {
559
+        const { height, width } = this.videoContainer.getStreamSize();
560
+        const isCurrentlyHD = Math.min(height, width) >= config.minHDSize;
561
+
562
+        APP.store.dispatch(setLargeVideoHDStatus(isCurrentlyHD));
563
+    }
520
 }
564
 }

+ 14
- 0
modules/UI/videolayout/VideoLayout.js View File

111
         this.registerListeners();
111
         this.registerListeners();
112
     },
112
     },
113
 
113
 
114
+    /**
115
+     * Cleans up any existing largeVideo instance.
116
+     *
117
+     * @returns {void}
118
+     */
119
+    resetLargeVideo() {
120
+        if (largeVideo) {
121
+            largeVideo.destroy();
122
+        }
123
+        largeVideo = null;
124
+    },
125
+
114
     /**
126
     /**
115
      * Registering listeners for UI events in Video layout component.
127
      * Registering listeners for UI events in Video layout component.
116
      *
128
      *
132
     },
144
     },
133
 
145
 
134
     initLargeVideo () {
146
     initLargeVideo () {
147
+        this.resetLargeVideo();
148
+
135
         largeVideo = new LargeVideoManager(eventEmitter);
149
         largeVideo = new LargeVideoManager(eventEmitter);
136
         if(localFlipX) {
150
         if(localFlipX) {
137
             largeVideo.onLocalFlipXChange(localFlipX);
151
             largeVideo.onLocalFlipXChange(localFlipX);

+ 1
- 0
react/features/conference/components/Conference.web.js View File

51
      * @inheritdoc
51
      * @inheritdoc
52
      */
52
      */
53
     componentWillUnmount() {
53
     componentWillUnmount() {
54
+        APP.UI.stopDaemons();
54
         APP.UI.unregisterListeners();
55
         APP.UI.unregisterListeners();
55
         APP.UI.unbindEvents();
56
         APP.UI.unbindEvents();
56
 
57
 

Loading…
Cancel
Save