Sfoglia il codice sorgente

[RN] Disable remote video while in the background

Set the video channel "last N" property to 0, thus making the client not receive
any remote video.
j8
Saúl Ibarra Corretgé 8 anni fa
parent
commit
2d5f0479bd

+ 15
- 0
react/features/background/actionTypes.js Vedi File

27
 export const _SET_BACKGROUND_VIDEO_MUTED
27
 export const _SET_BACKGROUND_VIDEO_MUTED
28
     = Symbol('_SET_BACKGROUND_VIDEO_MUTED');
28
     = Symbol('_SET_BACKGROUND_VIDEO_MUTED');
29
 
29
 
30
+/**
31
+ * The type of redux action which signals that the video channel's lastN value
32
+ * must be changed.
33
+ *
34
+ * {
35
+ *      type: _SET_LASTN,
36
+ *      lastN: boolean
37
+ * }
38
+ *
39
+ * @protected
40
+ */
41
+export const _SET_LASTN
42
+    = Symbol('_SET_LASTN');
43
+
44
+
30
 /**
45
 /**
31
  * The type of redux action which signals that the app state has changed (in
46
  * The type of redux action which signals that the app state has changed (in
32
  * terms of execution mode). The app state can be one of 'active', 'inactive',
47
  * terms of execution mode). The app state can be one of 'active', 'inactive',

+ 22
- 4
react/features/background/actions.js Vedi File

3
 import {
3
 import {
4
     _SET_APP_STATE_LISTENER,
4
     _SET_APP_STATE_LISTENER,
5
     _SET_BACKGROUND_VIDEO_MUTED,
5
     _SET_BACKGROUND_VIDEO_MUTED,
6
+    _SET_LASTN,
6
     APP_STATE_CHANGED
7
     APP_STATE_CHANGED
7
 } from './actionTypes';
8
 } from './actionTypes';
8
 
9
 
54
  */
55
  */
55
 export function _setBackgroundVideoMuted(muted: boolean) {
56
 export function _setBackgroundVideoMuted(muted: boolean) {
56
     return (dispatch, getState) => {
57
     return (dispatch, getState) => {
58
+        // Disable remote video when we mute by setting lastN to 0.
59
+        // Skip it if the conference is in audio only mode, as it's
60
+        // already configured to have no video.
61
+        const { audioOnly } = getState()['features/base/conference'];
62
+
63
+        if (!audioOnly) {
64
+            const { config } = getState()['features/base/lib-jitsi-meet'];
65
+            const defaultLastN
66
+                = typeof config.channelLastN === 'undefined'
67
+                ? -1 : config.channelLastN;
68
+
69
+            dispatch({
70
+                type: _SET_LASTN,
71
+                lastN: muted ? 0 : defaultLastN
72
+            });
73
+        }
74
+
57
         if (muted) {
75
         if (muted) {
58
             const mediaState = getState()['features/base/media'];
76
             const mediaState = getState()['features/base/media'];
59
 
77
 
62
                 return;
80
                 return;
63
             }
81
             }
64
         } else {
82
         } else {
65
-            const bgState = getState()['features/background'];
83
+            const { videoMuted } = getState()['features/background'];
66
 
84
 
67
-            if (!bgState.videoMuted) {
85
+            if (!videoMuted) {
68
                 // We didn't mute video, do nothing.
86
                 // We didn't mute video, do nothing.
69
                 return;
87
                 return;
70
             }
88
             }
71
         }
89
         }
72
 
90
 
73
-        // Remember that video was muted due to the app going to the background
74
-        // vs user's choice.
91
+        // Remember that local video was muted due to the app going to the
92
+        // background vs user's choice.
75
         dispatch({
93
         dispatch({
76
             type: _SET_BACKGROUND_VIDEO_MUTED,
94
             type: _SET_BACKGROUND_VIDEO_MUTED,
77
             muted
95
             muted

+ 15
- 0
react/features/background/middleware.js Vedi File

16
 } from './actions';
16
 } from './actions';
17
 import {
17
 import {
18
     _SET_APP_STATE_LISTENER,
18
     _SET_APP_STATE_LISTENER,
19
+    _SET_LASTN,
19
     APP_STATE_CHANGED
20
     APP_STATE_CHANGED
20
 } from './actionTypes';
21
 } from './actionTypes';
21
 
22
 
46
         break;
47
         break;
47
     }
48
     }
48
 
49
 
50
+    case _SET_LASTN: {
51
+        const { conference } = store.getState()['features/base/conference'];
52
+
53
+        if (conference) {
54
+            try {
55
+                conference.setLastN(action.lastN);
56
+            } catch (err) {
57
+                console.warn(`Error setting lastN: ${err}`);
58
+            }
59
+        }
60
+
61
+        break;
62
+    }
63
+
49
     case APP_STATE_CHANGED:
64
     case APP_STATE_CHANGED:
50
         _appStateChanged(store.dispatch, action.appState);
65
         _appStateChanged(store.dispatch, action.appState);
51
         break;
66
         break;

Loading…
Annulla
Salva