-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathCallClientState.ts
More file actions
815 lines (783 loc) · 26.3 KB
/
CallClientState.ts
File metadata and controls
815 lines (783 loc) · 26.3 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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import {
AudioDeviceInfo,
CallDirection,
CallEndReason,
CallerInfo,
CallState as CallStatus,
DeviceAccess,
DominantSpeakersInfo,
LatestMediaDiagnostics,
LatestNetworkDiagnostics,
MediaStreamType,
RemoteParticipantState as RemoteParticipantStatus,
ScalingMode,
VideoDeviceInfo
} from '@azure/communication-calling';
/* @conditional-compile-remove(capabilities) */
import { CapabilitiesChangeInfo, ParticipantCapabilities } from '@azure/communication-calling';
/* @conditional-compile-remove(close-captions) */
import { CaptionsResultType } from '@azure/communication-calling';
/* @conditional-compile-remove(video-background-effects) */
import { VideoEffectName } from '@azure/communication-calling';
/* @conditional-compile-remove(teams-identity-support) */
import { CallKind } from '@azure/communication-calling';
/* @conditional-compile-remove(unsupported-browser) */
import { EnvironmentInfo } from '@azure/communication-calling';
/* @conditional-compile-remove(rooms) */
import { ParticipantRole } from '@azure/communication-calling';
import {
CommunicationUserKind,
MicrosoftTeamsUserKind,
PhoneNumberKind,
UnknownIdentifierKind,
CommunicationIdentifierKind
} from '@azure/communication-common';
/* @conditional-compile-remove(communication-common-beta-v3) */
import { MicrosoftBotKind } from '@azure/communication-common';
/**
* State only version of {@link @azure/communication-calling#CallAgent} except calls is moved to be a child directly of
* {@link CallClientState} and not included here. The reason to have CallAgent's state proxied is to provide access to
* displayName. We don't flatten CallAgent.displayName and put it in CallClientState because it would be ambiguious that
* displayName is actually reliant on the creation/existence of CallAgent to be available.
*
* @public
*/
export interface CallAgentState {
/**
* Proxy of {@link @azure/communication-calling#CallAgent.displayName}.
*/
displayName?: string;
}
/* @conditional-compile-remove(close-captions) */
/**
* @beta
*/
export interface CaptionsInfo {
/**
* The state in which this caption data can be classified.
*/
resultType: CaptionsResultType;
/**
* The information of the call participant who spoke the captioned text.
*/
speaker: CallerInfo;
/**
* The language that the spoken words were interpretted as. Corresponds to the language specified in startCaptions / setSpokenLanguage.
*/
spokenLanguage: string;
/**
* The caption text.
*/
captionText: string;
/**
* Timestamp of when the captioned words were initially spoken.
*/
timestamp: Date;
/**
* The language that the captions are presented in. Corresponds to the captionLanguage specified in startCaptions / setCaptionLanguage.
*/
captionLanguage?: string;
/**
* The original spoken caption text prior to translating to subtitle language
*/
spokenText?: string;
}
/* @conditional-compile-remove(close-captions) */
/**
* @beta
*/
export interface CaptionsCallFeatureState {
/**
* supported spoken languages
*/
supportedSpokenLanguages: string[];
/**
* array of received captions
*/
captions: CaptionsInfo[];
/**
* whether captions is on/off
*/
isCaptionsFeatureActive: boolean;
/**
* whether start captions button is clicked or now
*/
startCaptionsInProgress: boolean;
/**
* supported caption languages
*/
supportedCaptionLanguages: string[];
/**
* current spoken language
*/
currentSpokenLanguage: string;
/**
* current caption language
*/
currentCaptionLanguage: string;
}
/**
* State only version of {@link @azure/communication-calling#TranscriptionCallFeature}. {@link StatefulCallClient} will
* automatically listen for transcription state of the call and update the state exposed by {@link StatefulCallClient}
* accordingly.
*
* @public
*/
export interface TranscriptionCallFeatureState {
/**
* Proxy of {@link @azure/communication-calling#TranscriptionCallFeature.isTranscriptionActive}.
*/
isTranscriptionActive: boolean;
}
/* @conditional-compile-remove(capabilities) */
/**
* State only version of {@link @azure/communication-calling#CapabilitiesFeature}
*
* @beta
*/
export interface CapabilitiesFeatureState {
/**
* Proxy of {@link @azure/communication-calling#CapabilitiesFeature.capabilities}.
*/
capabilities: ParticipantCapabilities;
/**
* Proxy of the latest {@link @azure/communication-calling#CapabilitiesChangeInfo}
*/
latestCapabilitiesChangeInfo: CapabilitiesChangeInfo;
}
/**
* State only version of {@link @azure/communication-calling#RecordingCallFeature}. {@link StatefulCallClient} will
* automatically listen for recording state of the call and update the state exposed by {@link StatefulCallClient} accordingly.
*
* @public
*/
export interface RecordingCallFeatureState {
/**
* Proxy of {@link @azure/communication-calling#RecordingCallFeature.isRecordingActive}.
*/
isRecordingActive: boolean;
}
/* @conditional-compile-remove(raise-hand) */
/**
* State only version of {@link @azure/communication-calling#RaiseHandCallFeature}. {@link StatefulCallClient} will
* automatically listen for raised hands on the call and update the state exposed by {@link StatefulCallClient} accordingly.
*
* @public
*/
export interface RaiseHandCallFeatureState {
/**
* Proxy of {@link @azure/communication-calling#RaiseHandCallFeature.raisedHands}.
*/
raisedHands: RaisedHandState[];
/**
* Contains information for local participant from list {@link @azure/communication-calling#RaiseHandCallFeature.raisedHands}.
*/
localParticipantRaisedHand?: RaisedHandState;
}
/* @conditional-compile-remove(raise-hand) */
/**
* Raised hand state with order
*
* @public
*/
export type RaisedHandState = {
raisedHandOrderPosition: number;
};
/**
* State only version of {@link @azure/communication-calling#LocalVideoStream}.
*
* @public
*/
export interface LocalVideoStreamState {
/**
* Proxy of {@link @azure/communication-calling#LocalVideoStream.source}.
*/
source: VideoDeviceInfo;
/**
* Proxy of {@link @azure/communication-calling#LocalVideoStream.mediaStreamType}.
*/
mediaStreamType: MediaStreamType;
/**
* {@link VideoStreamRendererView} that is managed by createView/disposeView in {@link StatefulCallClient}
* API. This can be undefined if the stream has not yet been rendered and defined after createView creates the view.
*/
view?: VideoStreamRendererViewState;
/* @conditional-compile-remove(video-background-effects) */
/**
* Stores the state of the video effects.
* @beta
*/
videoEffects?: LocalVideoStreamVideoEffectsState;
}
/* @conditional-compile-remove(video-background-effects) */
/**
* State only version of a LocalVideoStream's {@link @azure/communication-calling#VideoEffectsFeature}.
*
* @beta
*/
export interface LocalVideoStreamVideoEffectsState {
/**
* List of effects if any are active.
*/
activeEffects?: VideoEffectName[];
}
/* @conditional-compile-remove(optimal-video-count) */
/**
* State only version of Optimal Video Count Feature {@link @azure/communication-calling#OptimalVideoCountCallFeature}.
*
* @beta
*/
export interface OptimalVideoCountFeatureState {
/**
* State of the current optimal video count.
*/
maxRemoteVideoStreams: number;
}
/**
* State only version of {@link @azure/communication-calling#RemoteVideoStream}.
*
* @public
*/
export interface RemoteVideoStreamState {
/**
* Proxy of {@link @azure/communication-calling#RemoteVideoStream.id}.
*/
id: number;
/**
* Proxy of {@link @azure/communication-calling#RemoteVideoStream.mediaStreamType}.
*/
mediaStreamType: MediaStreamType;
/**
* Proxy of {@link @azure/communication-calling#RemoteVideoStream.isAvailable}.
*/
isAvailable: boolean;
/**
* Proxy of {@link @azure/communication-calling#RemoteVideoStream.isReceiving}.
* @beta
*/
/* @conditional-compile-remove(video-stream-is-receiving-flag) */
isReceiving: boolean;
/**
* {@link VideoStreamRendererView} that is managed by createView/disposeView in {@link StatefulCallClient}
* API. This can be undefined if the stream has not yet been rendered and defined after createView creates the view.
*/
view?: VideoStreamRendererViewState;
/* @conditional-compile-remove(pinned-participants) */
/**
* Proxy of {@link @azure/communication-calling#RemoteVideoStream.size}.
*/
streamSize?: { width: number; height: number };
}
/**
* State only version of {@link @azure/communication-calling#VideoStreamRendererView}. This property is added to the state exposed
* by {@link StatefulCallClient} by {@link StatefulCallClient.createView} and removed by {@link StatefulCallClient.disposeView}.
*
* @public
*/
export interface VideoStreamRendererViewState {
/**
* Proxy of {@link @azure/communication-calling#VideoStreamRendererView.scalingMode}.
*/
scalingMode: ScalingMode;
/**
* Proxy of {@link @azure/communication-calling#VideoStreamRendererView.isMirrored}.
*/
isMirrored: boolean;
/**
* Proxy of {@link @azure/communication-calling#VideoStreamRendererView.target}.
*/
target: HTMLElement;
}
/**
* State only version of {@link @azure/communication-calling#RemoteParticipant}. {@link StatefulCallClient} will
* automatically retrieve RemoteParticipants and add their state to the state exposed by {@link StatefulCallClient}.
*
* @public
*/
export interface RemoteParticipantState {
/**
* Proxy of {@link @azure/communication-calling#RemoteParticipant.identifier}.
*/
identifier:
| CommunicationUserKind
| PhoneNumberKind
| MicrosoftTeamsUserKind
| UnknownIdentifierKind
| /* @conditional-compile-remove(communication-common-beta-v3) */ MicrosoftBotKind;
/**
* Proxy of {@link @azure/communication-calling#RemoteParticipant.displayName}.
*/
displayName?: string;
/**
* Proxy of {@link @azure/communication-calling#RemoteParticipant.state}.
*/
state: RemoteParticipantStatus;
/**
* Proxy of {@link @azure/communication-calling#RemoteParticipant.callEndReason}.
*/
callEndReason?: CallEndReason;
/**
* Proxy of {@link @azure/communication-calling#RemoteParticipant.videoStreams} as an object with
* {@link RemoteVideoStream} fields keyed by {@link @azure/communication-calling#RemoteVideoStream.id}.
*/
videoStreams: { [key: number]: RemoteVideoStreamState };
/**
* Proxy of {@link @azure/communication-calling#RemoteParticipant.isMuted}.
*/
isMuted: boolean;
/**
* Proxy of {@link @azure/communication-calling#RemoteParticipant.isSpeaking}.
*/
isSpeaking: boolean;
/* @conditional-compile-remove(rooms) */
/**
* Proxy of {@link @azure/communication-calling#RemoteParticipant.role}.
*/
role?: ParticipantRole;
/* @conditional-compile-remove(raise-hand) */
/**
* Proxy of {@link @azure/communication-calling#Call.RaisedHand.raisedHands}.
*/
raisedHand?: RaisedHandState;
}
/**
* State only version of {@link @azure/communication-calling#Call}. {@link StatefulCallClient} will automatically
* retrieve Call's state and add it to the state exposed by {@link StatefulCallClient}.
*
* @public
*/
export interface CallState {
/**
* Proxy of {@link @azure/communication-calling#Call.id}.
*/
id: string;
/* @conditional-compile-remove(teams-identity-support) */
/**
* Type of the call.
*/
kind: CallKind;
/**
* Proxy of {@link @azure/communication-calling#Call.callerInfo}.
*/
callerInfo: CallerInfo;
/**
* Proxy of {@link @azure/communication-calling#Call.state}.
*/
state: CallStatus;
/**
* Proxy of {@link @azure/communication-calling#Call.callEndReason}.
*/
callEndReason?: CallEndReason;
/**
* Proxy of {@link @azure/communication-calling#Call.direction}.
*/
direction: CallDirection;
/**
* Proxy of {@link @azure/communication-calling#Call.isMuted}.
*/
isMuted: boolean;
/**
* Proxy of {@link @azure/communication-calling#Call.isScreenSharingOn}.
*/
isScreenSharingOn: boolean;
/**
* Proxy of {@link @azure/communication-calling#DominantSpeakersInfo }.
*/
dominantSpeakers?: DominantSpeakersInfo;
/**
* Proxy of {@link @azure/communication-calling#Call.localVideoStreams}.
*/
localVideoStreams: LocalVideoStreamState[];
/**
* Proxy of {@link @azure/communication-calling#Call.remoteParticipants}.
* Object with {@link RemoteParticipant} fields keyed by flattened {@link RemoteParticipantState.identifier}.
* To obtain a flattened {@link RemoteParticipantState.identifier}, use
* {@link @azure/communication-react#toFlatCommunicationIdentifier}.
*/
remoteParticipants: { [keys: string]: RemoteParticipantState };
/**
* Stores remote participants that have left the call so that the callEndReason could be retrieved.
* Object with {@link RemoteParticipant} fields keyed by flattened {@link RemoteParticipantState.identifier}.
* To obtain a flattened {@link RemoteParticipantState.identifier}, use
* {@link @azure/communication-react#toFlatCommunicationIdentifier}.
*/
remoteParticipantsEnded: { [keys: string]: RemoteParticipantState };
/**
* Proxy of {@link @azure/communication-calling#TranscriptionCallFeature}.
*/
transcription: TranscriptionCallFeatureState;
/* @conditional-compile-remove(close-captions) */
/**
* Proxy of {@link @azure/communication-calling#TranscriptionCallFeature}.
*/
captionsFeature: CaptionsCallFeatureState;
/* @conditional-compile-remove(optimal-video-count) */
/**
* Proxy of {@link @azure/communication-calling#OptimalVideoCountCallFeature}.
*/
optimalVideoCount: OptimalVideoCountFeatureState;
/**
* Proxy of {@link @azure/communication-calling#RecordingCallFeature}.
*/
recording: RecordingCallFeatureState;
/* @conditional-compile-remove(raise-hand) */
/**
* Proxy of {@link @azure/communication-calling#RaiseHandCallFeature}.
*/
raiseHand: RaiseHandCallFeatureState;
/**
* Stores the currently active screenshare participant's key. If there is no screenshare active, then this will be
* undefined. You can use this key to access the remoteParticipant data in {@link CallState.remoteParticipants} object.
*
* Note this only applies to ScreenShare in RemoteParticipant. A local ScreenShare being active will not affect this
* property.
*
* This property is added by the stateful layer and is not a proxy of SDK state
*/
screenShareRemoteParticipant?: string;
/**
* Stores the local date when the call started on the client. This property is added by the stateful layer and is not
* a proxy of SDK state.
*/
startTime: Date;
/**
* Stores the local date when the call ended on the client. This property is added by the stateful layer and is not
* a proxy of SDK state.
*/
endTime: Date | undefined;
/**
* Stores the latest call diagnostics.
*/
diagnostics: DiagnosticsCallFeatureState;
/* @conditional-compile-remove(rooms) */
/**
* Proxy of {@link @azure/communication-calling#Call.role}.
*/
role?: ParticipantRole;
/* @conditional-compile-remove(total-participant-count) */
/**
* Proxy of {@link @azure/communication-calling#Call.totalParticipantCount}.
*/
totalParticipantCount?: number;
/* @conditional-compile-remove(call-transfer) */
/**
* Transfer state of call
*/
transfer: TransferFeatureState;
/* @conditional-compile-remove(capabilities) */
/**
* Proxy of {@link @azure/communication-calling#CapabilitiesFeature}.
*/
capabilitiesFeature?: CapabilitiesFeatureState;
}
/* @conditional-compile-remove(call-transfer) */
/**
* Transfer feature state
*
* @beta
*/
export interface TransferFeatureState {
/**
* Accepted transfer requests
*/
acceptedTransfers: { [key: string]: AcceptedTransfer };
}
/* @conditional-compile-remove(call-transfer) */
/**
* Transfer feature state
*
* @beta
*/
export interface AcceptedTransfer {
/**
* Stores call id of accepted transfer
*/
callId: string;
/**
* Stores timestamp when transfer was accepted
*/
timestamp: Date;
}
/**
* State only version of {@link @azure/communication-calling#IncomingCall}. {@link StatefulCallClient} will
* automatically detect incoming calls and add their state to the state exposed by {@link StatefulCallClient}.
*
* @public
*/
export interface IncomingCallState {
/**
* Proxy of {@link @azure/communication-calling#IncomingCall.id}.
*/
id: string;
/**
* Proxy of {@link @azure/communication-calling#IncomingCall.callerInfo}.
*/
callerInfo: CallerInfo;
/**
* Set to the state returned by 'callEnded' event on {@link @azure/communication-calling#IncomingCall} when received.
* This property is added by the stateful layer and is not a proxy of SDK state.
*/
callEndReason?: CallEndReason;
/**
* Stores the local date when the call started on the client. This property is added by the stateful layer and is not
* a proxy of SDK state.
*/
startTime: Date;
/**
* Stores the local date when the call ended on the client. This property is added by the stateful layer and is not a
* proxy of SDK state. It is undefined if the call is not ended yet.
*/
endTime?: Date;
}
/**
* This type is meant to encapsulate all the state inside {@link @azure/communication-calling#DeviceManager}. For
* optional parameters they may not be available until permission is granted by the user. The cameras, microphones,
* speakers, and deviceAccess states will be empty until the corresponding
* {@link @azure/communication-calling#DeviceManager}'s getCameras, getMicrophones, getSpeakers, and askDevicePermission
* APIs are called and completed.
*
* @public
*/
export type DeviceManagerState = {
/**
* Proxy of {@link @azure/communication-calling#DeviceManager.isSpeakerSelectionAvailable}.
*/
isSpeakerSelectionAvailable: boolean;
/**
* Proxy of {@link @azure/communication-calling#DeviceManager.selectedMicrophone}.
*/
selectedMicrophone?: AudioDeviceInfo;
/**
* Proxy of {@link @azure/communication-calling#DeviceManager.selectedSpeaker}.
*/
selectedSpeaker?: AudioDeviceInfo;
/**
* Stores the selected camera device info. This is added by the stateful layer and does not exist in the Calling SDK.
* It is meant as a convenience to the developer. It must be explicitly set before it has any value and does not
* persist across instances of the {@link StatefulCallClient}. The developer controls entirely what this value holds
* at any time.
*/
selectedCamera?: VideoDeviceInfo;
/**
* Stores any cameras data returned from {@link @azure/communication-calling#DeviceManager.getCameras}.
*/
cameras: VideoDeviceInfo[];
/**
* Stores any microphones data returned from {@link @azure/communication-calling#DeviceManager.getMicrophones}.
*/
microphones: AudioDeviceInfo[];
/**
* Stores any speakers data returned from {@link @azure/communication-calling#DeviceManager.getSpeakers}.
*/
speakers: AudioDeviceInfo[];
/**
* Stores deviceAccess data returned from {@link @azure/communication-calling#DeviceManager.askDevicePermission}.
*/
deviceAccess?: DeviceAccess;
/**
* Stores created views that are not associated with any CallState (when {@link StatefulCallClient.createView} is
* called with undefined callId, undefined participantId, and defined LocalVideoStream).
*
* The values in this array are generated internally when {@link StatefulCallClient.createView} is called and are
* considered immutable.
*/
unparentedViews: LocalVideoStreamState[];
};
/**
* Container for all of the state data proxied by {@link StatefulCallClient}. The calls, callsEnded, incomingCalls, and
* incomingCallsEnded states will be automatically provided if a callAgent has been created. The deviceManager will be
* empty initially until populated see {@link DeviceManagerState}. The userId state is provided as a convenience for the
* developer and is completely controled and set by the developer.
*
* @public
*/
export interface CallClientState {
/**
* Proxy of {@link @azure/communication-calling#CallAgent.calls} as an object with CallState {@link CallState} fields.
* It is keyed by {@link @azure/communication-calling#Call.id}. Please note that
* {@link @azure/communication-calling#Call.id} could change. You should not cache the id itself but the entire
* {@link @azure/communication-calling#Call} and then use the id contained to look up data in this map.
*/
calls: { [key: string]: CallState };
/**
* Calls that have ended are stored here so the callEndReason could be checked.
* It is an object with {@link @azure/communication-calling#Call.id} keys and {@link CallState} values.
*
* Only {@link MAX_CALL_HISTORY_LENGTH} Calls are kept in the history. Oldest calls are evicted if required.
*/
callsEnded: { [key: string]: CallState };
/**
* Proxy of {@link @azure/communication-calling#IncomingCall} as an object with {@link IncomingCall} fields.
* It is keyed by {@link @azure/communication-calling#IncomingCall.id}.
*/
incomingCalls: { [key: string]: IncomingCallState };
/**
* Incoming Calls that have ended are stored here so the callEndReason could be checked.
* It is an as an object with {@link @azure/communication-calling#Call.id} keys and {@link IncomingCall} values.
*
* Only {@link MAX_CALL_HISTORY_LENGTH} Calls are kept in the history. Oldest calls are evicted if required.
*/
incomingCallsEnded: { [key: string]: IncomingCallState };
/**
* Proxy of {@link @azure/communication-calling#DeviceManager}. Please review {@link DeviceManagerState}.
*/
deviceManager: DeviceManagerState;
/**
* Proxy of {@link @azure/communication-calling#CallAgent}. Please review {@link CallAgentState}.
*/
callAgent?: CallAgentState;
/**
* Stores a userId. This is not used by the {@link StatefulCallClient} and is provided here as a convenience for the
* developer for easier access to userId. Must be passed in at initialization of the {@link StatefulCallClient}.
* Completely controlled by the developer.
*/
userId: CommunicationIdentifierKind;
/**
* Stores the latest error for each API method.
*
* See documentation of {@Link CallErrors} for details.
*/
latestErrors: CallErrors;
/* @conditional-compile-remove(PSTN-calls) */
/**
* A phone number in E.164 format that will be used to represent callers identity.
* For example, using the alternateCallerId to add a participant using PSTN, this number will
* be used as the caller id in the PSTN call.
*/
alternateCallerId?: string;
/* @conditional-compile-remove(unsupported-browser) */
/**
* state to track the environment that the stateful client was made in is supported
*/
environmentInfo?: EnvironmentInfo;
}
/**
* Errors teed from API calls to the Calling SDK.
*
* Each property in the object stores the latest error for a particular SDK API method.
*
* Errors from this object can be cleared using the {@link newClearCallErrorsModifier}.
* Additionally, errors are automatically cleared when:
* - The state is cleared.
* - Subsequent calls to related API methods succeed.
* See documentation of individual stateful client methods for details on when errors may be automatically cleared.
*
* @public
*/
export type CallErrors = {
[target in CallErrorTarget]: CallError;
};
/**
* Error thrown from failed stateful API methods.
*
* @public
*/
export class CallError extends Error {
/**
* The API method target that failed.
*/
public target: CallErrorTarget;
/**
* Error thrown by the failed SDK method.
*/
public innerError: Error;
/**
* Timestamp added to the error by the stateful layer.
*/
public timestamp: Date;
constructor(target: CallErrorTarget, innerError: Error, timestamp?: Date) {
super();
this.target = target;
this.innerError = innerError;
// Testing note: It is easier to mock Date::now() than the Date() constructor.
this.timestamp = timestamp ?? new Date(Date.now());
this.name = 'CallError';
this.message = `${this.target}: ${this.innerError.message}`;
}
}
/**
* String literal type for all permissible keys in {@Link CallErrors}.
*
* @public
*/
export type CallErrorTarget =
| 'Call.addParticipant'
| 'Call.dispose'
| 'Call.feature'
| 'Call.hangUp'
| 'Call.hold'
| 'Call.mute'
| 'Call.muteIncomingAudio'
| 'Call.off'
| 'Call.on'
| 'Call.removeParticipant'
| 'Call.resume'
| 'Call.sendDtmf'
| 'Call.startAudio'
| 'Call.startScreenSharing'
| 'Call.startVideo'
| 'Call.stopScreenSharing'
| 'Call.stopAudio'
| 'Call.stopVideo'
| 'Call.unmute'
| 'Call.unmuteIncomingAudio'
| 'CallAgent.dispose'
| 'CallAgent.feature'
| 'CallAgent.join'
| 'CallAgent.off'
| 'CallAgent.on'
| 'CallAgent.startCall'
| 'CallClient.createCallAgent'
| 'CallClient.createTeamsCallAgent'
| 'CallClient.feature'
| 'CallClient.getDeviceManager'
| /* @conditional-compile-remove(calling-beta-sdk) */ 'CallClient.getEnvironmentInfo'
| 'DeviceManager.askDevicePermission'
| 'DeviceManager.getCameras'
| 'DeviceManager.getMicrophones'
| 'DeviceManager.getSpeakers'
| 'DeviceManager.off'
| 'DeviceManager.on'
| 'DeviceManager.selectMicrophone'
| 'DeviceManager.selectSpeaker'
| 'IncomingCall.accept'
| 'IncomingCall.reject'
| /* @conditional-compile-remove(calling-beta-sdk) */ /* @conditional-compile-remove(teams-identity-support) */ 'TeamsCall.addParticipant'
| /* @conditional-compile-remove(video-background-effects) */ 'VideoEffectsFeature.startEffects'
| /* @conditional-compile-remove(calling-beta-sdk) */ 'CallAgent.handlePushNotification'
| /* @conditional-compile-remove(calling-beta-sdk) */ 'Call.admit'
| /* @conditional-compile-remove(calling-beta-sdk) */ 'Call.rejectParticipant'
| /* @conditional-compile-remove(calling-beta-sdk) */ 'Call.admitAll';
/**
* State only proxy for {@link @azure/communication-calling#DiagnosticsCallFeature}.
*
* @public
*/
export interface DiagnosticsCallFeatureState {
/**
* Stores diagnostics related to network conditions.
*/
network: NetworkDiagnosticsState;
/**
* Stores diagnostics related to media quality.
*/
media: MediaDiagnosticsState;
}
/**
* State only proxy for {@link @azure/communication-calling#NetworkDiagnostics}.
*
* @public
*/
export interface NetworkDiagnosticsState {
latest: LatestNetworkDiagnostics;
}
/**
* State only proxy for {@link @azure/communication-calling#MediaDiagnostics}.
*
* @public
*/
export interface MediaDiagnosticsState {
latest: LatestMediaDiagnostics;
}