2020-07-07 00:42:46 +03:00
|
|
|
/*
|
|
|
|
Copyright 2015, 2016 OpenMarket Ltd
|
|
|
|
Copyright 2019, 2020 The Matrix.org Foundation C.I.C.
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
2020-07-07 17:11:08 +03:00
|
|
|
|
2021-01-20 16:49:15 +03:00
|
|
|
import React, { createRef, CSSProperties } from 'react';
|
2020-07-07 00:42:46 +03:00
|
|
|
import dis from '../../../dispatcher/dispatcher';
|
|
|
|
import CallHandler from '../../../CallHandler';
|
2021-06-29 15:11:58 +03:00
|
|
|
import { MatrixClientPeg } from '../../../MatrixClientPeg';
|
2020-12-18 22:35:41 +03:00
|
|
|
import { _t, _td } from '../../../languageHandler';
|
2021-03-07 10:13:35 +03:00
|
|
|
import VideoFeed from './VideoFeed';
|
2020-07-07 00:42:46 +03:00
|
|
|
import RoomAvatar from "../avatars/RoomAvatar";
|
2021-03-06 11:02:15 +03:00
|
|
|
import { CallState, CallType, MatrixCall, CallEvent } from 'matrix-js-sdk/src/webrtc/call';
|
2020-11-18 17:22:38 +03:00
|
|
|
import classNames from 'classnames';
|
|
|
|
import AccessibleButton from '../elements/AccessibleButton';
|
2021-06-29 15:11:58 +03:00
|
|
|
import { isOnlyCtrlOrCmdKeyEvent, Key } from '../../../Keyboard';
|
|
|
|
import { alwaysAboveLeftOf, alwaysAboveRightOf, ChevronFace, ContextMenuButton } from '../../structures/ContextMenu';
|
2020-11-26 17:35:09 +03:00
|
|
|
import CallContextMenu from '../context_menus/CallContextMenu';
|
|
|
|
import { avatarUrlForMember } from '../../../Avatar';
|
2021-01-04 23:01:43 +03:00
|
|
|
import DialpadContextMenu from '../context_menus/DialpadContextMenu';
|
2021-03-07 10:13:35 +03:00
|
|
|
import { CallFeed } from 'matrix-js-sdk/src/webrtc/callFeed';
|
2021-06-29 15:11:58 +03:00
|
|
|
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
2021-05-07 22:35:32 +03:00
|
|
|
import DesktopCapturerSourcePicker from "../elements/DesktopCapturerSourcePicker";
|
|
|
|
import Modal from '../../../Modal';
|
|
|
|
import { SDPStreamMetadataPurpose } from 'matrix-js-sdk/src/webrtc/callEventTypes';
|
2021-06-12 09:15:26 +03:00
|
|
|
import CallViewSidebar from './CallViewSidebar';
|
2021-05-07 22:34:56 +03:00
|
|
|
|
2020-07-07 00:42:46 +03:00
|
|
|
interface IProps {
|
2020-12-03 20:45:49 +03:00
|
|
|
// The call for us to display
|
2021-07-02 01:23:03 +03:00
|
|
|
call: MatrixCall;
|
2020-12-03 20:45:49 +03:00
|
|
|
|
|
|
|
// Another ongoing call to display information about
|
2021-07-02 01:23:03 +03:00
|
|
|
secondaryCall?: MatrixCall;
|
2020-07-07 00:42:46 +03:00
|
|
|
|
2021-04-27 13:05:21 +03:00
|
|
|
// a callback which is called when the content in the CallView changes
|
2020-07-07 00:42:46 +03:00
|
|
|
// in a way that is likely to cause a resize.
|
2020-07-07 17:40:05 +03:00
|
|
|
onResize?: any;
|
2020-07-07 00:42:46 +03:00
|
|
|
|
2021-04-27 13:05:21 +03:00
|
|
|
// Whether this call view is for picture-in-picture mode
|
2020-12-03 20:45:49 +03:00
|
|
|
// otherwise, it's the larger call view when viewing the room the call is in.
|
|
|
|
// This is sort of a proxy for a number of things but we currently have no
|
|
|
|
// need to control those things separately, so this is simpler.
|
|
|
|
pipMode?: boolean;
|
2021-05-02 17:23:35 +03:00
|
|
|
|
2021-05-03 16:16:08 +03:00
|
|
|
// Used for dragging the PiP CallView
|
|
|
|
onMouseDownOnHeader?: (event: React.MouseEvent) => void;
|
2020-07-07 00:42:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
interface IState {
|
2021-07-02 01:23:03 +03:00
|
|
|
isLocalOnHold: boolean;
|
|
|
|
isRemoteOnHold: boolean;
|
|
|
|
micMuted: boolean;
|
|
|
|
vidMuted: boolean;
|
2021-07-07 11:53:22 +03:00
|
|
|
screensharing: boolean;
|
2021-07-02 01:23:03 +03:00
|
|
|
callState: CallState;
|
|
|
|
controlsVisible: boolean;
|
|
|
|
showMoreMenu: boolean;
|
|
|
|
showDialpad: boolean;
|
2021-07-07 11:53:22 +03:00
|
|
|
primaryFeed: CallFeed;
|
|
|
|
secondaryFeeds: Array<CallFeed>;
|
|
|
|
sidebarShown: boolean;
|
2020-10-29 20:56:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function getFullScreenElement() {
|
|
|
|
return (
|
|
|
|
document.fullscreenElement ||
|
|
|
|
// moz omitted because firefox supports this unprefixed now (webkit here for safari)
|
|
|
|
document.webkitFullscreenElement ||
|
|
|
|
document.msFullscreenElement
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function requestFullscreen(element: Element) {
|
|
|
|
const method = (
|
|
|
|
element.requestFullscreen ||
|
|
|
|
// moz omitted since firefox supports unprefixed now
|
|
|
|
element.webkitRequestFullScreen ||
|
|
|
|
element.msRequestFullscreen
|
|
|
|
);
|
|
|
|
if (method) method.call(element);
|
|
|
|
}
|
|
|
|
|
|
|
|
function exitFullscreen() {
|
|
|
|
const exitMethod = (
|
|
|
|
document.exitFullscreen ||
|
|
|
|
document.webkitExitFullscreen ||
|
|
|
|
document.msExitFullscreen
|
|
|
|
);
|
|
|
|
if (exitMethod) exitMethod.call(document);
|
2020-07-07 00:42:46 +03:00
|
|
|
}
|
|
|
|
|
2020-11-18 17:22:38 +03:00
|
|
|
const CONTROLS_HIDE_DELAY = 1000;
|
2020-11-19 20:33:43 +03:00
|
|
|
// Height of the header duplicated from CSS because we need to subtract it from our max
|
|
|
|
// height to get the max height of the video
|
2020-11-26 17:35:09 +03:00
|
|
|
const CONTEXT_MENU_VPADDING = 8; // How far the context menu sits above the button (px)
|
2020-11-18 17:22:38 +03:00
|
|
|
|
2021-03-09 06:20:07 +03:00
|
|
|
@replaceableComponent("views.voip.CallView")
|
2020-07-07 00:42:46 +03:00
|
|
|
export default class CallView extends React.Component<IProps, IState> {
|
|
|
|
private dispatcherRef: string;
|
2020-11-12 21:09:56 +03:00
|
|
|
private contentRef = createRef<HTMLDivElement>();
|
2020-11-18 17:22:38 +03:00
|
|
|
private controlsHideTimer: number = null;
|
2021-01-04 23:01:43 +03:00
|
|
|
private dialpadButton = createRef<HTMLDivElement>();
|
2020-11-26 17:35:09 +03:00
|
|
|
private contextMenuButton = createRef<HTMLDivElement>();
|
|
|
|
|
2020-07-07 00:42:46 +03:00
|
|
|
constructor(props: IProps) {
|
|
|
|
super(props);
|
|
|
|
|
2021-06-12 10:19:58 +03:00
|
|
|
const { primary, secondary } = this.getOrderedFeeds(this.props.call.getFeeds());
|
|
|
|
|
2020-07-07 00:42:46 +03:00
|
|
|
this.state = {
|
2020-12-03 20:45:49 +03:00
|
|
|
isLocalOnHold: this.props.call.isLocalOnHold(),
|
|
|
|
isRemoteOnHold: this.props.call.isRemoteOnHold(),
|
|
|
|
micMuted: this.props.call.isMicrophoneMuted(),
|
|
|
|
vidMuted: this.props.call.isLocalVideoMuted(),
|
2021-05-07 22:35:32 +03:00
|
|
|
screensharing: this.props.call.isScreensharing(),
|
2020-12-03 20:45:49 +03:00
|
|
|
callState: this.props.call.state,
|
2020-11-18 17:22:38 +03:00
|
|
|
controlsVisible: true,
|
2020-11-26 17:35:09 +03:00
|
|
|
showMoreMenu: false,
|
2021-01-04 23:01:43 +03:00
|
|
|
showDialpad: false,
|
2021-06-12 10:19:58 +03:00
|
|
|
primaryFeed: primary,
|
|
|
|
secondaryFeeds: secondary,
|
2021-06-12 18:20:13 +03:00
|
|
|
sidebarShown: true,
|
2021-06-29 15:11:58 +03:00
|
|
|
};
|
2020-07-07 00:42:46 +03:00
|
|
|
|
2020-12-03 20:45:49 +03:00
|
|
|
this.updateCallListeners(null, this.props.call);
|
2020-07-07 00:42:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public componentDidMount() {
|
|
|
|
this.dispatcherRef = dis.register(this.onAction);
|
2020-11-19 18:15:31 +03:00
|
|
|
document.addEventListener('keydown', this.onNativeKeyDown);
|
2020-07-07 00:42:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public componentWillUnmount() {
|
2020-12-03 20:45:49 +03:00
|
|
|
if (getFullScreenElement()) {
|
|
|
|
exitFullscreen();
|
|
|
|
}
|
|
|
|
|
2020-11-19 18:15:31 +03:00
|
|
|
document.removeEventListener("keydown", this.onNativeKeyDown);
|
2020-12-03 20:45:49 +03:00
|
|
|
this.updateCallListeners(this.props.call, null);
|
2020-07-07 00:42:46 +03:00
|
|
|
dis.unregister(this.dispatcherRef);
|
|
|
|
}
|
|
|
|
|
2020-12-03 20:45:49 +03:00
|
|
|
public componentDidUpdate(prevProps) {
|
|
|
|
if (this.props.call === prevProps.call) return;
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
isLocalOnHold: this.props.call.isLocalOnHold(),
|
|
|
|
isRemoteOnHold: this.props.call.isRemoteOnHold(),
|
|
|
|
micMuted: this.props.call.isMicrophoneMuted(),
|
|
|
|
vidMuted: this.props.call.isLocalVideoMuted(),
|
|
|
|
callState: this.props.call.state,
|
|
|
|
});
|
|
|
|
|
|
|
|
this.updateCallListeners(null, this.props.call);
|
|
|
|
}
|
|
|
|
|
2020-07-07 00:42:46 +03:00
|
|
|
private onAction = (payload) => {
|
2020-10-29 20:56:24 +03:00
|
|
|
switch (payload.action) {
|
|
|
|
case 'video_fullscreen': {
|
2020-11-12 21:09:56 +03:00
|
|
|
if (!this.contentRef.current) {
|
2020-10-29 20:56:24 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (payload.fullscreen) {
|
2020-11-12 21:09:56 +03:00
|
|
|
requestFullscreen(this.contentRef.current);
|
2020-10-29 20:56:24 +03:00
|
|
|
} else if (getFullScreenElement()) {
|
|
|
|
exitFullscreen();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2020-07-07 00:42:46 +03:00
|
|
|
}
|
2020-07-07 17:40:05 +03:00
|
|
|
};
|
2020-07-07 00:42:46 +03:00
|
|
|
|
2020-10-29 20:56:24 +03:00
|
|
|
private updateCallListeners(oldCall: MatrixCall, newCall: MatrixCall) {
|
|
|
|
if (oldCall === newCall) return;
|
2020-07-07 00:42:46 +03:00
|
|
|
|
2020-11-26 17:35:09 +03:00
|
|
|
if (oldCall) {
|
2020-12-03 20:45:49 +03:00
|
|
|
oldCall.removeListener(CallEvent.State, this.onCallState);
|
2020-11-26 17:35:09 +03:00
|
|
|
oldCall.removeListener(CallEvent.LocalHoldUnhold, this.onCallLocalHoldUnhold);
|
|
|
|
oldCall.removeListener(CallEvent.RemoteHoldUnhold, this.onCallRemoteHoldUnhold);
|
2021-03-07 10:13:35 +03:00
|
|
|
oldCall.removeListener(CallEvent.FeedsChanged, this.onFeedsChanged);
|
2020-11-26 17:35:09 +03:00
|
|
|
}
|
|
|
|
if (newCall) {
|
2020-12-03 20:45:49 +03:00
|
|
|
newCall.on(CallEvent.State, this.onCallState);
|
2020-11-26 17:35:09 +03:00
|
|
|
newCall.on(CallEvent.LocalHoldUnhold, this.onCallLocalHoldUnhold);
|
|
|
|
newCall.on(CallEvent.RemoteHoldUnhold, this.onCallRemoteHoldUnhold);
|
2021-03-07 10:13:35 +03:00
|
|
|
newCall.on(CallEvent.FeedsChanged, this.onFeedsChanged);
|
2020-11-26 17:35:09 +03:00
|
|
|
}
|
2020-07-07 00:42:46 +03:00
|
|
|
}
|
|
|
|
|
2020-12-03 20:45:49 +03:00
|
|
|
private onCallState = (state) => {
|
|
|
|
this.setState({
|
|
|
|
callState: state,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2021-03-07 10:13:35 +03:00
|
|
|
private onFeedsChanged = (newFeeds: Array<CallFeed>) => {
|
2021-06-12 10:19:58 +03:00
|
|
|
const { primary, secondary } = this.getOrderedFeeds(newFeeds);
|
|
|
|
this.setState({
|
|
|
|
primaryFeed: primary,
|
|
|
|
secondaryFeeds: secondary,
|
|
|
|
});
|
2021-04-19 08:42:32 +03:00
|
|
|
};
|
2021-03-07 10:13:35 +03:00
|
|
|
|
2020-11-26 17:35:09 +03:00
|
|
|
private onCallLocalHoldUnhold = () => {
|
|
|
|
this.setState({
|
2020-12-03 20:45:49 +03:00
|
|
|
isLocalOnHold: this.props.call.isLocalOnHold(),
|
2020-11-26 17:35:09 +03:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
private onCallRemoteHoldUnhold = () => {
|
2020-10-29 20:56:24 +03:00
|
|
|
this.setState({
|
2020-12-03 20:45:49 +03:00
|
|
|
isRemoteOnHold: this.props.call.isRemoteOnHold(),
|
2020-11-26 17:35:09 +03:00
|
|
|
// update both here because isLocalOnHold changes when we hold the call too
|
2020-12-03 20:45:49 +03:00
|
|
|
isLocalOnHold: this.props.call.isLocalOnHold(),
|
2020-10-29 20:56:24 +03:00
|
|
|
});
|
|
|
|
};
|
2020-07-07 00:42:46 +03:00
|
|
|
|
2020-11-12 21:09:56 +03:00
|
|
|
private onFullscreenClick = () => {
|
|
|
|
dis.dispatch({
|
|
|
|
action: 'video_fullscreen',
|
|
|
|
fullscreen: true,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2020-11-19 19:36:23 +03:00
|
|
|
private onExpandClick = () => {
|
2021-04-19 22:30:51 +03:00
|
|
|
const userFacingRoomId = CallHandler.sharedInstance().roomIdForCall(this.props.call);
|
2020-11-19 19:36:23 +03:00
|
|
|
dis.dispatch({
|
|
|
|
action: 'view_room',
|
2021-01-21 22:20:35 +03:00
|
|
|
room_id: userFacingRoomId,
|
2020-11-19 19:36:23 +03:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2020-11-19 18:15:31 +03:00
|
|
|
private onControlsHideTimer = () => {
|
2020-11-18 17:22:38 +03:00
|
|
|
this.controlsHideTimer = null;
|
|
|
|
this.setState({
|
|
|
|
controlsVisible: false,
|
|
|
|
});
|
2021-06-29 15:11:58 +03:00
|
|
|
};
|
2020-11-18 17:22:38 +03:00
|
|
|
|
2020-11-19 18:15:31 +03:00
|
|
|
private onMouseMove = () => {
|
|
|
|
this.showControls();
|
2021-06-29 15:11:58 +03:00
|
|
|
};
|
2020-11-19 18:15:31 +03:00
|
|
|
|
2021-06-12 10:19:58 +03:00
|
|
|
private getOrderedFeeds(feeds: Array<CallFeed>): { primary: CallFeed, secondary: Array<CallFeed> } {
|
|
|
|
let primary;
|
|
|
|
|
|
|
|
// First try to find remote screen-sharing stream
|
|
|
|
primary = feeds.find((feed) => {
|
|
|
|
return feed.purpose === SDPStreamMetadataPurpose.Screenshare && !feed.isLocal();
|
2021-05-10 14:21:02 +03:00
|
|
|
});
|
2021-06-12 10:19:58 +03:00
|
|
|
// If we didn't find remote screen-sharing stream, try to find any remote stream
|
|
|
|
if (!primary) {
|
|
|
|
primary = feeds.find((feed) => !feed.isLocal());
|
|
|
|
}
|
|
|
|
|
|
|
|
const secondary = [...feeds];
|
|
|
|
// Remove the primary feed from the array
|
|
|
|
if (primary) secondary.splice(secondary.indexOf(primary), 1);
|
|
|
|
secondary.sort((a, b) => {
|
|
|
|
if (a.isLocal() && !b.isLocal()) return -1;
|
|
|
|
if (!a.isLocal() && b.isLocal()) return 1;
|
|
|
|
return 0;
|
|
|
|
});
|
|
|
|
|
|
|
|
return { primary, secondary };
|
2021-05-10 14:21:02 +03:00
|
|
|
}
|
|
|
|
|
2021-07-20 14:47:07 +03:00
|
|
|
private showControls(): void {
|
2021-01-04 23:01:43 +03:00
|
|
|
if (this.state.showMoreMenu || this.state.showDialpad) return;
|
2020-11-26 17:35:09 +03:00
|
|
|
|
2020-11-18 17:22:38 +03:00
|
|
|
if (!this.state.controlsVisible) {
|
|
|
|
this.setState({
|
|
|
|
controlsVisible: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if (this.controlsHideTimer !== null) {
|
|
|
|
clearTimeout(this.controlsHideTimer);
|
|
|
|
}
|
|
|
|
this.controlsHideTimer = window.setTimeout(this.onControlsHideTimer, CONTROLS_HIDE_DELAY);
|
|
|
|
}
|
|
|
|
|
2021-07-20 14:47:07 +03:00
|
|
|
private onDialpadClick = (): void => {
|
2021-01-04 23:01:43 +03:00
|
|
|
if (!this.state.showDialpad) {
|
|
|
|
if (this.controlsHideTimer) {
|
|
|
|
clearTimeout(this.controlsHideTimer);
|
|
|
|
this.controlsHideTimer = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
showDialpad: true,
|
|
|
|
controlsVisible: true,
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
if (this.controlsHideTimer !== null) {
|
|
|
|
clearTimeout(this.controlsHideTimer);
|
|
|
|
}
|
|
|
|
this.controlsHideTimer = window.setTimeout(this.onControlsHideTimer, CONTROLS_HIDE_DELAY);
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
showDialpad: false,
|
|
|
|
});
|
|
|
|
}
|
2021-06-29 15:11:58 +03:00
|
|
|
};
|
2021-01-04 23:01:43 +03:00
|
|
|
|
2021-07-20 14:47:07 +03:00
|
|
|
private onMicMuteClick = (): void => {
|
2020-11-18 17:22:38 +03:00
|
|
|
const newVal = !this.state.micMuted;
|
|
|
|
|
2020-12-03 20:45:49 +03:00
|
|
|
this.props.call.setMicrophoneMuted(newVal);
|
2021-06-29 15:11:58 +03:00
|
|
|
this.setState({ micMuted: newVal });
|
|
|
|
};
|
2020-11-18 17:22:38 +03:00
|
|
|
|
2021-07-20 14:47:07 +03:00
|
|
|
private onVidMuteClick = (): void => {
|
2020-11-18 17:22:38 +03:00
|
|
|
const newVal = !this.state.vidMuted;
|
|
|
|
|
2020-12-03 20:45:49 +03:00
|
|
|
this.props.call.setLocalVideoMuted(newVal);
|
2021-06-29 15:11:58 +03:00
|
|
|
this.setState({ vidMuted: newVal });
|
|
|
|
};
|
2020-11-18 17:22:38 +03:00
|
|
|
|
2021-07-20 14:47:07 +03:00
|
|
|
private onScreenshareClick = async (): Promise<void> => {
|
2021-05-07 22:35:32 +03:00
|
|
|
const isScreensharing = await this.props.call.setScreensharingEnabled(
|
|
|
|
!this.state.screensharing,
|
|
|
|
async (): Promise<DesktopCapturerSource> => {
|
2021-07-07 11:53:22 +03:00
|
|
|
const { finished } = Modal.createDialog(DesktopCapturerSourcePicker);
|
2021-05-07 22:35:32 +03:00
|
|
|
const [source] = await finished;
|
|
|
|
return source;
|
|
|
|
},
|
|
|
|
);
|
2021-07-07 11:53:22 +03:00
|
|
|
this.setState({ screensharing: isScreensharing });
|
|
|
|
};
|
2021-05-07 22:35:32 +03:00
|
|
|
|
2021-07-20 14:47:07 +03:00
|
|
|
private onMoreClick = (): void => {
|
2020-11-26 17:35:09 +03:00
|
|
|
if (this.controlsHideTimer) {
|
|
|
|
clearTimeout(this.controlsHideTimer);
|
|
|
|
this.controlsHideTimer = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
showMoreMenu: true,
|
|
|
|
controlsVisible: true,
|
|
|
|
});
|
2021-06-29 15:11:58 +03:00
|
|
|
};
|
2020-11-26 17:35:09 +03:00
|
|
|
|
2021-07-20 14:47:07 +03:00
|
|
|
private closeDialpad = (): void => {
|
2021-01-04 23:01:43 +03:00
|
|
|
this.setState({
|
|
|
|
showDialpad: false,
|
|
|
|
});
|
|
|
|
this.controlsHideTimer = window.setTimeout(this.onControlsHideTimer, CONTROLS_HIDE_DELAY);
|
2021-06-29 15:11:58 +03:00
|
|
|
};
|
2021-01-04 23:01:43 +03:00
|
|
|
|
2021-07-20 14:47:07 +03:00
|
|
|
private closeContextMenu = (): void => {
|
2020-11-26 17:35:09 +03:00
|
|
|
this.setState({
|
|
|
|
showMoreMenu: false,
|
|
|
|
});
|
|
|
|
this.controlsHideTimer = window.setTimeout(this.onControlsHideTimer, CONTROLS_HIDE_DELAY);
|
2021-06-29 15:11:58 +03:00
|
|
|
};
|
2020-11-26 17:35:09 +03:00
|
|
|
|
2020-11-19 18:15:31 +03:00
|
|
|
// we register global shortcuts here, they *must not conflict* with local shortcuts elsewhere or both will fire
|
2021-04-27 13:05:46 +03:00
|
|
|
// Note that this assumes we always have a CallView on screen at any given time
|
2020-11-19 18:15:31 +03:00
|
|
|
// CallHandler would probably be a better place for this
|
2021-07-20 14:47:07 +03:00
|
|
|
private onNativeKeyDown = (ev): void => {
|
2020-11-19 18:15:31 +03:00
|
|
|
let handled = false;
|
|
|
|
const ctrlCmdOnly = isOnlyCtrlOrCmdKeyEvent(ev);
|
|
|
|
|
|
|
|
switch (ev.key) {
|
|
|
|
case Key.D:
|
|
|
|
if (ctrlCmdOnly) {
|
|
|
|
this.onMicMuteClick();
|
|
|
|
// show the controls to give feedback
|
|
|
|
this.showControls();
|
|
|
|
handled = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Key.E:
|
|
|
|
if (ctrlCmdOnly) {
|
|
|
|
this.onVidMuteClick();
|
|
|
|
// show the controls to give feedback
|
|
|
|
this.showControls();
|
|
|
|
handled = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (handled) {
|
|
|
|
ev.stopPropagation();
|
|
|
|
ev.preventDefault();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-07-20 14:47:07 +03:00
|
|
|
private onRoomAvatarClick = (): void => {
|
2021-04-19 22:30:51 +03:00
|
|
|
const userFacingRoomId = CallHandler.sharedInstance().roomIdForCall(this.props.call);
|
2020-11-18 17:22:38 +03:00
|
|
|
dis.dispatch({
|
|
|
|
action: 'view_room',
|
2021-01-21 22:20:35 +03:00
|
|
|
room_id: userFacingRoomId,
|
2020-12-03 20:45:49 +03:00
|
|
|
});
|
2021-06-29 15:11:58 +03:00
|
|
|
};
|
2020-12-03 20:45:49 +03:00
|
|
|
|
2021-07-20 14:47:07 +03:00
|
|
|
private onSecondaryRoomAvatarClick = (): void => {
|
2021-04-19 22:30:51 +03:00
|
|
|
const userFacingRoomId = CallHandler.sharedInstance().roomIdForCall(this.props.secondaryCall);
|
2021-01-21 22:20:35 +03:00
|
|
|
|
2020-12-03 20:45:49 +03:00
|
|
|
dis.dispatch({
|
|
|
|
action: 'view_room',
|
2021-01-21 22:20:35 +03:00
|
|
|
room_id: userFacingRoomId,
|
2020-11-18 17:22:38 +03:00
|
|
|
});
|
2021-06-29 15:11:58 +03:00
|
|
|
};
|
2020-11-18 17:22:38 +03:00
|
|
|
|
2021-07-20 14:47:07 +03:00
|
|
|
private onCallResumeClick = (): void => {
|
2021-04-19 22:30:51 +03:00
|
|
|
const userFacingRoomId = CallHandler.sharedInstance().roomIdForCall(this.props.call);
|
2021-01-21 22:20:35 +03:00
|
|
|
CallHandler.sharedInstance().setActiveCallRoomId(userFacingRoomId);
|
2021-06-29 15:11:58 +03:00
|
|
|
};
|
2020-11-26 17:35:09 +03:00
|
|
|
|
2021-07-20 14:47:07 +03:00
|
|
|
private onTransferClick = (): void => {
|
2021-03-25 22:56:21 +03:00
|
|
|
const transfereeCall = CallHandler.sharedInstance().getTransfereeForCallId(this.props.call.callId);
|
|
|
|
this.props.call.transferToCall(transfereeCall);
|
2021-06-29 15:11:58 +03:00
|
|
|
};
|
2021-03-25 22:56:21 +03:00
|
|
|
|
2021-07-20 14:47:07 +03:00
|
|
|
private onHangupClick = (): void => {
|
2021-06-12 17:32:01 +03:00
|
|
|
dis.dispatch({
|
|
|
|
action: 'hangup',
|
|
|
|
room_id: CallHandler.sharedInstance().roomIdForCall(this.props.call),
|
|
|
|
});
|
2021-07-07 11:53:22 +03:00
|
|
|
};
|
2020-11-26 17:35:09 +03:00
|
|
|
|
2021-07-20 14:47:07 +03:00
|
|
|
private onToggleSidebar = (): void => {
|
2021-06-12 19:13:28 +03:00
|
|
|
let vidMuted = this.state.vidMuted;
|
|
|
|
if (this.state.screensharing) {
|
|
|
|
vidMuted = this.state.sidebarShown;
|
|
|
|
this.props.call.setLocalVideoMuted(vidMuted);
|
|
|
|
}
|
|
|
|
this.setState({
|
|
|
|
vidMuted: vidMuted,
|
|
|
|
sidebarShown: !this.state.sidebarShown,
|
|
|
|
});
|
2021-07-07 11:53:22 +03:00
|
|
|
};
|
2021-06-12 18:20:13 +03:00
|
|
|
|
2021-06-12 17:32:01 +03:00
|
|
|
private renderCallControls(): JSX.Element {
|
2020-12-03 20:45:49 +03:00
|
|
|
const micClasses = classNames({
|
|
|
|
mx_CallView_callControls_button: true,
|
|
|
|
mx_CallView_callControls_button_micOn: !this.state.micMuted,
|
|
|
|
mx_CallView_callControls_button_micOff: this.state.micMuted,
|
|
|
|
});
|
2020-11-18 17:22:38 +03:00
|
|
|
|
2020-12-03 20:45:49 +03:00
|
|
|
const vidClasses = classNames({
|
|
|
|
mx_CallView_callControls_button: true,
|
|
|
|
mx_CallView_callControls_button_vidOn: !this.state.vidMuted,
|
|
|
|
mx_CallView_callControls_button_vidOff: this.state.vidMuted,
|
|
|
|
});
|
2020-11-18 17:22:38 +03:00
|
|
|
|
2021-05-07 22:35:32 +03:00
|
|
|
const screensharingClasses = classNames({
|
|
|
|
mx_CallView_callControls_button: true,
|
|
|
|
mx_CallView_callControls_button_screensharingOn: this.state.screensharing,
|
|
|
|
mx_CallView_callControls_button_screensharingOff: !this.state.screensharing,
|
|
|
|
});
|
|
|
|
|
2021-06-12 18:20:13 +03:00
|
|
|
const sidebarButtonClasses = classNames({
|
|
|
|
mx_CallView_callControls_button: true,
|
|
|
|
mx_CallView_callControls_button_sidebarOn: this.state.sidebarShown,
|
|
|
|
mx_CallView_callControls_button_sidebarOff: !this.state.sidebarShown,
|
|
|
|
});
|
|
|
|
|
2020-12-03 20:45:49 +03:00
|
|
|
// Put the other states of the mic/video icons in the document to make sure they're cached
|
|
|
|
// (otherwise the icon disappears briefly when toggled)
|
|
|
|
const micCacheClasses = classNames({
|
|
|
|
mx_CallView_callControls_button: true,
|
|
|
|
mx_CallView_callControls_button_micOn: this.state.micMuted,
|
|
|
|
mx_CallView_callControls_button_micOff: !this.state.micMuted,
|
|
|
|
mx_CallView_callControls_button_invisible: true,
|
|
|
|
});
|
2020-11-18 17:22:38 +03:00
|
|
|
|
2020-12-03 20:45:49 +03:00
|
|
|
const vidCacheClasses = classNames({
|
|
|
|
mx_CallView_callControls_button: true,
|
|
|
|
mx_CallView_callControls_button_vidOn: this.state.micMuted,
|
|
|
|
mx_CallView_callControls_button_vidOff: !this.state.micMuted,
|
|
|
|
mx_CallView_callControls_button_invisible: true,
|
|
|
|
});
|
2020-11-18 17:22:38 +03:00
|
|
|
|
2020-12-03 20:45:49 +03:00
|
|
|
const callControlsClasses = classNames({
|
|
|
|
mx_CallView_callControls: true,
|
|
|
|
mx_CallView_callControls_hidden: !this.state.controlsVisible,
|
|
|
|
});
|
2020-11-18 17:22:38 +03:00
|
|
|
|
2021-06-12 17:32:01 +03:00
|
|
|
// We don't support call upgrades (yet) so hide the video mute button in voice calls
|
|
|
|
let vidMuteButton;
|
|
|
|
if (this.props.call.type === CallType.Video) {
|
|
|
|
vidMuteButton = (
|
|
|
|
<AccessibleButton
|
|
|
|
className={vidClasses}
|
|
|
|
onClick={this.onVidMuteClick}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
2020-12-03 20:45:49 +03:00
|
|
|
|
2021-05-13 19:11:47 +03:00
|
|
|
// Screensharing is possible, if we can send a second stream and
|
|
|
|
// identify it using SDPStreamMetadata or if we can replace the already
|
|
|
|
// existing usermedia track by a screensharing track. We also need to be
|
|
|
|
// connected to know the state of the other side
|
2021-06-12 17:32:01 +03:00
|
|
|
let screensharingButton;
|
2021-05-13 19:11:47 +03:00
|
|
|
if (
|
|
|
|
(this.props.call.opponentSupportsSDPStreamMetadata() || this.props.call.type === CallType.Video) &&
|
|
|
|
this.props.call.state === CallState.Connected
|
|
|
|
) {
|
2021-05-08 11:04:26 +03:00
|
|
|
screensharingButton = (
|
|
|
|
<AccessibleButton
|
|
|
|
className={screensharingClasses}
|
|
|
|
onClick={this.onScreenshareClick}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
2021-05-07 22:35:32 +03:00
|
|
|
|
2021-06-12 18:20:13 +03:00
|
|
|
// To show the sidebar we need secondary feeds, if we don't have them,
|
|
|
|
// we can hide this button. If we are in PiP, sidebar is also hidden, so
|
|
|
|
// we can hide the button too
|
|
|
|
let sidebarButton;
|
|
|
|
if (
|
|
|
|
(this.props.call.type === CallType.Video ||
|
|
|
|
this.state.primaryFeed?.purpose === SDPStreamMetadataPurpose.Screenshare) &&
|
|
|
|
!this.props.pipMode
|
|
|
|
) {
|
|
|
|
sidebarButton = (
|
|
|
|
<AccessibleButton
|
|
|
|
className={sidebarButtonClasses}
|
|
|
|
onClick={this.onToggleSidebar}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-01-04 23:01:43 +03:00
|
|
|
// The dial pad & 'more' button actions are only relevant in a connected call
|
2020-12-03 20:45:49 +03:00
|
|
|
// When not connected, we have to put something there to make the flexbox alignment correct
|
2021-07-20 17:07:27 +03:00
|
|
|
let dialpadButton;
|
|
|
|
let contextMenuButton;
|
|
|
|
if (this.state.callState === CallState.Connected) {
|
|
|
|
contextMenuButton = (
|
|
|
|
<ContextMenuButton
|
|
|
|
className="mx_CallView_callControls_button mx_CallView_callControls_button_more"
|
|
|
|
onClick={this.onMoreClick}
|
|
|
|
inputRef={this.contextMenuButton}
|
|
|
|
isExpanded={this.state.showMoreMenu}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
dialpadButton = (
|
|
|
|
<ContextMenuButton
|
|
|
|
className="mx_CallView_callControls_button mx_CallView_callControls_dialpad"
|
|
|
|
inputRef={this.dialpadButton}
|
|
|
|
onClick={this.onDialpadClick}
|
|
|
|
isExpanded={this.state.showDialpad}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
2020-12-03 20:45:49 +03:00
|
|
|
|
2021-06-12 17:32:01 +03:00
|
|
|
return (
|
|
|
|
<div className={callControlsClasses}>
|
|
|
|
{ dialpadButton }
|
|
|
|
<AccessibleButton
|
|
|
|
className={micClasses}
|
|
|
|
onClick={this.onMicMuteClick}
|
|
|
|
/>
|
2021-06-12 18:20:13 +03:00
|
|
|
{ vidMuteButton }
|
2021-07-20 17:07:27 +03:00
|
|
|
<div className={micCacheClasses} />
|
|
|
|
<div className={vidCacheClasses} />
|
|
|
|
{ screensharingButton }
|
|
|
|
{ sidebarButton }
|
|
|
|
{ contextMenuButton }
|
2021-06-12 17:32:01 +03:00
|
|
|
<AccessibleButton
|
|
|
|
className="mx_CallView_callControls_button mx_CallView_callControls_button_hangup"
|
|
|
|
onClick={this.onHangupClick}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2020-11-12 21:09:56 +03:00
|
|
|
|
2021-06-12 17:32:01 +03:00
|
|
|
public render() {
|
|
|
|
const client = MatrixClientPeg.get();
|
|
|
|
const callRoomId = CallHandler.sharedInstance().roomIdForCall(this.props.call);
|
|
|
|
const secondaryCallRoomId = CallHandler.sharedInstance().roomIdForCall(this.props.secondaryCall);
|
|
|
|
const callRoom = client.getRoom(callRoomId);
|
|
|
|
const secCallRoom = this.props.secondaryCall ? client.getRoom(secondaryCallRoomId) : null;
|
2021-04-03 10:15:55 +03:00
|
|
|
const avatarSize = this.props.pipMode ? 76 : 160;
|
2021-03-25 22:56:21 +03:00
|
|
|
const transfereeCall = CallHandler.sharedInstance().getTransfereeForCallId(this.props.call.callId);
|
2020-11-26 17:35:09 +03:00
|
|
|
const isOnHold = this.state.isLocalOnHold || this.state.isRemoteOnHold;
|
2021-06-12 17:32:01 +03:00
|
|
|
|
|
|
|
let contentView: React.ReactNode;
|
2021-03-25 22:56:21 +03:00
|
|
|
let holdTransferContent;
|
2021-06-12 17:32:01 +03:00
|
|
|
|
2021-03-25 22:56:21 +03:00
|
|
|
if (transfereeCall) {
|
2021-04-19 22:30:51 +03:00
|
|
|
const transferTargetRoom = MatrixClientPeg.get().getRoom(
|
|
|
|
CallHandler.sharedInstance().roomIdForCall(this.props.call),
|
|
|
|
);
|
2021-03-25 22:56:21 +03:00
|
|
|
const transferTargetName = transferTargetRoom ? transferTargetRoom.name : _t("unknown person");
|
|
|
|
|
|
|
|
const transfereeRoom = MatrixClientPeg.get().getRoom(
|
2021-04-19 22:30:51 +03:00
|
|
|
CallHandler.sharedInstance().roomIdForCall(transfereeCall),
|
2021-03-25 22:56:21 +03:00
|
|
|
);
|
|
|
|
const transfereeName = transfereeRoom ? transfereeRoom.name : _t("unknown person");
|
|
|
|
|
|
|
|
holdTransferContent = <div className="mx_CallView_holdTransferContent">
|
2021-07-20 00:43:11 +03:00
|
|
|
{ _t(
|
2021-03-25 22:56:21 +03:00
|
|
|
"Consulting with %(transferTarget)s. <a>Transfer to %(transferee)s</a>",
|
|
|
|
{
|
|
|
|
transferTarget: transferTargetName,
|
|
|
|
transferee: transfereeName,
|
|
|
|
},
|
|
|
|
{
|
2021-07-20 00:43:11 +03:00
|
|
|
a: sub => <AccessibleButton kind="link" onClick={this.onTransferClick}>
|
|
|
|
{ sub }
|
|
|
|
</AccessibleButton>,
|
2021-03-25 22:56:21 +03:00
|
|
|
},
|
2021-07-20 00:43:11 +03:00
|
|
|
) }
|
2021-03-25 22:56:21 +03:00
|
|
|
</div>;
|
|
|
|
} else if (isOnHold) {
|
|
|
|
let onHoldText = null;
|
|
|
|
if (this.state.isRemoteOnHold) {
|
|
|
|
const holdString = CallHandler.sharedInstance().hasAnyUnheldCall() ?
|
|
|
|
_td("You held the call <a>Switch</a>") : _td("You held the call <a>Resume</a>");
|
|
|
|
onHoldText = _t(holdString, {}, {
|
|
|
|
a: sub => <AccessibleButton kind="link" onClick={this.onCallResumeClick}>
|
2021-07-20 00:43:11 +03:00
|
|
|
{ sub }
|
2021-03-25 22:56:21 +03:00
|
|
|
</AccessibleButton>,
|
|
|
|
});
|
|
|
|
} else if (this.state.isLocalOnHold) {
|
|
|
|
onHoldText = _t("%(peerName)s held the call", {
|
|
|
|
peerName: this.props.call.getOpponentMember().name,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
holdTransferContent = <div className="mx_CallView_holdTransferContent">
|
2021-07-20 00:43:11 +03:00
|
|
|
{ onHoldText }
|
2021-03-25 22:56:21 +03:00
|
|
|
</div>;
|
2020-11-26 17:35:09 +03:00
|
|
|
}
|
|
|
|
|
2021-06-12 12:03:14 +03:00
|
|
|
let sidebar;
|
2021-06-12 18:20:13 +03:00
|
|
|
if (!isOnHold && !transfereeCall && !this.props.pipMode && this.state.sidebarShown) {
|
2021-06-12 12:03:14 +03:00
|
|
|
sidebar = (
|
|
|
|
<CallViewSidebar
|
|
|
|
feeds={this.state.secondaryFeeds}
|
|
|
|
call={this.props.call}
|
2021-06-12 15:01:09 +03:00
|
|
|
hideFeedsWithMutedVideo={!this.state.primaryFeed || this.state.primaryFeed?.isVideoMuted()}
|
2021-06-12 12:03:14 +03:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-04-03 10:15:55 +03:00
|
|
|
// This is a bit messy. I can't see a reason to have two onHold/transfer screens
|
|
|
|
if (isOnHold || transfereeCall) {
|
2021-03-07 10:13:35 +03:00
|
|
|
if (this.props.call.type === CallType.Video) {
|
|
|
|
const containerClasses = classNames({
|
2021-04-16 13:50:23 +03:00
|
|
|
mx_CallView_content: true,
|
2021-03-07 10:13:35 +03:00
|
|
|
mx_CallView_video: true,
|
|
|
|
mx_CallView_video_hold: isOnHold,
|
|
|
|
});
|
|
|
|
let onHoldBackground = null;
|
|
|
|
const backgroundStyle: CSSProperties = {};
|
2020-11-26 17:35:09 +03:00
|
|
|
const backgroundAvatarUrl = avatarUrlForMember(
|
2021-03-07 10:13:35 +03:00
|
|
|
// is it worth getting the size of the div to pass here?
|
2020-12-03 20:45:49 +03:00
|
|
|
this.props.call.getOpponentMember(), 1024, 1024, 'crop',
|
2020-11-26 17:35:09 +03:00
|
|
|
);
|
|
|
|
backgroundStyle.backgroundImage = 'url(' + backgroundAvatarUrl + ')';
|
|
|
|
onHoldBackground = <div className="mx_CallView_video_holdBackground" style={backgroundStyle} />;
|
|
|
|
|
2021-03-07 10:13:35 +03:00
|
|
|
contentView = (
|
|
|
|
<div className={containerClasses} ref={this.contentRef} onMouseMove={this.onMouseMove}>
|
2021-06-12 17:32:01 +03:00
|
|
|
{ onHoldBackground }
|
|
|
|
{ holdTransferContent }
|
|
|
|
{ this.renderCallControls() }
|
2021-03-07 10:13:35 +03:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
const classes = classNames({
|
2021-04-16 13:50:23 +03:00
|
|
|
mx_CallView_content: true,
|
2021-03-07 10:13:35 +03:00
|
|
|
mx_CallView_voice: true,
|
|
|
|
mx_CallView_voice_hold: isOnHold,
|
|
|
|
});
|
|
|
|
|
|
|
|
contentView =(
|
|
|
|
<div className={classes} onMouseMove={this.onMouseMove}>
|
|
|
|
<div className="mx_CallView_voice_avatarsContainer">
|
|
|
|
<div
|
|
|
|
className="mx_CallView_voice_avatarContainer"
|
2021-06-29 15:11:58 +03:00
|
|
|
style={{ width: avatarSize, height: avatarSize }}
|
2021-03-07 10:13:35 +03:00
|
|
|
>
|
|
|
|
<RoomAvatar
|
|
|
|
room={callRoom}
|
|
|
|
height={avatarSize}
|
|
|
|
width={avatarSize}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-06-12 17:32:01 +03:00
|
|
|
{ holdTransferContent }
|
|
|
|
{ this.renderCallControls() }
|
2021-03-07 10:13:35 +03:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} else if (this.props.call.noIncomingFeeds()) {
|
|
|
|
// Here we're reusing the css classes from voice on hold, because
|
|
|
|
// I am lazy. If this gets merged, the CallView might be subject
|
|
|
|
// to change anyway - I might take an axe to this file in order to
|
|
|
|
// try to get other things working
|
2020-11-26 17:35:09 +03:00
|
|
|
const classes = classNames({
|
2021-04-16 13:50:23 +03:00
|
|
|
mx_CallView_content: true,
|
2020-11-26 17:35:09 +03:00
|
|
|
mx_CallView_voice: true,
|
|
|
|
});
|
2020-12-07 21:28:43 +03:00
|
|
|
|
2021-03-07 10:13:35 +03:00
|
|
|
// Saying "Connecting" here isn't really true, but the best thing
|
|
|
|
// I can come up with, but this might be subject to change as well
|
2021-06-12 09:15:26 +03:00
|
|
|
contentView = (
|
|
|
|
<div
|
|
|
|
className={classes}
|
|
|
|
onMouseMove={this.onMouseMove}
|
|
|
|
>
|
2021-06-12 12:03:14 +03:00
|
|
|
{ sidebar }
|
2021-06-12 09:15:26 +03:00
|
|
|
<div className="mx_CallView_voice_avatarsContainer">
|
|
|
|
<div
|
|
|
|
className="mx_CallView_voice_avatarContainer"
|
2021-07-07 11:53:22 +03:00
|
|
|
style={{ width: avatarSize, height: avatarSize }}
|
2021-06-12 09:15:26 +03:00
|
|
|
>
|
|
|
|
<RoomAvatar
|
|
|
|
room={callRoom}
|
|
|
|
height={avatarSize}
|
|
|
|
width={avatarSize}
|
|
|
|
/>
|
|
|
|
</div>
|
2020-12-07 21:28:43 +03:00
|
|
|
</div>
|
2021-07-20 14:24:05 +03:00
|
|
|
<div className="mx_CallView_holdTransferContent">{ _t("Connecting") }</div>
|
2021-06-12 17:32:01 +03:00
|
|
|
{ this.renderCallControls() }
|
2020-11-26 17:35:09 +03:00
|
|
|
</div>
|
2021-06-12 09:15:26 +03:00
|
|
|
);
|
2021-03-07 10:13:35 +03:00
|
|
|
} else {
|
|
|
|
const containerClasses = classNames({
|
2021-04-16 13:50:23 +03:00
|
|
|
mx_CallView_content: true,
|
2021-03-07 10:13:35 +03:00
|
|
|
mx_CallView_video: true,
|
|
|
|
});
|
|
|
|
|
2021-06-12 12:50:16 +03:00
|
|
|
let presenting;
|
2021-07-20 17:17:07 +03:00
|
|
|
if (
|
|
|
|
this.state.primaryFeed?.purpose === SDPStreamMetadataPurpose.Screenshare ||
|
|
|
|
this.props.call.isScreensharing()
|
|
|
|
) {
|
2021-06-12 12:50:16 +03:00
|
|
|
const presentingClasses = classNames({
|
|
|
|
mx_CallView_presenting: true,
|
|
|
|
mx_CallView_presenting_hidden: !this.state.controlsVisible,
|
|
|
|
});
|
|
|
|
const sharerName = this.state.primaryFeed.getMember().name;
|
2021-07-20 17:17:07 +03:00
|
|
|
const text = this.props.call.isScreensharing()
|
|
|
|
? _t("You are presenting")
|
|
|
|
: _t('%(sharerName)s is presenting', { sharerName });
|
2021-06-12 12:50:16 +03:00
|
|
|
|
|
|
|
presenting = (
|
|
|
|
<div className={presentingClasses}>
|
2021-07-20 17:17:07 +03:00
|
|
|
{ text }
|
2021-06-12 12:50:16 +03:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-06-12 09:15:26 +03:00
|
|
|
contentView = (
|
|
|
|
<div
|
|
|
|
className={containerClasses}
|
|
|
|
ref={this.contentRef}
|
|
|
|
onMouseMove={this.onMouseMove}
|
|
|
|
>
|
2021-06-12 12:50:16 +03:00
|
|
|
{ presenting }
|
2021-06-12 12:03:14 +03:00
|
|
|
{ sidebar }
|
2021-06-12 09:15:26 +03:00
|
|
|
<VideoFeed
|
2021-06-12 10:19:58 +03:00
|
|
|
feed={this.state.primaryFeed}
|
2021-06-12 09:15:26 +03:00
|
|
|
call={this.props.call}
|
|
|
|
pipMode={this.props.pipMode}
|
|
|
|
onResize={this.props.onResize}
|
|
|
|
primary={true}
|
|
|
|
/>
|
2021-06-12 17:32:01 +03:00
|
|
|
{ this.renderCallControls() }
|
2021-06-12 09:15:26 +03:00
|
|
|
</div>
|
|
|
|
);
|
2020-11-12 21:09:56 +03:00
|
|
|
}
|
|
|
|
|
2020-12-03 20:45:49 +03:00
|
|
|
const callTypeText = this.props.call.type === CallType.Video ? _t("Video Call") : _t("Voice Call");
|
2020-11-12 21:09:56 +03:00
|
|
|
let myClassName;
|
|
|
|
|
|
|
|
let fullScreenButton;
|
2021-06-12 18:15:17 +03:00
|
|
|
if (!this.props.pipMode) {
|
2020-11-19 19:36:23 +03:00
|
|
|
fullScreenButton = <div className="mx_CallView_header_button mx_CallView_header_button_fullscreen"
|
2020-11-23 18:28:54 +03:00
|
|
|
onClick={this.onFullscreenClick} title={_t("Fill Screen")}
|
2020-11-12 21:09:56 +03:00
|
|
|
/>;
|
|
|
|
}
|
|
|
|
|
2020-11-19 19:36:23 +03:00
|
|
|
let expandButton;
|
2020-12-03 20:45:49 +03:00
|
|
|
if (this.props.pipMode) {
|
2020-11-19 19:36:23 +03:00
|
|
|
expandButton = <div className="mx_CallView_header_button mx_CallView_header_button_expand"
|
|
|
|
onClick={this.onExpandClick} title={_t("Return to call")}
|
|
|
|
/>;
|
|
|
|
}
|
|
|
|
|
2020-11-12 21:09:56 +03:00
|
|
|
const headerControls = <div className="mx_CallView_header_controls">
|
2021-07-20 00:43:11 +03:00
|
|
|
{ fullScreenButton }
|
|
|
|
{ expandButton }
|
2020-11-12 21:09:56 +03:00
|
|
|
</div>;
|
|
|
|
|
|
|
|
let header: React.ReactNode;
|
2020-12-03 20:45:49 +03:00
|
|
|
if (!this.props.pipMode) {
|
2020-11-12 21:09:56 +03:00
|
|
|
header = <div className="mx_CallView_header">
|
|
|
|
<div className="mx_CallView_header_phoneIcon"></div>
|
2021-07-20 00:43:11 +03:00
|
|
|
<span className="mx_CallView_header_callType">{ callTypeText }</span>
|
|
|
|
{ headerControls }
|
2020-11-12 21:09:56 +03:00
|
|
|
</div>;
|
|
|
|
myClassName = 'mx_CallView_large';
|
|
|
|
} else {
|
2020-12-03 20:45:49 +03:00
|
|
|
let secondaryCallInfo;
|
|
|
|
if (this.props.secondaryCall) {
|
2020-12-07 20:56:36 +03:00
|
|
|
secondaryCallInfo = <span className="mx_CallView_header_secondaryCallInfo">
|
|
|
|
<AccessibleButton element='span' onClick={this.onSecondaryRoomAvatarClick}>
|
|
|
|
<RoomAvatar room={secCallRoom} height={16} width={16} />
|
|
|
|
<span className="mx_CallView_secondaryCall_roomName">
|
2021-07-20 00:43:11 +03:00
|
|
|
{ _t("%(name)s on hold", { name: secCallRoom.name }) }
|
2020-12-07 20:56:36 +03:00
|
|
|
</span>
|
|
|
|
</AccessibleButton>
|
|
|
|
</span>;
|
2020-12-03 20:45:49 +03:00
|
|
|
}
|
|
|
|
|
2021-05-02 17:24:47 +03:00
|
|
|
header = (
|
|
|
|
<div
|
|
|
|
className="mx_CallView_header"
|
2021-05-03 16:16:08 +03:00
|
|
|
onMouseDown={this.props.onMouseDownOnHeader}
|
2021-05-02 17:24:47 +03:00
|
|
|
>
|
|
|
|
<AccessibleButton onClick={this.onRoomAvatarClick}>
|
|
|
|
<RoomAvatar room={callRoom} height={32} width={32} />
|
|
|
|
</AccessibleButton>
|
|
|
|
<div className="mx_CallView_header_callInfo">
|
2021-07-20 00:43:11 +03:00
|
|
|
<div className="mx_CallView_header_roomName">{ callRoom.name }</div>
|
2021-05-02 17:24:47 +03:00
|
|
|
<div className="mx_CallView_header_callTypeSmall">
|
2021-07-20 00:43:11 +03:00
|
|
|
{ callTypeText }
|
|
|
|
{ secondaryCallInfo }
|
2021-05-02 17:24:47 +03:00
|
|
|
</div>
|
2020-12-07 20:56:36 +03:00
|
|
|
</div>
|
2021-07-20 00:43:11 +03:00
|
|
|
{ headerControls }
|
2020-11-12 21:09:56 +03:00
|
|
|
</div>
|
2021-05-02 17:24:47 +03:00
|
|
|
);
|
2020-11-12 21:09:56 +03:00
|
|
|
myClassName = 'mx_CallView_pip';
|
|
|
|
}
|
2020-07-07 00:42:46 +03:00
|
|
|
|
2021-06-12 17:32:01 +03:00
|
|
|
let dialPad;
|
|
|
|
if (this.state.showDialpad) {
|
|
|
|
dialPad = <DialpadContextMenu
|
|
|
|
{...alwaysAboveRightOf(
|
|
|
|
this.dialpadButton.current.getBoundingClientRect(),
|
|
|
|
ChevronFace.None,
|
|
|
|
CONTEXT_MENU_VPADDING,
|
|
|
|
)}
|
|
|
|
onFinished={this.closeDialpad}
|
|
|
|
call={this.props.call}
|
|
|
|
/>;
|
|
|
|
}
|
|
|
|
|
|
|
|
let contextMenu;
|
|
|
|
if (this.state.showMoreMenu) {
|
|
|
|
contextMenu = <CallContextMenu
|
|
|
|
{...alwaysAboveLeftOf(
|
|
|
|
this.contextMenuButton.current.getBoundingClientRect(),
|
|
|
|
ChevronFace.None,
|
|
|
|
CONTEXT_MENU_VPADDING,
|
|
|
|
)}
|
|
|
|
onFinished={this.closeContextMenu}
|
|
|
|
call={this.props.call}
|
|
|
|
/>;
|
|
|
|
}
|
|
|
|
|
2020-11-12 21:09:56 +03:00
|
|
|
return <div className={"mx_CallView " + myClassName}>
|
2021-06-12 17:32:01 +03:00
|
|
|
{ header }
|
|
|
|
{ contentView }
|
|
|
|
{ dialPad }
|
|
|
|
{ contextMenu }
|
2020-07-07 00:42:46 +03:00
|
|
|
</div>;
|
|
|
|
}
|
|
|
|
}
|