Quellcode durchsuchen

[RN] Try to create local tracks when unmuting, if track is missing

This is only desired when the unmuting action took place due to a manual user
intervention or the audio-only mode being disengaged.
master
Saúl Ibarra Corretgé vor 7 Jahren
Ursprung
Commit
3102ea6818

+ 5
- 1
react/features/base/conference/middleware.js Datei anzeigen

243
     dispatch(setLastN(audioOnly ? 0 : undefined));
243
     dispatch(setLastN(audioOnly ? 0 : undefined));
244
 
244
 
245
     // Mute/unmute the local video.
245
     // Mute/unmute the local video.
246
-    dispatch(setVideoMuted(audioOnly, VIDEO_MUTISM_AUTHORITY.AUDIO_ONLY));
246
+    dispatch(
247
+        setVideoMuted(
248
+            audioOnly,
249
+            VIDEO_MUTISM_AUTHORITY.AUDIO_ONLY,
250
+            /* ensureTrack */ true));
247
 
251
 
248
     if (typeof APP !== 'undefined') {
252
     if (typeof APP !== 'undefined') {
249
         // TODO This should be a temporary solution that lasts only until
253
         // TODO This should be a temporary solution that lasts only until

+ 10
- 2
react/features/base/media/actions.js Datei anzeigen

34
  *
34
  *
35
  * @param {boolean} muted - True if the local audio is to be muted or false if
35
  * @param {boolean} muted - True if the local audio is to be muted or false if
36
  * the local audio is to be unmuted.
36
  * the local audio is to be unmuted.
37
+ * @param {boolean} ensureTrack - True if we want to ensure that a new track is
38
+ * created if missing.
37
  * @returns {{
39
  * @returns {{
38
  *     type: SET_AUDIO_MUTED,
40
  *     type: SET_AUDIO_MUTED,
41
+ *     ensureTrack: boolean,
39
  *     muted: boolean
42
  *     muted: boolean
40
  * }}
43
  * }}
41
  */
44
  */
42
-export function setAudioMuted(muted: boolean) {
45
+export function setAudioMuted(muted: boolean, ensureTrack: boolean = false) {
43
     return {
46
     return {
44
         type: SET_AUDIO_MUTED,
47
         type: SET_AUDIO_MUTED,
48
+        ensureTrack,
45
         muted
49
         muted
46
     };
50
     };
47
 }
51
 }
86
  * the local video is to be unmuted.
90
  * the local video is to be unmuted.
87
  * @param {number} authority - The {@link VIDEO_MUTISM_AUTHORITY} which is
91
  * @param {number} authority - The {@link VIDEO_MUTISM_AUTHORITY} which is
88
  * muting/unmuting the local video.
92
  * muting/unmuting the local video.
93
+ * @param {boolean} ensureTrack - True if we want to ensure that a new track is
94
+ * created if missing.
89
  * @returns {Function}
95
  * @returns {Function}
90
  */
96
  */
91
 export function setVideoMuted(
97
 export function setVideoMuted(
92
         muted: boolean,
98
         muted: boolean,
93
-        authority: number = VIDEO_MUTISM_AUTHORITY.USER) {
99
+        authority: number = VIDEO_MUTISM_AUTHORITY.USER,
100
+        ensureTrack: boolean = false) {
94
     return (dispatch: Dispatch<*>, getState: Function) => {
101
     return (dispatch: Dispatch<*>, getState: Function) => {
95
         const oldValue = getState()['features/base/media'].video.muted;
102
         const oldValue = getState()['features/base/media'].video.muted;
96
 
103
 
99
 
106
 
100
         return dispatch({
107
         return dispatch({
101
             type: SET_VIDEO_MUTED,
108
             type: SET_VIDEO_MUTED,
109
+            ensureTrack,
102
             muted: newValue
110
             muted: newValue
103
         });
111
         });
104
     };
112
     };

+ 9
- 2
react/features/base/tracks/middleware.js Datei anzeigen

11
 } from '../media';
11
 } from '../media';
12
 import { MiddlewareRegistry } from '../redux';
12
 import { MiddlewareRegistry } from '../redux';
13
 
13
 
14
+import { createLocalTracksA } from './actions';
14
 import { TRACK_ADDED, TRACK_REMOVED, TRACK_UPDATED } from './actionTypes';
15
 import { TRACK_ADDED, TRACK_REMOVED, TRACK_UPDATED } from './actionTypes';
15
 import { getLocalTrack, setTrackMuted } from './functions';
16
 import { getLocalTrack, setTrackMuted } from './functions';
16
 
17
 
153
  * @private
154
  * @private
154
  * @returns {void}
155
  * @returns {void}
155
  */
156
  */
156
-function _setMuted(store, { muted }, mediaType: MEDIA_TYPE) {
157
+function _setMuted(store, { ensureTrack, muted }, mediaType: MEDIA_TYPE) {
157
     const localTrack = _getLocalTrack(store, mediaType);
158
     const localTrack = _getLocalTrack(store, mediaType);
158
 
159
 
159
-    localTrack && setTrackMuted(localTrack.jitsiTrack, muted);
160
+    if (localTrack) {
161
+        setTrackMuted(localTrack.jitsiTrack, muted);
162
+    } else if (!muted && ensureTrack && typeof APP === 'undefined') {
163
+        // FIXME: This only runs on mobile now because web has its own way of
164
+        // creating local tracks. Adjust the check once they are unified.
165
+        store.dispatch(createLocalTracksA({ devices: [ mediaType ] }));
166
+    }
160
 }
167
 }

+ 12
- 3
react/features/toolbox/components/Toolbox.native.js Datei anzeigen

7
     MEDIA_TYPE,
7
     MEDIA_TYPE,
8
     setAudioMuted,
8
     setAudioMuted,
9
     setVideoMuted,
9
     setVideoMuted,
10
-    toggleCameraFacingMode
10
+    toggleCameraFacingMode,
11
+    VIDEO_MUTISM_AUTHORITY
11
 } from '../../base/media';
12
 } from '../../base/media';
12
 import { Container } from '../../base/react';
13
 import { Container } from '../../base/react';
13
 import { ColorPalette } from '../../base/styles';
14
 import { ColorPalette } from '../../base/styles';
167
         // sets the state of base/media. Whether the user's intention will turn
168
         // sets the state of base/media. Whether the user's intention will turn
168
         // into reality is a whole different story which is of no concern to the
169
         // into reality is a whole different story which is of no concern to the
169
         // tapping.
170
         // tapping.
170
-        this.props.dispatch(setAudioMuted(!this.props._audioMuted));
171
+        this.props.dispatch(
172
+            setAudioMuted(
173
+                !this.props._audioMuted,
174
+                VIDEO_MUTISM_AUTHORITY.USER,
175
+                /* ensureTrack */ true));
171
     }
176
     }
172
 
177
 
173
     /**
178
     /**
182
         // sets the state of base/media. Whether the user's intention will turn
187
         // sets the state of base/media. Whether the user's intention will turn
183
         // into reality is a whole different story which is of no concern to the
188
         // into reality is a whole different story which is of no concern to the
184
         // tapping.
189
         // tapping.
185
-        this.props.dispatch(setVideoMuted(!this.props._videoMuted));
190
+        this.props.dispatch(
191
+            setVideoMuted(
192
+                !this.props._videoMuted,
193
+                VIDEO_MUTISM_AUTHORITY.USER,
194
+                /* ensureTrack */ true));
186
     }
195
     }
187
 
196
 
188
     /**
197
     /**

Laden…
Abbrechen
Speichern