From 6ede5c478f597fdc1ec94f8dba91402afe0d4751 Mon Sep 17 00:00:00 2001 From: Jaya Allamsetty <54324652+jallamsetty1@users.noreply.github.com> Date: Fri, 7 Oct 2022 10:32:07 -0400 Subject: [PATCH] fix(external-api) Remove muted SS tracks from the list of participants currently screensharing. Fixes an issue where 'contentSharingParticipantsChanged' event and 'getContentSharingParticipants' API continue to list IDs of the participants that have already stopped their screenshares. --- modules/API/API.js | 4 ++-- react/features/base/participants/functions.ts | 14 ++++++++++++++ react/features/base/tracks/subscriber.ts | 4 ++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/modules/API/API.js b/modules/API/API.js index 899cb6ccf..3ba8d4752 100644 --- a/modules/API/API.js +++ b/modules/API/API.js @@ -35,6 +35,7 @@ import { LOCAL_PARTICIPANT_DEFAULT_ID, getLocalParticipant, getParticipantById, + getScreenshareParticipantIds, grantModerator, hasRaisedHand, isLocalParticipantModerator, @@ -855,8 +856,7 @@ function initCommands() { callback(Boolean(APP.store.getState()['features/base/config'].startSilent)); break; case 'get-content-sharing-participants': { - const tracks = getState()['features/base/tracks']; - const sharingParticipantIds = tracks.filter(tr => tr.videoType === 'desktop').map(t => t.participantId); + const sharingParticipantIds = getScreenshareParticipantIds(APP.store.getState()); callback({ sharingParticipantIds diff --git a/react/features/base/participants/functions.ts b/react/features/base/participants/functions.ts index a10e88520..c41022894 100644 --- a/react/features/base/participants/functions.ts +++ b/react/features/base/participants/functions.ts @@ -10,6 +10,7 @@ import { GRAVATAR_BASE_URL } from '../avatar/constants'; import { isCORSAvatarURL } from '../avatar/functions'; import { getMultipleVideoSupportFeatureFlag } from '../config/functions.any'; import i18next from '../i18n/i18next'; +import { VIDEO_TYPE } from '../media/constants'; import { toState } from '../redux/functions'; import { getScreenShareTrack } from '../tracks/functions'; import { createDeferred } from '../util/helpers'; @@ -458,6 +459,19 @@ export function getScreenshareParticipantDisplayName(stateful: IStateful, id: st return i18next.t('screenshareDisplayName', { name: ownerDisplayName }); } +/** + * Returns a list of IDs of the participants that are currently screensharing. + * + * @param {(Function|Object)} stateful - The (whole) redux state, or redux's {@code getState} function to be used to + * retrieve the state. + * @returns {Array} + */ +export function getScreenshareParticipantIds(stateful: IStateful): Array { + return toState(stateful)['features/base/tracks'] + .filter(track => track.videoType === VIDEO_TYPE.DESKTOP && !track.muted) + .map(t => t.participantId); +} + /** * Returns the presence status of a participant associated with the passed id. * diff --git a/react/features/base/tracks/subscriber.ts b/react/features/base/tracks/subscriber.ts index 778b66c3e..5d107a8e0 100644 --- a/react/features/base/tracks/subscriber.ts +++ b/react/features/base/tracks/subscriber.ts @@ -1,5 +1,6 @@ import _ from 'lodash'; +import { getScreenshareParticipantIds } from '../participants/functions'; import StateListenerRegistry from '../redux/StateListenerRegistry'; import { isLocalCameraTrackMuted } from './functions'; @@ -8,8 +9,7 @@ import { isLocalCameraTrackMuted } from './functions'; * Notifies when the list of currently sharing participants changes. */ StateListenerRegistry.register( - /* selector */ state => - state['features/base/tracks'].filter(tr => tr.videoType === 'desktop').map(t => t.participantId), + /* selector */ state => getScreenshareParticipantIds(state), /* listener */ (participantIDs, store, previousParticipantIDs) => { if (typeof APP !== 'object') { return;