瀏覽代碼

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 年之前
父節點
當前提交
a88409bbfa

+ 3
- 1
config.js 查看文件

@@ -76,7 +76,9 @@ var config = { // eslint-disable-line no-unused-vars
76 76
     'During that time service will not be available. ' +
77 77
     'Apologise for inconvenience.',*/
78 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 82
     // If true - all users without token will be considered guests and all users
81 83
     // with token will be considered non-guests. Only guests will be allowed to
82 84
     // edit their profile.

+ 9
- 0
modules/UI/UI.js 查看文件

@@ -367,6 +367,15 @@ UI.start = function () {
367 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 380
  * Setup some UI event listeners.
372 381
  */

+ 1
- 36
modules/UI/videolayout/ConnectionIndicator.js 查看文件

@@ -1,11 +1,7 @@
1
-/* global $, APP, config */
1
+/* global $, APP */
2 2
 /* jshint -W101 */
3
-import {
4
-    setLargeVideoHDStatus
5
-} from '../../../react/features/base/conference';
6 3
 
7 4
 import JitsiPopover from "../util/JitsiPopover";
8
-import VideoLayout from "./VideoLayout";
9 5
 import UIUtil from "../util/UIUtil";
10 6
 
11 7
 /**
@@ -38,7 +34,6 @@ function ConnectionIndicator(videoContainer, videoId) {
38 34
     this.bitrate = null;
39 35
     this.showMoreValue = false;
40 36
     this.resolution = null;
41
-    this.isResolutionHD = null;
42 37
     this.transport = [];
43 38
     this.framerate = null;
44 39
     this.popover = null;
@@ -405,10 +400,6 @@ ConnectionIndicator.prototype.updateConnectionQuality =
405 400
     let width = qualityToWidth.find(x => percent >= x.percent);
406 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 403
     this.updatePopoverData();
413 404
 };
414 405
 
@@ -418,7 +409,6 @@ ConnectionIndicator.prototype.updateConnectionQuality =
418 409
  */
419 410
 ConnectionIndicator.prototype.updateResolution = function (resolution) {
420 411
     this.resolution = resolution;
421
-    this.updateResolutionIndicator();
422 412
     this.updatePopoverData();
423 413
 };
424 414
 
@@ -461,31 +451,6 @@ ConnectionIndicator.prototype.hideIndicator = function () {
461 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 455
  * Adds a hover listener to the popover.
491 456
  */

+ 45
- 1
modules/UI/videolayout/LargeVideoManager.js 查看文件

@@ -1,6 +1,8 @@
1
-/* global $, APP, JitsiMeetJS */
1
+/* global $, APP, config, JitsiMeetJS */
2 2
 const logger = require("jitsi-meet-logger").getLogger(__filename);
3 3
 
4
+import { setLargeVideoHDStatus } from '../../../react/features/base/conference';
5
+
4 6
 import Avatar from "../avatar/Avatar";
5 7
 import {createDeferred} from '../../util/helpers';
6 8
 import UIEvents from "../../../service/UI/UIEvents";
@@ -12,6 +14,13 @@ import AudioLevels from "../audio_levels/AudioLevels";
12 14
 const ParticipantConnectionStatus
13 15
     = JitsiMeetJS.constants.participantConnectionStatus;
14 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 26
  * Manager for all Large containers.
@@ -49,6 +58,27 @@ export default class LargeVideoManager {
49 58
             e => this.onHoverIn(e),
50 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 84
     onHoverIn (e) {
@@ -517,4 +547,18 @@ export default class LargeVideoManager {
517 547
     onLocalFlipXChange(val) {
518 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 查看文件

@@ -111,6 +111,18 @@ var VideoLayout = {
111 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 127
      * Registering listeners for UI events in Video layout component.
116 128
      *
@@ -132,6 +144,8 @@ var VideoLayout = {
132 144
     },
133 145
 
134 146
     initLargeVideo () {
147
+        this.resetLargeVideo();
148
+
135 149
         largeVideo = new LargeVideoManager(eventEmitter);
136 150
         if(localFlipX) {
137 151
             largeVideo.onLocalFlipXChange(localFlipX);

+ 1
- 0
react/features/conference/components/Conference.web.js 查看文件

@@ -51,6 +51,7 @@ class Conference extends Component {
51 51
      * @inheritdoc
52 52
      */
53 53
     componentWillUnmount() {
54
+        APP.UI.stopDaemons();
54 55
         APP.UI.unregisterListeners();
55 56
         APP.UI.unbindEvents();
56 57
 

Loading…
取消
儲存