Skip to content

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

feat(authentication): used config for control over joining audio/video mute/unmute

Calin-Teodor8cdde8804944
diff --git a/react/features/app/actions.any.ts b/react/features/app/actions.any.ts
index 000a74d61f..51e8db23b0 100644
--- a/react/features/app/actions.any.ts
+++ b/react/features/app/actions.any.ts
@@ -5,12 +5,15 @@ import { openTokenAuthUrl } from '../authentication/actions';
// @ts-ignore
import { getTokenAuthUrl, isTokenAuthEnabled } from '../authentication/functions';
import { getJwtExpirationDate } from '../base/jwt/functions';
+import { MEDIA_TYPE } from '../base/media/constants';
+import { isLocalTrackMuted } from '../base/tracks/functions.any';
import { getLocationContextRoot, parseURIString } from '../base/util/uri';
import { addTrackStateToURL } from './functions.any';
import logger from './logger';
import { IStore } from './types';
+
/**
* Redirects to another page generated by replacing the path in the original URL
* with the given path.
@@ -107,6 +110,8 @@ export function maybeRedirectToTokenAuthUrl(
const { enabled: audioOnlyEnabled } = state['features/base/audio-only'];
const { startAudioOnly } = config;
const { locationURL = { href: '' } as URL } = state['features/base/connection'];
+ const audioMuted = isLocalTrackMuted(state['features/base/tracks'], MEDIA_TYPE.AUDIO);
+ const videoMuted = isLocalTrackMuted(state['features/base/tracks'], MEDIA_TYPE.VIDEO);
if (!isTokenAuthEnabled(config)) {
return false;
@@ -122,7 +127,16 @@ export function maybeRedirectToTokenAuthUrl(
const room = state['features/base/conference'].room;
const { tenant } = parseURIString(locationURL.href) || {};
- getTokenAuthUrl(audioOnlyEnabled || startAudioOnly, config, room, tenant, true, locationURL)
+ getTokenAuthUrl(
+ audioMuted,
+ audioOnlyEnabled || startAudioOnly,
+ config,
+ room,
+ tenant,
+ true,
+ locationURL,
+ videoMuted
+ )
.then((tokenAuthServiceUrl: string | undefined) => {
if (!tokenAuthServiceUrl) {
logger.warn('Cannot handle login, token service URL is not set');
diff --git a/react/features/app/getRouteToRender.web.ts b/react/features/app/getRouteToRender.web.ts
index 2d330d552e..8745b1f122 100644
--- a/react/features/app/getRouteToRender.web.ts
+++ b/react/features/app/getRouteToRender.web.ts
@@ -57,7 +57,7 @@ function _getWebConferenceRoute(state: IReduxState) {
const { tenant } = parseURIString(locationURL.href) || {};
const { startAudioOnly } = config;
- return getTokenAuthUrl(startAudioOnly, config, room, tenant, false, locationURL)
+ return getTokenAuthUrl(false, startAudioOnly, config, room, tenant, false, locationURL, false)
.then((url: string | undefined) => {
route.href = url;
diff --git a/react/features/authentication/functions.any.ts b/react/features/authentication/functions.any.ts
index 5641474229..d35778bf9b 100644
--- a/react/features/authentication/functions.any.ts
+++ b/react/features/authentication/functions.any.ts
@@ -13,36 +13,52 @@ export const isTokenAuthEnabled = (config: IConfig): boolean =>
/**
* Returns the state that we can add as a parameter to the tokenAuthUrl.
*
+ * @param {boolean} audioMuted - Start conference with audio muted.
* @param {boolean} audioOnlyEnabled - Join conference audio only.
* @param {string?} roomName - The room name.
* @param {string?} tenant - The tenant name if any.
* @param {boolean} skipPrejoin - Whether to skip pre-join page.
* @param {URL} locationURL - The location URL.
+ * @param {boolean} videoMuted - Start conference with video muted.
* @returns {Object} The state object.
*/
export const _getTokenAuthState = (
+ audioMuted: boolean | undefined = false,
audioOnlyEnabled: boolean | undefined = false,
roomName: string | undefined,
tenant: string | undefined,
skipPrejoin: boolean | undefined = false,
+ locationURL: URL,
// eslint-disable-next-line max-params
- locationURL: URL): object => {
+ videoMuted: boolean | undefined = false): object => {
const state = {
room: roomName,
roomSafe: getBackendSafeRoomName(roomName),
tenant
};
+ if (audioMuted) {
+
+ // @ts-ignore
+ state['config.startWithAudioMuted'] = true;
+ }
+
+ if (audioOnlyEnabled) {
+
+ // @ts-ignore
+ state['config.startAudioOnly'] = true;
+ }
+
if (skipPrejoin) {
// We have already shown the prejoin screen, no need to show it again after obtaining the token.
// @ts-ignore
state['config.prejoinConfig.enabled'] = false;
}
- if (audioOnlyEnabled) {
+ if (videoMuted) {
// @ts-ignore
- state['config.startAudioOnly'] = true;
+ state['config.startWithVideoMuted'] = true;
}
const params = new URLSearchParams(locationURL.hash);
diff --git a/react/features/authentication/functions.native.ts b/react/features/authentication/functions.native.ts
index dfa1544914..7ea0e8a733 100644
--- a/react/features/authentication/functions.native.ts
+++ b/react/features/authentication/functions.native.ts
@@ -13,25 +13,29 @@ export * from './functions.any';
* '{room}' - name of the conference room passed as <tt>roomName</tt>
* argument to this method.
*
+ * @param {boolean} audioMuted - Start conference with audio muted.
* @param {boolean} audioOnlyEnabled - Join conference audio only.
* @param {Object} config - Configuration state object from store. A URL pattern pointing to the login service.
* @param {string} roomName - The name of the conference room for which the user will be authenticated.
* @param {string} tenant - The name of the conference tenant.
* @param {boolean} skipPrejoin - Whether to skip pre-join page.
* @param {URL} locationURL - The location URL.
+ * @param {boolean} videoMuted - Start conference with video muted.
*
* @returns {Promise<string|undefined>} - The URL pointing to JWT login service or
* <tt>undefined</tt> if the pattern stored in config is not a string and the URL can not be
* constructed.
*/
export const getTokenAuthUrl = (
+ audioMuted: boolean | undefined = false,
audioOnlyEnabled: boolean | undefined = false,
config: IConfig,
roomName: string | undefined,
tenant: string | undefined,
skipPrejoin: boolean | undefined = false,
+ locationURL: URL,
// eslint-disable-next-line max-params
- locationURL: URL): Promise<string | undefined> => {
+ videoMuted: boolean | undefined = false): Promise<string | undefined> => {
let url = config.tokenAuthUrl;
@@ -40,7 +44,15 @@ export const getTokenAuthUrl = (
}
if (url.indexOf('{state}')) {
- const state = _getTokenAuthState(audioOnlyEnabled, roomName, tenant, skipPrejoin, locationURL);
+ const state = _getTokenAuthState(
+ audioMuted,
+ audioOnlyEnabled,
+ roomName,
+ tenant,
+ skipPrejoin,
+ locationURL,
+ videoMuted
+ );
// Append ios=true or android=true to the token URL.
// @ts-ignore
diff --git a/react/features/authentication/functions.web.ts b/react/features/authentication/functions.web.ts
index 2157300c85..d385b985b2 100644
--- a/react/features/authentication/functions.web.ts
+++ b/react/features/authentication/functions.web.ts
@@ -31,25 +31,29 @@ function _cryptoRandom() {
* '{room}' - name of the conference room passed as <tt>roomName</tt>
* argument to this method.
*
+ * @param {boolean} audioMuted - Start conference with audio muted.
* @param {boolean} audioOnlyEnabled - Join conference audio only.
* @param {Object} config - Configuration state object from store. A URL pattern pointing to the login service.
* @param {string} roomName - The name of the conference room for which the user will be authenticated.
* @param {string} tenant - The name of the conference tenant.
* @param {boolean} skipPrejoin - Whether to skip pre-join page.
* @param {URL} locationURL - The current location URL.
+ * @param {boolean} videoMuted - Start conference with video muted.
*
* @returns {Promise<string|undefined>} - The URL pointing to JWT login service or
* <tt>undefined</tt> if the pattern stored in config is not a string and the URL can not be
* constructed.
*/
export const getTokenAuthUrl = (
+ audioMuted: boolean | undefined = false,
audioOnlyEnabled: boolean | undefined = false,
config: IConfig,
roomName: string | undefined,
tenant: string | undefined,
skipPrejoin: boolean | undefined = false,
+ locationURL: URL,
// eslint-disable-next-line max-params
- locationURL: URL): Promise<string | undefined> => {
+ videoMuted: boolean | undefined = false): Promise<string | undefined> => {
let url = config.tokenAuthUrl;
@@ -58,7 +62,15 @@ export const getTokenAuthUrl = (
}
if (url.indexOf('{state}')) {
- const state = _getTokenAuthState(audioOnlyEnabled, roomName, tenant, skipPrejoin, locationURL);
+ const state = _getTokenAuthState(
+ audioMuted,
+ audioOnlyEnabled,
+ roomName,
+ tenant,
+ skipPrejoin,
+ locationURL,
+ videoMuted
+ );
if (browser.isElectron()) {
// @ts-ignore
diff --git a/react/features/authentication/middleware.ts b/react/features/authentication/middleware.ts
index 7300c658c4..be954bebb9 100644
--- a/react/features/authentication/middleware.ts
+++ b/react/features/authentication/middleware.ts
@@ -13,7 +13,9 @@ import {
JitsiConferenceErrors,
JitsiConnectionErrors
} from '../base/lib-jitsi-meet';
+import { MEDIA_TYPE } from '../base/media/constants';
import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
+import { isLocalTrackMuted } from '../base/tracks/functions.any';
import { parseURIString } from '../base/util/uri';
import { openLogoutDialog } from '../settings/actions';
@@ -258,6 +260,8 @@ function _handleLogin({ dispatch, getState }: IStore) {
const { locationURL = { href: '' } as URL } = state['features/base/connection'];
const { tenant } = parseURIString(locationURL.href) || {};
const { enabled: audioOnlyEnabled } = state['features/base/audio-only'];
+ const audioMuted = isLocalTrackMuted(state['features/base/tracks'], MEDIA_TYPE.AUDIO);
+ const videoMuted = isLocalTrackMuted(state['features/base/tracks'], MEDIA_TYPE.VIDEO);
if (!room) {
logger.warn('Cannot handle login, room is undefined!');
@@ -271,7 +275,7 @@ function _handleLogin({ dispatch, getState }: IStore) {
return;
}
- getTokenAuthUrl(audioOnlyEnabled, config, room, tenant, true, locationURL)
+ getTokenAuthUrl(audioMuted, audioOnlyEnabled, config, room, tenant, true, locationURL, videoMuted)
.then((tokenAuthServiceUrl: string | undefined) => {
if (!tokenAuthServiceUrl) {
logger.warn('Cannot handle login, token service URL is not set');