fix(trackOpQueue):setEffect &_turnScreenSharingOff

This commit is contained in:
Hristo Terezov 2022-12-12 15:53:18 -06:00
parent 1e2f9160b5
commit 61d483ce1a
4 changed files with 81 additions and 62 deletions

View File

@ -1558,6 +1558,7 @@ export default {
const tracks = APP.store.getState()['features/base/tracks'];
const duration = getLocalVideoTrack(tracks)?.jitsiTrack.getDuration() ?? 0;
APP.store.dispatch(executeTrackOperation(TrackOperationType.Audio, async () => {
// If system audio was also shared stop the AudioMixerEffect and dispose of the desktop audio track.
if (this._mixerEffect) {
const localAudio = getLocalJitsiAudioTrack(APP.store.getState());
@ -1576,10 +1577,11 @@ export default {
}
APP.store.dispatch(setScreenAudioShareState(false));
let promise;
}));
const promise = APP.store.dispatch(executeTrackOperation(TrackOperationType.Video, () => {
if (didHaveVideo && !ignoreDidHaveVideo) {
promise = createLocalTracksF({ devices: [ 'video' ] })
return createLocalTracksF({ devices: [ 'video' ] })
.then(([ stream ]) => {
logger.debug(`_turnScreenSharingOff using ${stream} for useVideoStream`);
@ -1594,10 +1596,11 @@ export default {
Promise.reject(error)
);
});
} else {
promise = this.useVideoStream(null);
}
return this.useVideoStream(null);
}));
return promise.then(
() => {
this.videoSwitchInProgress = false;

View File

@ -1,5 +1,7 @@
import { IStore } from '../app/types';
import { executeTrackOperation } from '../base/tracks/actions';
import { getLocalJitsiAudioTrack } from '../base/tracks/functions';
import { TrackOperationType } from '../base/tracks/types';
import { showErrorNotification } from '../notifications/actions';
import { NOTIFICATION_TIMEOUT_TYPE } from '../notifications/constants';
import { NoiseSuppressionEffect } from '../stream-effects/noise-suppression/NoiseSuppressionEffect';
@ -48,14 +50,15 @@ export function toggleNoiseSuppression(): any {
*/
export function setNoiseSuppressionEnabled(enabled: boolean): any {
return async (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
logger.info(`Attempting to set noise suppression enabled state: ${enabled}`);
try {
await dispatch(executeTrackOperation(TrackOperationType.Audio, async () => {
const state = getState();
const localAudio = getLocalJitsiAudioTrack(state);
const noiseSuppressionEnabled = isNoiseSuppressionEnabled(state);
logger.info(`Attempting to set noise suppression enabled state: ${enabled}`);
try {
if (enabled && !noiseSuppressionEnabled) {
if (!canEnableNoiseSuppression(state, dispatch, localAudio)) {
return;
@ -72,6 +75,7 @@ export function setNoiseSuppressionEnabled(enabled: boolean): any {
} else {
logger.warn(`Noise suppression enabled state already: ${enabled}`);
}
}));
} catch (error) {
logger.error(
`Failed to set noise suppression enabled to: ${enabled}`,

View File

@ -1,4 +1,7 @@
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
// @ts-ignore
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.
*

View File

@ -18,9 +18,8 @@ import { connect } from '../../base/redux/functions';
import { updateSettings } from '../../base/settings/actions';
// @ts-ignore
import { Tooltip } from '../../base/tooltip';
import { getLocalVideoTrack } from '../../base/tracks/functions';
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 { toDataURL } from '../functions';
import logger from '../logger';
@ -36,11 +35,6 @@ interface IProps extends WithTranslation {
*/
_images: Array<Image>;
/**
* Returns the jitsi track that will have backgraund effect applied.
*/
_jitsiTrack: Object;
/**
* The current local flip x status.
*/
@ -104,7 +98,6 @@ function _mapStateToProps(state: IReduxState): Object {
_virtualBackground: state['features/virtual-background'],
_selectedThumbnail: state['features/virtual-background'].selectedThumbnail,
_showUploadButton: !(hasBrandingImages || state['features/base/config'].disableAddingBackgroundImages),
_jitsiTrack: getLocalVideoTrack(state['features/base/tracks'])?.jitsiTrack,
_multiStreamModeEnabled: getMultipleVideoSendingSupportFeatureFlag(state)
};
}
@ -272,7 +265,6 @@ const useStyles = makeStyles()(theme => {
*/
function VirtualBackground({
_images,
_jitsiTrack,
_localFlipX,
_selectedThumbnail,
_showUploadButton,
@ -422,7 +414,7 @@ function VirtualBackground({
const applyVirtualBackground = useCallback(async () => {
setLoading(true);
await dispatch(toggleBackgroundEffect(options, _jitsiTrack));
await dispatch(toggleBackgroundEffectForTheLocalTrack(options));
await setLoading(false);
// Set x scale to default value.