fix(trackOpQueue):setEffect &_turnScreenSharingOff
This commit is contained in:
parent
1e2f9160b5
commit
61d483ce1a
|
@ -1558,45 +1558,48 @@ export default {
|
||||||
const tracks = APP.store.getState()['features/base/tracks'];
|
const tracks = APP.store.getState()['features/base/tracks'];
|
||||||
const duration = getLocalVideoTrack(tracks)?.jitsiTrack.getDuration() ?? 0;
|
const duration = getLocalVideoTrack(tracks)?.jitsiTrack.getDuration() ?? 0;
|
||||||
|
|
||||||
// If system audio was also shared stop the AudioMixerEffect and dispose of the desktop audio track.
|
APP.store.dispatch(executeTrackOperation(TrackOperationType.Audio, async () => {
|
||||||
if (this._mixerEffect) {
|
// If system audio was also shared stop the AudioMixerEffect and dispose of the desktop audio track.
|
||||||
const localAudio = getLocalJitsiAudioTrack(APP.store.getState());
|
if (this._mixerEffect) {
|
||||||
|
const localAudio = getLocalJitsiAudioTrack(APP.store.getState());
|
||||||
|
|
||||||
await localAudio.setEffect(undefined);
|
await localAudio.setEffect(undefined);
|
||||||
await this._desktopAudioStream.dispose();
|
await this._desktopAudioStream.dispose();
|
||||||
this._mixerEffect = undefined;
|
this._mixerEffect = undefined;
|
||||||
this._desktopAudioStream = undefined;
|
this._desktopAudioStream = undefined;
|
||||||
|
|
||||||
// In case there was no local audio when screen sharing was started the fact that we set the audio stream to
|
// In case there was no local audio when screen sharing was started the fact that we set the audio stream to
|
||||||
// null will take care of the desktop audio stream cleanup.
|
// null will take care of the desktop audio stream cleanup.
|
||||||
} else if (this._desktopAudioStream) {
|
} else if (this._desktopAudioStream) {
|
||||||
await room.replaceTrack(this._desktopAudioStream, null);
|
await room.replaceTrack(this._desktopAudioStream, null);
|
||||||
this._desktopAudioStream.dispose();
|
this._desktopAudioStream.dispose();
|
||||||
this._desktopAudioStream = undefined;
|
this._desktopAudioStream = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
APP.store.dispatch(setScreenAudioShareState(false));
|
APP.store.dispatch(setScreenAudioShareState(false));
|
||||||
let promise;
|
}));
|
||||||
|
|
||||||
if (didHaveVideo && !ignoreDidHaveVideo) {
|
const promise = APP.store.dispatch(executeTrackOperation(TrackOperationType.Video, () => {
|
||||||
promise = createLocalTracksF({ devices: [ 'video' ] })
|
if (didHaveVideo && !ignoreDidHaveVideo) {
|
||||||
.then(([ stream ]) => {
|
return createLocalTracksF({ devices: [ 'video' ] })
|
||||||
logger.debug(`_turnScreenSharingOff using ${stream} for useVideoStream`);
|
.then(([ stream ]) => {
|
||||||
|
logger.debug(`_turnScreenSharingOff using ${stream} for useVideoStream`);
|
||||||
|
|
||||||
return this.useVideoStream(stream);
|
return this.useVideoStream(stream);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
logger.error('failed to switch back to local video', error);
|
logger.error('failed to switch back to local video', error);
|
||||||
|
|
||||||
return this.useVideoStream(null).then(() =>
|
return this.useVideoStream(null).then(() =>
|
||||||
|
|
||||||
// Still fail with the original err
|
// Still fail with the original err
|
||||||
Promise.reject(error)
|
Promise.reject(error)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
} else {
|
}
|
||||||
promise = this.useVideoStream(null);
|
|
||||||
}
|
return this.useVideoStream(null);
|
||||||
|
}));
|
||||||
|
|
||||||
return promise.then(
|
return promise.then(
|
||||||
() => {
|
() => {
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import { IStore } from '../app/types';
|
import { IStore } from '../app/types';
|
||||||
|
import { executeTrackOperation } from '../base/tracks/actions';
|
||||||
import { getLocalJitsiAudioTrack } from '../base/tracks/functions';
|
import { getLocalJitsiAudioTrack } from '../base/tracks/functions';
|
||||||
|
import { TrackOperationType } from '../base/tracks/types';
|
||||||
import { showErrorNotification } from '../notifications/actions';
|
import { showErrorNotification } from '../notifications/actions';
|
||||||
import { NOTIFICATION_TIMEOUT_TYPE } from '../notifications/constants';
|
import { NOTIFICATION_TIMEOUT_TYPE } from '../notifications/constants';
|
||||||
import { NoiseSuppressionEffect } from '../stream-effects/noise-suppression/NoiseSuppressionEffect';
|
import { NoiseSuppressionEffect } from '../stream-effects/noise-suppression/NoiseSuppressionEffect';
|
||||||
|
@ -48,30 +50,32 @@ export function toggleNoiseSuppression(): any {
|
||||||
*/
|
*/
|
||||||
export function setNoiseSuppressionEnabled(enabled: boolean): any {
|
export function setNoiseSuppressionEnabled(enabled: boolean): any {
|
||||||
return async (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
|
return async (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
|
||||||
const state = getState();
|
|
||||||
|
|
||||||
const localAudio = getLocalJitsiAudioTrack(state);
|
|
||||||
const noiseSuppressionEnabled = isNoiseSuppressionEnabled(state);
|
|
||||||
|
|
||||||
logger.info(`Attempting to set noise suppression enabled state: ${enabled}`);
|
logger.info(`Attempting to set noise suppression enabled state: ${enabled}`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (enabled && !noiseSuppressionEnabled) {
|
await dispatch(executeTrackOperation(TrackOperationType.Audio, async () => {
|
||||||
if (!canEnableNoiseSuppression(state, dispatch, localAudio)) {
|
const state = getState();
|
||||||
return;
|
|
||||||
|
const localAudio = getLocalJitsiAudioTrack(state);
|
||||||
|
const noiseSuppressionEnabled = isNoiseSuppressionEnabled(state);
|
||||||
|
|
||||||
|
if (enabled && !noiseSuppressionEnabled) {
|
||||||
|
if (!canEnableNoiseSuppression(state, dispatch, localAudio)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await localAudio.setEffect(new NoiseSuppressionEffect());
|
||||||
|
dispatch(setNoiseSuppressionEnabledState(true));
|
||||||
|
logger.info('Noise suppression enabled.');
|
||||||
|
|
||||||
|
} else if (!enabled && noiseSuppressionEnabled) {
|
||||||
|
await localAudio.setEffect(undefined);
|
||||||
|
dispatch(setNoiseSuppressionEnabledState(false));
|
||||||
|
logger.info('Noise suppression disabled.');
|
||||||
|
} else {
|
||||||
|
logger.warn(`Noise suppression enabled state already: ${enabled}`);
|
||||||
}
|
}
|
||||||
|
}));
|
||||||
await localAudio.setEffect(new NoiseSuppressionEffect());
|
|
||||||
dispatch(setNoiseSuppressionEnabledState(true));
|
|
||||||
logger.info('Noise suppression enabled.');
|
|
||||||
|
|
||||||
} else if (!enabled && noiseSuppressionEnabled) {
|
|
||||||
await localAudio.setEffect(undefined);
|
|
||||||
dispatch(setNoiseSuppressionEnabledState(false));
|
|
||||||
logger.info('Noise suppression disabled.');
|
|
||||||
} else {
|
|
||||||
logger.warn(`Noise suppression enabled state already: ${enabled}`);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(
|
logger.error(
|
||||||
`Failed to set noise suppression enabled to: ${enabled}`,
|
`Failed to set noise suppression enabled to: ${enabled}`,
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
import { IStore } from '../app/types';
|
import { IStore } from '../app/types';
|
||||||
|
import { executeTrackOperation } from '../base/tracks/actions';
|
||||||
|
import { getLocalJitsiVideoTrack } from '../base/tracks/functions.any';
|
||||||
|
import { TrackOperationType } from '../base/tracks/types';
|
||||||
// eslint-disable-next-line lines-around-comment
|
// eslint-disable-next-line lines-around-comment
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { createVirtualBackgroundEffect } from '../stream-effects/virtual-background';
|
import { createVirtualBackgroundEffect } from '../stream-effects/virtual-background';
|
||||||
|
@ -37,6 +40,23 @@ export function toggleBackgroundEffect(options: IVirtualBackgroundOptions, jitsi
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a track operation to enable/disable the virtual background for the local video.
|
||||||
|
*
|
||||||
|
* @param {Object} options - Represents the virtual background set options.
|
||||||
|
* @returns {Function}
|
||||||
|
*/
|
||||||
|
export function toggleBackgroundEffectForTheLocalTrack(options: IVirtualBackgroundOptions) {
|
||||||
|
return function(dispatch: IStore['dispatch'], getState: IStore['getState']) {
|
||||||
|
return dispatch(executeTrackOperation(TrackOperationType.Video, () => {
|
||||||
|
const localVideo = getLocalJitsiVideoTrack(getState());
|
||||||
|
|
||||||
|
return dispatch(toggleBackgroundEffect(options, localVideo));
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the selected virtual background image object.
|
* Sets the selected virtual background image object.
|
||||||
*
|
*
|
||||||
|
|
|
@ -18,9 +18,8 @@ import { connect } from '../../base/redux/functions';
|
||||||
import { updateSettings } from '../../base/settings/actions';
|
import { updateSettings } from '../../base/settings/actions';
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { Tooltip } from '../../base/tooltip';
|
import { Tooltip } from '../../base/tooltip';
|
||||||
import { getLocalVideoTrack } from '../../base/tracks/functions';
|
|
||||||
import Dialog from '../../base/ui/components/web/Dialog';
|
import Dialog from '../../base/ui/components/web/Dialog';
|
||||||
import { toggleBackgroundEffect } from '../actions';
|
import { toggleBackgroundEffectForTheLocalTrack } from '../actions';
|
||||||
import { BACKGROUNDS_LIMIT, IMAGES, type Image, VIRTUAL_BACKGROUND_TYPE } from '../constants';
|
import { BACKGROUNDS_LIMIT, IMAGES, type Image, VIRTUAL_BACKGROUND_TYPE } from '../constants';
|
||||||
import { toDataURL } from '../functions';
|
import { toDataURL } from '../functions';
|
||||||
import logger from '../logger';
|
import logger from '../logger';
|
||||||
|
@ -36,11 +35,6 @@ interface IProps extends WithTranslation {
|
||||||
*/
|
*/
|
||||||
_images: Array<Image>;
|
_images: Array<Image>;
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the jitsi track that will have backgraund effect applied.
|
|
||||||
*/
|
|
||||||
_jitsiTrack: Object;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current local flip x status.
|
* The current local flip x status.
|
||||||
*/
|
*/
|
||||||
|
@ -104,7 +98,6 @@ function _mapStateToProps(state: IReduxState): Object {
|
||||||
_virtualBackground: state['features/virtual-background'],
|
_virtualBackground: state['features/virtual-background'],
|
||||||
_selectedThumbnail: state['features/virtual-background'].selectedThumbnail,
|
_selectedThumbnail: state['features/virtual-background'].selectedThumbnail,
|
||||||
_showUploadButton: !(hasBrandingImages || state['features/base/config'].disableAddingBackgroundImages),
|
_showUploadButton: !(hasBrandingImages || state['features/base/config'].disableAddingBackgroundImages),
|
||||||
_jitsiTrack: getLocalVideoTrack(state['features/base/tracks'])?.jitsiTrack,
|
|
||||||
_multiStreamModeEnabled: getMultipleVideoSendingSupportFeatureFlag(state)
|
_multiStreamModeEnabled: getMultipleVideoSendingSupportFeatureFlag(state)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -272,7 +265,6 @@ const useStyles = makeStyles()(theme => {
|
||||||
*/
|
*/
|
||||||
function VirtualBackground({
|
function VirtualBackground({
|
||||||
_images,
|
_images,
|
||||||
_jitsiTrack,
|
|
||||||
_localFlipX,
|
_localFlipX,
|
||||||
_selectedThumbnail,
|
_selectedThumbnail,
|
||||||
_showUploadButton,
|
_showUploadButton,
|
||||||
|
@ -422,7 +414,7 @@ function VirtualBackground({
|
||||||
|
|
||||||
const applyVirtualBackground = useCallback(async () => {
|
const applyVirtualBackground = useCallback(async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
await dispatch(toggleBackgroundEffect(options, _jitsiTrack));
|
await dispatch(toggleBackgroundEffectForTheLocalTrack(options));
|
||||||
await setLoading(false);
|
await setLoading(false);
|
||||||
|
|
||||||
// Set x scale to default value.
|
// Set x scale to default value.
|
||||||
|
|
Loading…
Reference in New Issue