Browse Source

ref: one place for setting max recv frame height

Moves the logic from all different places into single state
listener to combine all inputs into a single output.
master
paweldomas 5 years ago
parent
commit
bf7aa39947

+ 1
- 9
react/features/conference/middleware.js View File

@@ -3,10 +3,8 @@ import { appNavigate } from '../app/actions';
3 3
 import {
4 4
     CONFERENCE_JOINED,
5 5
     KICKED_OUT,
6
-    VIDEO_QUALITY_LEVELS,
7 6
     conferenceLeft,
8
-    getCurrentConference,
9
-    setPreferredVideoQuality
7
+    getCurrentConference
10 8
 } from '../base/conference';
11 9
 import { hideDialog, isDialogOpen } from '../base/dialog';
12 10
 import { setActiveModalId } from '../base/modal';
@@ -32,12 +30,6 @@ MiddlewareRegistry.register(store => next => action => {
32 30
         dispatch(setToolboxEnabled(!reducedUI));
33 31
         dispatch(setFilmstripEnabled(!reducedUI));
34 32
 
35
-        dispatch(
36
-            setPreferredVideoQuality(
37
-                reducedUI
38
-                    ? VIDEO_QUALITY_LEVELS.LOW
39
-                    : VIDEO_QUALITY_LEVELS.HIGH));
40
-
41 33
         break;
42 34
     }
43 35
 

+ 13
- 1
react/features/filmstrip/actionTypes.js View File

@@ -34,7 +34,19 @@ export const SET_FILMSTRIP_VISIBLE = 'SET_FILMSTRIP_VISIBLE';
34 34
  *
35 35
  * {
36 36
  *     type: SET_TILE_VIEW_DIMENSIONS,
37
- *     dimensions: Object
37
+ *     dimensions: {
38
+ *         gridDimensions: {
39
+ *             columns: number,
40
+ *             height: number,
41
+ *             visibleRows: number,
42
+ *             width: number
43
+ *         },
44
+ *         thumbnailSize: {
45
+ *             height: number,
46
+ *             width: number
47
+ *         },
48
+ *         filmstripWidth: number
49
+ *     }
38 50
  * }
39 51
  */
40 52
 export const SET_TILE_VIEW_DIMENSIONS = 'SET_TILE_VIEW_DIMENSIONS';

+ 25
- 1
react/features/filmstrip/actions.native.js View File

@@ -3,7 +3,8 @@
3 3
 import {
4 4
     SET_FILMSTRIP_ENABLED,
5 5
     SET_FILMSTRIP_HOVERED,
6
-    SET_FILMSTRIP_VISIBLE
6
+    SET_FILMSTRIP_VISIBLE,
7
+    SET_TILE_VIEW_DIMENSIONS
7 8
 } from './actionTypes';
8 9
 
9 10
 /**
@@ -53,3 +54,26 @@ export function setFilmstripVisible(visible: boolean) {
53 54
         visible
54 55
     };
55 56
 }
57
+
58
+/**
59
+ * Sets the dimensions of the tile view grid. The action is only partially implemented on native as not all
60
+ * of the values are currently used. Check the description of {@link SET_TILE_VIEW_DIMENSIONS} for the full set
61
+ * of properties.
62
+ *
63
+ * @param {Object} dimensions - The tile view dimensions.
64
+ * @param {Object} thumbnailSize - The size of an individual video thumbnail.
65
+ * @param {number} thumbnailSize.height - The height of an individual video thumbnail.
66
+ * @param {number} thumbnailSize.width - The width of an individual video thumbnail.
67
+ * @returns {{
68
+ *     type: SET_TILE_VIEW_DIMENSIONS,
69
+ *     dimensions: Object
70
+ * }}
71
+ */
72
+export function setTileViewDimensions({ thumbnailSize }: Object) {
73
+    return {
74
+        type: SET_TILE_VIEW_DIMENSIONS,
75
+        dimensions: {
76
+            thumbnailSize
77
+        }
78
+    };
79
+}

+ 8
- 7
react/features/filmstrip/components/native/TileView.js View File

@@ -8,12 +8,9 @@ import {
8 8
 } from 'react-native';
9 9
 import type { Dispatch } from 'redux';
10 10
 
11
-import {
12
-    getNearestReceiverVideoQualityLevel,
13
-    setMaxReceiverVideoQuality
14
-} from '../../../base/conference';
15 11
 import { connect } from '../../../base/redux';
16 12
 import { ASPECT_RATIO_NARROW } from '../../../base/responsive-ui/constants';
13
+import { setTileViewDimensions } from '../../actions';
17 14
 
18 15
 import Thumbnail from './Thumbnail';
19 16
 import styles from './styles';
@@ -266,10 +263,14 @@ class TileView extends Component<Props> {
266 263
      * @returns {void}
267 264
      */
268 265
     _updateReceiverQuality() {
269
-        const { height } = this._getTileDimensions();
270
-        const qualityLevel = getNearestReceiverVideoQualityLevel(height);
266
+        const { height, width } = this._getTileDimensions();
271 267
 
272
-        this.props.dispatch(setMaxReceiverVideoQuality(qualityLevel));
268
+        this.props.dispatch(setTileViewDimensions({
269
+            thumbnailSize: {
270
+                height,
271
+                width
272
+            }
273
+        }));
273 274
     }
274 275
 }
275 276
 

+ 0
- 4
react/features/filmstrip/middleware.web.js View File

@@ -1,7 +1,6 @@
1 1
 // @flow
2 2
 
3 3
 import Filmstrip from '../../../modules/UI/videolayout/Filmstrip';
4
-import { getNearestReceiverVideoQualityLevel, setMaxReceiverVideoQuality } from '../base/conference';
5 4
 import { MiddlewareRegistry } from '../base/redux';
6 5
 import { CLIENT_RESIZED } from '../base/responsive-ui';
7 6
 import {
@@ -48,9 +47,6 @@ MiddlewareRegistry.register(store => next => action => {
48 47
 
49 48
         if (shouldDisplayTileView(state)) {
50 49
             const { width, height } = state['features/filmstrip'].tileViewDimensions.thumbnailSize;
51
-            const qualityLevel = getNearestReceiverVideoQualityLevel(height);
52
-
53
-            store.dispatch(setMaxReceiverVideoQuality(qualityLevel));
54 50
 
55 51
             // Once the thumbnails are reactified this should be moved there too.
56 52
             Filmstrip.resizeThumbnailsForTileView(width, height, true);

+ 0
- 6
react/features/video-layout/subscriber.js View File

@@ -2,10 +2,6 @@
2 2
 
3 3
 import debounce from 'lodash/debounce';
4 4
 
5
-import {
6
-    VIDEO_QUALITY_LEVELS,
7
-    setMaxReceiverVideoQuality
8
-} from '../base/conference';
9 5
 import {
10 6
     getPinnedParticipant,
11 7
     pinParticipant
@@ -32,8 +28,6 @@ StateListenerRegistry.register(
32 28
         dispatch(selectParticipant());
33 29
 
34 30
         if (!displayTileView) {
35
-            dispatch(setMaxReceiverVideoQuality(VIDEO_QUALITY_LEVELS.HIGH));
36
-
37 31
             if (_getAutoPinSetting()) {
38 32
                 _updateAutoPinnedParticipant(store);
39 33
             }

+ 41
- 3
react/features/video-quality/middleware.js View File

@@ -1,8 +1,14 @@
1 1
 // @flow
2 2
 
3
-import { CONFERENCE_JOINED } from '../base/conference/actionTypes';
4
-import { setPreferredVideoQuality } from '../base/conference/actions';
5
-import { MiddlewareRegistry } from '../base/redux';
3
+import {
4
+    CONFERENCE_JOINED,
5
+    VIDEO_QUALITY_LEVELS,
6
+    getNearestReceiverVideoQualityLevel,
7
+    setMaxReceiverVideoQuality,
8
+    setPreferredVideoQuality
9
+} from '../base/conference';
10
+import { MiddlewareRegistry, StateListenerRegistry } from '../base/redux';
11
+import { shouldDisplayTileView } from '../video-layout';
6 12
 
7 13
 import logger from './logger';
8 14
 
@@ -31,3 +37,35 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
31 37
 
32 38
     return result;
33 39
 });
40
+
41
+/**
42
+ * Implements a state listener in order to calculate max receiver video quality.
43
+ */
44
+StateListenerRegistry.register(
45
+    /* selector */ state => {
46
+        const { reducedUI } = state['features/base/responsive-ui'];
47
+        const _shouldDisplayTileView = shouldDisplayTileView(state);
48
+        const thumbnailSize = state['features/filmstrip']?.tileViewDimensions?.thumbnailSize;
49
+
50
+        return {
51
+            displayTileView: _shouldDisplayTileView,
52
+            reducedUI,
53
+            thumbnailHeight: thumbnailSize?.height
54
+        };
55
+    },
56
+    /* listener */ ({ displayTileView, reducedUI, thumbnailHeight }, { dispatch, getState }) => {
57
+        const { maxReceiverVideoQuality } = getState()['features/base/conference'];
58
+        let newMaxRecvVideoQuality = VIDEO_QUALITY_LEVELS.HIGH;
59
+
60
+        if (reducedUI) {
61
+            newMaxRecvVideoQuality = VIDEO_QUALITY_LEVELS.LOW;
62
+        } else if (displayTileView && !Number.isNaN(thumbnailHeight)) {
63
+            newMaxRecvVideoQuality = getNearestReceiverVideoQualityLevel(thumbnailHeight);
64
+        }
65
+
66
+        if (maxReceiverVideoQuality !== newMaxRecvVideoQuality) {
67
+            dispatch(setMaxReceiverVideoQuality(newMaxRecvVideoQuality));
68
+        }
69
+    }, {
70
+        deepEquals: true
71
+    });

Loading…
Cancel
Save