feat(config) Add config for disabled sound id's

- unify naming for sound id values
This commit is contained in:
Horatiu Muresan 2021-09-09 17:18:26 +03:00 committed by GitHub
parent d96246dea8
commit 9a16733950
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 88 additions and 42 deletions

View File

@ -683,13 +683,38 @@ var config = {
// userRegion: "asia" // userRegion: "asia"
}, },
// Array<string> of disabled sounds.
// Possible values:
// - 'E2EE_OFF_SOUND'
// - 'E2EE_ON_SOUND'
// - 'INCOMING_MSG_SOUND'
// - 'KNOCKING_PARTICIPANT_SOUND'
// - 'LIVE_STREAMING_OFF_SOUND'
// - 'LIVE_STREAMING_ON_SOUND'
// - 'NO_AUDIO_SIGNAL_SOUND'
// - 'NOISY_AUDIO_INPUT_SOUND'
// - 'OUTGOING_CALL_EXPIRED_SOUND'
// - 'OUTGOING_CALL_REJECTED_SOUND'
// - 'OUTGOING_CALL_RINGING_SOUND'
// - 'OUTGOING_CALL_START_SOUND'
// - 'PARTICIPANT_JOINED_SOUND'
// - 'PARTICIPANT_LEFT_SOUND'
// - 'RAISE_HAND_SOUND'
// - 'RECORDING_OFF_SOUND'
// - 'RECORDING_ON_SOUND'
// - 'TALK_WHILE_MUTED_SOUND'
// disabledSounds: [],
// DEPRECATED! Use `disabledSounds` instead.
// Decides whether the start/stop recording audio notifications should play on record. // Decides whether the start/stop recording audio notifications should play on record.
// disableRecordAudioNotification: false, // disableRecordAudioNotification: false,
// DEPRECATED! Use `disabledSounds` instead.
// Disables the sounds that play when other participants join or leave the // Disables the sounds that play when other participants join or leave the
// conference (if set to true, these sounds will not be played). // conference (if set to true, these sounds will not be played).
// disableJoinLeaveSounds: false, // disableJoinLeaveSounds: false,
// DEPRECATED! Use `disabledSounds` instead.
// Disables the sounds that play when a chat message is received. // Disables the sounds that play when a chat message is received.
// disableIncomingMessageSound: false, // disableIncomingMessageSound: false,

View File

