@azure/communication-react
Version:
React library for building modern communication user experiences utilizing Azure Communication Services
47 lines • 5.9 kB
JavaScript
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { toFlatCommunicationIdentifier } from "../../acs-ui-common/src";
import { createSelector } from 'reselect';
import { getDisplayName, getDominantSpeakers, getIdentifier, getIsMuted, getIsScreenSharingOn, getLocalVideoStreams, getRealTimeText, getRole, getScreenShareRemoteParticipant } from './baseSelectors';
import { getTogetherModeCallFeature } from './baseSelectors';
import { isHideAttendeeNamesEnabled } from './baseSelectors';
import { getOptimalVideoCount } from './baseSelectors';
import { _updateUserDisplayNames } from './utils/callUtils';
import { checkIsSpeaking } from './utils/SelectorUtils';
import { _videoGalleryRemoteParticipantsMemo, _dominantSpeakersWithFlatId, convertRemoteParticipantToVideoGalleryRemoteParticipant, memoizeLocalParticipant, memoizeTogetherModeStreams, memoizeTogetherModeSeatingPositions } from './utils/videoGalleryUtils';
import { memoizeSpotlightedParticipantIds } from './utils/videoGalleryUtils';
import { getLocalParticipantRaisedHand } from './baseSelectors';
import { getLocalParticipantReactionState } from './baseSelectors';
import { memoizedConvertToVideoTileReaction } from './utils/participantListSelectorUtils';
import { getRemoteParticipantsExcludingConsumers } from './getRemoteParticipantsExcludingConsumers';
import { getSpotlightCallFeature, getCapabilities } from './baseSelectors';
/**
* Provides data attributes to {@link VideoGallery} component.
* @public
*/
export const videoGallerySelector = createSelector([getScreenShareRemoteParticipant, getRemoteParticipantsExcludingConsumers, getLocalVideoStreams, getIsMuted, getIsScreenSharingOn, getDisplayName, getIdentifier, getDominantSpeakers, getOptimalVideoCount, getRole, getLocalParticipantRaisedHand, isHideAttendeeNamesEnabled, getLocalParticipantReactionState, getSpotlightCallFeature, getCapabilities, getTogetherModeCallFeature, getRealTimeText], (screenShareRemoteParticipantId, remoteParticipants, localVideoStreams, isMuted, isScreenSharingOn, displayName, identifier, dominantSpeakers, optimalVideoCount, role, raisedHand, isHideAttendeeNamesEnabled, localParticipantReaction, spotlightCallFeature, capabilities, togetherModeCallFeature, realTimeText) => {
const screenShareRemoteParticipant = screenShareRemoteParticipantId && remoteParticipants ? remoteParticipants[screenShareRemoteParticipantId] : undefined;
const localVideoStream = localVideoStreams === null || localVideoStreams === void 0 ? void 0 : localVideoStreams.find(i => i.mediaStreamType === 'Video');
const localScreenSharingStream = localVideoStreams === null || localVideoStreams === void 0 ? void 0 : localVideoStreams.find(i => i.mediaStreamType === 'ScreenSharing');
const dominantSpeakerIds = _dominantSpeakersWithFlatId(dominantSpeakers);
const dominantSpeakersMap = {};
dominantSpeakerIds === null || dominantSpeakerIds === void 0 ? void 0 : dominantSpeakerIds.forEach((speaker, idx) => dominantSpeakersMap[speaker] = idx);
const noRemoteParticipants = [];
const localParticipantReactionState = memoizedConvertToVideoTileReaction(localParticipantReaction);
const spotlightedParticipantIds = memoizeSpotlightedParticipantIds(spotlightCallFeature === null || spotlightCallFeature === void 0 ? void 0 : spotlightCallFeature.spotlightedParticipants);
const inProgressRealTimeTextParticipantsIds = (realTimeText === null || realTimeText === void 0 ? void 0 : realTimeText.currentInProgress) ? realTimeText.currentInProgress.map(info => toFlatCommunicationIdentifier(info.sender.identifier)) : undefined;
return {
screenShareParticipant: screenShareRemoteParticipant ? convertRemoteParticipantToVideoGalleryRemoteParticipant(toFlatCommunicationIdentifier(screenShareRemoteParticipant.identifier), screenShareRemoteParticipant.isMuted, checkIsSpeaking(screenShareRemoteParticipant, inProgressRealTimeTextParticipantsIds), screenShareRemoteParticipant.videoStreams, screenShareRemoteParticipant.state, screenShareRemoteParticipant.displayName, screenShareRemoteParticipant.raisedHand, screenShareRemoteParticipant.contentSharingStream, undefined, screenShareRemoteParticipant.spotlight, undefined, screenShareRemoteParticipant.mediaAccess, role) : undefined,
localParticipant: memoizeLocalParticipant(identifier, displayName, isMuted, isScreenSharingOn, localVideoStream, localScreenSharingStream, role, raisedHand, localParticipantReactionState, spotlightCallFeature === null || spotlightCallFeature === void 0 ? void 0 : spotlightCallFeature.localParticipantSpotlight, capabilities),
remoteParticipants: _videoGalleryRemoteParticipantsMemo(_updateUserDisplayNames(remoteParticipants ? Object.values(remoteParticipants) : noRemoteParticipants), isHideAttendeeNamesEnabled, role, inProgressRealTimeTextParticipantsIds),
dominantSpeakers: dominantSpeakerIds,
maxRemoteVideoStreams: optimalVideoCount,
spotlightedParticipants: spotlightedParticipantIds,
maxParticipantsToSpotlight: spotlightCallFeature === null || spotlightCallFeature === void 0 ? void 0 : spotlightCallFeature.maxParticipantsToSpotlight,
togetherModeStreams: memoizeTogetherModeStreams(togetherModeCallFeature === null || togetherModeCallFeature === void 0 ? void 0 : togetherModeCallFeature.streams),
togetherModeSeatingCoordinates: memoizeTogetherModeSeatingPositions(togetherModeCallFeature === null || togetherModeCallFeature === void 0 ? void 0 : togetherModeCallFeature.seatingPositions),
isTogetherModeActive: togetherModeCallFeature === null || togetherModeCallFeature === void 0 ? void 0 : togetherModeCallFeature.isActive,
startTogetherModeEnabled: capabilities === null || capabilities === void 0 ? void 0 : capabilities.startTogetherMode.isPresent
};
});
//# sourceMappingURL=videoGallerySelector.js.map