async _mutePresenterVideo()

in conference.js [1793:1871]


    async _mutePresenterVideo(mute) {
        const maybeShowErrorDialog = error => {
            APP.store.dispatch(notifyCameraError(error));
        };

        // Check for NO-OP
        if (mute && (!this.localPresenterVideo || this.localPresenterVideo.isMuted())) {

            return;
        } else if (!mute && this.localPresenterVideo && !this.localPresenterVideo.isMuted()) {

            return;
        }

        // Create a new presenter track and apply the presenter effect.
        if (!this.localPresenterVideo && !mute) {
            const localVideo = getLocalJitsiVideoTrack(APP.store.getState());
            const { height, width } = localVideo.track.getSettings() ?? localVideo.track.getConstraints();
            const isPortrait = height >= width;
            const DESKTOP_STREAM_CAP = 720;

            const highResolutionTrack
                = (isPortrait && width > DESKTOP_STREAM_CAP) || (!isPortrait && height > DESKTOP_STREAM_CAP);

            // Resizing the desktop track for presenter is causing blurriness of the desktop share on chrome.
            // Disable resizing by default, enable it only when config.js setting is enabled.
            const resizeDesktopStream = highResolutionTrack && config.videoQuality?.resizeDesktopForPresenter;

            if (resizeDesktopStream) {
                let desktopResizeConstraints = {};

                if (height && width) {
                    const advancedConstraints = [ { aspectRatio: (width / height).toPrecision(4) } ];
                    const constraint = isPortrait ? { width: DESKTOP_STREAM_CAP } : { height: DESKTOP_STREAM_CAP };

                    advancedConstraints.push(constraint);
                    desktopResizeConstraints.advanced = advancedConstraints;
                } else {
                    desktopResizeConstraints = {
                        width: 1280,
                        height: 720
                    };
                }

                // Apply the constraints on the desktop track.
                try {
                    await localVideo.track.applyConstraints(desktopResizeConstraints);
                } catch (err) {
                    logger.error('Failed to apply constraints on the desktop stream for presenter mode', err);

                    return;
                }
            }
            const trackHeight = resizeDesktopStream
                ? localVideo.track.getSettings().height ?? DESKTOP_STREAM_CAP
                : height;
            let effect;

            try {
                effect = await this._createPresenterStreamEffect(trackHeight);
            } catch (err) {
                logger.error('Failed to unmute Presenter Video', err);
                maybeShowErrorDialog(err);

                return;
            }

            // Replace the desktop track on the peerconnection.
            try {
                await localVideo.setEffect(effect);
                APP.store.dispatch(setVideoMuted(mute, MEDIA_TYPE.PRESENTER));
                this.setVideoMuteStatus();
            } catch (err) {
                logger.error('Failed to apply the Presenter effect', err);
            }
        } else {
            APP.store.dispatch(setVideoMuted(mute, MEDIA_TYPE.PRESENTER));
        }
    },