2022-11-10 08:45:56 +00:00
|
|
|
import { IReduxState } from '../app/types';
|
|
|
|
import { IStateful } from '../base/app/types';
|
2022-02-24 12:20:37 +00:00
|
|
|
import { isMobileBrowser } from '../base/environment/utils';
|
2022-11-10 08:45:56 +00:00
|
|
|
import { MEDIA_TYPE } from '../base/media/constants';
|
2018-05-22 22:41:53 +00:00
|
|
|
import {
|
2020-11-09 20:59:13 +00:00
|
|
|
getLocalParticipant,
|
|
|
|
getParticipantById,
|
2022-06-29 13:59:49 +00:00
|
|
|
getParticipantCount,
|
2018-11-27 20:22:25 +00:00
|
|
|
getParticipantCountWithFake,
|
2022-10-06 11:12:57 +00:00
|
|
|
getPinnedParticipant,
|
|
|
|
isScreenShareParticipant
|
2022-11-10 08:45:56 +00:00
|
|
|
} from '../base/participants/functions';
|
|
|
|
import { toState } from '../base/redux/functions';
|
2023-01-27 14:30:47 +00:00
|
|
|
import { getHideSelfView } from '../base/settings/functions.any';
|
2020-11-09 20:59:13 +00:00
|
|
|
import {
|
2022-11-08 19:15:49 +00:00
|
|
|
getVideoTrackByParticipant,
|
2020-11-09 20:59:13 +00:00
|
|
|
isLocalTrackMuted,
|
|
|
|
isRemoteTrackMuted
|
2021-01-07 20:39:21 +00:00
|
|
|
} from '../base/tracks/functions';
|
2022-11-08 19:15:49 +00:00
|
|
|
import { isTrackStreamingStatusActive } from '../connection-indicator/functions';
|
2022-03-29 08:45:09 +00:00
|
|
|
import { isSharingStatus } from '../shared-video/functions';
|
2022-11-10 08:45:56 +00:00
|
|
|
import { LAYOUTS } from '../video-layout/constants';
|
|
|
|
import { getCurrentLayout, getNotResponsiveTileViewGridDimensions } from '../video-layout/functions.web';
|
2017-08-29 15:08:16 +00:00
|
|
|
|
2021-01-21 20:46:47 +00:00
|
|
|
import {
|
|
|
|
ASPECT_RATIO_BREAKPOINT,
|
2022-02-24 12:20:37 +00:00
|
|
|
DEFAULT_FILMSTRIP_WIDTH,
|
2022-03-02 14:46:20 +00:00
|
|
|
DEFAULT_LOCAL_TILE_ASPECT_RATIO,
|
2021-01-21 20:46:47 +00:00
|
|
|
DISPLAY_AVATAR,
|
|
|
|
DISPLAY_VIDEO,
|
2022-02-24 12:20:37 +00:00
|
|
|
FILMSTRIP_GRID_BREAKPOINT,
|
2022-06-29 13:59:49 +00:00
|
|
|
FILMSTRIP_TYPE,
|
2021-12-15 13:18:41 +00:00
|
|
|
INDICATORS_TOOLTIP_POSITION,
|
2022-03-12 03:44:34 +00:00
|
|
|
SCROLL_SIZE,
|
2021-01-21 20:46:47 +00:00
|
|
|
SQUARE_TILE_ASPECT_RATIO,
|
2022-04-12 13:19:10 +00:00
|
|
|
THUMBNAIL_TYPE,
|
2021-03-26 20:23:05 +00:00
|
|
|
TILE_ASPECT_RATIO,
|
|
|
|
TILE_HORIZONTAL_MARGIN,
|
2022-02-24 12:20:37 +00:00
|
|
|
TILE_MIN_HEIGHT_LARGE,
|
|
|
|
TILE_MIN_HEIGHT_SMALL,
|
|
|
|
TILE_PORTRAIT_ASPECT_RATIO,
|
2021-03-26 20:23:05 +00:00
|
|
|
TILE_VERTICAL_MARGIN,
|
2022-03-11 00:27:37 +00:00
|
|
|
TILE_VIEW_DEFAULT_NUMBER_OF_VISIBLE_TILES,
|
2021-12-15 13:18:41 +00:00
|
|
|
TILE_VIEW_GRID_HORIZONTAL_MARGIN,
|
|
|
|
TILE_VIEW_GRID_VERTICAL_MARGIN,
|
2022-02-24 12:20:37 +00:00
|
|
|
VERTICAL_VIEW_HORIZONTAL_MARGIN
|
2021-01-21 20:46:47 +00:00
|
|
|
} from './constants';
|
2020-01-24 16:28:47 +00:00
|
|
|
|
2021-08-23 23:02:41 +00:00
|
|
|
export * from './functions.any';
|
|
|
|
|
2018-06-14 09:14:32 +00:00
|
|
|
/**
|
|
|
|
* Returns true if the filmstrip on mobile is visible, false otherwise.
|
|
|
|
*
|
|
|
|
* NOTE: Filmstrip on web behaves differently to mobile, much simpler, but so
|
|
|
|
* function lies here only for the sake of consistency and to avoid flow errors
|
|
|
|
* on import.
|
|
|
|
*
|
2022-11-10 08:45:56 +00:00
|
|
|
* @param {IStateful} stateful - The Object or Function that can be
|
2018-06-14 09:14:32 +00:00
|
|
|
* resolved to a Redux state object with the toState function.
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2022-11-10 08:45:56 +00:00
|
|
|
export function isFilmstripVisible(stateful: IStateful) {
|
2018-06-14 09:14:32 +00:00
|
|
|
return toState(stateful)['features/filmstrip'].visible;
|
|
|
|
}
|
|
|
|
|
2017-08-29 15:08:16 +00:00
|
|
|
/**
|
2017-10-13 19:31:05 +00:00
|
|
|
* Determines whether the remote video thumbnails should be displayed/visible in
|
|
|
|
* the filmstrip.
|
2017-08-29 15:08:16 +00:00
|
|
|
*
|
2022-11-10 08:45:56 +00:00
|
|
|
* @param {IReduxState} state - The full redux state.
|
2017-10-13 19:31:05 +00:00
|
|
|
* @returns {boolean} - If remote video thumbnails should be displayed/visible
|
|
|
|
* in the filmstrip, then {@code true}; otherwise, {@code false}.
|
2017-08-29 15:08:16 +00:00
|
|
|
*/
|
2022-11-10 08:45:56 +00:00
|
|
|
export function shouldRemoteVideosBeVisible(state: IReduxState) {
|
2018-06-26 22:56:22 +00:00
|
|
|
if (state['features/invite'].calleeInfoVisible) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-07-14 07:10:08 +00:00
|
|
|
// Include fake participants to derive how many thumbnails are displayed,
|
2018-11-27 20:22:25 +00:00
|
|
|
// as it is assumed all participants, including fake, will be displayed
|
|
|
|
// in the filmstrip.
|
|
|
|
const participantCount = getParticipantCountWithFake(state);
|
2017-10-13 19:31:05 +00:00
|
|
|
let pinnedParticipant;
|
2021-06-10 11:51:51 +00:00
|
|
|
const { disable1On1Mode } = state['features/base/config'];
|
2021-09-14 07:43:52 +00:00
|
|
|
const { contextMenuOpened } = state['features/base/responsive-ui'];
|
2017-08-29 15:08:16 +00:00
|
|
|
|
2017-10-13 19:31:05 +00:00
|
|
|
return Boolean(
|
2021-09-14 07:43:52 +00:00
|
|
|
contextMenuOpened
|
|
|
|
|| participantCount > 2
|
2017-08-29 15:08:16 +00:00
|
|
|
|
2017-10-13 19:31:05 +00:00
|
|
|
// Always show the filmstrip when there is another participant to
|
2021-01-29 13:34:37 +00:00
|
|
|
// show and the local video is pinned, or the toolbar is displayed.
|
2017-10-13 19:31:05 +00:00
|
|
|
|| (participantCount > 1
|
2021-06-10 11:51:51 +00:00
|
|
|
&& disable1On1Mode !== null
|
2021-01-29 13:34:37 +00:00
|
|
|
&& (state['features/toolbox'].visible
|
2018-05-22 22:41:53 +00:00
|
|
|
|| ((pinnedParticipant = getPinnedParticipant(state))
|
2017-10-13 19:31:05 +00:00
|
|
|
&& pinnedParticipant.local)))
|
2017-08-29 15:08:16 +00:00
|
|
|
|
2021-06-10 11:51:51 +00:00
|
|
|
|| disable1On1Mode);
|
2017-08-29 15:08:16 +00:00
|
|
|
}
|
2020-01-24 16:28:47 +00:00
|
|
|
|
2020-11-09 20:59:13 +00:00
|
|
|
/**
|
|
|
|
* Checks whether there is a playable video stream available for the user associated with the passed ID.
|
|
|
|
*
|
2022-11-10 08:45:56 +00:00
|
|
|
* @param {IStateful} stateful - The Object or Function that can be
|
2020-11-09 20:59:13 +00:00
|
|
|
* resolved to a Redux state object with the toState function.
|
|
|
|
* @param {string} id - The id of the participant.
|
|
|
|
* @returns {boolean} <tt>true</tt> if there is a playable video stream available
|
|
|
|
* or <tt>false</tt> otherwise.
|
|
|
|
*/
|
2022-11-10 08:45:56 +00:00
|
|
|
export function isVideoPlayable(stateful: IStateful, id: string) {
|
2020-11-09 20:59:13 +00:00
|
|
|
const state = toState(stateful);
|
|
|
|
const tracks = state['features/base/tracks'];
|
|
|
|
const participant = id ? getParticipantById(state, id) : getLocalParticipant(state);
|
|
|
|
const isLocal = participant?.local ?? true;
|
2022-11-08 19:15:49 +00:00
|
|
|
const videoTrack = getVideoTrackByParticipant(state, participant);
|
2020-11-09 20:59:13 +00:00
|
|
|
const isAudioOnly = Boolean(state['features/base/audio-only'].enabled);
|
|
|
|
let isPlayable = false;
|
|
|
|
|
2021-01-06 23:50:28 +00:00
|
|
|
if (isLocal) {
|
|
|
|
const isVideoMuted = isLocalTrackMuted(tracks, MEDIA_TYPE.VIDEO);
|
|
|
|
|
2020-11-09 20:59:13 +00:00
|
|
|
isPlayable = Boolean(videoTrack) && !isVideoMuted && !isAudioOnly;
|
2022-10-06 11:12:57 +00:00
|
|
|
} else if (!participant?.fakeParticipant || isScreenShareParticipant(participant)) {
|
|
|
|
// remote participants excluding shared video
|
2021-01-06 23:50:28 +00:00
|
|
|
const isVideoMuted = isRemoteTrackMuted(tracks, MEDIA_TYPE.VIDEO, id);
|
|
|
|
|
2022-11-08 19:15:49 +00:00
|
|
|
isPlayable = Boolean(videoTrack) && !isVideoMuted && !isAudioOnly && isTrackStreamingStatusActive(videoTrack);
|
2020-11-09 20:59:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return isPlayable;
|
|
|
|
}
|
|
|
|
|
2020-01-24 16:28:47 +00:00
|
|
|
/**
|
|
|
|
* Calculates the size for thumbnails when in horizontal view layout.
|
|
|
|
*
|
|
|
|
* @param {number} clientHeight - The height of the app window.
|
|
|
|
* @returns {{local: {height, width}, remote: {height, width}}}
|
|
|
|
*/
|
2022-11-10 08:45:56 +00:00
|
|
|
export function calculateThumbnailSizeForHorizontalView(clientHeight = 0) {
|
2020-01-24 16:28:47 +00:00
|
|
|
const topBottomMargin = 15;
|
2022-02-24 12:20:37 +00:00
|
|
|
const availableHeight = Math.min(clientHeight,
|
|
|
|
(interfaceConfig.FILM_STRIP_MAX_HEIGHT || DEFAULT_FILMSTRIP_WIDTH) + topBottomMargin);
|
2020-01-24 16:28:47 +00:00
|
|
|
const height = availableHeight - topBottomMargin;
|
|
|
|
|
|
|
|
return {
|
|
|
|
local: {
|
|
|
|
height,
|
|
|
|
width: Math.floor(interfaceConfig.LOCAL_THUMBNAIL_RATIO * height)
|
|
|
|
},
|
|
|
|
remote: {
|
|
|
|
height,
|
|
|
|
width: Math.floor(interfaceConfig.REMOTE_THUMBNAIL_RATIO * height)
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-03-26 20:23:05 +00:00
|
|
|
/**
|
|
|
|
* Calculates the size for thumbnails when in vertical view layout.
|
|
|
|
*
|
|
|
|
* @param {number} clientWidth - The height of the app window.
|
2022-02-24 12:20:37 +00:00
|
|
|
* @param {number} filmstripWidth - The width of the filmstrip.
|
2022-03-02 14:46:20 +00:00
|
|
|
* @param {boolean} isResizable - Whether the filmstrip is resizable or not.
|
2022-02-24 12:20:37 +00:00
|
|
|
* @returns {{local: {height, width}, remote: {height, width}}}
|
|
|
|
*/
|
2022-11-10 08:45:56 +00:00
|
|
|
export function calculateThumbnailSizeForVerticalView(clientWidth = 0, filmstripWidth = 0, isResizable = false) {
|
2022-02-24 12:20:37 +00:00
|
|
|
const availableWidth = Math.min(
|
|
|
|
Math.max(clientWidth - VERTICAL_VIEW_HORIZONTAL_MARGIN, 0),
|
2022-03-02 14:46:20 +00:00
|
|
|
(isResizable ? filmstripWidth : interfaceConfig.FILM_STRIP_MAX_HEIGHT) || DEFAULT_FILMSTRIP_WIDTH);
|
2022-02-24 12:20:37 +00:00
|
|
|
|
|
|
|
return {
|
|
|
|
local: {
|
2022-03-02 14:46:20 +00:00
|
|
|
height: Math.floor(availableWidth
|
|
|
|
/ (interfaceConfig.LOCAL_THUMBNAIL_RATIO || DEFAULT_LOCAL_TILE_ASPECT_RATIO)),
|
2022-02-24 12:20:37 +00:00
|
|
|
width: availableWidth
|
|
|
|
},
|
|
|
|
remote: {
|
2022-03-02 14:46:20 +00:00
|
|
|
height: isResizable
|
|
|
|
? DEFAULT_FILMSTRIP_WIDTH
|
|
|
|
: Math.floor(availableWidth / interfaceConfig.REMOTE_THUMBNAIL_RATIO),
|
2022-02-24 12:20:37 +00:00
|
|
|
width: availableWidth
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-03-11 00:27:37 +00:00
|
|
|
/**
|
|
|
|
* Returns the minimum height of a thumbnail.
|
|
|
|
*
|
|
|
|
* @param {number} clientWidth - The width of the window.
|
|
|
|
* @returns {number} The minimum height of a thumbnail.
|
|
|
|
*/
|
2022-11-10 08:45:56 +00:00
|
|
|
export function getThumbnailMinHeight(clientWidth: number) {
|
2022-03-11 00:27:37 +00:00
|
|
|
return clientWidth < ASPECT_RATIO_BREAKPOINT ? TILE_MIN_HEIGHT_SMALL : TILE_MIN_HEIGHT_LARGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the default aspect ratio for a tile.
|
|
|
|
*
|
|
|
|
* @param {boolean} disableResponsiveTiles - Indicates whether the responsive tiles functionality is disabled.
|
|
|
|
* @param {boolean} disableTileEnlargement - Indicates whether the tiles enlargement functionality is disabled.
|
|
|
|
* @param {number} clientWidth - The width of the window.
|
|
|
|
* @returns {number} The default aspect ratio for a tile.
|
|
|
|
*/
|
2022-11-10 08:45:56 +00:00
|
|
|
export function getTileDefaultAspectRatio(disableResponsiveTiles: boolean,
|
|
|
|
disableTileEnlargement: boolean, clientWidth: number) {
|
2022-03-11 00:27:37 +00:00
|
|
|
if (!disableResponsiveTiles && disableTileEnlargement && clientWidth < ASPECT_RATIO_BREAKPOINT) {
|
|
|
|
return SQUARE_TILE_ASPECT_RATIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TILE_ASPECT_RATIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the number of participants that will be displayed in tile view.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The redux store state.
|
|
|
|
* @returns {number} The number of participants that will be displayed in tile view.
|
|
|
|
*/
|
2022-11-10 08:45:56 +00:00
|
|
|
export function getNumberOfPartipantsForTileView(state: IReduxState) {
|
2022-03-11 00:27:37 +00:00
|
|
|
const { iAmRecorder } = state['features/base/config'];
|
2023-01-27 14:30:47 +00:00
|
|
|
const disableSelfView = getHideSelfView(state);
|
2022-04-04 18:57:58 +00:00
|
|
|
const { localScreenShare } = state['features/base/participants'];
|
2022-11-08 19:15:49 +00:00
|
|
|
const localParticipantsCount = localScreenShare ? 2 : 1;
|
2022-03-11 00:27:37 +00:00
|
|
|
const numberOfParticipants = getParticipantCountWithFake(state)
|
|
|
|
- (iAmRecorder ? 1 : 0)
|
2022-04-04 18:57:58 +00:00
|
|
|
- (disableSelfView ? localParticipantsCount : 0);
|
2022-03-11 00:27:37 +00:00
|
|
|
|
|
|
|
return numberOfParticipants;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Calculates the dimensions (thumbnail width/height and columns/row) for tile view when the responsive tiles are
|
|
|
|
* disabled.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The redux store state.
|
|
|
|
* @returns {Object} - The dimensions.
|
|
|
|
*/
|
2022-11-10 08:45:56 +00:00
|
|
|
export function calculateNonResponsiveTileViewDimensions(state: IReduxState) {
|
2022-03-11 00:27:37 +00:00
|
|
|
const { clientHeight, clientWidth } = state['features/base/responsive-ui'];
|
|
|
|
const { disableTileEnlargement } = state['features/base/config'];
|
2022-04-12 13:19:10 +00:00
|
|
|
const { columns: c, minVisibleRows, rows: r } = getNotResponsiveTileViewGridDimensions(state);
|
2022-03-11 00:27:37 +00:00
|
|
|
const size = calculateThumbnailSizeForTileView({
|
|
|
|
columns: c,
|
|
|
|
minVisibleRows,
|
2022-04-12 13:19:10 +00:00
|
|
|
clientWidth,
|
2022-03-11 00:27:37 +00:00
|
|
|
clientHeight,
|
|
|
|
disableTileEnlargement,
|
|
|
|
disableResponsiveTiles: true
|
|
|
|
});
|
|
|
|
|
|
|
|
if (typeof size === 'undefined') { // The columns don't fit into the screen. We will have horizontal scroll.
|
|
|
|
const aspectRatio = disableTileEnlargement
|
|
|
|
? getTileDefaultAspectRatio(true, disableTileEnlargement, clientWidth)
|
|
|
|
: TILE_PORTRAIT_ASPECT_RATIO;
|
|
|
|
|
|
|
|
const height = getThumbnailMinHeight(clientWidth);
|
|
|
|
|
|
|
|
return {
|
|
|
|
height,
|
|
|
|
width: aspectRatio * height,
|
|
|
|
columns: c,
|
|
|
|
rows: r
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
height: size.height,
|
|
|
|
width: size.width,
|
|
|
|
columns: c,
|
|
|
|
rows: r
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Calculates the dimensions (thumbnail width/height and columns/row) for tile view when the responsive tiles are
|
|
|
|
* enabled.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The redux store state.
|
|
|
|
* @returns {Object} - The dimensions.
|
|
|
|
*/
|
|
|
|
export function calculateResponsiveTileViewDimensions({
|
|
|
|
clientWidth,
|
|
|
|
clientHeight,
|
|
|
|
disableTileEnlargement = false,
|
2022-03-29 08:45:09 +00:00
|
|
|
noHorizontalContainerMargin = false,
|
2022-03-11 00:27:37 +00:00
|
|
|
maxColumns,
|
|
|
|
numberOfParticipants,
|
2022-06-29 13:59:49 +00:00
|
|
|
desiredNumberOfVisibleTiles = TILE_VIEW_DEFAULT_NUMBER_OF_VISIBLE_TILES,
|
|
|
|
minTileHeight
|
2022-11-10 08:45:56 +00:00
|
|
|
}: {
|
|
|
|
clientHeight: number;
|
|
|
|
clientWidth: number;
|
|
|
|
desiredNumberOfVisibleTiles: number;
|
|
|
|
disableTileEnlargement?: boolean;
|
|
|
|
maxColumns: number;
|
|
|
|
minTileHeight?: number | null;
|
|
|
|
noHorizontalContainerMargin?: boolean;
|
|
|
|
numberOfParticipants: number;
|
2022-03-11 00:27:37 +00:00
|
|
|
}) {
|
|
|
|
let height, width;
|
|
|
|
let columns, rows;
|
2022-11-10 08:45:56 +00:00
|
|
|
|
|
|
|
interface IDimensions {
|
|
|
|
columns?: number;
|
|
|
|
height?: number;
|
|
|
|
maxArea: number;
|
|
|
|
numberOfVisibleParticipants?: number;
|
|
|
|
rows?: number;
|
|
|
|
width?: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
let dimensions: IDimensions = {
|
2022-03-11 00:27:37 +00:00
|
|
|
maxArea: 0
|
|
|
|
};
|
2022-11-10 08:45:56 +00:00
|
|
|
let minHeightEnforcedDimensions: IDimensions = {
|
2022-03-11 00:27:37 +00:00
|
|
|
maxArea: 0
|
|
|
|
};
|
2022-11-10 08:45:56 +00:00
|
|
|
let zeroVisibleRowsDimensions: IDimensions = {
|
2022-03-11 00:27:37 +00:00
|
|
|
maxArea: 0
|
|
|
|
};
|
|
|
|
|
2022-03-25 15:40:46 +00:00
|
|
|
for (let c = 1; c <= Math.min(maxColumns, numberOfParticipants, desiredNumberOfVisibleTiles); c++) {
|
2022-03-11 00:27:37 +00:00
|
|
|
const r = Math.ceil(numberOfParticipants / c);
|
|
|
|
|
2022-03-25 15:40:46 +00:00
|
|
|
// we want to display as much as possible tumbnails up to desiredNumberOfVisibleTiles
|
2022-03-11 00:27:37 +00:00
|
|
|
const visibleRows
|
2022-03-25 15:40:46 +00:00
|
|
|
= numberOfParticipants <= desiredNumberOfVisibleTiles ? r : Math.floor(desiredNumberOfVisibleTiles / c);
|
2022-03-11 00:27:37 +00:00
|
|
|
|
|
|
|
const size = calculateThumbnailSizeForTileView({
|
|
|
|
columns: c,
|
|
|
|
minVisibleRows: visibleRows,
|
|
|
|
clientWidth,
|
|
|
|
clientHeight,
|
|
|
|
disableTileEnlargement,
|
|
|
|
disableResponsiveTiles: false,
|
2022-06-29 13:59:49 +00:00
|
|
|
noHorizontalContainerMargin,
|
|
|
|
minTileHeight
|
2022-03-11 00:27:37 +00:00
|
|
|
});
|
|
|
|
|
2022-03-12 03:44:34 +00:00
|
|
|
if (size) {
|
2022-03-11 00:27:37 +00:00
|
|
|
const { height: currentHeight, width: currentWidth, minHeightEnforced, maxVisibleRows } = size;
|
2022-03-25 15:40:46 +00:00
|
|
|
const numberOfVisibleParticipants = Math.min(c * maxVisibleRows, numberOfParticipants);
|
|
|
|
|
|
|
|
let area = Math.round(
|
|
|
|
(currentHeight + TILE_VERTICAL_MARGIN)
|
|
|
|
* (currentWidth + TILE_HORIZONTAL_MARGIN)
|
|
|
|
* numberOfVisibleParticipants);
|
|
|
|
|
2022-03-12 03:44:34 +00:00
|
|
|
const currentDimensions = {
|
|
|
|
maxArea: area,
|
|
|
|
height: currentHeight,
|
|
|
|
width: currentWidth,
|
|
|
|
columns: c,
|
2022-03-25 15:40:46 +00:00
|
|
|
rows: r,
|
|
|
|
numberOfVisibleParticipants
|
2022-03-12 03:44:34 +00:00
|
|
|
};
|
2022-03-25 15:40:46 +00:00
|
|
|
const { numberOfVisibleParticipants: oldNumberOfVisibleParticipants = 0 } = dimensions;
|
|
|
|
|
|
|
|
if (!minHeightEnforced) {
|
|
|
|
if (area > dimensions.maxArea) {
|
|
|
|
dimensions = currentDimensions;
|
|
|
|
} else if ((area === dimensions.maxArea)
|
|
|
|
&& ((oldNumberOfVisibleParticipants > desiredNumberOfVisibleTiles
|
|
|
|
&& oldNumberOfVisibleParticipants >= numberOfParticipants)
|
|
|
|
|| (oldNumberOfVisibleParticipants < numberOfParticipants
|
|
|
|
&& numberOfVisibleParticipants <= desiredNumberOfVisibleTiles))
|
2022-07-14 07:10:08 +00:00
|
|
|
) { // If the area of the new candidates and the old ones are equal we prefer the one that will have
|
2022-03-25 15:40:46 +00:00
|
|
|
// closer number of visible participants to desiredNumberOfVisibleTiles config.
|
|
|
|
dimensions = currentDimensions;
|
|
|
|
}
|
|
|
|
} else if (minHeightEnforced && area >= minHeightEnforcedDimensions.maxArea) {
|
|
|
|
// If we choose configuration with minHeightEnforced there will be less than desiredNumberOfVisibleTiles
|
|
|
|
// visible tiles, that's why we prefer more columns when the area is the same.
|
2022-03-12 03:44:34 +00:00
|
|
|
minHeightEnforcedDimensions = currentDimensions;
|
|
|
|
} else if (minHeightEnforced && maxVisibleRows === 0) {
|
|
|
|
area = currentHeight * currentWidth * Math.min(c, numberOfParticipants);
|
|
|
|
|
|
|
|
if (area > zeroVisibleRowsDimensions.maxArea) {
|
|
|
|
zeroVisibleRowsDimensions = {
|
|
|
|
...currentDimensions,
|
|
|
|
maxArea: area
|
2022-03-11 00:27:37 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dimensions.maxArea > 0) {
|
|
|
|
({ height, width, columns, rows } = dimensions);
|
|
|
|
} else if (minHeightEnforcedDimensions.maxArea > 0) {
|
|
|
|
({ height, width, columns, rows } = minHeightEnforcedDimensions);
|
|
|
|
} else if (zeroVisibleRowsDimensions.maxArea > 0) {
|
|
|
|
({ height, width, columns, rows } = zeroVisibleRowsDimensions);
|
|
|
|
} else { // This would mean that we can't fit even one thumbnail with minimal size.
|
|
|
|
const aspectRatio = disableTileEnlargement
|
|
|
|
? getTileDefaultAspectRatio(false, disableTileEnlargement, clientWidth)
|
|
|
|
: TILE_PORTRAIT_ASPECT_RATIO;
|
|
|
|
|
|
|
|
height = getThumbnailMinHeight(clientWidth);
|
|
|
|
width = aspectRatio * height;
|
|
|
|
columns = 1;
|
|
|
|
rows = numberOfParticipants;
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
height,
|
|
|
|
width,
|
|
|
|
columns,
|
|
|
|
rows
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-01-24 16:28:47 +00:00
|
|
|
/**
|
|
|
|
* Calculates the size for thumbnails when in tile view layout.
|
|
|
|
*
|
|
|
|
* @param {Object} dimensions - The desired dimensions of the tile view grid.
|
2021-03-26 20:23:05 +00:00
|
|
|
* @returns {{hasScroll, height, width}}
|
2020-01-24 16:28:47 +00:00
|
|
|
*/
|
|
|
|
export function calculateThumbnailSizeForTileView({
|
|
|
|
columns,
|
2021-03-26 20:23:05 +00:00
|
|
|
minVisibleRows,
|
2020-01-24 16:28:47 +00:00
|
|
|
clientWidth,
|
2021-01-26 08:33:31 +00:00
|
|
|
clientHeight,
|
2022-03-11 00:27:37 +00:00
|
|
|
disableResponsiveTiles = false,
|
|
|
|
disableTileEnlargement = false,
|
2022-06-29 13:59:49 +00:00
|
|
|
noHorizontalContainerMargin = false,
|
|
|
|
minTileHeight
|
2022-11-10 08:45:56 +00:00
|
|
|
}: {
|
|
|
|
clientHeight: number;
|
|
|
|
clientWidth: number;
|
|
|
|
columns: number;
|
|
|
|
disableResponsiveTiles: boolean;
|
|
|
|
disableTileEnlargement?: boolean;
|
|
|
|
minTileHeight?: number | null;
|
|
|
|
minVisibleRows: number;
|
|
|
|
noHorizontalContainerMargin?: boolean;
|
|
|
|
}) {
|
2022-03-11 00:27:37 +00:00
|
|
|
const aspectRatio = getTileDefaultAspectRatio(disableResponsiveTiles, disableTileEnlargement, clientWidth);
|
2022-06-29 13:59:49 +00:00
|
|
|
const minHeight = minTileHeight || getThumbnailMinHeight(clientWidth);
|
2022-02-24 12:20:37 +00:00
|
|
|
const viewWidth = clientWidth - (columns * TILE_HORIZONTAL_MARGIN)
|
2022-03-29 08:45:09 +00:00
|
|
|
- (noHorizontalContainerMargin ? SCROLL_SIZE : TILE_VIEW_GRID_HORIZONTAL_MARGIN);
|
2022-03-25 15:40:46 +00:00
|
|
|
const availableHeight = clientHeight - TILE_VIEW_GRID_VERTICAL_MARGIN;
|
|
|
|
const viewHeight = availableHeight - (minVisibleRows * TILE_VERTICAL_MARGIN);
|
2020-01-24 16:28:47 +00:00
|
|
|
const initialWidth = viewWidth / columns;
|
2022-03-11 00:27:37 +00:00
|
|
|
let initialHeight = viewHeight / minVisibleRows;
|
|
|
|
let minHeightEnforced = false;
|
2021-12-20 09:32:31 +00:00
|
|
|
|
2022-03-11 00:27:37 +00:00
|
|
|
if (initialHeight < minHeight) {
|
|
|
|
minHeightEnforced = true;
|
|
|
|
initialHeight = minHeight;
|
2021-12-20 09:32:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (disableTileEnlargement) {
|
2022-03-11 00:27:37 +00:00
|
|
|
const aspectRatioHeight = initialWidth / aspectRatio;
|
|
|
|
|
|
|
|
if (aspectRatioHeight < minHeight) { // we can't fit the required number of columns.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-03-25 15:40:46 +00:00
|
|
|
const height = Math.min(aspectRatioHeight, initialHeight);
|
2022-03-11 00:27:37 +00:00
|
|
|
|
2021-12-20 09:32:31 +00:00
|
|
|
return {
|
|
|
|
height,
|
2022-03-25 15:40:46 +00:00
|
|
|
width: aspectRatio * height,
|
2022-03-11 00:27:37 +00:00
|
|
|
minHeightEnforced,
|
2022-03-25 15:40:46 +00:00
|
|
|
maxVisibleRows: Math.floor(availableHeight / (height + TILE_VERTICAL_MARGIN))
|
2021-12-20 09:32:31 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-03-11 00:27:37 +00:00
|
|
|
const initialRatio = initialWidth / initialHeight;
|
2022-03-25 15:40:46 +00:00
|
|
|
let height = initialHeight;
|
|
|
|
let width;
|
2021-12-20 09:32:31 +00:00
|
|
|
|
2022-03-11 00:27:37 +00:00
|
|
|
// The biggest area of the grid will be when the grid's height is equal to clientHeight or when the grid's width is
|
|
|
|
// equal to clientWidth.
|
2021-12-20 09:32:31 +00:00
|
|
|
|
2022-03-11 00:27:37 +00:00
|
|
|
if (initialRatio > aspectRatio) {
|
2022-03-25 15:40:46 +00:00
|
|
|
width = initialHeight * aspectRatio;
|
2022-03-11 00:27:37 +00:00
|
|
|
} else if (initialRatio >= TILE_PORTRAIT_ASPECT_RATIO) {
|
2022-03-25 15:40:46 +00:00
|
|
|
width = initialWidth;
|
|
|
|
// eslint-disable-next-line no-negated-condition
|
2022-03-11 00:27:37 +00:00
|
|
|
} else if (!minHeightEnforced) {
|
2022-03-25 15:40:46 +00:00
|
|
|
height = initialWidth / TILE_PORTRAIT_ASPECT_RATIO;
|
2020-01-24 16:28:47 +00:00
|
|
|
|
2022-03-11 00:27:37 +00:00
|
|
|
if (height >= minHeight) {
|
2022-03-25 15:40:46 +00:00
|
|
|
width = initialWidth;
|
|
|
|
} else { // The width is so small that we can't reach the minimum height with portrait aspect ratio.
|
|
|
|
return;
|
2022-03-11 00:27:37 +00:00
|
|
|
}
|
2022-03-25 15:40:46 +00:00
|
|
|
} else {
|
|
|
|
// We can't fit that number of columns with the desired min height and aspect ratio.
|
|
|
|
return;
|
2022-03-11 00:27:37 +00:00
|
|
|
}
|
2021-12-20 09:32:31 +00:00
|
|
|
|
2022-03-25 15:40:46 +00:00
|
|
|
return {
|
|
|
|
height,
|
|
|
|
width,
|
|
|
|
minHeightEnforced,
|
|
|
|
maxVisibleRows: Math.floor(availableHeight / (height + TILE_VERTICAL_MARGIN))
|
|
|
|
};
|
2020-01-24 16:28:47 +00:00
|
|
|
}
|
2020-02-10 15:27:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the width of the visible area (doesn't include the left margin/padding) of the the vertical filmstrip.
|
|
|
|
*
|
|
|
|
* @returns {number} - The width of the vertical filmstrip.
|
|
|
|
*/
|
|
|
|
export function getVerticalFilmstripVisibleAreaWidth() {
|
|
|
|
// Adding 11px for the 2px right margin, 2px borders on the left and right and 5px right padding.
|
|
|
|
// Also adding 7px for the scrollbar. Note that we are not counting the left margins and paddings because this
|
|
|
|
// function is used for calculating the available space and they are invisible.
|
|
|
|
// TODO: Check if we can remove the left margins and paddings from the CSS.
|
|
|
|
// FIXME: This function is used to calculate the size of the large video, etherpad or shared video. Once everything
|
|
|
|
// is reactified this calculation will need to move to the corresponding components.
|
2022-02-24 12:20:37 +00:00
|
|
|
const filmstripMaxWidth = (interfaceConfig.FILM_STRIP_MAX_HEIGHT || DEFAULT_FILMSTRIP_WIDTH) + 18;
|
2020-02-10 15:27:43 +00:00
|
|
|
|
|
|
|
return Math.min(filmstripMaxWidth, window.innerWidth);
|
|
|
|
}
|
2021-01-21 20:46:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Computes information that determine the display mode.
|
|
|
|
*
|
2021-12-15 13:18:41 +00:00
|
|
|
* @param {Object} input - Object containing all necessary information for determining the display mode for
|
2021-01-21 20:46:47 +00:00
|
|
|
* the thumbnail.
|
2021-12-15 13:18:41 +00:00
|
|
|
* @returns {number} - One of <tt>DISPLAY_VIDEO</tt> or <tt>DISPLAY_AVATAR</tt>.
|
2021-01-21 20:46:47 +00:00
|
|
|
*/
|
2022-11-10 08:45:56 +00:00
|
|
|
export function computeDisplayModeFromInput(input: any) {
|
2021-01-21 20:46:47 +00:00
|
|
|
const {
|
2022-06-29 13:59:49 +00:00
|
|
|
filmstripType,
|
2022-03-29 08:45:09 +00:00
|
|
|
isActiveParticipant,
|
2021-01-21 20:46:47 +00:00
|
|
|
isAudioOnly,
|
|
|
|
isCurrentlyOnLargeVideo,
|
2022-04-29 14:32:16 +00:00
|
|
|
isVirtualScreenshareParticipant,
|
2021-01-21 20:46:47 +00:00
|
|
|
isScreenSharing,
|
|
|
|
canPlayEventReceived,
|
|
|
|
isRemoteParticipant,
|
2022-04-12 06:57:01 +00:00
|
|
|
stageParticipantsVisible,
|
2021-01-21 20:46:47 +00:00
|
|
|
tileViewActive
|
|
|
|
} = input;
|
|
|
|
const adjustedIsVideoPlayable = input.isVideoPlayable && (!isRemoteParticipant || canPlayEventReceived);
|
|
|
|
|
2022-11-08 19:15:49 +00:00
|
|
|
// Display video for virtual screen share participants in all layouts.
|
|
|
|
if (isVirtualScreenshareParticipant) {
|
|
|
|
return DISPLAY_VIDEO;
|
|
|
|
}
|
2022-04-29 14:32:16 +00:00
|
|
|
|
2022-11-08 19:15:49 +00:00
|
|
|
// Multi-stream is not supported on plan-b endpoints even if its is enabled via config.js. A virtual
|
|
|
|
// screenshare tile is still created when a remote endpoint starts screenshare to keep the behavior consistent
|
|
|
|
// and an avatar is displayed on the original participant thumbnail as long as screenshare is in progress.
|
|
|
|
if (isScreenSharing) {
|
|
|
|
return DISPLAY_AVATAR;
|
2022-04-04 18:57:58 +00:00
|
|
|
}
|
|
|
|
|
2022-06-29 13:59:49 +00:00
|
|
|
if (!tileViewActive && filmstripType === FILMSTRIP_TYPE.MAIN && ((isScreenSharing && isRemoteParticipant)
|
|
|
|
|| (stageParticipantsVisible && isActiveParticipant))) {
|
2021-12-15 13:18:41 +00:00
|
|
|
return DISPLAY_AVATAR;
|
2021-01-21 20:46:47 +00:00
|
|
|
} else if (isCurrentlyOnLargeVideo && !tileViewActive) {
|
|
|
|
// Display name is always and only displayed when user is on the stage
|
2021-12-15 13:18:41 +00:00
|
|
|
return adjustedIsVideoPlayable && !isAudioOnly ? DISPLAY_VIDEO : DISPLAY_AVATAR;
|
2021-01-21 20:46:47 +00:00
|
|
|
} else if (adjustedIsVideoPlayable && !isAudioOnly) {
|
|
|
|
// check hovering and change state to video with name
|
2021-12-15 13:18:41 +00:00
|
|
|
return DISPLAY_VIDEO;
|
2021-01-21 20:46:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// check hovering and change state to avatar with name
|
2021-12-15 13:18:41 +00:00
|
|
|
return DISPLAY_AVATAR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Extracts information for props and state needed to compute the display mode.
|
|
|
|
*
|
|
|
|
* @param {Object} props - The Thumbnail component's props.
|
|
|
|
* @param {Object} state - The Thumbnail component's state.
|
|
|
|
* @returns {Object}
|
|
|
|
*/
|
2022-11-10 08:45:56 +00:00
|
|
|
export function getDisplayModeInput(props: any, state: { canPlayEventReceived: boolean; }) {
|
2021-12-15 13:18:41 +00:00
|
|
|
const {
|
|
|
|
_currentLayout,
|
2022-03-29 08:45:09 +00:00
|
|
|
_isActiveParticipant,
|
2021-12-15 13:18:41 +00:00
|
|
|
_isAudioOnly,
|
|
|
|
_isCurrentlyOnLargeVideo,
|
2022-04-29 14:32:16 +00:00
|
|
|
_isVirtualScreenshareParticipant,
|
2021-12-15 13:18:41 +00:00
|
|
|
_isScreenSharing,
|
|
|
|
_isVideoPlayable,
|
|
|
|
_participant,
|
2022-04-12 06:57:01 +00:00
|
|
|
_stageParticipantsVisible,
|
2022-04-12 13:19:10 +00:00
|
|
|
_videoTrack,
|
2022-06-29 13:59:49 +00:00
|
|
|
filmstripType = FILMSTRIP_TYPE.MAIN
|
2021-12-15 13:18:41 +00:00
|
|
|
} = props;
|
|
|
|
const tileViewActive = _currentLayout === LAYOUTS.TILE_VIEW;
|
|
|
|
const { canPlayEventReceived } = state;
|
|
|
|
|
|
|
|
return {
|
2022-06-29 13:59:49 +00:00
|
|
|
filmstripType,
|
2022-03-29 08:45:09 +00:00
|
|
|
isActiveParticipant: _isActiveParticipant,
|
2021-12-15 13:18:41 +00:00
|
|
|
isCurrentlyOnLargeVideo: _isCurrentlyOnLargeVideo,
|
|
|
|
isAudioOnly: _isAudioOnly,
|
|
|
|
tileViewActive,
|
|
|
|
isVideoPlayable: _isVideoPlayable,
|
|
|
|
canPlayEventReceived,
|
|
|
|
videoStream: Boolean(_videoTrack),
|
2022-10-06 11:12:57 +00:00
|
|
|
isRemoteParticipant: !_participant?.fakeParticipant && !_participant?.local,
|
2021-12-15 13:18:41 +00:00
|
|
|
isScreenSharing: _isScreenSharing,
|
2022-04-29 14:32:16 +00:00
|
|
|
isVirtualScreenshareParticipant: _isVirtualScreenshareParticipant,
|
2022-04-12 06:57:01 +00:00
|
|
|
stageParticipantsVisible: _stageParticipantsVisible,
|
2021-12-15 13:18:41 +00:00
|
|
|
videoStreamMuted: _videoTrack ? _videoTrack.muted : 'no stream'
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the tooltip position for the thumbnail indicators.
|
|
|
|
*
|
2022-04-12 13:19:10 +00:00
|
|
|
* @param {string} thumbnailType - The current thumbnail type.
|
2021-12-15 13:18:41 +00:00
|
|
|
* @returns {string}
|
|
|
|
*/
|
2022-04-12 13:19:10 +00:00
|
|
|
export function getIndicatorsTooltipPosition(thumbnailType: string) {
|
|
|
|
return INDICATORS_TOOLTIP_POSITION[thumbnailType] || 'top';
|
2021-01-21 20:46:47 +00:00
|
|
|
}
|
2022-02-24 12:20:37 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether or not the filmstrip is resizable.
|
|
|
|
*
|
|
|
|
* @param {Object} state - Redux state.
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2022-11-10 08:45:56 +00:00
|
|
|
export function isFilmstripResizable(state: IReduxState) {
|
2022-02-24 12:20:37 +00:00
|
|
|
const { filmstrip } = state['features/base/config'];
|
|
|
|
const _currentLayout = getCurrentLayout(state);
|
|
|
|
|
|
|
|
return !filmstrip?.disableResizable && !isMobileBrowser()
|
2022-04-12 13:19:10 +00:00
|
|
|
&& (_currentLayout === LAYOUTS.VERTICAL_FILMSTRIP_VIEW || _currentLayout === LAYOUTS.STAGE_FILMSTRIP_VIEW);
|
2022-02-24 12:20:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether or not grid should be displayed in the vertical filmstrip.
|
|
|
|
*
|
|
|
|
* @param {Object} state - Redux state.
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2022-11-10 08:45:56 +00:00
|
|
|
export function showGridInVerticalView(state: IReduxState) {
|
2022-02-24 12:20:37 +00:00
|
|
|
const resizableFilmstrip = isFilmstripResizable(state);
|
|
|
|
const { width } = state['features/filmstrip'];
|
|
|
|
|
|
|
|
return resizableFilmstrip && ((width.current ?? 0) > FILMSTRIP_GRID_BREAKPOINT);
|
|
|
|
}
|
2022-03-04 13:10:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the vertical filmstrip max width.
|
|
|
|
*
|
|
|
|
* @param {Object} state - Redux state.
|
|
|
|
* @returns {number}
|
|
|
|
*/
|
2022-11-10 08:45:56 +00:00
|
|
|
export function getVerticalViewMaxWidth(state: IReduxState) {
|
2022-03-04 13:10:57 +00:00
|
|
|
const { width } = state['features/filmstrip'];
|
|
|
|
const _resizableFilmstrip = isFilmstripResizable(state);
|
|
|
|
const _verticalViewGrid = showGridInVerticalView(state);
|
|
|
|
let maxWidth = _resizableFilmstrip
|
|
|
|
? width.current || DEFAULT_FILMSTRIP_WIDTH
|
|
|
|
: interfaceConfig.FILM_STRIP_MAX_HEIGHT || DEFAULT_FILMSTRIP_WIDTH;
|
|
|
|
|
|
|
|
// Adding 4px for the border-right and margin-right.
|
|
|
|
// On non-resizable filmstrip add 4px for the left margin and border.
|
|
|
|
// Also adding 7px for the scrollbar. Also adding 9px for the drag handle.
|
|
|
|
maxWidth += (_verticalViewGrid ? 0 : 11) + (_resizableFilmstrip ? 9 : 4);
|
|
|
|
|
|
|
|
return maxWidth;
|
|
|
|
}
|
2022-03-15 17:34:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if the scroll is displayed and false otherwise.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The redux state.
|
|
|
|
* @returns {boolean} - True if the scroll is displayed and false otherwise.
|
|
|
|
*/
|
2022-11-10 08:45:56 +00:00
|
|
|
export function isFilmstripScrollVisible(state: IReduxState) {
|
2022-03-15 17:34:46 +00:00
|
|
|
const _currentLayout = getCurrentLayout(state);
|
|
|
|
let hasScroll = false;
|
|
|
|
|
|
|
|
switch (_currentLayout) {
|
|
|
|
case LAYOUTS.TILE_VIEW:
|
2022-11-10 08:45:56 +00:00
|
|
|
({ hasScroll = false } = state['features/filmstrip'].tileViewDimensions ?? {});
|
2022-03-15 17:34:46 +00:00
|
|
|
break;
|
2022-04-12 13:19:10 +00:00
|
|
|
case LAYOUTS.VERTICAL_FILMSTRIP_VIEW:
|
|
|
|
case LAYOUTS.STAGE_FILMSTRIP_VIEW: {
|
2022-03-15 17:34:46 +00:00
|
|
|
({ hasScroll = false } = state['features/filmstrip'].verticalViewDimensions);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case LAYOUTS.HORIZONTAL_FILMSTRIP_VIEW: {
|
|
|
|
({ hasScroll = false } = state['features/filmstrip'].horizontalViewDimensions);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return hasScroll;
|
|
|
|
}
|
2022-03-29 08:45:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the ids of the active participants.
|
|
|
|
*
|
|
|
|
* @param {Object} state - Redux state.
|
|
|
|
* @returns {Array<string>}
|
|
|
|
*/
|
2022-11-10 08:45:56 +00:00
|
|
|
export function getActiveParticipantsIds(state: IReduxState) {
|
2022-03-29 08:45:09 +00:00
|
|
|
const { activeParticipants } = state['features/filmstrip'];
|
|
|
|
|
|
|
|
return activeParticipants.map(p => p.participantId);
|
|
|
|
}
|
|
|
|
|
2022-04-05 13:00:32 +00:00
|
|
|
/**
|
|
|
|
* Gets the ids of the active participants.
|
|
|
|
*
|
|
|
|
* @param {Object} state - Redux state.
|
2022-04-12 06:57:01 +00:00
|
|
|
* @returns {Array<Object>}
|
2022-04-05 13:00:32 +00:00
|
|
|
*/
|
2022-11-10 08:45:56 +00:00
|
|
|
export function getPinnedActiveParticipants(state: IReduxState) {
|
2022-04-05 13:00:32 +00:00
|
|
|
const { activeParticipants } = state['features/filmstrip'];
|
|
|
|
|
|
|
|
return activeParticipants.filter(p => p.pinned);
|
|
|
|
}
|
|
|
|
|
2022-03-29 08:45:09 +00:00
|
|
|
/**
|
2022-04-12 13:19:10 +00:00
|
|
|
* Get whether or not the stage filmstrip is available (enabled & can be used).
|
2022-03-29 08:45:09 +00:00
|
|
|
*
|
|
|
|
* @param {Object} state - Redux state.
|
2022-04-12 06:57:01 +00:00
|
|
|
* @param {number} minParticipantCount - The min number of participants for the stage filmstrip
|
|
|
|
* to be displayed.
|
2022-03-29 08:45:09 +00:00
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2022-11-10 08:45:56 +00:00
|
|
|
export function isStageFilmstripAvailable(state: IReduxState, minParticipantCount = 0) {
|
2022-03-29 08:45:09 +00:00
|
|
|
const { activeParticipants } = state['features/filmstrip'];
|
|
|
|
const { remoteScreenShares } = state['features/video-layout'];
|
2022-11-10 08:45:56 +00:00
|
|
|
const sharedVideo = isSharingStatus(state['features/shared-video']?.status ?? '');
|
2022-03-29 08:45:09 +00:00
|
|
|
|
2022-06-29 13:59:49 +00:00
|
|
|
return isStageFilmstripEnabled(state) && !sharedVideo
|
|
|
|
&& activeParticipants.length >= minParticipantCount
|
|
|
|
&& (isTopPanelEnabled(state) || remoteScreenShares.length === 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether the stage filmstrip should be displayed on the top.
|
|
|
|
*
|
|
|
|
* @param {Object} state - Redux state.
|
|
|
|
* @param {number} minParticipantCount - The min number of participants for the stage filmstrip
|
|
|
|
* to be displayed.
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2022-11-10 08:45:56 +00:00
|
|
|
export function isStageFilmstripTopPanel(state: IReduxState, minParticipantCount = 0) {
|
2022-06-29 13:59:49 +00:00
|
|
|
const { remoteScreenShares } = state['features/video-layout'];
|
|
|
|
|
|
|
|
return isTopPanelEnabled(state)
|
|
|
|
&& isStageFilmstripAvailable(state, minParticipantCount) && remoteScreenShares.length > 0;
|
2022-04-12 13:19:10 +00:00
|
|
|
}
|
|
|
|
|
2022-03-29 08:45:09 +00:00
|
|
|
/**
|
|
|
|
* Whether the stage filmstrip is disabled or not.
|
|
|
|
*
|
|
|
|
* @param {Object} state - Redux state.
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2022-11-10 08:45:56 +00:00
|
|
|
export function isStageFilmstripEnabled(state: IReduxState) {
|
2022-03-29 08:45:09 +00:00
|
|
|
const { filmstrip } = state['features/base/config'];
|
|
|
|
|
2023-02-17 09:34:30 +00:00
|
|
|
return Boolean(!filmstrip?.disableStageFilmstrip && interfaceConfig.VERTICAL_FILMSTRIP);
|
2022-03-29 08:45:09 +00:00
|
|
|
}
|
2022-04-12 13:19:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the thumbnail type by filmstrip type.
|
|
|
|
*
|
|
|
|
* @param {string} currentLayout - Current app layout.
|
2022-06-29 13:59:49 +00:00
|
|
|
* @param {string} filmstripType - The current filmstrip type.
|
2022-04-12 13:19:10 +00:00
|
|
|
* @returns {string}
|
|
|
|
*/
|
2022-11-10 08:45:56 +00:00
|
|
|
export function getThumbnailTypeFromLayout(currentLayout: string, filmstripType: string) {
|
2022-04-12 13:19:10 +00:00
|
|
|
switch (currentLayout) {
|
|
|
|
case LAYOUTS.TILE_VIEW:
|
|
|
|
return THUMBNAIL_TYPE.TILE;
|
|
|
|
case LAYOUTS.VERTICAL_FILMSTRIP_VIEW:
|
|
|
|
return THUMBNAIL_TYPE.VERTICAL;
|
|
|
|
case LAYOUTS.HORIZONTAL_FILMSTRIP_VIEW:
|
|
|
|
return THUMBNAIL_TYPE.HORIZONTAL;
|
|
|
|
case LAYOUTS.STAGE_FILMSTRIP_VIEW:
|
2022-06-29 13:59:49 +00:00
|
|
|
if (filmstripType !== FILMSTRIP_TYPE.MAIN) {
|
2022-04-12 13:19:10 +00:00
|
|
|
return THUMBNAIL_TYPE.TILE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return THUMBNAIL_TYPE.VERTICAL;
|
|
|
|
}
|
|
|
|
}
|
2022-06-29 13:59:49 +00:00
|
|
|
|
2022-08-16 11:56:47 +00:00
|
|
|
/**
|
|
|
|
* Returns the id of the participant displayed on the screen share filmstrip.
|
|
|
|
*
|
|
|
|
* @param {Object} state - Redux state.
|
|
|
|
* @returns {string} - The participant id.
|
|
|
|
*/
|
2022-11-10 08:45:56 +00:00
|
|
|
export function getScreenshareFilmstripParticipantId(state: IReduxState) {
|
2022-08-16 11:56:47 +00:00
|
|
|
const { screenshareFilmstripParticipantId } = state['features/filmstrip'];
|
|
|
|
const screenshares = state['features/video-layout'].remoteScreenShares;
|
|
|
|
let id = screenshares.find(sId => sId === screenshareFilmstripParticipantId);
|
|
|
|
|
|
|
|
if (!id && screenshares.length) {
|
|
|
|
id = screenshares[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
2022-06-29 13:59:49 +00:00
|
|
|
/**
|
|
|
|
* Whether or not the top panel is enabled.
|
|
|
|
*
|
|
|
|
* @param {Object} state - Redux state.
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2022-11-10 08:45:56 +00:00
|
|
|
export function isTopPanelEnabled(state: IReduxState) {
|
2022-06-29 13:59:49 +00:00
|
|
|
const { filmstrip } = state['features/base/config'];
|
|
|
|
const participantsCount = getParticipantCount(state);
|
|
|
|
|
|
|
|
return !filmstrip?.disableTopPanel && participantsCount >= (filmstrip?.minParticipantCountForTopPanel ?? 50);
|
|
|
|
|
|
|
|
}
|