communication-react-19
Version:
React library for building modern communication user experiences utilizing Azure Communication Services (React 19 compatible fork)
450 lines • 23.2 kB
TypeScript
import { StatefulCallClient, StatefulDeviceManager, TeamsCall } from "../../../../../calling-stateful-client/src";
import { _TelemetryImplementationHint } from "../../../../../acs-ui-common/src";
import { CallAgent, GroupCallLocator, TeamsMeetingLinkLocator, AudioDeviceInfo, VideoDeviceInfo, PermissionConstraints, PropertyChangedEvent, RoomCallLocator, StartCallOptions, Call } from '@azure/communication-calling';
import { TeamsMeetingIdLocator } from '@azure/communication-calling';
import { Reaction } from '@azure/communication-calling';
import type { DeviceAccess } from '@azure/communication-calling';
import { TeamsCallAgent } from '@azure/communication-calling';
import { AddPhoneNumberOptions } from '@azure/communication-calling';
import { DtmfTone } from '@azure/communication-calling';
import type { BreakoutRoomsUpdatedListener } from '@azure/communication-calling';
import { CommonCallAdapter, CallEndedListener, CallIdChangedListener, CallAdapterState, DisplayNameChangedListener, IsMutedChangedListener, IsLocalScreenSharingActiveChangedListener, IsSpeakingChangedListener, ParticipantsJoinedListener, ParticipantsLeftListener, DiagnosticChangedEventListner, CallAdapter, JoinCallOptions, StartCallIdentifier, StartCaptionsAdapterOptions, StopCaptionsAdapterOptions } from './CallAdapter';
import { ReactionResources } from "../../../../../react-components/src";
import { TransferAcceptedListener } from './CallAdapter';
import { CapabilitiesChangedListener } from './CallAdapter';
import { SpotlightChangedListener } from './CallAdapter';
import { CaptionsReceivedListener, IsCaptionsActiveChangedListener, IsCaptionLanguageChangedListener, IsSpokenLanguageChangedListener } from './CallAdapter';
import { RealTimeTextReceivedListener } from './CallAdapter';
import { VideoBackgroundImage, VideoBackgroundEffect } from './CallAdapter';
import { TeamsCallAdapter } from './CallAdapter';
import { CreateVideoStreamViewResult, VideoStreamOptions } from "../../../../../react-components/src";
import { CommunicationTokenCredential, CommunicationUserIdentifier, CommunicationIdentifier, MicrosoftTeamsUserIdentifier, MicrosoftTeamsAppIdentifier, UnknownIdentifier } from '@azure/communication-common';
import { PhoneNumberIdentifier } from '@azure/communication-common';
import { AdapterError } from '../../common/adapters';
import { OnFetchProfileCallback } from './OnFetchProfileCallback';
import { DeepNoiseSuppressionEffectDependency, VideoBackgroundEffectsDependency } from "../../../../../calling-component-bindings/src";
import { CallSurvey, CallSurveyResponse } from '@azure/communication-calling';
import { CallingSounds } from './CallAdapter';
import { TogetherModeStreamViewResult, TogetherModeStreamOptions } from "../../../../../react-components/src";
type CallTypeOf<AgentType extends CallAgent | TeamsCallAgent> = AgentType extends CallAgent ? Call : TeamsCall;
/**
* @private
*/
export type AdapterStateModifier = (state: CallAdapterState) => CallAdapterState;
/**
* @private
*/
export declare class AzureCommunicationCallAdapter<AgentType extends CallAgent | TeamsCallAgent = CallAgent> implements CommonCallAdapter {
private callClient;
private callAgent;
private deviceManager;
private locator?;
targetCallees?: StartCallIdentifier[];
private _call?;
private context;
private diagnosticsForwarder?;
private handlers;
private participantSubscribers;
private emitter;
private callingSoundSubscriber;
private onClientStateChange;
private originCall;
private onResolveVideoBackgroundEffectsDependency?;
private onResolveDeepNoiseSuppressionDependency?;
private get call();
private set call(value);
constructor(callClient: StatefulCallClient, locator: CallAdapterLocator, callAgent: AgentType, deviceManager: StatefulDeviceManager, options?: AzureCommunicationCallAdapterOptions | TeamsAdapterOptions);
constructor(callClient: StatefulCallClient, targetCallees: StartCallIdentifier[], callAgent: AgentType, deviceManager: StatefulDeviceManager, options?: AzureCommunicationCallAdapterOptions | TeamsAdapterOptions);
private subscribeDeviceManagerEvents;
private bindPublicMethods;
dispose(): void;
queryCameras(): Promise<VideoDeviceInfo[]>;
queryMicrophones(): Promise<AudioDeviceInfo[]>;
querySpeakers(): Promise<AudioDeviceInfo[]>;
askDevicePermission(constrain: PermissionConstraints): Promise<DeviceAccess>;
joinCall(options?: boolean | JoinCallOptions): CallTypeOf<AgentType> | undefined;
private _joinCall;
createStreamView(remoteUserId?: string, options?: VideoStreamOptions): Promise<void | CreateVideoStreamViewResult>;
disposeStreamView(remoteUserId?: string): Promise<void>;
disposeScreenShareStreamView(remoteUserId: string): Promise<void>;
disposeRemoteVideoStreamView(remoteUserId: string): Promise<void>;
disposeLocalVideoStreamView(): Promise<void>;
createTogetherModeStreamView(options?: TogetherModeStreamOptions): Promise<void | TogetherModeStreamViewResult>;
startTogetherMode(): Promise<void>;
setTogetherModeSceneSize(width: number, height: number): void;
disposeTogetherModeStreamView(): Promise<void>;
leaveCall(forEveryone?: boolean): Promise<void>;
setCamera(device: VideoDeviceInfo, options?: VideoStreamOptions): Promise<void>;
setMicrophone(device: AudioDeviceInfo): Promise<void>;
setSpeaker(device: AudioDeviceInfo): Promise<void>;
startCamera(options?: VideoStreamOptions): Promise<void>;
stopCamera(): Promise<void>;
mute(): Promise<void>;
unmute(): Promise<void>;
startScreenShare(): Promise<void>;
stopScreenShare(): Promise<void>;
raiseHand(): Promise<void>;
lowerHand(): Promise<void>;
onReactionClick(reaction: Reaction): Promise<void>;
allowUnsupportedBrowserVersion(): void;
startVideoBackgroundEffect(videoBackgroundEffect: VideoBackgroundEffect): Promise<void>;
stopVideoBackgroundEffects(): Promise<void>;
updateBackgroundPickerImages(backgroundImages: VideoBackgroundImage[]): void;
updateSelectedVideoBackgroundEffect(selectedVideoBackground: VideoBackgroundEffect): void;
startNoiseSuppressionEffect(): Promise<void>;
stopNoiseSuppressionEffect(): Promise<void>;
startCall(participants: string[] | (MicrosoftTeamsAppIdentifier | PhoneNumberIdentifier | CommunicationUserIdentifier | MicrosoftTeamsUserIdentifier | UnknownIdentifier)[] | /* @conditional-compile-remove(calling-beta-sdk) */ CommunicationIdentifier[], options?: StartCallOptions): CallTypeOf<AgentType> | undefined;
private processNewCall;
private isBlurEffect;
private isReplacementEffect;
removeParticipant(userId: string | CommunicationIdentifier): Promise<void>;
addParticipant(participant: PhoneNumberIdentifier, options?: AddPhoneNumberOptions): Promise<void>;
addParticipant(participant: CommunicationUserIdentifier): Promise<void>;
holdCall(): Promise<void>;
resumeCall(): Promise<void>;
sendDtmfTone(dtmfTone: DtmfTone): Promise<void>;
startCaptions(options?: StartCaptionsAdapterOptions): Promise<void>;
stopCaptions(options?: StopCaptionsAdapterOptions): Promise<void>;
setCaptionLanguage(language: string): Promise<void>;
setSpokenLanguage(language: string): Promise<void>;
sendRealTimeText(text: string, isFinalized: boolean): Promise<void>;
submitSurvey(survey: CallSurvey): Promise<CallSurveyResponse | undefined>;
muteParticipant(userId: string): Promise<void>;
muteAllRemoteParticipants(): Promise<void>;
startSpotlight(userIds?: string[]): Promise<void>;
stopSpotlight(userIds?: string[]): Promise<void>;
stopAllSpotlight(): Promise<void>;
forbidAudio(userIds: string[]): Promise<void>;
permitAudio(userIds: string[]): Promise<void>;
forbidOthersAudio(): Promise<void>;
permitOthersAudio(): Promise<void>;
forbidVideo(userIds: string[]): Promise<void>;
permitVideo(userIds: string[]): Promise<void>;
forbidOthersVideo(): Promise<void>;
permitOthersVideo(): Promise<void>;
returnFromBreakoutRoom(): Promise<void>;
getState(): CallAdapterState;
onStateChange(handler: (state: CallAdapterState) => void): void;
offStateChange(handler: (state: CallAdapterState) => void): void;
on(event: 'participantsJoined', listener: ParticipantsJoinedListener): void;
on(event: 'participantsLeft', listener: ParticipantsLeftListener): void;
on(event: 'isMutedChanged', listener: IsMutedChangedListener): void;
on(event: 'callIdChanged', listener: CallIdChangedListener): void;
on(event: 'isLocalScreenSharingActiveChanged', listener: IsLocalScreenSharingActiveChangedListener): void;
on(event: 'displayNameChanged', listener: DisplayNameChangedListener): void;
on(event: 'isSpeakingChanged', listener: IsSpeakingChangedListener): void;
on(event: 'callEnded', listener: CallEndedListener): void;
on(event: 'diagnosticChanged', listener: DiagnosticChangedEventListner): void;
on(event: 'selectedMicrophoneChanged', listener: PropertyChangedEvent): void;
on(event: 'selectedSpeakerChanged', listener: PropertyChangedEvent): void;
on(event: 'error', errorHandler: (e: AdapterError) => void): void;
on(event: 'captionsReceived', listener: CaptionsReceivedListener): void;
on(event: 'isCaptionsActiveChanged', listener: IsCaptionsActiveChangedListener): void;
on(event: 'isCaptionLanguageChanged', listener: IsCaptionLanguageChangedListener): void;
on(event: 'isSpokenLanguageChanged', listener: IsSpokenLanguageChangedListener): void;
on(event: 'realTimeTextReceived', listener: RealTimeTextReceivedListener): void;
on(event: 'transferAccepted', listener: TransferAcceptedListener): void;
on(event: 'capabilitiesChanged', listener: CapabilitiesChangedListener): void;
on(event: 'roleChanged', listener: PropertyChangedEvent): void;
on(event: 'spotlightChanged', listener: SpotlightChangedListener): void;
on(event: 'mutedByOthers', listener: PropertyChangedEvent): void;
on(event: 'breakoutRoomsUpdated', listener: BreakoutRoomsUpdatedListener): void;
private subscribeToCaptionEvents;
private unsubscribeFromCaptionEvents;
private subscribeCallEvents;
private unsubscribeCallEvents;
private isMyMutedChanged;
private captionsKindChanged;
private onRemoteParticipantsUpdated;
private isScreenSharingOnChanged;
private teamsCaptionsReceived;
private captionsReceived;
private realTimeTextReceived;
private isCaptionsActiveChanged;
private isSpokenLanguageChanged;
private isCaptionLanguageChanged;
private transferAccepted;
private capabilitiesChanged;
private roleChanged;
private spotlightChanged;
private breakoutRoomsUpdated;
private assignedBreakoutRoomUpdated;
private breakoutRoomJoined;
private hangupOtherBreakoutRoomCalls;
private callIdChanged;
private resetDiagnosticsForwarder;
off(event: 'participantsJoined', listener: ParticipantsJoinedListener): void;
off(event: 'participantsLeft', listener: ParticipantsLeftListener): void;
off(event: 'isMutedChanged', listener: IsMutedChangedListener): void;
off(event: 'callIdChanged', listener: CallIdChangedListener): void;
off(event: 'isLocalScreenSharingActiveChanged', listener: IsLocalScreenSharingActiveChangedListener): void;
off(event: 'displayNameChanged', listener: DisplayNameChangedListener): void;
off(event: 'isSpeakingChanged', listener: IsSpeakingChangedListener): void;
off(event: 'callEnded', listener: CallEndedListener): void;
off(event: 'diagnosticChanged', listener: DiagnosticChangedEventListner): void;
off(event: 'selectedMicrophoneChanged', listener: PropertyChangedEvent): void;
off(event: 'selectedSpeakerChanged', listener: PropertyChangedEvent): void;
off(event: 'error', errorHandler: (e: AdapterError) => void): void;
off(event: 'captionsReceived', listener: CaptionsReceivedListener): void;
off(event: 'isCaptionsActiveChanged', listener: IsCaptionsActiveChangedListener): void;
off(event: 'isCaptionLanguageChanged', listener: IsCaptionLanguageChangedListener): void;
off(event: 'isSpokenLanguageChanged', listener: IsSpokenLanguageChangedListener): void;
off(event: 'realTimeTextReceived', listener: RealTimeTextReceivedListener): void;
off(event: 'transferAccepted', listener: TransferAcceptedListener): void;
off(event: 'capabilitiesChanged', listener: CapabilitiesChangedListener): void;
off(event: 'roleChanged', listener: PropertyChangedEvent): void;
off(event: 'spotlightChanged', listener: SpotlightChangedListener): void;
off(event: 'mutedByOthers', listener: PropertyChangedEvent): void;
off(event: 'breakoutRoomsUpdated', listener: BreakoutRoomsUpdatedListener): void;
private asyncTeeErrorToEventEmitter;
private teeErrorToEventEmitter;
}
/**
* Locator used by {@link createAzureCommunicationCallAdapter} to call one or more participants
*
* @remarks
* This is currently in beta and only supports calling one Teams User.
*
* @example
* ```
* ['8:orgid:ab220efe-5725-4742-9792-9fba7c9ac458']
* ```
*
* @beta
*/
export type CallParticipantsLocator = {
participantIds: string[];
};
/**
* Locator used by {@link createAzureCommunicationCallAdapter} to locate the call to join
*
* @public
*/
export type CallAdapterLocator = TeamsMeetingLinkLocator | GroupCallLocator | RoomCallLocator | /* @conditional-compile-remove(call-participants-locator) */ CallParticipantsLocator | TeamsMeetingIdLocator;
/**
* Common optional parameters to create {@link AzureCommunicationCallAdapter} or {@link TeamsCallAdapter}
*
* @public
*/
export type CommonCallAdapterOptions = {
/**
* Default set of background images for background image picker.
*/
videoBackgroundOptions?: {
videoBackgroundImages?: VideoBackgroundImage[];
onResolveDependency?: () => Promise<VideoBackgroundEffectsDependency>;
};
/**
* `DeepNoiseSuppressionEffect` options to be used for noise suppression.
*/
deepNoiseSuppressionOptions?: {
onResolveDependency?: () => Promise<DeepNoiseSuppressionEffectDependency>;
deepNoiseSuppressionOnByDefault?: boolean;
hideDeepNoiseSuppressionButton?: boolean;
};
/**
* Use this to fetch profile information which will override data in {@link CallAdapterState} like display name
* The onFetchProfile is fetch-and-forget one time action for each user, once a user profile is updated, the value will be cached
* and would not be updated again within the lifecycle of adapter.
*/
onFetchProfile?: OnFetchProfileCallback;
/**
* Sounds to use for calling events
*/
callingSounds?: CallingSounds;
/**
* Reaction resource for reaction resources
* @beta
*/
reactionResources?: ReactionResources;
/**
* A phone number in E.164 format procured using Azure Communication Services that will be used to represent callers identity.
* E.164 numbers are formatted as [+] [country code] [phone number including area code]. For example, +14255550123 for a US phone number.
*/
alternateCallerId?: string;
};
/**
* Optional parameters to create {@link AzureCommunicationCallAdapter}
*
* @public
*/
export type AzureCommunicationCallAdapterOptions = CommonCallAdapterOptions;
/**
* Arguments for creating the Azure Communication Services implementation of {@link CallAdapter}.
*
* Note: `displayName` can be a maximum of 256 characters.
*
* @public
*/
export type AzureCommunicationCallAdapterArgs = {
userId: CommunicationUserIdentifier;
displayName: string;
credential: CommunicationTokenCredential;
locator: CallAdapterLocator;
/**
* Optional parameters for the {@link AzureCommunicationCallAdapter} created
*/
options?: AzureCommunicationCallAdapterOptions;
};
/**
* Arguments for creating the Azure Communication Services implementation of {@link CallAdapter}.
*
* These arguments are used to create an outbound call scenarios.
*
* Note: `displayName` can be a maximum of 256 characters.
*
* @public
*/
export type AzureCommunicationOutboundCallAdapterArgs = {
userId: CommunicationUserIdentifier;
displayName: string;
credential: CommunicationTokenCredential;
targetCallees: StartCallIdentifier[];
/**
* A phone number in E.164 format procured using Azure Communication Services that will be used to represent callers identity.
* E.164 numbers are formatted as [+] [country code] [phone number including area code]. For example, +14255550123 for a US phone number.
*/
alternateCallerId?: string;
/**
* Optional parameters for the {@link AzureCommunicationCallAdapter} created
*/
options?: AzureCommunicationCallAdapterOptions;
};
/**
* Optional parameters to create {@link TeamsCallAdapter}
*
* @public
*/
export type TeamsAdapterOptions = CommonCallAdapterOptions;
/**
* Common part of args to create the Azure Communication Services implementation of {@link TeamsCallAdapter}.
*
* @public
*/
export type TeamsCallAdapterArgsCommon = {
userId: MicrosoftTeamsUserIdentifier;
credential: CommunicationTokenCredential;
options?: TeamsAdapterOptions;
};
/**
* Arguments for creating the Azure Communication Services implementation of {@link TeamsCallAdapter}.
*
* @public
*/
export type TeamsCallAdapterArgs = TeamsCallAdapterArgsCommon & {
locator: TeamsMeetingLinkLocator | /* @conditional-compile-remove(call-participants-locator) */ CallParticipantsLocator | TeamsMeetingIdLocator;
};
/**
* Parameter to start a call using a Teams user identity.
*
* @beta
*/
export type StartTeamsCallIdentifier = MicrosoftTeamsUserIdentifier | PhoneNumberIdentifier | MicrosoftTeamsAppIdentifier | UnknownIdentifier;
/**
* Arguments for creating the Azure Communication Services implementation of {@link TeamsCallAdapter}.
*
* This is used to create an outbound call scenarios.
*
* @beta
*/
export type TeamsOutboundCallAdapterArgs = TeamsCallAdapterArgsCommon & {
targetCallees: StartTeamsCallIdentifier[];
};
/**
* Create a {@link CallAdapter} backed by Azure Communication Services.
*
* This is the default implementation of {@link CallAdapter} provided by this library.
*
* Note: `displayName` can be a maximum of 256 characters.
*
* @public
*/
export declare function createAzureCommunicationCallAdapter(args: AzureCommunicationCallAdapterArgs): Promise<CallAdapter>;
/**
* Create a {@link CallAdapter} backed by Azure Communication Services.
*
* This is the default implementation of {@link CallAdapter} provided by this library.
*
* Note: `displayName` can be a maximum of 256 characters.
*
* @public
*/
export declare function createAzureCommunicationCallAdapter(args: AzureCommunicationOutboundCallAdapterArgs): Promise<CallAdapter>;
/**
* This inner function is used to allow injection of TelemetryImplementationHint without changing the public API.
*
* @internal
*/
export declare const _createAzureCommunicationCallAdapterInner: ({ userId, displayName, credential, locator, targetCallees, options, telemetryImplementationHint }: {
userId: CommunicationUserIdentifier;
displayName: string;
credential: CommunicationTokenCredential;
locator: CallAdapterLocator;
targetCallees?: StartCallIdentifier[];
alternateCallerId?: string;
options?: AzureCommunicationCallAdapterOptions;
telemetryImplementationHint?: _TelemetryImplementationHint;
}) => Promise<CallAdapter>;
/**
* @public
*/
export declare const createTeamsCallAdapter: (args: TeamsCallAdapterArgs | /* @conditional-compile-remove(teams-identity-support-beta) */ TeamsOutboundCallAdapterArgs) => Promise<TeamsCallAdapter>;
/**
* A custom React hook to simplify the creation of {@link CallAdapter}.
*
* Similar to {@link createAzureCommunicationCallAdapter}, but takes care of asynchronous
* creation of the adapter internally.
*
* Allows arguments to be undefined so that you can respect the rule-of-hooks and pass in arguments
* as they are created. The adapter is only created when all arguments are defined.
*
* Note that you must memoize the arguments to avoid recreating adapter on each render.
* See storybook for typical usage examples.
*
* @public
*/
export declare const useAzureCommunicationCallAdapter: (args: Partial<AzureCommunicationCallAdapterArgs | AzureCommunicationOutboundCallAdapterArgs>, afterCreate?: (adapter: CallAdapter) => Promise<CallAdapter>, beforeDispose?: (adapter: CallAdapter) => Promise<void>) => CallAdapter | undefined;
/**
* A custom React hook to simplify the creation of {@link TeamsCallAdapter}.
*
* Similar to {@link createTeamsAzureCommunicationCallAdapter}, but takes care of asynchronous
* creation of the adapter internally.
*
* Allows arguments to be undefined so that you can respect the rule-of-hooks and pass in arguments
* as they are created. The adapter is only created when all arguments are defined.
*
* Note that you must memoize the arguments to avoid recreating adapter on each render.
* See storybook for typical usage examples.
*
* @public
*/
export declare const useTeamsCallAdapter: (args: Partial<TeamsCallAdapterArgs | /* @conditional-compile-remove(teams-identity-support-beta) */ TeamsOutboundCallAdapterArgs>, afterCreate?: (adapter: TeamsCallAdapter) => Promise<TeamsCallAdapter>, beforeDispose?: (adapter: TeamsCallAdapter) => Promise<void>) => TeamsCallAdapter | undefined;
/**
* Create a {@link CallAdapter} using the provided {@link StatefulCallClient}.
*
* Useful if you want to keep a reference to {@link StatefulCallClient}.
* Consider using {@link createAzureCommunicationCallAdapter} for a simpler API.
*
* @public
*/
export declare function createAzureCommunicationCallAdapterFromClient(callClient: StatefulCallClient, callAgent: CallAgent, targetCallees: StartCallIdentifier[], options?: AzureCommunicationCallAdapterOptions): Promise<CallAdapter>;
/**
* Create a {@link CallAdapter} using the provided {@link StatefulCallClient}.
*
* Useful if you want to keep a reference to {@link StatefulCallClient}.
* Consider using {@link createAzureCommunicationCallAdapter} for a simpler API.
*
* @public
*/
export declare function createAzureCommunicationCallAdapterFromClient(callClient: StatefulCallClient, callAgent: CallAgent, locator: CallAdapterLocator, options?: AzureCommunicationCallAdapterOptions): Promise<CallAdapter>;
/**
* Create a {@link TeamsCallAdapter} using the provided {@link StatefulCallClient}.
*
* Useful if you want to keep a reference to {@link StatefulCallClient}.
* Consider using {@link createAzureCommunicationCallAdapter} for a simpler API.
*
* @public
*/
export declare const createTeamsCallAdapterFromClient: (callClient: StatefulCallClient, callAgent: TeamsCallAgent, locator: CallAdapterLocator | /* @conditional-compile-remove(teams-identity-support-beta) */ StartTeamsCallIdentifier[], options?: TeamsAdapterOptions) => Promise<TeamsCallAdapter>;
export {};
//# sourceMappingURL=AzureCommunicationCallAdapter.d.ts.map