-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
Calling.ts
130 lines (116 loc) · 3.56 KB
/
Calling.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// Copyright 2020 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { ColorType } from './Colors';
export enum CallMode {
None = 'None',
Direct = 'Direct',
Group = 'Group',
}
// Ideally, we would import many of these directly from RingRTC. But because Storybook
// cannot import RingRTC (as it runs in the browser), we have these copies. That also
// means we have to convert the "real" enum to our enum in some cases.
// Must be kept in sync with RingRTC.CallState
export enum CallState {
Prering = 'init',
Ringing = 'ringing',
Accepted = 'connected',
Reconnecting = 'connecting',
Ended = 'ended',
}
// Must be kept in sync with RingRTC.CallEndedReason
export enum CallEndedReason {
LocalHangup = 'LocalHangup',
RemoteHangup = 'RemoteHangup',
RemoteHangupNeedPermission = 'RemoteHangupNeedPermission',
Declined = 'Declined',
Busy = 'Busy',
Glare = 'Glare',
ReceivedOfferExpired = 'ReceivedOfferExpired',
ReceivedOfferWhileActive = 'ReceivedOfferWhileActive',
ReceivedOfferWithGlare = 'ReceivedOfferWithGlare',
SignalingFailure = 'SignalingFailure',
ConnectionFailure = 'ConnectionFailure',
InternalFailure = 'InternalFailure',
Timeout = 'Timeout',
AcceptedOnAnotherDevice = 'AcceptedOnAnotherDevice',
DeclinedOnAnotherDevice = 'DeclinedOnAnotherDevice',
BusyOnAnotherDevice = 'BusyOnAnotherDevice',
CallerIsNotMultiring = 'CallerIsNotMultiring',
}
// Must be kept in sync with RingRTC's ConnectionState
export enum GroupCallConnectionState {
NotConnected = 0,
Connecting = 1,
Connected = 2,
Reconnecting = 3,
}
// Must be kept in sync with RingRTC's JoinState
export enum GroupCallJoinState {
NotJoined = 0,
Joining = 1,
Joined = 2,
}
// TODO: The way we deal with remote participants isn't ideal. See DESKTOP-949.
export interface GroupCallPeekedParticipantType {
avatarPath?: string;
color?: ColorType;
firstName?: string;
isSelf: boolean;
name?: string;
profileName?: string;
title: string;
}
export interface GroupCallRemoteParticipantType {
avatarPath?: string;
color?: ColorType;
demuxId: number;
firstName?: string;
hasRemoteAudio: boolean;
hasRemoteVideo: boolean;
isBlocked: boolean;
isSelf: boolean;
name?: string;
profileName?: string;
speakerTime?: number;
title: string;
videoAspectRatio: number;
}
// Should match RingRTC's VideoFrameSource
export interface VideoFrameSource {
receiveVideoFrame(buffer: ArrayBuffer): [number, number] | undefined;
}
// Must be kept in sync with RingRTC.AudioDevice
export interface AudioDevice {
// Device name.
name: string;
// Index of this device, starting from 0.
index: number;
// A unique and somewhat stable identifier of this device.
uniqueId: string;
// If present, the identifier of a localized string to substitute for the device name.
i18nKey?: string;
}
export enum CallingDeviceType {
CAMERA,
MICROPHONE,
SPEAKER,
}
export type MediaDeviceSettings = {
availableMicrophones: Array<AudioDevice>;
selectedMicrophone: AudioDevice | undefined;
availableSpeakers: Array<AudioDevice>;
selectedSpeaker: AudioDevice | undefined;
availableCameras: Array<MediaDeviceInfo>;
selectedCamera: string | undefined;
};
export type CallHistoryDetailsType = {
wasIncoming: boolean;
wasVideoCall: boolean;
wasDeclined: boolean;
acceptedTime?: number;
endedTime: number;
};
export type ChangeIODevicePayloadType =
| { type: CallingDeviceType.CAMERA; selectedDevice: string }
| { type: CallingDeviceType.MICROPHONE; selectedDevice: AudioDevice }
| { type: CallingDeviceType.SPEAKER; selectedDevice: AudioDevice };