-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathbaseSelectors.ts
More file actions
232 lines (205 loc) · 6.74 KB
/
baseSelectors.ts
File metadata and controls
232 lines (205 loc) · 6.74 KB
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import { DominantSpeakersInfo } from '@azure/communication-calling';
/* @conditional-compile-remove(capabilities) */
import { ParticipantCapabilities } from '@azure/communication-calling';
/* @conditional-compile-remove(unsupported-browser) */
import { EnvironmentInfo } from '@azure/communication-calling';
import { ParticipantRole } from '@azure/communication-calling';
import { toFlatCommunicationIdentifier } from '@internal/acs-ui-common';
import {
CallClientState,
DeviceManagerState,
RemoteParticipantState,
LocalVideoStreamState,
CallErrors,
DiagnosticsCallFeatureState
} from '@internal/calling-stateful-client';
/* @conditional-compile-remove(close-captions) */
import { CaptionsInfo } from '@internal/calling-stateful-client';
/* @conditional-compile-remove(raise-hand) */
import { RaisedHandState } from '@internal/calling-stateful-client';
/**
* Common props used to reference calling declarative client state.
*
* @public
*/
export type CallingBaseSelectorProps = {
callId: string;
};
/**
* @private
*/
export const getDeviceManager = (state: CallClientState): DeviceManagerState => state.deviceManager;
/**
* @private
*/
export const getRole = (state: CallClientState, props: CallingBaseSelectorProps): ParticipantRole | undefined => {
/* @conditional-compile-remove(rooms) */
return state.calls[props.callId]?.role;
return 'Unknown';
};
/* @conditional-compile-remove(capabilities) */
/**
* @private
*/
export const getCapabilites = (
state: CallClientState,
props: CallingBaseSelectorProps
): ParticipantCapabilities | undefined => state.calls[props.callId]?.capabilitiesFeature?.capabilities;
/**
* @private
*/
export const getCallExists = (state: CallClientState, props: CallingBaseSelectorProps): boolean =>
!!state.calls[props.callId];
/**
* @private
*/
export const getDominantSpeakers = (
state: CallClientState,
props: CallingBaseSelectorProps
): undefined | DominantSpeakersInfo => state.calls[props.callId]?.dominantSpeakers;
/**
* @private
*/
export const getRemoteParticipants = (
state: CallClientState,
props: CallingBaseSelectorProps
):
| {
[keys: string]: RemoteParticipantState;
}
| undefined => {
return state.calls[props.callId]?.remoteParticipants;
};
/* @conditional-compile-remove(raise-hand) */
/**
* @private
*/
export const getLocalParticipantRaisedHand = (
state: CallClientState,
props: CallingBaseSelectorProps
): RaisedHandState | undefined => {
return state.calls[props.callId]?.raiseHand?.localParticipantRaisedHand;
};
/**
* @private
*/
export const getIsScreenSharingOn = (state: CallClientState, props: CallingBaseSelectorProps): boolean | undefined =>
state.calls[props.callId]?.isScreenSharingOn;
/**
* @private
*/
export const getIsMuted = (state: CallClientState, props: CallingBaseSelectorProps): boolean | undefined =>
state.calls[props.callId]?.isMuted;
/* @conditional-compile-remove(optimal-video-count) */
/**
* @private
*/
export const getOptimalVideoCount = (state: CallClientState, props: CallingBaseSelectorProps): number | undefined =>
state.calls[props.callId]?.optimalVideoCount.maxRemoteVideoStreams;
/**
* @private
*/
export const getLocalVideoStreams = (
state: CallClientState,
props: CallingBaseSelectorProps
): LocalVideoStreamState[] | undefined => state.calls[props.callId]?.localVideoStreams;
/**
* @private
*/
export const getScreenShareRemoteParticipant = (
state: CallClientState,
props: CallingBaseSelectorProps
): string | undefined => state.calls[props.callId]?.screenShareRemoteParticipant;
/**
* @private
*/
export const getDisplayName = (state: CallClientState): string | undefined => state.callAgent?.displayName;
/**
* @private
*/
export const getIdentifier = (state: CallClientState): string => toFlatCommunicationIdentifier(state.userId);
/**
* @private
*/
export const getLatestErrors = (state: CallClientState): CallErrors => state.latestErrors;
/**
* @private
*/
export const getDiagnostics = (
state: CallClientState,
props: CallingBaseSelectorProps
): DiagnosticsCallFeatureState | undefined => state.calls[props.callId]?.diagnostics;
/* @conditional-compile-remove(PSTN-calls) */
/**
* @private
*/
export const getCallState = (state: CallClientState, props: CallingBaseSelectorProps): string =>
state.calls[props.callId]?.state;
/**
* @private
*/
export const getEnvironmentInfo = (
state: CallClientState
): undefined | /* @conditional-compile-remove(unsupported-browser) */ EnvironmentInfo => {
/* @conditional-compile-remove(unsupported-browser) */
return state.environmentInfo;
return undefined;
};
/** @private */
export const getParticipantCount = (state: CallClientState, props: CallingBaseSelectorProps): number | undefined => {
/* @conditional-compile-remove(total-participant-count) */
return state.calls[props.callId]?.totalParticipantCount;
return undefined;
};
/* @conditional-compile-remove(close-captions) */
/** @private */
export const getCaptions = (state: CallClientState, props: CallingBaseSelectorProps): CaptionsInfo[] | undefined => {
return state.calls[props.callId]?.captionsFeature.captions;
};
/* @conditional-compile-remove(close-captions) */
/** @private */
export const getCaptionsStatus = (state: CallClientState, props: CallingBaseSelectorProps): boolean | undefined => {
return state.calls[props.callId]?.captionsFeature.isCaptionsFeatureActive;
};
/* @conditional-compile-remove(close-captions) */
/** @private */
export const getStartCaptionsInProgress = (
state: CallClientState,
props: CallingBaseSelectorProps
): boolean | undefined => {
return state.calls[props.callId]?.captionsFeature.startCaptionsInProgress;
};
/* @conditional-compile-remove(close-captions) */
/** @private */
export const getCurrentCaptionLanguage = (
state: CallClientState,
props: CallingBaseSelectorProps
): string | undefined => {
return state.calls[props.callId]?.captionsFeature.currentCaptionLanguage;
};
/* @conditional-compile-remove(close-captions) */
/** @private */
export const getCurrentSpokenLanguage = (
state: CallClientState,
props: CallingBaseSelectorProps
): string | undefined => {
return state.calls[props.callId]?.captionsFeature.currentSpokenLanguage;
};
/* @conditional-compile-remove(close-captions) */
/** @private */
export const getSupportedCaptionLanguages = (
state: CallClientState,
props: CallingBaseSelectorProps
): string[] | undefined => {
return state.calls[props.callId]?.captionsFeature.supportedCaptionLanguages;
};
/* @conditional-compile-remove(close-captions) */
/** @private */
export const getSupportedSpokenLanguages = (
state: CallClientState,
props: CallingBaseSelectorProps
): string[] | undefined => {
return state.calls[props.callId]?.captionsFeature.supportedSpokenLanguages;
};