From 873cdbb4049f38be81016fe19fd19ae1157debff Mon Sep 17 00:00:00 2001 From: Jaya Allamsetty <54324652+jallamsetty1@users.noreply.github.com> Date: Wed, 3 Aug 2022 10:57:33 -0400 Subject: [PATCH] fix(external-api) Fix toggleShareScreen in multi-stream mode. Fixes https://github.com/jitsi/jitsi-meet/issues/11916. --- .../base/conference/middleware.web.js | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/react/features/base/conference/middleware.web.js b/react/features/base/conference/middleware.web.js index a149fcb31..bc40230c5 100644 --- a/react/features/base/conference/middleware.web.js +++ b/react/features/base/conference/middleware.web.js @@ -7,7 +7,12 @@ import { setPrejoinPageVisibility, setSkipPrejoinOnReload } from '../../prejoin'; -import { isAudioOnlySharing, setScreenAudioShareState, setScreenshareAudioTrack } from '../../screen-share'; +import { + isAudioOnlySharing, + isScreenVideoShared, + setScreenAudioShareState, + setScreenshareAudioTrack +} from '../../screen-share'; import { isScreenshotCaptureEnabled, toggleScreenshotCaptureSummary } from '../../screenshot-capture'; import { AudioMixerEffect } from '../../stream-effects/audio-mixer/AudioMixerEffect'; import { setAudioOnly } from '../audio-only'; @@ -28,6 +33,8 @@ import { CONFERENCE_FAILED, CONFERENCE_JOIN_IN_PROGRESS, CONFERENCE_JOINED } fro import { getCurrentConference } from './functions'; import './middleware.any'; +declare var APP: Object; + MiddlewareRegistry.register(store => next => action => { const { dispatch, getState } = store; const { enableForcedReload } = getState()['features/base/config']; @@ -135,15 +142,18 @@ async function _toggleScreenSharing({ enabled, audioOnly = false }, store) { const { dispatch, getState } = store; const state = getState(); const audioOnlySharing = isAudioOnlySharing(state); + const screenSharing = isScreenVideoShared(state); const conference = getCurrentConference(state); const localAudio = getLocalJitsiAudioTrack(state); const localScreenshare = getLocalDesktopTrack(state['features/base/tracks']); - // ShareAudioDialog passes undefined when the user hits continue in the share audio demo modal. Audio screen-share - // state is toggled based on the current state of audio share in that case. + // Toggle screenshare or audio-only share if the new state is not passed. Happens in the following two cases. + // 1. ShareAudioDialog passes undefined when the user hits continue in the share audio demo modal. + // 2. Toggle screenshare called from the external API. const enable = audioOnly ? enabled ?? !audioOnlySharing - : enabled; + : enabled ?? !screenSharing; + const screensharingDetails = {}; if (enable) { let tracks; @@ -176,6 +186,7 @@ async function _toggleScreenSharing({ enabled, audioOnly = false }, store) { if (isScreenshotCaptureEnabled(state, false, true)) { dispatch(toggleScreenshotCaptureSummary(true)); } + screensharingDetails.sourceType = desktopVideoTrack.sourceType; } // Apply the AudioMixer effect if there is a local audio track, add the desktop track to the conference @@ -218,5 +229,8 @@ async function _toggleScreenSharing({ enabled, audioOnly = false }, store) { if (audioOnly) { dispatch(setScreenAudioShareState(enable)); + } else { + // Notify the external API. + APP.API.notifyScreenSharingStatusChanged(enable, screensharingDetails); } }