Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

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.

Jaya Allamsetty6ede5c478f59
diff --git a/modules/API/API.js b/modules/API/API.js
index 899cb6ccf5..3ba8d47524 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 a10e885204..c410228943 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<string>}
+ */
+export function getScreenshareParticipantIds(stateful: IStateful): Array<string> {
+ 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 778b66c3ed..5d107a8e06 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;