@ -84,6 +84,7 @@ export default [
'disableAP', 'disableAP',
'disableAudioLevels', 'disableAudioLevels',
'disableDeepLinking', 'disableDeepLinking',
'disabledSounds',
'disableFilmstripAutohiding', 'disableFilmstripAutohiding',
'disableInitialGUM', 'disableInitialGUM',
'disableH264', 'disableH264',

View File

@ -66,11 +66,11 @@ ReducerRegistry.register('features/base/config', (state = _getInitialState(), ac
error: undefined, error: undefined,
/** /**
* The URL of the location associated with/configured by this * The URL of the location associated with/configured by this
* configuration. * configuration.
* *
* @type URL * @type URL
*/ */
locationURL: action.locationURL locationURL: action.locationURL
}; };
@ -84,11 +84,11 @@ ReducerRegistry.register('features/base/config', (state = _getInitialState(), ac
if (state.locationURL === action.locationURL) { if (state.locationURL === action.locationURL) {
return { return {
/** /**
* The {@link Error} which prevented the loading of the * The {@link Error} which prevented the loading of the
* configuration of the associated {@code locationURL}. * configuration of the associated {@code locationURL}.
* *
* @type Error * @type Error
*/ */
error: action.error error: action.error
}; };
} }
@ -206,6 +206,25 @@ function _translateLegacyConfig(oldValue: Object) {
}; };
} }
newValue.disabledSounds = newValue.disabledSounds || [];
if (oldValue.disableJoinLeaveSounds) {
newValue.disabledSounds.unshift('PARTICIPANT_LEFT_SOUND', 'PARTICIPANT_JOINED_SOUND');
}
if (oldValue.disableRecordAudioNotification) {
newValue.disabledSounds.unshift(
'RECORDING_ON_SOUND',
'RECORDING_OFF_SOUND',
'LIVE_STREAMING_ON_SOUND',
'LIVE_STREAMING_OFF_SOUND'
);
}
if (oldValue.disableIncomingMessageSound) {
newValue.disabledSounds.unshift('INCOMING_MSG_SOUND');
}
if (oldValue.stereo || oldValue.opusMaxAverageBitrate) { if (oldValue.stereo || oldValue.opusMaxAverageBitrate) {
newValue.audioQuality = { newValue.audioQuality = {
opusMaxAverageBitrate: oldValue.audioQuality?.opusMaxAverageBitrate ?? oldValue.opusMaxAverageBitrate, opusMaxAverageBitrate: oldValue.audioQuality?.opusMaxAverageBitrate ?? oldValue.opusMaxAverageBitrate,

View File

@ -371,14 +371,9 @@ function _localParticipantLeft({ dispatch }, next, action) {
*/ */
function _maybePlaySounds({ getState, dispatch }, action) { function _maybePlaySounds({ getState, dispatch }, action) {
const state = getState(); const state = getState();
const { startAudioMuted, disableJoinLeaveSounds } = state['features/base/config']; const { startAudioMuted } = state['features/base/config'];
const { soundsParticipantJoined: joinSound, soundsParticipantLeft: leftSound } = state['features/base/settings']; const { soundsParticipantJoined: joinSound, soundsParticipantLeft: leftSound } = state['features/base/settings'];
// If we have join/leave sounds disabled, don't play anything.
if (disableJoinLeaveSounds) {
return;
}
// We're not playing sounds for local participant // We're not playing sounds for local participant
// nor when the user is joining past the "startAudioMuted" limit. // nor when the user is joining past the "startAudioMuted" limit.
// The intention there was to not play user joined notification in big // The intention there was to not play user joined notification in big

View File

@ -11,6 +11,7 @@ import {
UNREGISTER_SOUND UNREGISTER_SOUND
} from './actionTypes'; } from './actionTypes';
import { getSoundsPath } from './functions'; import { getSoundsPath } from './functions';
import { getDisabledSounds } from './functions.any';
/** /**
* Adds {@link AudioElement} instance to the base/sounds feature state for the * Adds {@link AudioElement} instance to the base/sounds feature state for the
@ -63,15 +64,18 @@ export function _removeAudioElement(soundId: string) {
* *
* @param {string} soundId - The id of the sound to be played (the same one * @param {string} soundId - The id of the sound to be played (the same one
* which was used in {@link registerSound} to register the sound). * which was used in {@link registerSound} to register the sound).
* @returns {{ * @returns {Function}
* type: PLAY_SOUND,
* soundId: string
* }}
*/ */
export function playSound(soundId: string): Object { export function playSound(soundId: string): Object {
return { return (dispatch: Function, getState: Function) => {
type: PLAY_SOUND, const disabledSounds = getDisabledSounds(getState());
soundId
if (!disabledSounds.includes(soundId)) {
dispatch({
type: PLAY_SOUND,
soundId
});
}
}; };
} }

View File

@ -0,0 +1,11 @@
// @flow
/**
* Selector for retrieving the disabled sounds array.
*
* @param {Object} state - The Redux state.
* @returns {Array<string>} - The disabled sound id's array.
*/
export function getDisabledSounds(state: Object) {
return state['features/base/config'].disabledSounds || [];
}

View File

@ -313,10 +313,10 @@ function _handleReceivedMessage({ dispatch, getState },
// Logic for all platforms: // Logic for all platforms:
const state = getState(); const state = getState();
const { isOpen: isChatOpen } = state['features/chat']; const { isOpen: isChatOpen } = state['features/chat'];
const { disableIncomingMessageSound, iAmRecorder } = state['features/base/config']; const { iAmRecorder } = state['features/base/config'];
const { soundsIncomingMessage: soundEnabled } = state['features/base/settings']; const { soundsIncomingMessage: soundEnabled } = state['features/base/settings'];
if (!disableIncomingMessageSound && soundEnabled && shouldPlaySound && !isChatOpen) { if (soundEnabled && shouldPlaySound && !isChatOpen) {
dispatch(playSound(INCOMING_MSG_SOUND_ID)); dispatch(playSound(INCOMING_MSG_SOUND_ID));
} }

View File

@ -17,7 +17,7 @@ export const DIAL_IN_SUMMARY_VIEW_ID = 'DIAL_IN_SUMMARY_VIEW_ID';
* @type {string} * @type {string}
*/ */
export const OUTGOING_CALL_EXPIRED_SOUND_ID export const OUTGOING_CALL_EXPIRED_SOUND_ID
= 'OUTGOING_CALL_EXPIRED_SOUND_ID'; = 'OUTGOING_CALL_EXPIRED_SOUND';
/** /**
* The identifier of the sound to be played when the status of an outgoing call * The identifier of the sound to be played when the status of an outgoing call
@ -26,7 +26,7 @@ export const OUTGOING_CALL_EXPIRED_SOUND_ID
* @type {string} * @type {string}
*/ */
export const OUTGOING_CALL_REJECTED_SOUND_ID export const OUTGOING_CALL_REJECTED_SOUND_ID
= 'OUTGOING_CALL_REJECTED_SOUND_ID'; = 'OUTGOING_CALL_REJECTED_SOUND';
/** /**
* The identifier of the sound to be played when the status of an outgoing call * The identifier of the sound to be played when the status of an outgoing call
@ -34,14 +34,14 @@ export const OUTGOING_CALL_REJECTED_SOUND_ID
* *
* @type {string} * @type {string}
*/ */
export const OUTGOING_CALL_RINGING_SOUND_ID = 'OUTGOING_CALL_RINGING_SOUND_ID'; export const OUTGOING_CALL_RINGING_SOUND_ID = 'OUTGOING_CALL_RINGING_SOUND';
/** /**
* The identifier of the sound to be played when outgoing call is started. * The identifier of the sound to be played when outgoing call is started.
* *
* @type {string} * @type {string}
*/ */
export const OUTGOING_CALL_START_SOUND_ID = 'OUTGOING_CALL_START_SOUND_ID'; export const OUTGOING_CALL_START_SOUND_ID = 'OUTGOING_CALL_START_SOUND';
/** /**
* Regex for matching sip addresses. * Regex for matching sip addresses.

View File

@ -3,4 +3,4 @@
* *
* @type {string} * @type {string}
*/ */
export const NO_AUDIO_SIGNAL_SOUND_ID = 'NO_AUDIO_SIGNAL_SOUND_ID'; export const NO_AUDIO_SIGNAL_SOUND_ID = 'NO_AUDIO_SIGNAL_SOUND';

View File

@ -3,4 +3,4 @@
* *
* @type {string} * @type {string}
*/ */
export const NOISY_AUDIO_INPUT_SOUND_ID = 'NOISY_AUDIO_INPUT_SOUND_ID'; export const NOISY_AUDIO_INPUT_SOUND_ID = 'NOISY_AUDIO_INPUT_SOUND';

View File

@ -68,7 +68,7 @@ export const SILENCE_SOUND_ID = 'SILENCE_SOUND_';
* *
* @type {string} * @type {string}
*/ */
export const RAISE_HAND_SOUND_ID = 'RAISE_HAND_SOUND_ID'; export const RAISE_HAND_SOUND_ID = 'RAISE_HAND_SOUND';
export type ReactionEmojiProps = { export type ReactionEmojiProps = {

View File

@ -135,7 +135,6 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
const { const {
iAmRecorder, iAmRecorder,
iAmSipGateway, iAmSipGateway,
disableRecordAudioNotification,
recordingLimit recordingLimit
} = getState()['features/base/config']; } = getState()['features/base/config'];
@ -165,10 +164,6 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
sendAnalytics(createRecordingEvent('start', mode)); sendAnalytics(createRecordingEvent('start', mode));
if (disableRecordAudioNotification) {
break;
}
let soundID; let soundID;
if (mode === JitsiRecordingConstants.mode.FILE) { if (mode === JitsiRecordingConstants.mode.FILE) {
@ -200,10 +195,6 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
} }
sendAnalytics(createRecordingEvent('stop', mode, duration)); sendAnalytics(createRecordingEvent('stop', mode, duration));
if (disableRecordAudioNotification) {
break;
}
if (mode === JitsiRecordingConstants.mode.FILE) { if (mode === JitsiRecordingConstants.mode.FILE) {
soundOff = RECORDING_OFF_SOUND_ID; soundOff = RECORDING_OFF_SOUND_ID;
soundOn = RECORDING_ON_SOUND_ID; soundOn = RECORDING_ON_SOUND_ID;

View File

@ -3,4 +3,4 @@
* *
* @type {string} * @type {string}
*/ */
export const TALK_WHILE_MUTED_SOUND_ID = 'TALK_WHILE_MUTED_SOUND_ID'; export const TALK_WHILE_MUTED_SOUND_ID = 'TALK_WHILE_MUTED_SOUND';