2018-09-13 15:20:22 +00:00
|
|
|
// @flow
|
|
|
|
|
2021-08-20 23:32:38 +00:00
|
|
|
import React, { PureComponent } from 'react';
|
2019-03-29 13:26:49 +00:00
|
|
|
import { View } from 'react-native';
|
2019-03-19 15:42:25 +00:00
|
|
|
import type { Dispatch } from 'redux';
|
2016-10-05 14:36:59 +00:00
|
|
|
|
2019-01-22 10:35:28 +00:00
|
|
|
import { ColorSchemeRegistry } from '../../../base/color-scheme';
|
2018-12-19 18:40:17 +00:00
|
|
|
import { openDialog } from '../../../base/dialog';
|
2019-09-13 10:00:08 +00:00
|
|
|
import { MEDIA_TYPE, VIDEO_TYPE } from '../../../base/media';
|
2017-02-27 20:37:53 +00:00
|
|
|
import {
|
|
|
|
PARTICIPANT_ROLE,
|
|
|
|
ParticipantView,
|
2019-09-12 13:03:20 +00:00
|
|
|
getParticipantCount,
|
2019-05-22 10:00:17 +00:00
|
|
|
isEveryoneModerator,
|
2021-07-09 12:36:19 +00:00
|
|
|
pinParticipant,
|
2021-08-04 08:51:05 +00:00
|
|
|
getParticipantByIdOrUndefined,
|
|
|
|
getLocalParticipant
|
2018-05-10 23:01:55 +00:00
|
|
|
} from '../../../base/participants';
|
|
|
|
import { Container } from '../../../base/react';
|
2019-03-21 16:38:29 +00:00
|
|
|
import { connect } from '../../../base/redux';
|
2019-01-22 10:35:28 +00:00
|
|
|
import { StyleType } from '../../../base/styles';
|
2018-05-10 23:01:55 +00:00
|
|
|
import { getTrackByMediaTypeAndParticipant } from '../../../base/tracks';
|
2019-04-15 16:23:28 +00:00
|
|
|
import { ConnectionIndicator } from '../../../connection-indicator';
|
2019-04-11 10:04:50 +00:00
|
|
|
import { DisplayNameLabel } from '../../../display-name';
|
2020-07-24 12:14:33 +00:00
|
|
|
import { toggleToolboxVisible } from '../../../toolbox/actions.native';
|
2021-01-21 20:46:47 +00:00
|
|
|
import { RemoteVideoMenu } from '../../../video-menu';
|
|
|
|
import ConnectionStatusComponent from '../../../video-menu/components/native/ConnectionStatusComponent';
|
2021-08-20 23:32:38 +00:00
|
|
|
import SharedVideoMenu from '../../../video-menu/components/native/SharedVideoMenu';
|
|
|
|
import { SQUARE_TILE_ASPECT_RATIO } from '../../constants';
|
2018-12-19 18:40:17 +00:00
|
|
|
|
2018-05-10 23:01:55 +00:00
|
|
|
import AudioMutedIndicator from './AudioMutedIndicator';
|
|
|
|
import DominantSpeakerIndicator from './DominantSpeakerIndicator';
|
|
|
|
import ModeratorIndicator from './ModeratorIndicator';
|
2019-03-27 10:23:41 +00:00
|
|
|
import RaisedHandIndicator from './RaisedHandIndicator';
|
2020-07-16 15:03:15 +00:00
|
|
|
import ScreenShareIndicator from './ScreenShareIndicator';
|
2018-05-10 23:01:55 +00:00
|
|
|
import VideoMutedIndicator from './VideoMutedIndicator';
|
2020-05-20 10:57:03 +00:00
|
|
|
import styles, { AVATAR_SIZE } from './styles';
|
2018-02-05 10:57:40 +00:00
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
/**
|
2018-09-13 15:20:22 +00:00
|
|
|
* Thumbnail component's property types.
|
2016-10-05 14:36:59 +00:00
|
|
|
*/
|
2018-09-13 15:20:22 +00:00
|
|
|
type Props = {
|
|
|
|
|
2016-12-01 01:52:39 +00:00
|
|
|
/**
|
2019-09-13 10:00:08 +00:00
|
|
|
* Whether local audio (microphone) is muted or not.
|
2018-09-13 15:20:22 +00:00
|
|
|
*/
|
2019-09-13 10:00:08 +00:00
|
|
|
_audioMuted: boolean,
|
2018-09-13 15:20:22 +00:00
|
|
|
|
|
|
|
/**
|
2021-08-20 23:32:38 +00:00
|
|
|
* Indicates whether the participant is fake.
|
2018-09-13 15:20:22 +00:00
|
|
|
*/
|
2021-08-20 23:32:38 +00:00
|
|
|
_isFakeParticipant: boolean,
|
|
|
|
|
|
|
|
/**
|
2021-08-26 23:23:38 +00:00
|
|
|
* Indicates whether the participant is screen sharing.
|
2021-08-20 23:32:38 +00:00
|
|
|
*/
|
|
|
|
_isScreenShare: boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates whether the participant is local.
|
|
|
|
*/
|
|
|
|
_local: boolean,
|
2018-09-13 15:20:22 +00:00
|
|
|
|
2021-08-04 08:51:05 +00:00
|
|
|
/**
|
|
|
|
* Shared video local participant owner.
|
|
|
|
*/
|
|
|
|
_localVideoOwner: boolean,
|
|
|
|
|
2019-01-05 16:49:21 +00:00
|
|
|
/**
|
2021-08-20 23:32:38 +00:00
|
|
|
* The ID of the participant obtain from the participant object in Redux.
|
|
|
|
*
|
|
|
|
* NOTE: Generally it should be the same as the participantID prop except the case where the passed
|
|
|
|
* participantID doesn't corespond to any of the existing participants.
|
|
|
|
*/
|
|
|
|
_participantId: string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates whether the participant is displayed on the large video.
|
|
|
|
*/
|
|
|
|
_participantInLargeVideo: boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates whether the participant is pinned or not.
|
2019-01-05 16:49:21 +00:00
|
|
|
*/
|
2021-08-20 23:32:38 +00:00
|
|
|
_pinned: boolean,
|
2019-01-05 16:49:21 +00:00
|
|
|
|
2019-09-12 13:03:20 +00:00
|
|
|
/**
|
|
|
|
* Whether to show the dominant speaker indicator or not.
|
|
|
|
*/
|
2019-09-13 09:51:49 +00:00
|
|
|
_renderDominantSpeakerIndicator: boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether to show the moderator indicator or not.
|
|
|
|
*/
|
|
|
|
_renderModeratorIndicator: boolean,
|
2019-09-12 13:03:20 +00:00
|
|
|
|
2019-01-22 10:35:28 +00:00
|
|
|
/**
|
|
|
|
* The color-schemed stylesheet of the feature.
|
|
|
|
*/
|
|
|
|
_styles: StyleType,
|
|
|
|
|
2018-09-13 15:20:22 +00:00
|
|
|
/**
|
2021-08-20 23:32:38 +00:00
|
|
|
* Indicates whether the participant is video muted.
|
2018-09-13 15:20:22 +00:00
|
|
|
*/
|
2021-08-20 23:32:38 +00:00
|
|
|
_videoMuted: boolean,
|
2018-09-13 15:20:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If true, there will be no color overlay (tint) on the thumbnail
|
|
|
|
* indicating the participant associated with the thumbnail is displayed on
|
|
|
|
* large video. By default there will be a tint.
|
2016-12-01 01:52:39 +00:00
|
|
|
*/
|
2018-09-13 15:20:22 +00:00
|
|
|
disableTint?: boolean,
|
2016-12-01 01:52:39 +00:00
|
|
|
|
2018-09-13 15:20:22 +00:00
|
|
|
/**
|
|
|
|
* Invoked to trigger state changes in Redux.
|
|
|
|
*/
|
2019-03-19 15:42:25 +00:00
|
|
|
dispatch: Dispatch<any>,
|
2018-09-13 15:20:22 +00:00
|
|
|
|
2021-08-20 23:32:38 +00:00
|
|
|
/**
|
|
|
|
* The height of the thumnail.
|
|
|
|
*/
|
|
|
|
height: ?number,
|
|
|
|
|
2018-09-13 15:20:22 +00:00
|
|
|
/**
|
2021-07-09 12:36:19 +00:00
|
|
|
* The ID of the participant related to the thumbnail.
|
2018-09-13 15:20:22 +00:00
|
|
|
*/
|
2021-07-09 12:36:19 +00:00
|
|
|
participantID: ?string,
|
2018-09-13 15:20:22 +00:00
|
|
|
|
2019-04-11 10:04:50 +00:00
|
|
|
/**
|
|
|
|
* Whether to display or hide the display name of the participant in the thumbnail.
|
|
|
|
*/
|
|
|
|
renderDisplayName: ?boolean,
|
|
|
|
|
2019-06-19 12:44:39 +00:00
|
|
|
/**
|
|
|
|
* If true, it tells the thumbnail that it needs to behave differently. E.g. react differently to a single tap.
|
|
|
|
*/
|
|
|
|
tileView?: boolean
|
2018-09-13 15:20:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* React component for video thumbnail.
|
|
|
|
*/
|
2021-08-20 23:32:38 +00:00
|
|
|
class Thumbnail extends PureComponent<Props> {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates new Thumbnail component.
|
|
|
|
*
|
|
|
|
* @param {Props} props - The props of the component.
|
|
|
|
* @returns {Thumbnail}
|
|
|
|
*/
|
|
|
|
constructor(props: Props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this._onClick = this._onClick.bind(this);
|
|
|
|
this._onThumbnailLongPress = this._onThumbnailLongPress.bind(this);
|
2021-08-23 23:02:41 +00:00
|
|
|
}
|
|
|
|
|
2021-08-20 23:32:38 +00:00
|
|
|
_onClick: () => void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Thumbnail click handler.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onClick() {
|
|
|
|
const { _participantId, _pinned, dispatch, tileView } = this.props;
|
|
|
|
|
2021-07-09 12:36:19 +00:00
|
|
|
if (tileView) {
|
|
|
|
dispatch(toggleToolboxVisible());
|
|
|
|
} else {
|
2021-08-20 23:32:38 +00:00
|
|
|
dispatch(pinParticipant(_pinned ? null : _participantId));
|
2021-07-09 12:36:19 +00:00
|
|
|
}
|
2021-08-20 23:32:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_onThumbnailLongPress: () => void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Thumbnail long press handler.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onThumbnailLongPress() {
|
|
|
|
const { _participantId, _local, _isFakeParticipant, _localVideoOwner, dispatch } = this.props;
|
|
|
|
|
|
|
|
if (_local) {
|
2021-07-09 12:36:19 +00:00
|
|
|
dispatch(openDialog(ConnectionStatusComponent, {
|
2021-08-20 23:32:38 +00:00
|
|
|
participantID: _participantId
|
2021-07-09 12:36:19 +00:00
|
|
|
}));
|
2021-08-20 23:32:38 +00:00
|
|
|
} else if (_isFakeParticipant) {
|
2021-08-04 08:51:05 +00:00
|
|
|
if (_localVideoOwner) {
|
|
|
|
dispatch(openDialog(SharedVideoMenu, {
|
2021-08-20 23:32:38 +00:00
|
|
|
_participantId
|
2021-08-04 08:51:05 +00:00
|
|
|
}));
|
|
|
|
}
|
2021-08-04 13:11:32 +00:00
|
|
|
} else {
|
|
|
|
dispatch(openDialog(RemoteVideoMenu, {
|
2021-08-20 23:32:38 +00:00
|
|
|
participantId: _participantId
|
2021-08-04 13:11:32 +00:00
|
|
|
}));
|
2021-07-09 12:36:19 +00:00
|
|
|
}
|
2021-08-20 23:32:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-08-26 23:23:38 +00:00
|
|
|
* Renders the indicators for the thumbnail.
|
2021-08-20 23:32:38 +00:00
|
|
|
*
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
2021-08-26 23:23:38 +00:00
|
|
|
_renderIndicators() {
|
2021-08-20 23:32:38 +00:00
|
|
|
const {
|
|
|
|
_audioMuted: audioMuted,
|
|
|
|
_isScreenShare: isScreenShare,
|
|
|
|
_isFakeParticipant,
|
|
|
|
_renderDominantSpeakerIndicator: renderDominantSpeakerIndicator,
|
|
|
|
_renderModeratorIndicator: renderModeratorIndicator,
|
|
|
|
_participantId: participantId,
|
2021-08-26 23:23:38 +00:00
|
|
|
_videoMuted: videoMuted
|
|
|
|
} = this.props;
|
|
|
|
const indicators = [];
|
|
|
|
|
|
|
|
if (renderModeratorIndicator) {
|
2021-09-22 14:05:42 +00:00
|
|
|
indicators.push(<View
|
|
|
|
key = 'moderator-indicator'
|
|
|
|
style = { styles.moderatorIndicatorContainer }>
|
2021-08-26 23:23:38 +00:00
|
|
|
<ModeratorIndicator />
|
|
|
|
</View>);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!_isFakeParticipant) {
|
|
|
|
indicators.push(<View
|
2021-09-01 11:04:51 +00:00
|
|
|
key = 'top-left-indicators'
|
2021-08-26 23:23:38 +00:00
|
|
|
style = { [
|
|
|
|
styles.thumbnailTopIndicatorContainer,
|
|
|
|
styles.thumbnailTopLeftIndicatorContainer
|
|
|
|
] }>
|
|
|
|
<RaisedHandIndicator participantId = { participantId } />
|
|
|
|
{ renderDominantSpeakerIndicator && <DominantSpeakerIndicator /> }
|
|
|
|
</View>);
|
|
|
|
indicators.push(<View
|
2021-09-01 11:04:51 +00:00
|
|
|
key = 'top-right-indicators'
|
2021-08-26 23:23:38 +00:00
|
|
|
style = { [
|
|
|
|
styles.thumbnailTopIndicatorContainer,
|
|
|
|
styles.thumbnailTopRightIndicatorContainer
|
|
|
|
] }>
|
|
|
|
<ConnectionIndicator participantId = { participantId } />
|
|
|
|
</View>);
|
2021-09-01 11:04:51 +00:00
|
|
|
indicators.push(<Container
|
|
|
|
key = 'bottom-indicators'
|
|
|
|
style = { styles.thumbnailIndicatorContainer }>
|
2021-08-26 23:23:38 +00:00
|
|
|
{ audioMuted && <AudioMutedIndicator /> }
|
|
|
|
{ videoMuted && <VideoMutedIndicator /> }
|
|
|
|
{ isScreenShare && <ScreenShareIndicator /> }
|
|
|
|
</Container>);
|
|
|
|
}
|
|
|
|
|
|
|
|
return indicators;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
render() {
|
|
|
|
const {
|
|
|
|
_isScreenShare: isScreenShare,
|
|
|
|
_isFakeParticipant,
|
|
|
|
_participantId: participantId,
|
2021-08-20 23:32:38 +00:00
|
|
|
_participantInLargeVideo: participantInLargeVideo,
|
|
|
|
_pinned,
|
|
|
|
_styles,
|
|
|
|
disableTint,
|
|
|
|
height,
|
|
|
|
renderDisplayName,
|
|
|
|
tileView
|
|
|
|
} = this.props;
|
|
|
|
const styleOverrides = tileView ? {
|
|
|
|
aspectRatio: SQUARE_TILE_ASPECT_RATIO,
|
|
|
|
flex: 0,
|
|
|
|
height,
|
|
|
|
maxHeight: null,
|
|
|
|
maxWidth: null,
|
|
|
|
width: null
|
|
|
|
} : null;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Container
|
|
|
|
onClick = { this._onClick }
|
|
|
|
onLongPress = { this._onThumbnailLongPress }
|
2019-09-13 10:06:02 +00:00
|
|
|
style = { [
|
2021-08-20 23:32:38 +00:00
|
|
|
styles.thumbnail,
|
|
|
|
_pinned && !tileView ? _styles.thumbnailPinned : null,
|
|
|
|
styleOverrides
|
|
|
|
] }
|
|
|
|
touchFeedback = { false }>
|
|
|
|
<ParticipantView
|
|
|
|
avatarSize = { tileView ? AVATAR_SIZE * 1.5 : AVATAR_SIZE }
|
|
|
|
disableVideo = { isScreenShare || _isFakeParticipant }
|
|
|
|
participantId = { participantId }
|
|
|
|
style = { _styles.participantViewStyle }
|
|
|
|
tintEnabled = { participantInLargeVideo && !disableTint }
|
|
|
|
tintStyle = { _styles.activeThumbnailTint }
|
|
|
|
zOrder = { 1 } />
|
|
|
|
{
|
|
|
|
renderDisplayName
|
|
|
|
&& <Container style = { styles.displayNameContainer }>
|
|
|
|
<DisplayNameLabel participantId = { participantId } />
|
|
|
|
</Container>
|
|
|
|
}
|
|
|
|
{
|
2021-08-26 23:23:38 +00:00
|
|
|
this._renderIndicators()
|
2021-08-20 23:32:38 +00:00
|
|
|
}
|
|
|
|
</Container>
|
|
|
|
);
|
|
|
|
}
|
2019-01-05 16:49:21 +00:00
|
|
|
}
|
2017-01-28 23:28:13 +00:00
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
/**
|
|
|
|
* Function that maps parts of Redux state tree into component props.
|
|
|
|
*
|
|
|
|
* @param {Object} state - Redux state.
|
2019-01-05 16:49:21 +00:00
|
|
|
* @param {Props} ownProps - Properties of component.
|
2019-09-12 13:03:20 +00:00
|
|
|
* @returns {Object}
|
2016-10-05 14:36:59 +00:00
|
|
|
*/
|
2017-01-28 23:34:57 +00:00
|
|
|
function _mapStateToProps(state, ownProps) {
|
2017-01-17 14:44:50 +00:00
|
|
|
// We need read-only access to the state of features/large-video so that the
|
2017-04-10 17:59:44 +00:00
|
|
|
// filmstrip doesn't render the video of the participant who is rendered on
|
2016-10-05 14:36:59 +00:00
|
|
|
// the stage i.e. as a large video.
|
2017-01-17 14:44:50 +00:00
|
|
|
const largeVideo = state['features/large-video'];
|
2021-08-04 08:51:05 +00:00
|
|
|
const { ownerId } = state['features/shared-video'];
|
2016-10-05 14:36:59 +00:00
|
|
|
const tracks = state['features/base/tracks'];
|
2021-07-09 12:36:19 +00:00
|
|
|
const { participantID } = ownProps;
|
|
|
|
const participant = getParticipantByIdOrUndefined(state, participantID);
|
2021-08-04 08:51:05 +00:00
|
|
|
const localParticipantId = getLocalParticipant(state).id;
|
2021-07-09 12:36:19 +00:00
|
|
|
const id = participant?.id;
|
2016-10-05 14:36:59 +00:00
|
|
|
const audioTrack
|
|
|
|
= getTrackByMediaTypeAndParticipant(tracks, MEDIA_TYPE.AUDIO, id);
|
|
|
|
const videoTrack
|
|
|
|
= getTrackByMediaTypeAndParticipant(tracks, MEDIA_TYPE.VIDEO, id);
|
2021-08-26 23:26:41 +00:00
|
|
|
const videoMuted = videoTrack?.muted ?? true;
|
|
|
|
const isScreenShare = videoTrack?.videoType === VIDEO_TYPE.DESKTOP;
|
2019-09-12 13:03:20 +00:00
|
|
|
const participantCount = getParticipantCount(state);
|
2021-07-09 12:36:19 +00:00
|
|
|
const renderDominantSpeakerIndicator = participant && participant.dominantSpeaker && participantCount > 2;
|
2019-09-13 09:51:49 +00:00
|
|
|
const _isEveryoneModerator = isEveryoneModerator(state);
|
2021-07-09 12:36:19 +00:00
|
|
|
const renderModeratorIndicator = !_isEveryoneModerator
|
2021-08-26 23:26:41 +00:00
|
|
|
&& participant?.role === PARTICIPANT_ROLE.MODERATOR;
|
2021-08-20 23:32:38 +00:00
|
|
|
const participantInLargeVideo = id === largeVideo.participantId;
|
2016-10-05 14:36:59 +00:00
|
|
|
|
|
|
|
return {
|
2019-09-13 10:00:08 +00:00
|
|
|
_audioMuted: audioTrack?.muted ?? true,
|
2021-08-20 23:32:38 +00:00
|
|
|
_isFakeParticipant: participant?.isFakeParticipant,
|
2021-08-30 14:50:24 +00:00
|
|
|
_isScreenShare: isScreenShare,
|
2021-08-20 23:32:38 +00:00
|
|
|
_local: participant?.local,
|
2021-08-04 08:51:05 +00:00
|
|
|
_localVideoOwner: Boolean(ownerId === localParticipantId),
|
2021-08-20 23:32:38 +00:00
|
|
|
_participantInLargeVideo: participantInLargeVideo,
|
|
|
|
_participantId: id,
|
|
|
|
_pinned: participant?.pinned,
|
2019-09-13 09:51:49 +00:00
|
|
|
_renderDominantSpeakerIndicator: renderDominantSpeakerIndicator,
|
|
|
|
_renderModeratorIndicator: renderModeratorIndicator,
|
2019-01-22 10:35:28 +00:00
|
|
|
_styles: ColorSchemeRegistry.get(state, 'Thumbnail'),
|
2021-08-20 23:32:38 +00:00
|
|
|
_videoMuted: videoMuted
|
2016-10-05 14:36:59 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-07-09 12:36:19 +00:00
|
|
|
export default connect(_mapStateToProps)(Thumbnail);
|