Browse Source

fix(conference): start muted values on initial GUM

Take into account the start muted values stored in local storage.
master
Hristo Terezov 5 years ago
parent
commit
9c10ac3028
3 changed files with 48 additions and 33 deletions
  1. 4
    2
      conference.js
  2. 41
    0
      react/features/base/media/functions.js
  3. 3
    31
      react/features/base/media/middleware.js

+ 4
- 2
conference.js View File

65
     JitsiTrackEvents
65
     JitsiTrackEvents
66
 } from './react/features/base/lib-jitsi-meet';
66
 } from './react/features/base/lib-jitsi-meet';
67
 import {
67
 import {
68
+    getStartWithAudioMuted,
69
+    getStartWithVideoMuted,
68
     isVideoMutedByUser,
70
     isVideoMutedByUser,
69
     MEDIA_TYPE,
71
     MEDIA_TYPE,
70
     setAudioAvailable,
72
     setAudioAvailable,
731
         const initialOptions = {
733
         const initialOptions = {
732
             startAudioOnly: config.startAudioOnly,
734
             startAudioOnly: config.startAudioOnly,
733
             startScreenSharing: config.startScreenSharing,
735
             startScreenSharing: config.startScreenSharing,
734
-            startWithAudioMuted: config.startWithAudioMuted
736
+            startWithAudioMuted: getStartWithAudioMuted(APP.store.getState())
735
                 || config.startSilent
737
                 || config.startSilent
736
                 || isUserInteractionRequiredForUnmute(APP.store.getState()),
738
                 || isUserInteractionRequiredForUnmute(APP.store.getState()),
737
-            startWithVideoMuted: config.startWithVideoMuted
739
+            startWithVideoMuted: getStartWithVideoMuted(APP.store.getState())
738
                 || isUserInteractionRequiredForUnmute(APP.store.getState())
740
                 || isUserInteractionRequiredForUnmute(APP.store.getState())
739
         };
741
         };
740
 
742
 

+ 41
- 0
react/features/base/media/functions.js View File

1
 /* @flow */
1
 /* @flow */
2
 
2
 
3
 import { toState } from '../redux';
3
 import { toState } from '../redux';
4
+import { getPropertyValue } from '../settings';
4
 
5
 
5
 import { VIDEO_MUTISM_AUTHORITY } from './constants';
6
 import { VIDEO_MUTISM_AUTHORITY } from './constants';
6
 
7
 
8
+
9
+// XXX The configurations/preferences/settings startWithAudioMuted and startWithVideoMuted were introduced for
10
+// conferences/meetings. So it makes sense for these to not be considered outside of conferences/meetings
11
+// (e.g. WelcomePage). Later on, though, we introduced a "Video <-> Voice" toggle on the WelcomePage which utilizes
12
+// startAudioOnly outside of conferences/meetings so that particular configuration/preference/setting employs slightly
13
+// exclusive logic.
14
+const START_WITH_AUDIO_VIDEO_MUTED_SOURCES = {
15
+    // We have startWithAudioMuted and startWithVideoMuted here:
16
+    config: true,
17
+    settings: true,
18
+
19
+    // XXX We've already overwritten base/config with urlParams. However,
20
+    // settings are more important than the server-side config.
21
+    // Consequently, we need to read from urlParams anyway:
22
+    urlParams: true,
23
+
24
+    // We don't have startWithAudioMuted and startWithVideoMuted here:
25
+    jwt: false
26
+};
27
+
7
 /**
28
 /**
8
  * Determines whether audio is currently muted.
29
  * Determines whether audio is currently muted.
9
  *
30
  *
47
     return Boolean(muted & videoMutismAuthority);
68
     return Boolean(muted & videoMutismAuthority);
48
 }
69
 }
49
 
70
 
71
+/**
72
+ * Computes the startWithAudioMuted by retrieving its values from config, URL and settings.
73
+ *
74
+ * @param {Object|Function} stateful - The redux state object or {@code getState} function.
75
+ * @returns {boolean} - The computed startWithAudioMuted value that will be used.
76
+ */
77
+export function getStartWithAudioMuted(stateful: Object | Function) {
78
+    return Boolean(getPropertyValue(stateful, 'startWithAudioMuted', START_WITH_AUDIO_VIDEO_MUTED_SOURCES));
79
+}
80
+
81
+/**
82
+ * Computes the startWithAudioMuted by retrieving its values from config, URL and settings.
83
+ *
84
+ * @param {Object|Function} stateful - The redux state object or {@code getState} function.
85
+ * @returns {boolean} - The computed startWithAudioMuted value that will be used.
86
+ */
87
+export function getStartWithVideoMuted(stateful: Object | Function) {
88
+    return Boolean(getPropertyValue(stateful, 'startWithVideoMuted', START_WITH_AUDIO_VIDEO_MUTED_SOURCES));
89
+}
90
+
50
 /**
91
 /**
51
  * Determines whether video is currently muted by the user authority.
92
  * Determines whether video is currently muted by the user authority.
52
  *
93
  *

+ 3
- 31
react/features/base/media/middleware.js View File

21
     MEDIA_TYPE,
21
     MEDIA_TYPE,
22
     VIDEO_MUTISM_AUTHORITY
22
     VIDEO_MUTISM_AUTHORITY
23
 } from './constants';
23
 } from './constants';
24
+import { getStartWithAudioMuted, getStartWithVideoMuted } from './functions';
24
 import logger from './logger';
25
 import logger from './logger';
25
 import {
26
 import {
26
     _AUDIO_INITIAL_MEDIA_STATE,
27
     _AUDIO_INITIAL_MEDIA_STATE,
133
     const state = getState();
134
     const state = getState();
134
     const { room } = action;
135
     const { room } = action;
135
     const roomIsValid = isRoomValid(room);
136
     const roomIsValid = isRoomValid(room);
136
-
137
-    // XXX The configurations/preferences/settings startWithAudioMuted,
138
-    // startWithVideoMuted, and startAudioOnly were introduced for
139
-    // conferences/meetings. So it makes sense for these to not be considered
140
-    // outside of conferences/meetings (e.g. WelcomePage). Later on, though, we
141
-    // introduced a "Video <-> Voice" toggle on the WelcomePage which utilizes
142
-    // startAudioOnly outside of conferences/meetings so that particular
143
-    // configuration/preference/setting employs slightly exclusive logic.
144
-    const mutedSources = {
145
-        // We have startWithAudioMuted and startWithVideoMuted here:
146
-        config: true,
147
-        settings: true,
148
-
149
-        // XXX We've already overwritten base/config with urlParams. However,
150
-        // settings are more important than the server-side config.
151
-        // Consequently, we need to read from urlParams anyway:
152
-        urlParams: true,
153
-
154
-        // We don't have startWithAudioMuted and startWithVideoMuted here:
155
-        jwt: false
156
-    };
157
-    const audioMuted
158
-        = roomIsValid
159
-            ? Boolean(
160
-                getPropertyValue(state, 'startWithAudioMuted', mutedSources))
161
-            : _AUDIO_INITIAL_MEDIA_STATE.muted;
162
-    const videoMuted
163
-        = roomIsValid
164
-            ? Boolean(
165
-                getPropertyValue(state, 'startWithVideoMuted', mutedSources))
166
-            : _VIDEO_INITIAL_MEDIA_STATE.muted;
137
+    const audioMuted = roomIsValid ? getStartWithAudioMuted(state) : _AUDIO_INITIAL_MEDIA_STATE.muted;
138
+    const videoMuted = roomIsValid ? getStartWithVideoMuted(state) : _VIDEO_INITIAL_MEDIA_STATE.muted;
167
 
139
 
168
     sendAnalytics(
140
     sendAnalytics(
169
         createStartMutedConfigurationEvent('local', audioMuted, videoMuted));
141
         createStartMutedConfigurationEvent('local', audioMuted, videoMuted));

Loading…
Cancel
Save