2023-01-03 19:55:46 +00:00
|
|
|
// Copyright 2020 Signal Messenger, LLC
|
2020-10-30 20:34:04 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2020-12-02 18:14:03 +00:00
|
|
|
import { memoize } from 'lodash';
|
2024-03-13 20:44:13 +00:00
|
|
|
import React, { memo } from 'react';
|
|
|
|
import { useSelector } from 'react-redux';
|
2024-01-04 22:16:33 +00:00
|
|
|
import type {
|
|
|
|
DirectIncomingCall,
|
|
|
|
GroupIncomingCall,
|
|
|
|
} from '../../components/CallManager';
|
2020-06-04 18:16:19 +00:00
|
|
|
import { CallManager } from '../../components/CallManager';
|
2024-03-13 20:44:13 +00:00
|
|
|
import { isConversationTooBigToRing as getIsConversationTooBigToRing } from '../../conversations/isConversationTooBigToRing';
|
|
|
|
import * as log from '../../logging/log';
|
2020-11-13 19:57:55 +00:00
|
|
|
import { calling as callingService } from '../../services/calling';
|
2024-03-13 20:44:13 +00:00
|
|
|
import {
|
|
|
|
FALLBACK_NOTIFICATION_TITLE,
|
|
|
|
NotificationSetting,
|
|
|
|
NotificationType,
|
|
|
|
notificationService,
|
|
|
|
} from '../../services/notifications';
|
|
|
|
import {
|
|
|
|
bounceAppIconStart,
|
|
|
|
bounceAppIconStop,
|
|
|
|
} from '../../shims/bounceAppIcon';
|
|
|
|
import type { CallLinkType } from '../../types/CallLink';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type {
|
2023-09-20 14:00:01 +00:00
|
|
|
ActiveCallBaseType,
|
2020-12-02 18:14:03 +00:00
|
|
|
ActiveCallType,
|
2023-09-20 14:00:01 +00:00
|
|
|
ActiveDirectCallType,
|
|
|
|
ActiveGroupCallType,
|
2024-02-22 21:19:50 +00:00
|
|
|
CallingConversationType,
|
2023-11-16 19:55:35 +00:00
|
|
|
ConversationsByDemuxIdType,
|
2020-11-20 20:14:07 +00:00
|
|
|
GroupCallRemoteParticipantType,
|
|
|
|
} from '../../types/Calling';
|
2021-10-26 19:15:33 +00:00
|
|
|
import { CallMode, CallState } from '../../types/Calling';
|
2024-03-13 20:44:13 +00:00
|
|
|
import type { AciString } from '../../types/ServiceId';
|
|
|
|
import { strictAssert } from '../../util/assert';
|
|
|
|
import { callLinkToConversation } from '../../util/callLinks';
|
|
|
|
import { callingTones } from '../../util/callingTones';
|
|
|
|
import { isGroupCallRaiseHandEnabled } from '../../util/isGroupCallRaiseHandEnabled';
|
|
|
|
import { isGroupCallReactionsEnabled } from '../../util/isGroupCallReactionsEnabled';
|
2020-12-02 18:14:03 +00:00
|
|
|
import { missingCaseError } from '../../util/missingCaseError';
|
2024-03-13 20:44:13 +00:00
|
|
|
import { useAudioPlayerActions } from '../ducks/audioPlayer';
|
|
|
|
import { getActiveCall, useCallingActions } from '../ducks/calling';
|
|
|
|
import type { ConversationType } from '../ducks/conversations';
|
|
|
|
import { useToastActions } from '../ducks/toast';
|
|
|
|
import type { StateType } from '../reducer';
|
|
|
|
import { getHasInitialLoadCompleted } from '../selectors/app';
|
|
|
|
import {
|
|
|
|
getAvailableCameras,
|
|
|
|
getCallLinkSelector,
|
|
|
|
getIncomingCall,
|
|
|
|
} from '../selectors/calling';
|
|
|
|
import { getConversationSelector, getMe } from '../selectors/conversations';
|
2024-04-16 21:55:09 +00:00
|
|
|
import { getIntl } from '../selectors/user';
|
2020-08-27 00:03:42 +00:00
|
|
|
import { SmartCallingDeviceSelection } from './CallingDeviceSelection';
|
2023-11-16 19:55:35 +00:00
|
|
|
import { renderEmojiPicker } from './renderEmojiPicker';
|
|
|
|
import { renderReactionPicker } from './renderReactionPicker';
|
2020-08-27 00:03:42 +00:00
|
|
|
|
|
|
|
function renderDeviceSelection(): JSX.Element {
|
2020-10-26 21:32:46 +00:00
|
|
|
return <SmartCallingDeviceSelection />;
|
2020-08-27 00:03:42 +00:00
|
|
|
}
|
|
|
|
|
2021-11-11 22:43:05 +00:00
|
|
|
const getGroupCallVideoFrameSource =
|
|
|
|
callingService.getGroupCallVideoFrameSource.bind(callingService);
|
2020-11-13 19:57:55 +00:00
|
|
|
|
2021-08-20 16:06:15 +00:00
|
|
|
async function notifyForCall(
|
2023-08-01 16:06:29 +00:00
|
|
|
conversationId: string,
|
2021-08-20 16:06:15 +00:00
|
|
|
title: string,
|
|
|
|
isVideoCall: boolean
|
|
|
|
): Promise<void> {
|
|
|
|
const shouldNotify =
|
2022-07-05 16:44:53 +00:00
|
|
|
!window.SignalContext.activeWindowService.isActive() &&
|
|
|
|
window.Events.getCallSystemNotification();
|
2021-08-20 16:06:15 +00:00
|
|
|
if (!shouldNotify) {
|
|
|
|
return;
|
|
|
|
}
|
2021-09-23 18:16:09 +00:00
|
|
|
|
|
|
|
let notificationTitle: string;
|
|
|
|
|
|
|
|
const notificationSetting = notificationService.getNotificationSetting();
|
|
|
|
switch (notificationSetting) {
|
|
|
|
case NotificationSetting.Off:
|
|
|
|
case NotificationSetting.NoNameOrMessage:
|
|
|
|
notificationTitle = FALLBACK_NOTIFICATION_TITLE;
|
|
|
|
break;
|
|
|
|
case NotificationSetting.NameOnly:
|
|
|
|
case NotificationSetting.NameAndMessage:
|
|
|
|
notificationTitle = title;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
log.error(missingCaseError(notificationSetting));
|
|
|
|
notificationTitle = FALLBACK_NOTIFICATION_TITLE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2023-08-01 16:06:29 +00:00
|
|
|
const conversation = window.ConversationController.get(conversationId);
|
|
|
|
strictAssert(conversation, 'notifyForCall: conversation not found');
|
|
|
|
|
|
|
|
const { url, absolutePath } = await conversation.getAvatarOrIdenticon();
|
|
|
|
|
2021-09-23 18:16:09 +00:00
|
|
|
notificationService.notify({
|
2023-08-01 16:06:29 +00:00
|
|
|
conversationId,
|
2021-09-23 18:16:09 +00:00
|
|
|
title: notificationTitle,
|
2023-08-01 16:06:29 +00:00
|
|
|
iconPath: absolutePath,
|
|
|
|
iconUrl: url,
|
2023-03-28 18:26:46 +00:00
|
|
|
message: isVideoCall
|
2023-03-30 00:03:25 +00:00
|
|
|
? window.i18n('icu:incomingVideoCall')
|
|
|
|
: window.i18n('icu:incomingAudioCall'),
|
2023-06-14 20:55:50 +00:00
|
|
|
sentAt: 0,
|
2023-05-08 19:59:36 +00:00
|
|
|
// The ringtone plays so we don't need sound for the notification
|
|
|
|
silent: true,
|
2023-08-01 16:06:29 +00:00
|
|
|
type: NotificationType.IncomingCall,
|
2021-08-20 16:06:15 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
const playRingtone = callingTones.playRingtone.bind(callingTones);
|
|
|
|
const stopRingtone = callingTones.stopRingtone.bind(callingTones);
|
|
|
|
|
2020-12-02 18:14:03 +00:00
|
|
|
const mapStateToActiveCallProp = (
|
|
|
|
state: StateType
|
|
|
|
): undefined | ActiveCallType => {
|
2020-10-08 01:25:33 +00:00
|
|
|
const { calling } = state;
|
2020-11-06 17:36:37 +00:00
|
|
|
const { activeCallState } = calling;
|
|
|
|
|
|
|
|
if (!activeCallState) {
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
const call = getActiveCall(calling);
|
|
|
|
if (!call) {
|
2021-09-17 18:27:53 +00:00
|
|
|
log.error('There was an active call state but no corresponding call');
|
2020-11-06 17:36:37 +00:00
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
2020-11-17 15:07:53 +00:00
|
|
|
const conversationSelector = getConversationSelector(state);
|
2024-02-22 21:19:50 +00:00
|
|
|
let conversation: CallingConversationType;
|
|
|
|
if (call.callMode === CallMode.Adhoc) {
|
|
|
|
const callLinkSelector = getCallLinkSelector(state);
|
|
|
|
const callLink = callLinkSelector(activeCallState.conversationId);
|
|
|
|
if (!callLink) {
|
|
|
|
// An error is logged in mapStateToCallLinkProp
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
conversation = callLinkToConversation(callLink, window.i18n);
|
|
|
|
} else {
|
|
|
|
conversation = conversationSelector(activeCallState.conversationId);
|
|
|
|
}
|
2020-11-06 17:36:37 +00:00
|
|
|
if (!conversation) {
|
2021-09-17 18:27:53 +00:00
|
|
|
log.error('The active call has no corresponding conversation');
|
2020-11-06 17:36:37 +00:00
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
2023-08-10 16:43:33 +00:00
|
|
|
const conversationSelectorByAci = memoize<
|
|
|
|
(aci: AciString) => undefined | ConversationType
|
|
|
|
>(aci => {
|
|
|
|
const convoForAci = window.ConversationController.lookupOrCreate({
|
2023-08-16 20:54:39 +00:00
|
|
|
serviceId: aci,
|
2022-12-03 01:05:27 +00:00
|
|
|
reason: 'CallManager.mapStateToActiveCallProp',
|
2020-11-20 20:14:07 +00:00
|
|
|
});
|
2023-08-10 16:43:33 +00:00
|
|
|
return convoForAci ? conversationSelector(convoForAci.id) : undefined;
|
2020-12-02 18:14:03 +00:00
|
|
|
});
|
2020-11-20 20:14:07 +00:00
|
|
|
|
2023-09-20 14:00:01 +00:00
|
|
|
const baseResult: ActiveCallBaseType = {
|
2020-12-02 18:14:03 +00:00
|
|
|
conversation,
|
|
|
|
hasLocalAudio: activeCallState.hasLocalAudio,
|
|
|
|
hasLocalVideo: activeCallState.hasLocalVideo,
|
2022-05-19 03:28:51 +00:00
|
|
|
localAudioLevel: activeCallState.localAudioLevel,
|
2022-05-25 18:03:27 +00:00
|
|
|
viewMode: activeCallState.viewMode,
|
2023-11-13 14:56:48 +00:00
|
|
|
viewModeBeforePresentation: activeCallState.viewModeBeforePresentation,
|
2020-12-02 18:14:03 +00:00
|
|
|
joinedAt: activeCallState.joinedAt,
|
2021-08-25 21:42:51 +00:00
|
|
|
outgoingRing: activeCallState.outgoingRing,
|
2020-12-02 18:14:03 +00:00
|
|
|
pip: activeCallState.pip,
|
2021-05-20 21:54:03 +00:00
|
|
|
presentingSource: activeCallState.presentingSource,
|
|
|
|
presentingSourcesAvailable: activeCallState.presentingSourcesAvailable,
|
2020-12-02 18:14:03 +00:00
|
|
|
settingsDialogOpen: activeCallState.settingsDialogOpen,
|
2021-05-20 21:54:03 +00:00
|
|
|
showNeedsScreenRecordingPermissionsWarning: Boolean(
|
|
|
|
activeCallState.showNeedsScreenRecordingPermissionsWarning
|
|
|
|
),
|
2020-12-02 18:14:03 +00:00
|
|
|
showParticipantsList: activeCallState.showParticipantsList,
|
2023-11-16 19:55:35 +00:00
|
|
|
reactions: activeCallState.reactions,
|
2020-12-02 18:14:03 +00:00
|
|
|
};
|
2020-11-17 15:07:53 +00:00
|
|
|
|
2020-12-02 18:14:03 +00:00
|
|
|
switch (call.callMode) {
|
|
|
|
case CallMode.Direct:
|
2021-08-10 23:16:18 +00:00
|
|
|
if (
|
|
|
|
call.isIncoming &&
|
|
|
|
(call.callState === CallState.Prering ||
|
|
|
|
call.callState === CallState.Ringing)
|
|
|
|
) {
|
2021-08-10 17:15:35 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-12-02 18:14:03 +00:00
|
|
|
return {
|
|
|
|
...baseResult,
|
|
|
|
callEndedReason: call.callEndedReason,
|
|
|
|
callMode: CallMode.Direct,
|
|
|
|
callState: call.callState,
|
|
|
|
peekedParticipants: [],
|
|
|
|
remoteParticipants: [
|
|
|
|
{
|
|
|
|
hasRemoteVideo: Boolean(call.hasRemoteVideo),
|
2021-05-20 21:54:03 +00:00
|
|
|
presenting: Boolean(call.isSharingScreen),
|
|
|
|
title: conversation.title,
|
2023-08-16 20:54:39 +00:00
|
|
|
serviceId: conversation.serviceId,
|
2020-12-02 18:14:03 +00:00
|
|
|
},
|
|
|
|
],
|
2023-09-20 14:00:01 +00:00
|
|
|
} satisfies ActiveDirectCallType;
|
2024-02-22 21:19:50 +00:00
|
|
|
case CallMode.Group:
|
|
|
|
case CallMode.Adhoc: {
|
2021-08-17 21:45:18 +00:00
|
|
|
const groupMembers: Array<ConversationType> = [];
|
2020-12-02 18:14:03 +00:00
|
|
|
const remoteParticipants: Array<GroupCallRemoteParticipantType> = [];
|
2020-12-08 19:37:04 +00:00
|
|
|
const peekedParticipants: Array<ConversationType> = [];
|
2023-11-16 19:55:35 +00:00
|
|
|
const conversationsByDemuxId: ConversationsByDemuxIdType = new Map();
|
2023-12-06 21:52:29 +00:00
|
|
|
const { localDemuxId } = call;
|
|
|
|
const raisedHands: Set<number> = new Set(call.raisedHands ?? []);
|
2020-12-02 18:14:03 +00:00
|
|
|
|
2021-08-17 21:45:18 +00:00
|
|
|
const { memberships = [] } = conversation;
|
2022-02-08 19:18:51 +00:00
|
|
|
|
|
|
|
// Active calls should have peek info, but TypeScript doesn't know that so we have a
|
|
|
|
// fallback.
|
|
|
|
const {
|
|
|
|
peekInfo = {
|
|
|
|
deviceCount: 0,
|
|
|
|
maxDevices: Infinity,
|
2023-08-10 16:43:33 +00:00
|
|
|
acis: [],
|
2022-02-08 19:18:51 +00:00
|
|
|
},
|
|
|
|
} = call;
|
|
|
|
|
2021-08-17 21:45:18 +00:00
|
|
|
for (let i = 0; i < memberships.length; i += 1) {
|
2023-08-16 20:54:39 +00:00
|
|
|
const { aci } = memberships[i];
|
2021-08-17 21:45:18 +00:00
|
|
|
|
2023-08-16 20:54:39 +00:00
|
|
|
const member = conversationSelector(aci);
|
2021-08-17 21:45:18 +00:00
|
|
|
if (!member) {
|
2021-09-17 18:27:53 +00:00
|
|
|
log.error('Group member has no corresponding conversation');
|
2021-08-17 21:45:18 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
groupMembers.push(member);
|
|
|
|
}
|
|
|
|
|
2020-12-02 18:14:03 +00:00
|
|
|
for (let i = 0; i < call.remoteParticipants.length; i += 1) {
|
|
|
|
const remoteParticipant = call.remoteParticipants[i];
|
|
|
|
|
2023-08-10 16:43:33 +00:00
|
|
|
const remoteConversation = conversationSelectorByAci(
|
|
|
|
remoteParticipant.aci
|
2020-12-02 18:14:03 +00:00
|
|
|
);
|
2020-11-17 15:07:53 +00:00
|
|
|
if (!remoteConversation) {
|
2021-09-17 18:27:53 +00:00
|
|
|
log.error('Remote participant has no corresponding conversation');
|
2020-12-02 18:14:03 +00:00
|
|
|
continue;
|
2020-11-17 15:07:53 +00:00
|
|
|
}
|
|
|
|
|
2020-12-02 18:14:03 +00:00
|
|
|
remoteParticipants.push({
|
2020-12-08 19:37:04 +00:00
|
|
|
...remoteConversation,
|
2023-08-30 21:34:58 +00:00
|
|
|
aci: remoteParticipant.aci,
|
2024-01-23 19:08:21 +00:00
|
|
|
addedTime: remoteParticipant.addedTime,
|
2020-11-19 18:13:36 +00:00
|
|
|
demuxId: remoteParticipant.demuxId,
|
2020-11-17 15:07:53 +00:00
|
|
|
hasRemoteAudio: remoteParticipant.hasRemoteAudio,
|
|
|
|
hasRemoteVideo: remoteParticipant.hasRemoteVideo,
|
2023-12-06 21:52:29 +00:00
|
|
|
isHandRaised: raisedHands.has(remoteParticipant.demuxId),
|
2024-01-23 19:08:21 +00:00
|
|
|
mediaKeysReceived: remoteParticipant.mediaKeysReceived,
|
2021-05-20 21:54:03 +00:00
|
|
|
presenting: remoteParticipant.presenting,
|
|
|
|
sharingScreen: remoteParticipant.sharingScreen,
|
2020-12-01 23:52:09 +00:00
|
|
|
speakerTime: remoteParticipant.speakerTime,
|
2020-11-19 18:13:36 +00:00
|
|
|
videoAspectRatio: remoteParticipant.videoAspectRatio,
|
2020-11-17 15:07:53 +00:00
|
|
|
});
|
2023-11-16 19:55:35 +00:00
|
|
|
conversationsByDemuxId.set(
|
|
|
|
remoteParticipant.demuxId,
|
|
|
|
remoteConversation
|
|
|
|
);
|
2020-11-17 15:07:53 +00:00
|
|
|
}
|
2020-12-02 01:30:25 +00:00
|
|
|
|
2023-12-06 21:52:29 +00:00
|
|
|
if (localDemuxId !== undefined) {
|
|
|
|
conversationsByDemuxId.set(localDemuxId, getMe(state));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Filter raisedHands to ensure valid demuxIds.
|
|
|
|
raisedHands.forEach(demuxId => {
|
|
|
|
if (!conversationsByDemuxId.has(demuxId)) {
|
|
|
|
raisedHands.delete(demuxId);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2023-08-10 16:43:33 +00:00
|
|
|
for (let i = 0; i < peekInfo.acis.length; i += 1) {
|
|
|
|
const peekedParticipantAci = peekInfo.acis[i];
|
2020-11-17 15:07:53 +00:00
|
|
|
|
2023-08-10 16:43:33 +00:00
|
|
|
const peekedConversation =
|
|
|
|
conversationSelectorByAci(peekedParticipantAci);
|
2020-12-02 18:14:03 +00:00
|
|
|
if (!peekedConversation) {
|
2021-09-17 18:27:53 +00:00
|
|
|
log.error('Remote participant has no corresponding conversation');
|
2020-12-02 18:14:03 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2020-12-08 19:37:04 +00:00
|
|
|
peekedParticipants.push(peekedConversation);
|
2020-12-02 18:14:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
...baseResult,
|
2024-02-22 21:19:50 +00:00
|
|
|
callMode: call.callMode,
|
2020-12-02 18:14:03 +00:00
|
|
|
connectionState: call.connectionState,
|
2023-11-16 19:55:35 +00:00
|
|
|
conversationsByDemuxId,
|
2022-02-08 19:18:51 +00:00
|
|
|
deviceCount: peekInfo.deviceCount,
|
2021-08-17 21:45:18 +00:00
|
|
|
groupMembers,
|
2024-03-13 20:44:13 +00:00
|
|
|
isConversationTooBigToRing: getIsConversationTooBigToRing(conversation),
|
2020-12-02 18:14:03 +00:00
|
|
|
joinState: call.joinState,
|
2023-12-06 21:52:29 +00:00
|
|
|
localDemuxId,
|
2022-02-08 19:18:51 +00:00
|
|
|
maxDevices: peekInfo.maxDevices,
|
2020-12-02 18:14:03 +00:00
|
|
|
peekedParticipants,
|
2023-12-06 21:52:29 +00:00
|
|
|
raisedHands,
|
2020-12-02 18:14:03 +00:00
|
|
|
remoteParticipants,
|
2022-05-19 03:28:51 +00:00
|
|
|
remoteAudioLevels: call.remoteAudioLevels || new Map<number, number>(),
|
2023-09-20 14:00:01 +00:00
|
|
|
} satisfies ActiveGroupCallType;
|
2020-12-02 18:14:03 +00:00
|
|
|
}
|
|
|
|
default:
|
|
|
|
throw missingCaseError(call);
|
|
|
|
}
|
2020-06-04 18:16:19 +00:00
|
|
|
};
|
|
|
|
|
2024-02-22 21:19:50 +00:00
|
|
|
const mapStateToCallLinkProp = (state: StateType): CallLinkType | undefined => {
|
|
|
|
const { calling } = state;
|
|
|
|
const { activeCallState } = calling;
|
|
|
|
|
|
|
|
if (!activeCallState) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const call = getActiveCall(calling);
|
|
|
|
if (call?.callMode !== CallMode.Adhoc) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const callLinkSelector = getCallLinkSelector(state);
|
|
|
|
const callLink = callLinkSelector(activeCallState.conversationId);
|
|
|
|
if (!callLink) {
|
|
|
|
log.error(
|
|
|
|
'Active call referred to a call link but no corresponding call link in state.'
|
|
|
|
);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
return callLink;
|
|
|
|
};
|
|
|
|
|
2024-01-04 22:16:33 +00:00
|
|
|
const mapStateToIncomingCallProp = (
|
|
|
|
state: StateType
|
|
|
|
): DirectIncomingCall | GroupIncomingCall | null => {
|
2020-12-02 18:11:54 +00:00
|
|
|
const call = getIncomingCall(state);
|
2020-11-06 17:36:37 +00:00
|
|
|
if (!call) {
|
2024-01-04 22:16:33 +00:00
|
|
|
return null;
|
2020-11-06 17:36:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const conversation = getConversationSelector(state)(call.conversationId);
|
|
|
|
if (!conversation) {
|
2021-09-17 18:27:53 +00:00
|
|
|
log.error('The incoming call has no corresponding conversation');
|
2024-01-04 22:16:33 +00:00
|
|
|
return null;
|
2020-11-06 17:36:37 +00:00
|
|
|
}
|
|
|
|
|
2021-08-20 16:06:15 +00:00
|
|
|
switch (call.callMode) {
|
|
|
|
case CallMode.Direct:
|
|
|
|
return {
|
|
|
|
callMode: CallMode.Direct as const,
|
2024-01-04 22:16:33 +00:00
|
|
|
callState: call.callState,
|
|
|
|
callEndedReason: call.callEndedReason,
|
2021-08-20 16:06:15 +00:00
|
|
|
conversation,
|
|
|
|
isVideoCall: call.isVideoCall,
|
|
|
|
};
|
|
|
|
case CallMode.Group: {
|
2023-08-10 16:43:33 +00:00
|
|
|
if (!call.ringerAci) {
|
2021-09-17 18:27:53 +00:00
|
|
|
log.error('The incoming group call has no ring state');
|
2024-01-04 22:16:33 +00:00
|
|
|
return null;
|
2021-08-20 16:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const conversationSelector = getConversationSelector(state);
|
2023-08-10 16:43:33 +00:00
|
|
|
const ringer = conversationSelector(call.ringerAci);
|
2021-08-20 16:06:15 +00:00
|
|
|
const otherMembersRung = (conversation.sortedGroupMembers ?? []).filter(
|
|
|
|
c => c.id !== ringer.id && !c.isMe
|
|
|
|
);
|
|
|
|
|
|
|
|
return {
|
|
|
|
callMode: CallMode.Group as const,
|
2024-01-04 22:16:33 +00:00
|
|
|
connectionState: call.connectionState,
|
|
|
|
joinState: call.joinState,
|
2021-08-20 16:06:15 +00:00
|
|
|
conversation,
|
|
|
|
otherMembersRung,
|
|
|
|
ringer,
|
2024-01-04 22:16:33 +00:00
|
|
|
remoteParticipants: call.remoteParticipants,
|
2021-08-20 16:06:15 +00:00
|
|
|
};
|
|
|
|
}
|
2024-02-22 21:19:50 +00:00
|
|
|
case CallMode.Adhoc:
|
|
|
|
log.error('Cannot handle an incoming adhoc call');
|
|
|
|
return null;
|
2021-08-20 16:06:15 +00:00
|
|
|
default:
|
|
|
|
throw missingCaseError(call);
|
|
|
|
}
|
2020-11-06 17:36:37 +00:00
|
|
|
};
|
|
|
|
|
2024-03-13 20:44:13 +00:00
|
|
|
export const SmartCallManager = memo(function SmartCallManager() {
|
|
|
|
const i18n = useSelector(getIntl);
|
|
|
|
const activeCall = useSelector(mapStateToActiveCallProp);
|
|
|
|
const callLink = useSelector(mapStateToCallLinkProp);
|
|
|
|
const incomingCall = useSelector(mapStateToIncomingCallProp);
|
|
|
|
const availableCameras = useSelector(getAvailableCameras);
|
|
|
|
const hasInitialLoadCompleted = useSelector(getHasInitialLoadCompleted);
|
|
|
|
const me = useSelector(getMe);
|
|
|
|
const isConversationTooBigToRing = incomingCall
|
|
|
|
? getIsConversationTooBigToRing(incomingCall.conversation)
|
|
|
|
: false;
|
|
|
|
|
|
|
|
const {
|
|
|
|
changeCallView,
|
|
|
|
closeNeedPermissionScreen,
|
|
|
|
getPresentingSources,
|
|
|
|
cancelCall,
|
|
|
|
startCall,
|
|
|
|
toggleParticipants,
|
|
|
|
acceptCall,
|
|
|
|
declineCall,
|
|
|
|
openSystemPreferencesAction,
|
|
|
|
sendGroupCallRaiseHand,
|
|
|
|
sendGroupCallReaction,
|
|
|
|
setGroupCallVideoRequest,
|
|
|
|
setIsCallActive,
|
|
|
|
setLocalAudio,
|
|
|
|
setLocalVideo,
|
|
|
|
setLocalPreview,
|
|
|
|
setOutgoingRing,
|
|
|
|
setPresenting,
|
|
|
|
setRendererCanvas,
|
|
|
|
switchToPresentationView,
|
|
|
|
switchFromPresentationView,
|
|
|
|
hangUpActiveCall,
|
|
|
|
togglePip,
|
|
|
|
toggleScreenRecordingPermissionsDialog,
|
|
|
|
toggleSettings,
|
|
|
|
} = useCallingActions();
|
|
|
|
const { showToast } = useToastActions();
|
|
|
|
const { pauseVoiceNotePlayer } = useAudioPlayerActions();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<CallManager
|
|
|
|
acceptCall={acceptCall}
|
|
|
|
activeCall={activeCall}
|
|
|
|
availableCameras={availableCameras}
|
|
|
|
bounceAppIconStart={bounceAppIconStart}
|
|
|
|
bounceAppIconStop={bounceAppIconStop}
|
|
|
|
callLink={callLink}
|
|
|
|
cancelCall={cancelCall}
|
|
|
|
changeCallView={changeCallView}
|
|
|
|
closeNeedPermissionScreen={closeNeedPermissionScreen}
|
|
|
|
declineCall={declineCall}
|
|
|
|
getGroupCallVideoFrameSource={getGroupCallVideoFrameSource}
|
|
|
|
getPresentingSources={getPresentingSources}
|
|
|
|
hangUpActiveCall={hangUpActiveCall}
|
|
|
|
hasInitialLoadCompleted={hasInitialLoadCompleted}
|
|
|
|
i18n={i18n}
|
|
|
|
incomingCall={incomingCall}
|
|
|
|
isConversationTooBigToRing={isConversationTooBigToRing}
|
|
|
|
isGroupCallRaiseHandEnabled={isGroupCallRaiseHandEnabled()}
|
|
|
|
isGroupCallReactionsEnabled={isGroupCallReactionsEnabled()}
|
|
|
|
me={me}
|
|
|
|
notifyForCall={notifyForCall}
|
|
|
|
openSystemPreferencesAction={openSystemPreferencesAction}
|
|
|
|
pauseVoiceNotePlayer={pauseVoiceNotePlayer}
|
|
|
|
playRingtone={playRingtone}
|
|
|
|
renderDeviceSelection={renderDeviceSelection}
|
|
|
|
renderEmojiPicker={renderEmojiPicker}
|
|
|
|
renderReactionPicker={renderReactionPicker}
|
|
|
|
sendGroupCallRaiseHand={sendGroupCallRaiseHand}
|
|
|
|
sendGroupCallReaction={sendGroupCallReaction}
|
|
|
|
setGroupCallVideoRequest={setGroupCallVideoRequest}
|
|
|
|
setIsCallActive={setIsCallActive}
|
|
|
|
setLocalAudio={setLocalAudio}
|
|
|
|
setLocalPreview={setLocalPreview}
|
|
|
|
setLocalVideo={setLocalVideo}
|
|
|
|
setOutgoingRing={setOutgoingRing}
|
|
|
|
setPresenting={setPresenting}
|
|
|
|
setRendererCanvas={setRendererCanvas}
|
|
|
|
showToast={showToast}
|
|
|
|
startCall={startCall}
|
|
|
|
stopRingtone={stopRingtone}
|
|
|
|
switchFromPresentationView={switchFromPresentationView}
|
|
|
|
switchToPresentationView={switchToPresentationView}
|
|
|
|
toggleParticipants={toggleParticipants}
|
|
|
|
togglePip={togglePip}
|
|
|
|
toggleScreenRecordingPermissionsDialog={
|
|
|
|
toggleScreenRecordingPermissionsDialog
|
|
|
|
}
|
|
|
|
toggleSettings={toggleSettings}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
});
|