2020-06-04 18:16:19 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { CallScreen, PropsType as CallScreenPropsType } from './CallScreen';
|
|
|
|
import {
|
|
|
|
IncomingCallBar,
|
|
|
|
PropsType as IncomingCallBarPropsType,
|
|
|
|
} from './IncomingCallBar';
|
|
|
|
import { CallState } from '../types/Calling';
|
|
|
|
import { CallDetailsType } from '../state/ducks/calling';
|
|
|
|
|
|
|
|
type CallManagerPropsType = {
|
|
|
|
callDetails?: CallDetailsType;
|
|
|
|
callState?: CallState;
|
2020-08-27 00:03:42 +00:00
|
|
|
renderDeviceSelection: () => JSX.Element;
|
|
|
|
settingsDialogOpen: boolean;
|
2020-06-04 18:16:19 +00:00
|
|
|
};
|
2020-08-27 00:03:42 +00:00
|
|
|
|
2020-06-04 18:16:19 +00:00
|
|
|
type PropsType = IncomingCallBarPropsType &
|
|
|
|
CallScreenPropsType &
|
|
|
|
CallManagerPropsType;
|
|
|
|
|
|
|
|
export const CallManager = ({
|
|
|
|
acceptCall,
|
|
|
|
callDetails,
|
|
|
|
callState,
|
|
|
|
declineCall,
|
|
|
|
hangUp,
|
|
|
|
hasLocalAudio,
|
|
|
|
hasLocalVideo,
|
|
|
|
hasRemoteVideo,
|
|
|
|
i18n,
|
2020-08-27 00:03:42 +00:00
|
|
|
renderDeviceSelection,
|
2020-06-04 18:16:19 +00:00
|
|
|
setLocalAudio,
|
2020-08-27 00:03:42 +00:00
|
|
|
setLocalPreview,
|
2020-06-04 18:16:19 +00:00
|
|
|
setLocalVideo,
|
2020-08-27 00:03:42 +00:00
|
|
|
setRendererCanvas,
|
|
|
|
settingsDialogOpen,
|
|
|
|
toggleSettings,
|
2020-06-04 18:16:19 +00:00
|
|
|
}: PropsType): JSX.Element | null => {
|
|
|
|
if (!callDetails || !callState) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
const incoming = callDetails.isIncoming;
|
|
|
|
const outgoing = !incoming;
|
|
|
|
const ongoing =
|
|
|
|
callState === CallState.Accepted || callState === CallState.Reconnecting;
|
|
|
|
const ringing = callState === CallState.Ringing;
|
|
|
|
|
|
|
|
if (outgoing || ongoing) {
|
|
|
|
return (
|
2020-08-27 00:03:42 +00:00
|
|
|
<>
|
|
|
|
<CallScreen
|
|
|
|
callDetails={callDetails}
|
|
|
|
callState={callState}
|
|
|
|
hangUp={hangUp}
|
|
|
|
hasLocalAudio={hasLocalAudio}
|
|
|
|
hasLocalVideo={hasLocalVideo}
|
|
|
|
i18n={i18n}
|
|
|
|
hasRemoteVideo={hasRemoteVideo}
|
|
|
|
setLocalPreview={setLocalPreview}
|
|
|
|
setRendererCanvas={setRendererCanvas}
|
|
|
|
setLocalAudio={setLocalAudio}
|
|
|
|
setLocalVideo={setLocalVideo}
|
|
|
|
toggleSettings={toggleSettings}
|
|
|
|
/>
|
|
|
|
{settingsDialogOpen && renderDeviceSelection()}
|
|
|
|
</>
|
2020-06-04 18:16:19 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (incoming && ringing) {
|
|
|
|
return (
|
|
|
|
<IncomingCallBar
|
|
|
|
acceptCall={acceptCall}
|
|
|
|
callDetails={callDetails}
|
|
|
|
declineCall={declineCall}
|
|
|
|
i18n={i18n}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ended || (Incoming && Prering)
|
|
|
|
return null;
|
|
|
|
};
|