2018-02-05 10:57:40 +00:00
|
|
|
// @flow
|
2017-05-24 17:01:46 +00:00
|
|
|
|
2020-06-02 09:03:17 +00:00
|
|
|
import React, { PureComponent } from 'react';
|
2022-06-01 20:13:27 +00:00
|
|
|
import type { Dispatch } from 'redux';
|
2016-10-05 14:36:59 +00:00
|
|
|
|
2022-06-01 20:13:27 +00:00
|
|
|
import { JitsiTrackEvents } from '../../base/lib-jitsi-meet';
|
2022-10-07 12:18:49 +00:00
|
|
|
import ParticipantView from '../../base/participants/components/ParticipantView.native';
|
2022-10-13 14:48:20 +00:00
|
|
|
import { getParticipantById, isLocalScreenshareParticipant } from '../../base/participants/functions';
|
2019-03-21 16:38:29 +00:00
|
|
|
import { connect } from '../../base/redux';
|
2022-06-01 20:13:27 +00:00
|
|
|
import {
|
|
|
|
getVideoTrackByParticipant,
|
|
|
|
isLocalVideoTrackDesktop,
|
|
|
|
trackStreamingStatusChanged
|
|
|
|
} from '../../base/tracks';
|
2016-10-05 14:36:59 +00:00
|
|
|
|
2019-01-22 10:35:28 +00:00
|
|
|
import { AVATAR_SIZE } from './styles';
|
2018-02-05 10:57:40 +00:00
|
|
|
|
2018-02-13 15:55:18 +00:00
|
|
|
/**
|
|
|
|
* The type of the React {@link Component} props of {@link LargeVideo}.
|
|
|
|
*/
|
2018-02-05 10:57:40 +00:00
|
|
|
type Props = {
|
|
|
|
|
2020-11-04 13:13:32 +00:00
|
|
|
/**
|
|
|
|
* Whether video should be disabled.
|
|
|
|
*/
|
|
|
|
_disableVideo: boolean,
|
|
|
|
|
2020-06-02 09:03:17 +00:00
|
|
|
/**
|
|
|
|
* Application's viewport height.
|
|
|
|
*/
|
|
|
|
_height: number,
|
|
|
|
|
2018-02-05 10:57:40 +00:00
|
|
|
/**
|
|
|
|
* The ID of the participant (to be) depicted by LargeVideo.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
*/
|
2019-01-22 10:35:28 +00:00
|
|
|
_participantId: string,
|
|
|
|
|
2022-06-01 20:13:27 +00:00
|
|
|
/**
|
|
|
|
* The video track that will be displayed in the thumbnail.
|
|
|
|
*/
|
|
|
|
_videoTrack: ?Object,
|
|
|
|
|
2020-06-02 09:03:17 +00:00
|
|
|
/**
|
|
|
|
* Application's viewport height.
|
|
|
|
*/
|
|
|
|
_width: number,
|
|
|
|
|
2022-06-01 20:13:27 +00:00
|
|
|
/**
|
|
|
|
* Invoked to trigger state changes in Redux.
|
|
|
|
*/
|
|
|
|
dispatch: Dispatch<any>,
|
|
|
|
|
2019-01-22 10:35:28 +00:00
|
|
|
/**
|
|
|
|
* Callback to invoke when the {@code LargeVideo} is clicked/pressed.
|
|
|
|
*/
|
|
|
|
onClick: Function,
|
2018-02-05 10:57:40 +00:00
|
|
|
};
|
|
|
|
|
2018-02-13 15:55:18 +00:00
|
|
|
/**
|
|
|
|
* The type of the React {@link Component} state of {@link LargeVideo}.
|
|
|
|
*/
|
2018-02-05 10:57:40 +00:00
|
|
|
type State = {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Size for the Avatar. It will be dynamically adjusted based on the
|
|
|
|
* available size.
|
|
|
|
*/
|
|
|
|
avatarSize: number,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether the connectivity indicator will be shown or not. It will be true
|
|
|
|
* by default, but it may be turned off if there is not enough space.
|
|
|
|
*/
|
|
|
|
useConnectivityInfoLabel: boolean
|
|
|
|
};
|
|
|
|
|
|
|
|
const DEFAULT_STATE = {
|
|
|
|
avatarSize: AVATAR_SIZE,
|
|
|
|
useConnectivityInfoLabel: true
|
|
|
|
};
|
2016-10-05 14:36:59 +00:00
|
|
|
|
2021-11-04 21:10:43 +00:00
|
|
|
/** .
|
2017-05-24 17:01:46 +00:00
|
|
|
* Implements a React {@link Component} which represents the large video (a.k.a.
|
2021-11-04 21:10:43 +00:00
|
|
|
* The conference participant who is on the local stage) on mobile/React Native.
|
2016-10-05 14:36:59 +00:00
|
|
|
*
|
2021-11-04 21:10:43 +00:00
|
|
|
* @augments Component
|
2016-10-05 14:36:59 +00:00
|
|
|
*/
|
2020-06-02 09:03:17 +00:00
|
|
|
class LargeVideo extends PureComponent<Props, State> {
|
2022-06-01 20:13:27 +00:00
|
|
|
/**
|
|
|
|
* Creates new LargeVideo component.
|
|
|
|
*
|
|
|
|
* @param {Props} props - The props of the component.
|
|
|
|
* @returns {LargeVideo}
|
|
|
|
*/
|
|
|
|
constructor(props: Props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this.handleTrackStreamingStatusChanged = this.handleTrackStreamingStatusChanged.bind(this);
|
|
|
|
}
|
|
|
|
|
2018-02-05 10:57:40 +00:00
|
|
|
state = {
|
|
|
|
...DEFAULT_STATE
|
|
|
|
};
|
|
|
|
|
2016-12-01 01:52:39 +00:00
|
|
|
/**
|
2020-06-02 09:03:17 +00:00
|
|
|
* Handles dimension changes. In case we deem it's too
|
2018-02-05 10:57:40 +00:00
|
|
|
* small, the connectivity indicator won't be rendered and the avatar
|
|
|
|
* will occupy the entirety of the available screen state.
|
2016-12-01 01:52:39 +00:00
|
|
|
*
|
2020-06-02 09:03:17 +00:00
|
|
|
* @inheritdoc
|
2016-12-01 01:52:39 +00:00
|
|
|
*/
|
2020-06-02 09:03:17 +00:00
|
|
|
static getDerivedStateFromProps(props: Props) {
|
|
|
|
const { _height, _width } = props;
|
|
|
|
|
2018-02-05 10:57:40 +00:00
|
|
|
// Get the size, rounded to the nearest even number.
|
2020-06-02 09:03:17 +00:00
|
|
|
const size = 2 * Math.round(Math.min(_height, _width) / 2);
|
2018-02-05 10:57:40 +00:00
|
|
|
|
|
|
|
if (size < AVATAR_SIZE * 1.5) {
|
2020-06-02 09:03:17 +00:00
|
|
|
return {
|
2018-02-05 10:57:40 +00:00
|
|
|
avatarSize: size - 15, // Leave some margin.
|
|
|
|
useConnectivityInfoLabel: false
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-06-02 09:03:17 +00:00
|
|
|
return DEFAULT_STATE;
|
|
|
|
|
2018-02-05 10:57:40 +00:00
|
|
|
}
|
2016-12-01 01:52:39 +00:00
|
|
|
|
2022-06-01 20:13:27 +00:00
|
|
|
/**
|
|
|
|
* Starts listening for track streaming status updates after the initial render.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
componentDidMount() {
|
|
|
|
// Listen to track streaming status changed event to keep it updated.
|
|
|
|
// TODO: after converting this component to a react function component,
|
|
|
|
// use a custom hook to update local track streaming status.
|
2022-11-08 19:15:49 +00:00
|
|
|
const { _videoTrack, dispatch } = this.props;
|
2022-06-01 20:13:27 +00:00
|
|
|
|
2022-11-08 19:15:49 +00:00
|
|
|
if (_videoTrack && !_videoTrack.local) {
|
2022-06-01 20:13:27 +00:00
|
|
|
_videoTrack.jitsiTrack.on(JitsiTrackEvents.TRACK_STREAMING_STATUS_CHANGED,
|
|
|
|
this.handleTrackStreamingStatusChanged);
|
|
|
|
dispatch(trackStreamingStatusChanged(_videoTrack.jitsiTrack,
|
|
|
|
_videoTrack.jitsiTrack.getTrackStreamingStatus()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Stops listening for track streaming status updates on the old track and starts listening instead on the new
|
|
|
|
* track.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
componentDidUpdate(prevProps: Props) {
|
|
|
|
// TODO: after converting this component to a react function component,
|
|
|
|
// use a custom hook to update local track streaming status.
|
2022-11-08 19:15:49 +00:00
|
|
|
const { _videoTrack, dispatch } = this.props;
|
2022-06-01 20:13:27 +00:00
|
|
|
|
2022-11-08 19:15:49 +00:00
|
|
|
if (prevProps._videoTrack?.jitsiTrack?.getSourceName() !== _videoTrack?.jitsiTrack?.getSourceName()) {
|
2022-06-01 20:13:27 +00:00
|
|
|
if (prevProps._videoTrack && !prevProps._videoTrack.local) {
|
|
|
|
prevProps._videoTrack.jitsiTrack.off(JitsiTrackEvents.TRACK_STREAMING_STATUS_CHANGED,
|
|
|
|
this.handleTrackStreamingStatusChanged);
|
|
|
|
dispatch(trackStreamingStatusChanged(prevProps._videoTrack.jitsiTrack,
|
|
|
|
prevProps._videoTrack.jitsiTrack.getTrackStreamingStatus()));
|
|
|
|
}
|
|
|
|
if (_videoTrack && !_videoTrack.local) {
|
|
|
|
_videoTrack.jitsiTrack.on(JitsiTrackEvents.TRACK_STREAMING_STATUS_CHANGED,
|
|
|
|
this.handleTrackStreamingStatusChanged);
|
|
|
|
dispatch(trackStreamingStatusChanged(_videoTrack.jitsiTrack,
|
|
|
|
_videoTrack.jitsiTrack.getTrackStreamingStatus()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove listeners for track streaming status update.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
componentWillUnmount() {
|
|
|
|
// TODO: after converting this component to a react function component,
|
|
|
|
// use a custom hook to update local track streaming status.
|
2022-11-08 19:15:49 +00:00
|
|
|
const { _videoTrack, dispatch } = this.props;
|
2022-06-01 20:13:27 +00:00
|
|
|
|
2022-11-08 19:15:49 +00:00
|
|
|
if (_videoTrack && !_videoTrack.local) {
|
2022-06-01 20:13:27 +00:00
|
|
|
_videoTrack.jitsiTrack.off(JitsiTrackEvents.TRACK_STREAMING_STATUS_CHANGED,
|
|
|
|
this.handleTrackStreamingStatusChanged);
|
|
|
|
dispatch(trackStreamingStatusChanged(_videoTrack.jitsiTrack,
|
|
|
|
_videoTrack.jitsiTrack.getTrackStreamingStatus()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle track streaming status change event by by dispatching an action to update track streaming status for the
|
|
|
|
* given track in app state.
|
|
|
|
*
|
|
|
|
* @param {JitsiTrack} jitsiTrack - The track with streaming status updated.
|
|
|
|
* @param {JitsiTrackStreamingStatus} streamingStatus - The updated track streaming status.
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
handleTrackStreamingStatusChanged(jitsiTrack, streamingStatus) {
|
|
|
|
this.props.dispatch(trackStreamingStatusChanged(jitsiTrack, streamingStatus));
|
|
|
|
}
|
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
render() {
|
2018-02-05 10:57:40 +00:00
|
|
|
const {
|
|
|
|
avatarSize,
|
|
|
|
useConnectivityInfoLabel
|
|
|
|
} = this.state;
|
2018-04-06 21:11:01 +00:00
|
|
|
const {
|
2020-11-04 13:13:32 +00:00
|
|
|
_disableVideo,
|
2018-09-13 15:20:22 +00:00
|
|
|
_participantId,
|
|
|
|
onClick
|
2018-04-06 21:11:01 +00:00
|
|
|
} = this.props;
|
2018-02-05 10:57:40 +00:00
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
return (
|
2020-06-02 09:03:17 +00:00
|
|
|
<ParticipantView
|
|
|
|
avatarSize = { avatarSize }
|
2020-11-04 13:13:32 +00:00
|
|
|
disableVideo = { _disableVideo }
|
2020-06-02 09:03:17 +00:00
|
|
|
onPress = { onClick }
|
|
|
|
participantId = { _participantId }
|
|
|
|
testHintId = 'org.jitsi.meet.LargeVideo'
|
|
|
|
useConnectivityInfoLabel = { useConnectivityInfoLabel }
|
|
|
|
zOrder = { 0 }
|
|
|
|
zoomEnabled = { true } />
|
2016-10-05 14:36:59 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps (parts of) the Redux state to the associated LargeVideo's props.
|
|
|
|
*
|
|
|
|
* @param {Object} state - Redux state.
|
2017-01-28 23:34:57 +00:00
|
|
|
* @private
|
2020-06-02 09:03:17 +00:00
|
|
|
* @returns {Props}
|
2016-10-05 14:36:59 +00:00
|
|
|
*/
|
2017-01-28 23:34:57 +00:00
|
|
|
function _mapStateToProps(state) {
|
2020-11-04 13:13:32 +00:00
|
|
|
const { participantId } = state['features/large-video'];
|
|
|
|
const participant = getParticipantById(state, participantId);
|
2020-06-02 09:03:17 +00:00
|
|
|
const { clientHeight: height, clientWidth: width } = state['features/base/responsive-ui'];
|
2022-10-06 11:12:57 +00:00
|
|
|
const videoTrack = getVideoTrackByParticipant(state, participant);
|
2020-11-04 13:13:32 +00:00
|
|
|
let disableVideo = false;
|
|
|
|
|
2022-10-13 14:48:20 +00:00
|
|
|
if (isLocalScreenshareParticipant(participant)) {
|
|
|
|
disableVideo = true;
|
|
|
|
} else if (participant?.local) {
|
2020-11-04 13:13:32 +00:00
|
|
|
disableVideo = isLocalVideoTrackDesktop(state);
|
|
|
|
}
|
2020-06-02 09:03:17 +00:00
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
return {
|
2020-11-04 13:13:32 +00:00
|
|
|
_disableVideo: disableVideo,
|
2020-06-02 09:03:17 +00:00
|
|
|
_height: height,
|
2020-11-04 13:13:32 +00:00
|
|
|
_participantId: participantId,
|
2022-06-01 20:13:27 +00:00
|
|
|
_videoTrack: videoTrack,
|
2020-06-02 09:03:17 +00:00
|
|
|
_width: width
|
2016-10-05 14:36:59 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-01-28 23:34:57 +00:00
|
|
|
export default connect(_mapStateToProps)(LargeVideo);
|