mirror of
https://gitcode.com/GitHub_Trending/ji/jitsi-meet.git
synced 2025-12-30 03:12:29 +00:00
feat(noise-suppression): persist noise suppression setting (#13593)
* persist noise suppression setting * address code review
This commit is contained in:
committed by
GitHub
parent
3f93a81818
commit
309f23ba94
@@ -743,7 +743,6 @@
|
||||
"newDeviceCameraTitle": "New camera detected",
|
||||
"noiseSuppressionDesktopAudioDescription": "Noise suppression can't be enabled while sharing desktop audio, please disable it and try again.",
|
||||
"noiseSuppressionFailedTitle": "Failed to start noise suppression",
|
||||
"noiseSuppressionNoTrackDescription": "Please unmute your microphone first.",
|
||||
"noiseSuppressionStereoDescription": "Stereo audio noise suppression is not currently supported.",
|
||||
"oldElectronClientDescription1": "You appear to be using an old version of the Jitsi Meet client which has known security vulnerabilities. Please make sure you update to our ",
|
||||
"oldElectronClientDescription2": "latest build",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { IStore } from '../../app/types';
|
||||
import { NoiseSuppressionEffect } from '../../stream-effects/noise-suppression/NoiseSuppressionEffect';
|
||||
import { createVirtualBackgroundEffect } from '../../stream-effects/virtual-background';
|
||||
|
||||
import logger from './logger';
|
||||
@@ -12,6 +13,9 @@ import logger from './logger';
|
||||
export default function loadEffects(store: IStore): Promise<any> {
|
||||
const state = store.getState();
|
||||
const virtualBackground = state['features/virtual-background'];
|
||||
const noiseSuppression = state['features/noise-suppression'];
|
||||
const { noiseSuppression: nsOptions } = state['features/base/config'];
|
||||
|
||||
|
||||
const backgroundPromise = virtualBackground.backgroundEffectEnabled
|
||||
? createVirtualBackgroundEffect(virtualBackground)
|
||||
@@ -22,5 +26,9 @@ export default function loadEffects(store: IStore): Promise<any> {
|
||||
})
|
||||
: Promise.resolve();
|
||||
|
||||
return Promise.all([ backgroundPromise ]);
|
||||
const noiseSuppressionPromise = noiseSuppression?.enabled
|
||||
? Promise.resolve(new NoiseSuppressionEffect(nsOptions))
|
||||
: Promise.resolve();
|
||||
|
||||
return Promise.all([ backgroundPromise, noiseSuppressionPromise ]);
|
||||
}
|
||||
|
||||
@@ -56,8 +56,22 @@ export function setNoiseSuppressionEnabled(enabled: boolean): any {
|
||||
|
||||
logger.info(`Attempting to set noise suppression enabled state: ${enabled}`);
|
||||
|
||||
if (enabled === noiseSuppressionEnabled) {
|
||||
logger.warn(`Noise suppression enabled state already: ${enabled}`);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// If there is no local audio, simply set the enabled state. Once an audio track is created
|
||||
// the effects list will be applied.
|
||||
if (!localAudio) {
|
||||
dispatch(setNoiseSuppressionEnabledState(enabled));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (enabled && !noiseSuppressionEnabled) {
|
||||
if (enabled) {
|
||||
if (!canEnableNoiseSuppression(state, dispatch, localAudio)) {
|
||||
return;
|
||||
}
|
||||
@@ -66,12 +80,10 @@ export function setNoiseSuppressionEnabled(enabled: boolean): any {
|
||||
dispatch(setNoiseSuppressionEnabledState(true));
|
||||
logger.info('Noise suppression enabled.');
|
||||
|
||||
} else if (!enabled && noiseSuppressionEnabled) {
|
||||
} else {
|
||||
await localAudio.setEffect(undefined);
|
||||
dispatch(setNoiseSuppressionEnabledState(false));
|
||||
logger.info('Noise suppression disabled.');
|
||||
} else {
|
||||
logger.warn(`Noise suppression enabled state already: ${enabled}`);
|
||||
}
|
||||
} catch (error) {
|
||||
logger.error(
|
||||
|
||||
@@ -22,15 +22,6 @@ export function isNoiseSuppressionEnabled(state: IReduxState): boolean {
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function canEnableNoiseSuppression(state: IReduxState, dispatch: IStore['dispatch'], localAudio: any): boolean {
|
||||
if (!localAudio) {
|
||||
dispatch(showWarningNotification({
|
||||
titleKey: 'notify.noiseSuppressionFailedTitle',
|
||||
descriptionKey: 'notify.noiseSuppressionNoTrackDescription'
|
||||
}, NOTIFICATION_TIMEOUT_TYPE.MEDIUM));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
const { channelCount } = localAudio.track.getSettings();
|
||||
|
||||
// Sharing screen audio implies an effect being applied to the local track, because currently we don't support
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import PersistenceRegistry from '../base/redux/PersistenceRegistry';
|
||||
import ReducerRegistry from '../base/redux/ReducerRegistry';
|
||||
|
||||
import {
|
||||
@@ -8,14 +9,18 @@ export interface INoiseSuppressionState {
|
||||
enabled: boolean;
|
||||
}
|
||||
|
||||
const STORE_NAME = 'features/noise-suppression';
|
||||
|
||||
const DEFAULT_STATE = {
|
||||
enabled: false
|
||||
};
|
||||
|
||||
PersistenceRegistry.register(STORE_NAME);
|
||||
|
||||
/**
|
||||
* Reduces the Redux actions of the feature features/noise-suppression.
|
||||
*/
|
||||
ReducerRegistry.register<INoiseSuppressionState>('features/noise-suppression',
|
||||
ReducerRegistry.register<INoiseSuppressionState>(STORE_NAME,
|
||||
(state = DEFAULT_STATE, action): INoiseSuppressionState => {
|
||||
const { enabled } = action;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user