fix(video-mute) prevent multiple camera track creation

This commit is contained in:
William Liang 2022-09-29 11:26:07 -04:00 committed by Jaya Allamsetty
parent 51bdf67cf2
commit 83dfb67f23
1 changed files with 11 additions and 1 deletions

View File

@ -459,6 +459,11 @@ export default {
*/ */
_localTracksInitialized: false, _localTracksInitialized: false,
/**
* Flag used to prevent the creation of another local video track in this.muteVideo if one is already in progress.
*/
isCreatingLocalTrack: false,
isSharingScreen: false, isSharingScreen: false,
/** /**
@ -1028,11 +1033,13 @@ export default {
const localVideo = getLocalJitsiVideoTrack(APP.store.getState()); const localVideo = getLocalJitsiVideoTrack(APP.store.getState());
if (!localVideo && !mute) { if (!localVideo && !mute && !this.isCreatingLocalTrack) {
const maybeShowErrorDialog = error => { const maybeShowErrorDialog = error => {
showUI && APP.store.dispatch(notifyCameraError(error)); showUI && APP.store.dispatch(notifyCameraError(error));
}; };
this.isCreatingLocalTrack = true;
// Try to create local video if there wasn't any. // Try to create local video if there wasn't any.
// This handles the case when user joined with no video // This handles the case when user joined with no video
// (dismissed screen sharing screen or in audio only mode), but // (dismissed screen sharing screen or in audio only mode), but
@ -1054,6 +1061,9 @@ export default {
logger.debug(`muteVideo: calling useVideoStream for track: ${videoTrack}`); logger.debug(`muteVideo: calling useVideoStream for track: ${videoTrack}`);
return this.useVideoStream(videoTrack); return this.useVideoStream(videoTrack);
})
.finally(() => {
this.isCreatingLocalTrack = false;
}); });
} else { } else {
// FIXME show error dialog if it fails (should be handled by react) // FIXME show error dialog if it fails (should be handled by react)