Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

fix(conference): start muted values on initial GUM

Hristo Terezov9c10ac302854
diff --git a/conference.js b/conference.js
index f6c5c77dbe..b04f5d38c1 100644
--- a/conference.js
+++ b/conference.js
@@ -65,6 +65,8 @@ import {
JitsiTrackEvents
} from './react/features/base/lib-jitsi-meet';
import {
+ getStartWithAudioMuted,
+ getStartWithVideoMuted,
isVideoMutedByUser,
MEDIA_TYPE,
setAudioAvailable,
@@ -731,10 +733,10 @@ export default {
const initialOptions = {
startAudioOnly: config.startAudioOnly,
startScreenSharing: config.startScreenSharing,
- startWithAudioMuted: config.startWithAudioMuted
+ startWithAudioMuted: getStartWithAudioMuted(APP.store.getState())
|| config.startSilent
|| isUserInteractionRequiredForUnmute(APP.store.getState()),
- startWithVideoMuted: config.startWithVideoMuted
+ startWithVideoMuted: getStartWithVideoMuted(APP.store.getState())
|| isUserInteractionRequiredForUnmute(APP.store.getState())
};
diff --git a/react/features/base/media/functions.js b/react/features/base/media/functions.js
index ceeb39735b..7354462908 100644
--- a/react/features/base/media/functions.js
+++ b/react/features/base/media/functions.js
@@ -1,9 +1,30 @@
/* @flow */
import { toState } from '../redux';
+import { getPropertyValue } from '../settings';
import { VIDEO_MUTISM_AUTHORITY } from './constants';
+
+// XXX The configurations/preferences/settings startWithAudioMuted and startWithVideoMuted were introduced for
+// conferences/meetings. So it makes sense for these to not be considered outside of conferences/meetings
+// (e.g. WelcomePage). Later on, though, we introduced a "Video <-> Voice" toggle on the WelcomePage which utilizes
+// startAudioOnly outside of conferences/meetings so that particular configuration/preference/setting employs slightly
+// exclusive logic.
+const START_WITH_AUDIO_VIDEO_MUTED_SOURCES = {
+ // We have startWithAudioMuted and startWithVideoMuted here:
+ config: true,
+ settings: true,
+
+ // XXX We've already overwritten base/config with urlParams. However,
+ // settings are more important than the server-side config.
+ // Consequently, we need to read from urlParams anyway:
+ urlParams: true,
+
+ // We don't have startWithAudioMuted and startWithVideoMuted here:
+ jwt: false
+};
+
/**
* Determines whether audio is currently muted.
*
@@ -47,6 +68,26 @@ function _isVideoMutedByAuthority(
return Boolean(muted & videoMutismAuthority);
}
+/**
+ * Computes the startWithAudioMuted by retrieving its values from config, URL and settings.
+ *
+ * @param {Object|Function} stateful - The redux state object or {@code getState} function.
+ * @returns {boolean} - The computed startWithAudioMuted value that will be used.
+ */
+export function getStartWithAudioMuted(stateful: Object | Function) {
+ return Boolean(getPropertyValue(stateful, 'startWithAudioMuted', START_WITH_AUDIO_VIDEO_MUTED_SOURCES));
+}
+
+/**
+ * Computes the startWithAudioMuted by retrieving its values from config, URL and settings.
+ *
+ * @param {Object|Function} stateful - The redux state object or {@code getState} function.
+ * @returns {boolean} - The computed startWithAudioMuted value that will be used.
+ */
+export function getStartWithVideoMuted(stateful: Object | Function) {
+ return Boolean(getPropertyValue(stateful, 'startWithVideoMuted', START_WITH_AUDIO_VIDEO_MUTED_SOURCES));
+}
+
/**
* Determines whether video is currently muted by the user authority.
*
diff --git a/react/features/base/media/middleware.js b/react/features/base/media/middleware.js
index 868808feb4..0ea99eae84 100644
--- a/react/features/base/media/middleware.js
+++ b/react/features/base/media/middleware.js
@@ -21,6 +21,7 @@ import {
MEDIA_TYPE,
VIDEO_MUTISM_AUTHORITY
} from './constants';
+import { getStartWithAudioMuted, getStartWithVideoMuted } from './functions';
import logger from './logger';
import {
_AUDIO_INITIAL_MEDIA_STATE,
@@ -133,37 +134,8 @@ function _setRoom({ dispatch, getState }, next, action) {
const state = getState();
const { room } = action;
const roomIsValid = isRoomValid(room);
-
- // XXX The configurations/preferences/settings startWithAudioMuted,
- // startWithVideoMuted, and startAudioOnly were introduced for
- // conferences/meetings. So it makes sense for these to not be considered
- // outside of conferences/meetings (e.g. WelcomePage). Later on, though, we
- // introduced a "Video <-> Voice" toggle on the WelcomePage which utilizes
- // startAudioOnly outside of conferences/meetings so that particular
- // configuration/preference/setting employs slightly exclusive logic.
- const mutedSources = {
- // We have startWithAudioMuted and startWithVideoMuted here:
- config: true,
- settings: true,
-
- // XXX We've already overwritten base/config with urlParams. However,
- // settings are more important than the server-side config.
- // Consequently, we need to read from urlParams anyway:
- urlParams: true,
-
- // We don't have startWithAudioMuted and startWithVideoMuted here:
- jwt: false
- };
- const audioMuted
- = roomIsValid
- ? Boolean(
- getPropertyValue(state, 'startWithAudioMuted', mutedSources))
- : _AUDIO_INITIAL_MEDIA_STATE.muted;
- const videoMuted
- = roomIsValid
- ? Boolean(
- getPropertyValue(state, 'startWithVideoMuted', mutedSources))
- : _VIDEO_INITIAL_MEDIA_STATE.muted;
+ const audioMuted = roomIsValid ? getStartWithAudioMuted(state) : _AUDIO_INITIAL_MEDIA_STATE.muted;
+ const videoMuted = roomIsValid ? getStartWithVideoMuted(state) : _VIDEO_INITIAL_MEDIA_STATE.muted;
sendAnalytics(
createStartMutedConfigurationEvent('local', audioMuted, videoMuted));