type ObjectKey = string | number | symbol; type EmptyObject = Record; type UUID = string; type EndpointId = string; type TrackId = string; type MediaId = string; type BaseMediaKind = "audio" | "video"; type SipHeaders = Record; type Type = string; type SubType = string; type CommonMIMEType = `${Type}/${SubType}`; type MIMEType = T; declare enum SimulcastLayerRid { /** * Simulcast layer with the highest resolution */ High = "h", /** * Simulcast layer with a medium resolution */ Medium = "m", /** * Simulcast layer with the lowest resolution */ Low = "l" } declare enum VideoCodec { /** * Call or conference is set to prioritize the VP8 video codec. */ VP8 = "video/VP8", /** * Call or conference is set to prioritize the H.264 video codec. */ H264 = "video/H264", /** * Video codec for a call or conference is chosen automatically. */ Auto = "auto" } type OnValueChangeCallback = (newValue: T, oldValue: T) => unknown | Promise; type UnwatchFunction = () => void; interface WatchOptions { /** * Whether the callback should be called only once. The default value is false. */ once?: boolean; /** * A function that returns a boolean to determine if the callback should be called. * The guard not set by default. * * @since 5.1.0 */ guard?: (newValue: T, oldValue: T) => boolean; /** * Whether the callback should be removed after calling the clear method. The default value is true. */ clearable?: boolean; /** * An AbortSignal. The watch callback will be removed when the abort() method of the AbortController which owns the AbortSignal is called. * See [AbortController](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) for details. * * @since 5.1.0 */ signal?: AbortSignal; /** * Whether the callback should be called immediately after being added. The default value is false. * * @since 5.1.0 */ immediate?: boolean; } interface Watchable { /** * Current value of the observable property. */ value: T; /** * Previous value of the observable property. */ get oldValue(): T; /** * Subscribes to the value changes. * * When the value is changed, the [Core.Watchable.OnValueChangeCallback] callback is triggered. * * Returns [Core.Watchable.UnwatchFunction], to unwatch observable value changes. * * @param onValueChangeCallback Observer to be triggered when the value is changed * @param options Options */ watch: (onValueChangeCallback: OnValueChangeCallback, options?: WatchOptions) => UnwatchFunction; /** * Stops triggering the specified callback on the value change. * * @param onValueChangeCallback Observer that should not be triggered anymore */ unwatch: (onValueChangeCallback: OnValueChangeCallback) => void; /** * Clears all observers for this watchable excluding the ones created with [Core.Watchable.WatchOptions.clearable]: false. */ clear: () => void; /** * Locks the watchable from mutations. The value becomes readonly. * @hidden */ lock: (key: string) => void; /** * Unlocks the watchable. The value becomes mutable again. * @hidden */ unlock: (key: string) => void; } interface ReadonlyWatchable extends Watchable { } interface BaseBusEvent { name: string; } interface ListenerOptions { /** * Whether a listener should be invoked at most once after being added. * The default value is false. */ once?: boolean; /** * A function that returns a boolean to determine if the listener should be called. * The guard not set by default. * * @since 5.1.0 */ guard?: (event: Extract) => boolean; /** * An AbortSignal. The listener will be removed when the abort() method of the AbortController which owns the AbortSignal is called. * See [AbortController](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) for details. * * @since 5.1.0 */ signal?: AbortSignal; } type Listener = (event: Extract) => void | Promise; type AddEventListener = (event: EventName, listener: Listener, options?: ListenerOptions) => void; type RemoveEventListener = (event: EventName, listener: Listener) => void; type DispatchEvent = (event: Extract) => void; declare enum StreamEvent { /** * Triggered when a stream has ended. * * Listener is called with [Stream.Events.StreamEnded] and payload: * @cast Stream.Events.StreamEndedPayload */ Ended = "ENDED" } interface BaseStreamEvent extends BaseBusEvent { name: Name; payload: Payload; } interface StreamEndedPayload { /** * Stream id */ streamId: Stream["id"]; } type StreamEnded = BaseStreamEvent; type AnyStreamEvent = StreamEnded; declare enum StreamType { /** * Audio stream type. */ Audio = "audio", /** * Video stream type. */ Video = "video", /** * Screen sharing video stream type. */ ScreenVideo = "screen_video", /** * Screen sharing audio stream type. */ ScreenAudio = "screen_audio" } type StreamSource = "local" | "remote"; interface StreamInfo { id: string; source: StreamSource; type: StreamType; trackId?: string; deviceId?: string; } interface Stream { /** * Stream id. */ readonly id: string; /** * Stream source type. */ readonly source: StreamSource; /** * Stream type. */ get type(): StreamType; /** * [MediaStreamTrack](https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack) object. */ get track(): MediaStreamTrack; /** * [MediaStream](https://developer.mozilla.org/en-US/docs/Web/API/MediaStream) object. */ get sourceStream(): MediaStream; /** * @hidden */ get info(): StreamInfo; /** * @reinterpret Stream.DocStreamAddEventListener */ addEventListener: AddEventListener; /** * @reinterpret Stream.DocStreamAddEventListener */ removeEventListener: RemoveEventListener; } interface LocalStream extends Stream { /** * Stream source type (local). */ readonly source: Extract; /** * Media device id that produces media data for the local stream. */ get sourceDeviceId(): string | null; /** * Stops capturing media and releases all resources. */ close: () => void; } interface LocalScreenSharingStream extends LocalStream { /** * Stream source type (local). */ readonly source: Extract; /** * Stream type. */ get type(): StreamType.ScreenVideo | StreamType.ScreenAudio; } interface RemoteStreamInfo extends StreamInfo { isReceiving: boolean; source: "remote"; } interface RemoteStream extends Stream { /** * Stream source type (remote). */ readonly source: Extract; /** * Watchable property that allows getting and setting video receiving status and observe its changes. * * For the remote streams in a conference, changes the value when one of the following events is triggered: * - [Conference.EndpointEvents.EndpointEvent.StartReceivingAudioStream] * - [Conference.EndpointEvents.EndpointEvent.StartReceivingVideoStream] * - [Conference.EndpointEvents.EndpointEvent.StopReceivingAudioStream] * - [Conference.EndpointEvents.EndpointEvent.StopReceivingVideoStream] * * For remote stream in a call, it is always true. */ readonly isReceiving: Watchable; get info(): RemoteStreamInfo; } /** * Enum that contains the states of a call. */ export declare enum CallState { /** * Call has been created */ Created = "CREATED", /** * Call is connecting */ Connecting = "CONNECTING", /** * Call is connected */ Connected = "CONNECTED", /** * Call is reconnecting after a failure */ Reconnecting = "RECONNECTING", /** * Call is disconnecting */ Disconnecting = "DISCONNECTING", /** * Call has been disconnected */ Disconnected = "DISCONNECTED", /** * Call failed */ Failed = "FAILED" } declare enum ContainerEvent { ModuleRegistered = "MODULE_REGISTERED" } interface ModuleRegisteredEvent extends BaseBusEvent { name: ContainerEvent.ModuleRegistered; token: Token; } type ContainerEvents = ModuleRegisteredEvent; interface Container { readonly key: string; registerModule: (module: ModuleLoader) => void; registerModules: (modules: ModuleLoader[]) => void; getModule(token: Token, required?: false): Module | undefined; getModule(token: Token, required: true): Module; getModuleAsync: (token: Token) => Promise; addEventListener: AddEventListener; removeEventListener: RemoveEventListener; } interface Token { name: string; module?: ModuleType; } interface InitModuleOptions { container: Container; key: string; } interface ModuleLoader { token: Token; options: Options; required: Token[]; setup: (initOptions: InitModuleOptions) => ModuleType; } type ModuleFactory = Options extends EmptyObject ? () => ModuleLoader : (options: Options) => ModuleLoader; interface BaseModule { /** * @hidden */ container: Container; } declare class BaseModuleImpl implements BaseModule { /** * @hidden */ container: Container; /** * @hidden */ constructor(initOptions: InitModuleOptions); } declare enum EventType { id = "id", lastReceivedMessage = "lastrx", acknowledge = "ack", message = "msg", close = "close", error = "error" } interface BaseEvent { type: EventType; seq?: number; } interface MsgCommand> extends BaseEvent { type: EventType.message; payload: Message; } type LoginIncomingMsgNames = "loginSuccessful" | "loginFailed" | "refreshOauthTokenSuccessful" | "refreshOauthTokenFailed"; type LoginOutgoingMsgNames = "login" | "loginUsingOneTimeKey" | "loginGenerateOneTimeKey" | "refreshOauthToken"; type Mids = Record; type StatsReportInterval = number; declare global { interface Navigator { getBattery?: () => Promise; } } interface BatteryManager extends EventTarget { level: number; charging: boolean; chargingTime: number; dischargingTime: number; } type MediaEventIncomingMsgNames = "handleReInvite" | "handleSIPInfo" | "handleAcceptReinvite" | "handleRejectReinvite"; type MediaEventOutgoingMsgNames = "AcceptReInvite" | "sendSIPInfo" | "ReInvite"; type EndpointType = "call"; interface ReInviteCause { id: EndpointId; displayName: string; username: string; place: number; sipURI: string; event: MIMEType; } interface EndpointInfo { mids: Mids; tracks: Record; place: number; type: EndpointType; } interface ReInviteScheme { conferenceCall: boolean; politeIndex: number; endpoints: Record; reinviteCauses: ReInviteCause[]; } type ReInviteSchemeWithOptionalCauses = ReInviteScheme & { reinviteCauses?: ReInviteCause[]; }; interface HandleReInviteParams { id: string; headers: SipHeaders; sdp: string; scheme: ReInviteScheme; } interface HandleAcceptReinviteParams { id: string; headers: SipHeaders; sdp: string; scheme: ReInviteScheme; } interface SIPInfoParams { id: string; mimeType: MIMEType; body: string; headers: SipHeaders; } type HandleSIPInfo = BaseInternalRPCMsg<"handleSIPInfo", SIPInfoParams>; type ConferenceIncomingMsgNames = "handleConnectionConnected" | "handleConnectionFailed" | "handleConnectionDisconnected"; type ConferenceOutgoingMsgName = "callConference" | "disconnectCall"; interface ConnectionConnectedHeaders { "VI-Call-ID": string; "VI-Session-ID": string; [otherHeaderKey: string]: string; } interface HandleConnectionConnectedParams { id: string; headers: ConnectionConnectedHeaders; sdp: string; endpointName: string[]; scheme: Partial; } interface HandleConnectionDisconnectedParams { id: string; headers: Record; params: { answeredElsewhere: boolean; }; } interface HandleConnectionFailedParams { id: string; code: number; reason: string; headers: Record; } type CallIncomingMsgNames = "handleConnectionConnected" | "handleConnectionFailed" | "handleConnectionDisconnected" | "handleRingOut" | "startEarlyMedia" | "stopRinging" | "handleIncomingConnection" | "onICEConfig" | "handleTransferStarted" | "handleTransferComplete" | "handleTransferFailed"; type CallOutgoingMsgName = "createCall" | "disconnectCall" | "rejectCall" | "confirmIncomingConnection" | "acceptCall" | "transferCall"; interface StartEarlyMediaParams { id: string; headers: SipHeaders; sdp: string; scheme: ReInviteSchemeWithOptionalCauses; } interface OnICEConfigParams { id: string; config: RTCIceServer[]; } type SmartQueueIncomingMsgNames = "onACDStatus" | "SQMessagingStatusUpdated" | "onSQStatusError"; type SmartQueueOutgoingMsgName = "getOperatorACDStatus" | "getOperatorMessagingStatus" | "setOperatorACDStatus" | "setOperatorMessagingStatus"; type PushServiceIncomingMsgNames = "registerPushTokenResult" | "unregisterPushTokenResult"; type PushServiceOutgoingMsgName = "registerPushToken" | "unregisterPushToken" | "pushFeedback"; type BaseInternalRPCMsg> = MsgCommand<{ kind: "rpc"; name: Name; params: Params; }>; type BaseIncomingRPCMsgNames = "__pong" | "__createConnection"; type BaseOutgoingRPCMsgNames = "__ping"; type AnyIncomingRPCMsgNames = BaseIncomingRPCMsgNames | LoginIncomingMsgNames | ConferenceIncomingMsgNames | CallIncomingMsgNames | MediaEventIncomingMsgNames | SmartQueueIncomingMsgNames | PushServiceIncomingMsgNames; type AnyOutgoingRPCMsgNames = BaseOutgoingRPCMsgNames | LoginOutgoingMsgNames | ConferenceOutgoingMsgName | CallOutgoingMsgName | MediaEventOutgoingMsgNames | SmartQueueOutgoingMsgName | PushServiceOutgoingMsgName; type AnyRPCMsgNames = AnyIncomingRPCMsgNames | AnyOutgoingRPCMsgNames; declare const WEB_SDK_ERROR_SYMBOL: unique symbol; declare class WebSDKError extends Error { /** * @hidden */ [WEB_SDK_ERROR_SYMBOL]?: boolean; /** * Because of using class in different modules (bundled js files) need to override instanceof operator - * different physical instances of the class in different modules should be treated as the same class * @hidden */ static [Symbol.hasInstance](instance: unknown): instance is WebSDKError; } interface LocalAudioStatsReport { /** * Local audio stream type. */ streamType: StreamType.Audio | StreamType.ScreenAudio; /** * Total number of bytes sent within an audio stream. */ bytesSent: number; /** * Total number of packets sent within an audio stream. */ packetsSent: number; /** * Audio codec name for an audio stream. */ codec: string | null; /** * Audio level value is in the 0..1 range (linear), where 1.0 represents 0 dBov, 0 represents silence, and * 0.5 represents approximately 6 dBSPL change in the sound pressure level from 0 dBov. * * Not supported in the Safari browser below 17.4 and the Firefox browser. */ audioLevel: number | null; } interface LocalVideoLayerStats { /** * Encoding layer identifier. * * Not supported in the Firefox browser (the value is null). * * Returns null for calls and if the simulcast feature is disabled for a conference. */ rid: SimulcastLayerRid | null; /** * Total number of bytes sent within a video stream. */ bytesSent: number; /** * Total number of packets sent within a video stream. */ packetsSent: number; /** * Video frame width sent within a video stream at the moment of the statistics collection. */ frameWidth: number | null; /** * Video frame height sent within a video stream at the moment of the statistics collection. */ frameHeight: number | null; /** * The number of complete frames in the last second. */ fps: number | null; } interface LocalVideoStatsReport { /** * Video stream type. */ streamType: StreamType.Video | StreamType.ScreenVideo; /** * Total number of bytes sent within a video stream. */ bytesSent: number; /** * Total number of packets sent within a video stream. */ packetsSent: number; /** * Video codec name for a video stream. */ codec: string | null; /** * Width of the video frame captured by a video source. * * Not supported in the Safari browser (the value is null). * Partly supported in the Firefox browser. */ sourceFrameWidth: number | null; /** * Height of the video frame captured by a video source. * * Not supported in the Safari browser (the value is null). * Partly supported in the Firefox browser. */ sourceFrameHeight: number | null; /** * Number of complete source frames in the last second. * * Not supported in the Safari browser below 17.4 and party supported in the Firefox browser. */ sourceFps: number | null; /** * Statistics for the video stream layers. */ layers: LocalVideoLayerStats[]; } interface RemoteAudioStatsReport { /** * Total number of bytes received within an audio stream. */ bytesReceived: number; /** * Total number of packets received within an audio stream. */ packetsReceived: number; /** * Total number of audio packets lost for an audio stream. */ packetsLost: number; /** * Audio level value is in the 0..1 range (linear), where 1.0 represents 0 dBov, 0 represents silence, * and 0.5 represents approximately 6 dBSPLchange in the sound pressure level from 0 dBov. */ audioLevel: number | null; /** * Audio codec name for an audio stream. */ codec: string | null; } interface RemoteVideoStatsReport { /** * Total number of bytes received within a video stream. */ bytesReceived: number; /** * Total number of packets received within a video stream. */ packetsReceived: number; /** * Total number of video packets lost for a video stream. */ packetsLost: number; /** * Video frame width received within a video stream at the moment of the statistics collection. */ frameWidth: number | null; /** * Video frame height received within a video stream at the moment of the statistics collection. */ frameHeight: number | null; /** * Number of complete frames in the last second. */ fps: number | null; /** * Video codec name for a video stream. */ codec: string | null; } interface ConnectionStatsReport { /** * Available outgoing bitrate calculated by the underlying congestion control by combining the available bitrate * for all the outgoing RTP streams with the current selected candidate pair. * * Not supported in the Firefox browser (the value is null). */ availableOutgoingBitrate: number | null; /** * Represents the latest round trip time measured in seconds. * * Not supported in the Firefox browser (the value is null). */ rtt: number | null; /** * Local ICE candidate type. * * Possible values: * - "host" - A host candidate * - "srflx" - A server reflexive candidate * - "prflx" - A peer reflexive candidate * - "relay" - A relay candidate */ localCandidateType: string; /** * Remote ICE candidate type. * * Possible values: * - "host" - A host candidate * - "srflx" - A server reflexive candidate * - "prflx" - A peer reflexive candidate * - "relay" - A relay candidate */ remoteCandidateType: string; } type LocalAudioStreamStatsReport = Record; type LocalVideoStreamStatsReport = Record; type RemoteAudioStreamStatsReport = Record; type RemoteVideoStreamStatsReport = Record; /** * Enum that represents call directions. */ export declare enum CallDirection { /** * Incoming call */ Incoming = "INCOMING", /** * Outgoing call */ Outgoing = "OUTGOING" } /** * Enum that contains the call rejection reasons. */ export declare enum RejectMode { /** * Call line is busy. */ Busy = "Busy", /** * Call has been declined. */ Decline = "Decline" } /** * Call settings with additional call parameters, such as the preferred video codec, custom data, extra headers, etc. */ export interface CallSettings { /** * Custom string associated with a call session. * * It can be passed to the cloud to be obtained from the [CallAlerting](/docs/references/voxengine/appevents#callalerting) * event or [Call History](/docs/references/httpapi/history#getcallhistory) via Management API. * * Maximum size is 200 bytes. * * Use the [Call.Call.sendMessage] method to pass a string over the limit; in order to pass a large data use * [media_session_access_url](/docs/references/httpapi/scenarios#startscenarios) on your backend. */ customData?: string; /** * Optional set of headers to be sent to the Voximplant cloud. Names should begin with “X-” to be processed by SDK. */ extraHeaders?: Record; /** * Call statistics collection interval in milliseconds. * * The default value is 1000. * * The interval value should be multiple of 500, otherwise the provided value is rounded to a less value that is multiple of 500. * * To receive the [Call.CallEvents.CallStatsReport] event, [Call.CallSettings.reportStats] should be set to true. */ statsReportInterval?: StatsReportInterval; /** * Whether the [Call.CallEvents.CallStatsReport] event should be triggered for a call. * * The default value is false. */ reportStats?: boolean; /** * Preferred video codec for a particular call that these settings are applied to. * * The default value is [Core.VideoCodec.Auto]. */ preferredVideoCodec?: VideoCodec; /** * Whether video receiving is enabled in a call. * * The default value is false. * * If the call is started without video and the user enables video in an active call * via the [Call.Call.addStream] API, enables video receiving. */ receiveVideo?: boolean; } interface OutgoingCallSettings extends CallSettings { direction: CallDirection.Outgoing; } interface IncomingCallSettings extends CallSettings { id: string; remoteSipUri: string; remoteDisplayName: string; direction: CallDirection.Incoming; remoteSdp: string; remoteSchema: ReInviteScheme; iceServers?: RTCIceServer[]; } type AnyCallSettings = OutgoingCallSettings | IncomingCallSettings; /** * @interface * @internal * * Registers a handler for the specified event. * * One event can have more than one handler; handlers are executed in order of their registration. */ export type DocCallAddEventListener = ( /** * Event name */ eventName: CallEvent, /** * Handler function that is triggered when an event of the specified type occurs */ listener: (event: AnyCallEvent) => void | Promise, /** * Object that specifies characteristics about the event listener */ options: ListenerOptions) => void; /** * @interface * @internal * * Removes a previously registered handler for the specified event. */ export type DocCallRemoveEventListener = ( /** * Event name */ eventName: CallEvent, /** * Handler function to remove from the event target */ listener: (event: AnyCallEvent) => void | Promise) => void; /** * Interface that represents a call and provides the API to manage it. */ export interface Call { /** * Call id. */ readonly id: UUID; /** * Call duration in milliseconds. */ readonly duration: number; /** * Destination that the call has been created with. */ readonly destination: string; /** * Watchable property that allows getting the current call state and observing its changes. */ readonly state: ReadonlyWatchable; /** * Watchable property that allows getting the call participant user display name and observing its changes. * * Null for outgoing calls until the [Call.CallEvents.CallEvent.Connected] event is triggered. */ readonly remoteDisplayName: ReadonlyWatchable; /** * Watchable property that allows getting the call participant sip URI and observing its changes. * * Null for outgoing calls until the [Call.CallEvents.CallEvent.Connected] event is triggered. */ remoteSipUri: ReadonlyWatchable; /** * Watchable property that allows getting whether the call is on hold. */ isOnHold: ReadonlyWatchable; /** * Call direction. */ readonly direction: CallDirection; /** * Watchable property that allows getting the array of the local audio and video streams that are currently being sent. */ localStreams: ReadonlyWatchable>; /** * Watchable property that allows getting the array of the remote audio and video streams that are currently being received. */ remoteStreams: ReadonlyWatchable>; /** * Watchable property that indicates whether the video is enabled and allows observing its changes. */ isVideoEnabled: ReadonlyWatchable; /** * Starts sending an audio or video stream to the call. * * If a video stream is added to a call that was originally started as audio only, * the remote participant receives the [Call.CallEvents.CallEvent.CallUpgrade] event * and can accept or reject the request to switch the call to video. * * Returns a promise that is resolved when the operation is completed. * * @throws * - [Call.Errors.CallWrongStateError] — if the call is in the [Call.CallState.Failed], * [Call.CallState.Disconnecting], or [Call.CallState.Disconnected] state * - [Core.SharedErrors.StreamTypeMismatchError] — if the stream is of the [Stream.StreamType.ScreenVideo] type * - [Call.Errors.CallOnHoldError] — if the call is currently on hold * - [Core.SharedErrors.InactiveStreamError] — if the stream is not [active](https://developer.mozilla.org/en-US/docs/Web/API/MediaStream/active) * - [Core.SharedErrors.StreamUpdateFailedError] — if the operation has failed * * @param stream Audio or video stream */ addStream: (stream: LocalStream) => Promise; /** * Stops sending audio or video stream to the call. * * Returns a promise that is resolved when the operation is completed. * * @throws * - [Call.Errors.CallWrongStateError] — if the call is in the [Call.CallState.Failed], * [Call.CallState.Disconnecting], or [Call.CallState.Disconnected] state * - [Core.SharedErrors.StreamTypeMismatchError] — if the stream is of the [Stream.StreamType.ScreenAudio] or [Stream.StreamType.ScreenVideo] type * - [Call.Errors.CallOnHoldError] — if the call is currently on hold * - [Core.SharedErrors.StreamUpdateFailedError] — if the operation has failed * * @param stream */ removeStream: (stream: LocalStream) => Promise; /** * Replaces the local audio or video stream that is currently being sent to the call with another local audio or video stream. * * Returns a promise that is resolved when the operation is completed. * * @throws * - [Call.Errors.CallWrongStateError] — if the call is in the [Call.CallState.Failed], * [Call.CallState.Disconnecting], or [Call.CallState.Disconnected] state * - [Core.SharedErrors.StreamTypeMismatchError] — if the stream is of [Stream.StreamType.ScreenAudio] or [Stream.StreamType.ScreenVideo] type * - [Core.SharedErrors.InactiveStreamError] — if the stream is not [active](https://developer.mozilla.org/en-US/docs/Web/API/MediaStream/active) * - [Core.SharedErrors.StreamUpdateFailedError] — if the operation has failed * * @param stream New local stream * @param oldStream Stream to replace */ replaceStream: (stream: LocalStream, oldStream?: LocalStream) => Promise; /** * Watchable property that allows getting the screen sharing sending status and observing its changes. */ hasScreenSharing: ReadonlyWatchable; /** * Watchable property indicating the current sending status of the local video stream. * * This property holds one of the following values: * - [Call.VideoSendingStatus.Sending]: A local video stream is being sent. * - [Call.VideoSendingStatus.NotSending]: No local video is being sent. * - [Call.VideoSendingStatus.Pending]: A video stream is currently being added, removed, or replaced via the * [Call.Call.addStream], [Call.Call.removeStream], or [Call.Call.replaceStream] API. * * The initial status when the call is connected is available in the * [Call.CallEvents.CallEvent.Connected] event payload. * * @since 5.2.0 */ videoSendingStatus: ReadonlyWatchable; /** * Starts sending a screen sharing stream to the call. * * Returns a promise that is resolved when the operation is completed. * * @throws * - [Call.Errors.CallWrongStateError] — if the call is not in the [Call.CallState.Connected] state * - [Call.Errors.CallOnHoldError] — if the call is currently on hold * - [Core.SharedErrors.InactiveStreamError] — if the stream is not [active](https://developer.mozilla.org/en-US/docs/Web/API/MediaStream/active) * - [Core.SharedErrors.StreamUpdateFailedError] — if the operation has failed or the screen sharing is already being sent to the call * * @param stream Array of screen sharing streams */ startScreenSharing: (stream: LocalScreenSharingStream[]) => Promise; /** * Stops sending a screen sharing stream to the call. * * Returns a promise that is resolved when the operation is completed. * * @throws * - [Call.Errors.CallWrongStateError] — if the call is not in the [Call.CallState.Connected] state * - [Call.Errors.CallOnHoldError] — if the call is currently on hold * - [Core.SharedErrors.StreamUpdateFailedError] — if the operation has failed or the screen sharing is not currently being sent */ stopScreenSharing: () => Promise; /** * Watchable property that allows getting the audio mute status and observing its changes. */ isMicrophoneMuted: ReadonlyWatchable; /** * Toggles the audio mute status in the call. */ toggleMicrophone: () => boolean; /** * Mutes the audio in the call. */ muteMicrophone: () => void; /** * Unmutes the audio in the call. */ unmuteMicrophone: () => void; /** * Starts an outgoing call. * * Returns a promise that is resolved if the call connection process has started successfully. A resolved promise * does not mean that the call is connected. You should subscribe to [Call.CallEvents.CallEvent.Connected] to be * notified that the call is established. * * @throws * - [Call.Errors.CallWrongDirectionError] — if the method is called for an incoming call * - [Call.Errors.CallWrongStateError] — if the call is in a state different from [Call.CallState.Created] or [Call.CallState.Reconnecting] */ start: () => Promise; /** * Answers an incoming call. * * Returns a promise that is resolved if the call connection process has started successfully. A resolved promise * does not mean that the call is connected. You should subscribe to [Call.CallEvents.CallEvent.Connected] to be * notified that the call is established. * * @throws * - [Call.Errors.CallWrongDirectionError] — if the method is called for an outgoing call * - [Call.Errors.CallWrongStateError] — if the call is in a state different from [Call.CallState.Created] or [Call.CallState.Reconnecting] * - [Call.Errors.CallInternalError] — if the operation has failed * * @param settings Call settings with additional call parameters, such as the preferred video codec, custom data, extra headers, etc. */ answer: (settings?: CallSettings) => Promise; /** * Rejects an incoming call. * * @param rejectMode Call rejection mode * @param headers Optional set of headers to be sent. Names should begin with “X-” to be processed by the SDK. * @throws [Call.Errors.CallWrongDirectionError] if the method is called for the outgoing call */ reject: (rejectMode: RejectMode, headers?: Record) => void; /** * Terminates the call. * * @param headers Optional set of headers to be sent. Names should begin with “X-” to be processed by the SDK. */ hangup: (headers?: Record) => void; /** * Holds or unholds the call. * * Returns a promise that is resolved when the operation is completed. * * @throws * - [Call.Errors.CallWrongStateError] — if the call is not in the [Call.CallState.Connected] state * - [Call.Errors.CallOnHoldError] on the attempt to hold the call that is already on hold * - [Call.Errors.CallNotOnHoldError] on the attempt to resume the call that is currently not on hold * - [Call.Errors.CallInternalError] — if the operation has failed * * @param enable Whether to hold or unhold the call */ hold: (enable: boolean) => Promise; /** * Sends DTMF(s) within the call. * * @param tones DTMF(s) * @throws [Core.SharedErrors.InvalidArgumentsError] if the tones parameter is an empty string */ sendDTMF: (tones: string) => void; /** * Sends an INFO message within the call. * * @param mimeType MIME type of the info * @param body Custom string data * @param headers Optional set of headers to be sent with the message. Names should begin with “X-” to be processed by the SDK. * @throws [Core.SharedErrors.InvalidMimeTypeError] if the provided mimeType is in an invalid format */ sendInfo: (mimeType: MIMEType, body: string, headers?: Record) => void; /** * Sends a message within the call. * * Implemented atop of SIP INFO for communication between the call endpoint and the Voximplant Cloud, and is separated * from Voximplant messaging API. * @param message Message text */ sendMessage: (message: string) => void; /** * @reinterpret Call.DocCallAddEventListener */ addEventListener: AddEventListener; /** * @reinterpret Call.DocCallRemoveEventListener */ removeEventListener: RemoveEventListener; } /** * Enum that represents the status of a call upgrade request. */ export declare enum CallUpgradeStatus { /** * Call upgrade request is pending. */ Pending = "Pending", /** * Call upgrade request has been accepted via the [Call.CallEvents.CallUpgradePayload.accept] API. */ Accepted = "Accepted", /** * Call upgrade request has been rejected via the [Call.CallEvents.CallUpgradePayload.reject] API * or when the request times out. */ Rejected = "Rejected" } /** * Enum that represents the status of a video sending. */ export declare enum VideoSendingStatus { /** * Video is currently being sent. */ Sending = "Sending", /** * Video is not currently being sent. */ NotSending = "NotSending", /** * Video is currently negotiating. */ Pending = "Pending" } /** * @folder CallEvents * @event */ export declare enum CallEvent { /** * Triggered after a call has been successfully connected. * * Listener is called with [Call.CallEvents.CallConnected] and payload: * @cast Call.CallEvents.CallConnectedPayload */ Connected = "Connected", /** * Triggered if a call failed. * * Listener is called with [Call.CallEvents.CallFailed] and payload: * @cast Call.CallEvents.CallFailedPayload */ Failed = "Failed", /** * Triggered after a call has been disconnected. * * Listener is called with [Call.CallEvents.CallDisconnected] and payload: * @cast Call.CallEvents.CallDisconnectedPayload */ Disconnected = "Disconnected", /** * Triggered when the [Call.ring](/docs/references/voxengine/call#ring) method is called on the scenario side. * * Listener is called with [Call.CallEvents.CallStartRinging] and payload: * @cast Call.CallEvents.CallStartRingingPayload */ StartRinging = "StartRinging", /** * Triggered when the [Call.answer](/docs/references/voxengine/call#answer) or * [Call.startEarlyMedia method](/docs/references/voxengine/call#startearlymedia) is called on the scenario side. * * Listener is called with [Call.CallEvents.CallStopRinging] and payload: * @cast Call.CallEvents.CallStopRingingPayload */ StopRinging = "StopRinging", /** * Triggered when call statistics are available for a call. * * Listener is called with [Call.CallEvents.CallStatsReport] and payload: * @cast Call.CallEvents.CallStatsReportPayload */ StatsReport = "StatsReport", /** * Triggered when an INFO message is received within a call. * * Listener is called with [Call.CallEvents.CallInfoReceived] and payload: * @cast Call.CallEvents.CallInfoReceivedPayload */ InfoReceived = "InfoReceived", /** * Triggered when another call participant has added an audio or video stream to a call. * * Listener is called with [Call.CallEvents.CallRemoteMediaAdded] and payload: * @cast Call.CallEvents.CallRemoteMediaAddedPayload */ RemoteMediaAdded = "RemoteMediaAdded", /** * Triggered when another call participant has removed an audio or video stream from a call. * * Listener is called with [Call.CallEvents.CallRemoteMediaRemoved] and payload: * @cast Call.CallEvents.CallRemoteMediaRemovedPayload */ RemoteMediaRemoved = "RemoteMediaRemoved", /** * Triggered when a message is received within a call. * * Listener is called with [Call.CallEvents.CallMessageReceived] and payload: * @cast Call.CallEvents.CallMessageReceivedPayload */ MessageReceived = "MessageReceived", /** * Triggered when the remote participant enables video during an audio call. * * This event allows the application to either accept or reject the request * to upgrade the call to video. * * If no event listener is registered for the event, the SDK automatically accepts * the video upgrade. * * If a listener is registered, the application should explicitly call either `accept` * or `reject`. If neither method is invoked within 8 seconds, * the upgrade request is automatically rejected. * * Listener is called with [Call.CallEvents.CallUpgrade] and payload: * @cast Call.CallEvents.CallUpgradePayload * * @since 5.2.0 */ CallUpgrade = "CallUpgrade" } /** * @hidden */ export interface BaseCallEvent extends BaseBusEvent { name: Name; payload: Payload; } /** * @folder CallEvents */ export interface CallConnectedPayload { /** * Call id */ callId: UUID; /** * Optional headers passed with the event */ headers?: Record; /** * Local video sending status at the moment when the call is connected. * * This property is initialized with one of the following [Call.VideoSendingStatus] values: * - [Call.VideoSendingStatus.Sending]: A local video stream is being sent. * - [Call.VideoSendingStatus.NotSending]: No local video is being sent. * * To monitor status changes after the call is established, observe [Call.Call.videoSendingStatus]. * * @since 5.2.0 */ videoSendingStatus: VideoSendingStatus; } /** * @interface * @folder CallEvents */ export type CallConnected = BaseCallEvent; /** * @folder CallEvents */ export interface CallFailedPayload { /** * Call id */ callId: UUID; /** * Optional headers passed with the event */ headers?: Record; /** * Call status code */ code: number; /** * Call failure reason */ reason: string; } /** * @interface * @folder CallEvents */ export type CallFailed = BaseCallEvent; /** * Enum that represents the reason why a call has been ended. * * @folder CallEvents */ export declare enum CallDisconnectReason { /** * Local party has explicitly ended a call. */ LocalEnded = "LOCAL_ENDED", /** * Remote party has explicitly ended a call. */ RemoteEnded = "REMOTE_ENDED", /** * Connection to the Voximplant Cloud has been lost and cannot be recovered during a call. */ ConnectionLost = "CONNECTION_LOST", /** * Another device has answered the call. */ AnsweredElsewhere = "ANSWERED_ELSEWHERE" } /** * @folder CallEvents */ export interface CallDisconnectedPayload { /** * Call id */ callId: UUID; /** * Optional headers passed with the event */ headers?: Record; /** * Reason that the call ended */ reason: CallDisconnectReason; } /** * @interface * @folder CallEvents */ export type CallDisconnected = BaseCallEvent; /** * @folder CallEvents */ export interface CallStartRingingPayload { /** * Call id */ callId: UUID; } /** * @interface * @folder CallEvents */ export type CallStartRinging = BaseCallEvent; /** * @folder CallEvents */ export interface CallStopRingingPayload { /** * Call id */ callId: UUID; } /** * @interface * @folder CallEvents */ export type CallStopRinging = BaseCallEvent; /** * @folder CallEvents */ export interface CallStatsReportPayload { /** * Time at which the call statistics are collected, relative to the UNIX epoch (Jan 1, 1970, UTC), in microseconds. */ timestamp: number; /** * Media connectivity statistics. */ connection: ConnectionStatsReport; /** * Statistics for all active outgoing audio streams in a call at the moment of the statistics collection. */ localAudio: LocalAudioStreamStatsReport; /** * Statistics for all active outgoing video streams in a call at the moment of the statistics collection. */ localVideo: LocalVideoStreamStatsReport; /** * Statistics for all incoming audio and video streams of a call at the moment of the statistics collection. */ remote: { audio: RemoteAudioStreamStatsReport; video: RemoteVideoStreamStatsReport; }; } /** * @interface * @folder CallEvents */ export type CallStatsReport = BaseCallEvent; /** * @folder CallEvents */ export interface CallRemoteMediaAddedPayload { /** * Call id */ callId: UUID; /** * Remote media stream */ stream: RemoteStream; /** * Remote media stream type */ type: StreamType; } /** * @interface * @folder CallEvents */ export type CallRemoteMediaAdded = BaseCallEvent; /** * @folder CallEvents */ export interface CallRemoteMediaRemovedPayload { /** * Call id */ callId: UUID; /** * Remote media stream */ stream: RemoteStream; /** * Remote media stream type */ type: StreamType; } /** * @interface * @folder CallEvents */ export type CallRemoteMediaRemoved = BaseCallEvent; /** * @folder CallEvents */ export interface CallInfoReceivedPayload { /** * Call id */ callId: UUID; /** * Body of an INFO message */ body: string; /** * Optional headers passed with the event */ headers?: Record; /** * MIME type of an INFO message */ mimeType: MIMEType; } /** * @interface * @folder CallEvents */ export type CallInfoReceived = BaseCallEvent; /** * @folder CallEvents */ export interface CallMessageReceivedPayload { /** * Call id */ callId: UUID; /** * Content of the message */ message: string; } /** * @interface * @folder CallEvents */ export type CallMessageReceived = BaseCallEvent; /** * * If neither [Call.CallEvents.CallUpgradePayload.accept] nor [Call.CallEvents.CallUpgradePayload.reject] * is called within 8 seconds, the request is automatically rejected. * * @folder CallEvents * * @since 5.2.0 */ export interface CallUpgradePayload { /** * Call id */ callId: UUID; /** * Watchable property that reflects the current state of the call upgrade request. * * Initially set to [Call.CallUpgradeStatus.Pending]. */ upgradeStatus: ReadonlyWatchable; /** * Accepts the call upgrade request and enables video receiving for the call. * * To also send local video, use [Call.Call.addStream] after accepting. * * @method */ accept: () => void; /** * Rejects the call upgrade request. * * The call continues as audio only. * * @method */ reject: () => void; } /** * @interface * @folder CallEvents */ export type CallUpgrade = BaseCallEvent; /** * @folder CallEvents */ export type AnyCallEvent = CallStartRinging | CallStopRinging | CallConnected | CallFailed | CallDisconnected | CallStatsReport | CallRemoteMediaAdded | CallRemoteMediaRemoved | CallInfoReceived | CallMessageReceived | CallUpgrade; /** * Thrown if an operation cannot be done because a call is in an incorrect state. * * @folder Errors * @hideconstructor */ export declare class CallWrongStateError extends WebSDKError { constructor(state: CallState, operation: string); } /** * Thrown on the attempt to call the [Call.Call.answer] method for an outgoing call or * the [Call.Call.start] method for an incoming call. * * @folder Errors * @hideconstructor */ export declare class CallWrongDirectionError extends WebSDKError { constructor(currentDirection: string, reason: string); } /** * Thrown if an internal error has occurred. * * @folder Errors * @hideconstructor */ export declare class CallInternalError extends WebSDKError { constructor(reason?: string); } /** * Thrown if an operation is not permitted because a call is on hold. * * @folder Errors * @hideconstructor */ export declare class CallOnHoldError extends WebSDKError { constructor(description?: string); } /** * Thrown on the attempt to resume a call that is currently not on hold. * @folder Errors * @hideconstructor */ export declare class CallNotOnHoldError extends WebSDKError { constructor(description?: string); } /** * @hidden */ export declare class CallImpl implements Call { readonly id: string; readonly destination: string; readonly direction: CallDirection; private readonly container; private readonly connection; private readonly logger?; private readonly reInviteQueue; private readonly login; readonly state: ReadonlyWatchable; readonly hasScreenSharing: ReadonlyWatchable; readonly isOnHold: ReadonlyWatchable; readonly isMicrophoneMuted: ReadonlyWatchable; readonly isVideoEnabled: ReadonlyWatchable; readonly localStreams: ReadonlyWatchable>; readonly remoteStreams: ReadonlyWatchable>; readonly remoteDisplayName: ReadonlyWatchable; readonly remoteSipUri: ReadonlyWatchable; readonly addEventListener: AddEventListener; readonly removeEventListener: RemoveEventListener; readonly dispatchEvent: DispatchEvent; readonly listeners: Map[]>; private pc; private statistics; private settings; private currentReceiveVideo; private pendingRemoteVideoStream; private readonly incomingRemoteSdp; private callType; private headers; private midsMap; private startEarlyMediaPromise; private onICEConfigServers; private p2pIncomingIceRestartAwaiter; private disconnectReason; wasConnected: boolean; readonly isRemoteOnHold: ReadonlyWatchable; readonly videoSendingStatus: ReadonlyWatchable; constructor(destination: string, callSettings: AnyCallSettings, container: Container); private initWatchers; private initStateWatcher; private initDurationWatcher; private startTime; private endTime; get duration(): number; addStream(stream: LocalStream): Promise; removeStream(stream: LocalStream): Promise; replaceStream(stream: LocalStream, oldStream?: LocalStream): Promise; private handleStartReInviteQueue; private processAddStream; private processRemoveStream; private processReplaceStream; private checkCallBeforeStreamManipulation; handleRingOut(): void; handleStopRinging(): void; answer(settings?: CallSettings): Promise; reject(rejectMode: RejectMode, headers?: Record): void; private handleHangup; hangup(headers?: Record): void; hold(enable: boolean): Promise; sendDTMF(tones: string): void; sendInfo(mimeType: MIMEType, body: string, headers?: Record): void; sendMessage(message: string): void; start(): Promise; startScreenSharing(streams: LocalScreenSharingStream[]): Promise; stopScreenSharing(): Promise; private initLocalStreamsWatcher; toggleMicrophone(): boolean; muteMicrophone(): void; unmuteMicrophone(): void; private setLocalMediaEnabledState; handleConnectionFailed(params: HandleConnectionFailedParams): void; private forceHandleDisconnect; handleConnectionDisconnected(params: HandleConnectionDisconnectedParams): void; handleStartEarlyMedia(params: StartEarlyMediaParams): Promise; private updateVideoSendingStatusAndStreams; handleConnectionConnected(params: HandleConnectionConnectedParams): Promise; handleSipInfo(event: HandleSIPInfo): Promise; private handleCustomMimeType; handleOnICEConfig(params: OnICEConfigParams): void; private initIceConfigWatcher; private handleSystemMimeType; private readonly removeListenersAbortController; private registerReconnectionWatchers; private initStatistics; private detectCallType; private setRemoteDescription; private iceRestart; private isFirstReinvite; handleReInvite(params: HandleReInviteParams): void; handleAcceptReInvite(params: HandleAcceptReinviteParams): void; private readonly unprocessedRemoteTracks; private untilTranscieverDirectionStable; private pcTrackHandler; private setMidsMap; private initConnectionWatcher; private unestablishedReconnect; private reconnect; private createIncomingCallIceRestartAwaiter; enableReceiveVideo(): void; private addPendingRemoteVideoStream; private setDisconnectReason; get canReceiveVideo(): boolean; private clear; } /** * @folder CallManagerEvents * @event */ export declare enum CallManagerEvent { /** * Triggered when an incoming call arrives to the current user. * * Listener is called with [Call.CallManagerEvents.CallManagerIncomingCall] and payload: * @cast Call.CallManagerEvents.CallManagerIncomingCallPayload */ IncomingCall = "IncomingCall" } /** * @hidden */ export interface BaseCallManagerEvent extends BaseBusEvent { name: Name; payload: Payload; } /** * @folder CallManagerEvents */ export interface CallManagerIncomingCallPayload { /** * Call id */ callId: UUID; /** * Optional headers passed with the event */ headers?: Record; /** * Whether the incoming call has video */ hasIncomingVideo: boolean; } /** * @interface * @folder CallManagerEvents */ export type CallManagerIncomingCall = BaseCallManagerEvent; /** * @folder CallManagerEvents */ export type AnyCallManagerEvent = CallManagerIncomingCall; /** * @interface * @internal * * Registers a handler for the specified event. * * One event can have more than one handler; handlers are executed in order of their registration. */ export type DocCallManagerAddEventListener = ( /** * Event name */ eventName: CallManagerEvent, /** * Handler function that is triggered when an event of the specified type occurs */ listener: (event: AnyCallManagerEvent) => void | Promise, /** * Object that specifies characteristics about the event listener */ options: ListenerOptions) => void; /** * @interface * @internal * * Removes a previously registered handler for the specified event. */ export type DocCallManagerRemoveEventListener = ( /** * Event name */ eventName: CallManagerEvent, /** * Handler function to remove from the event target */ listener: (event: AnyCallManagerEvent) => void | Promise) => void; export interface CallManager extends BaseModule { /** * Creates a new call instance. * * The call should be started via the [Call.Call.start] method. * * @param destination SIP URI, username or phone number to make call to. Actual routing is then performed by a VoxEngine scenario * @param settings Call settings with additional call parameters, such as the preferred video codec, custom data, extra headers, etc. * @throws [Core.SharedErrors.RequiredParameterError] if the destination parameter is undefined or an empty string */ createCall: (destination: string, settings?: CallSettings) => Call; /** * Returns a map of actual calls with their ids. */ getCalls: () => Map; /** * Transfers a call. * * Returns a promise that is resolved when the call transfer is completed successfully. * * @throws * - [Call.Errors.CallNotFoundError] — if there are no call(s) with the provided call ids * - [Call.Errors.CallWrongStateError] — if the call(s) with the provided id is not in the [Call.CallState.Connected] state * - [Call.Errors.CallTransferTimeoutError] — if the operation is not completed in time * - [Call.Errors.CallTransferFailedError] — if the operation has failed * * @param call1Id Call to transfer * @param call2Id Destination call where the call1 needs to be transferred */ transferCall: (call1Id: Call["id"], call2Id: Call["id"]) => Promise; /** * @reinterpret Call.DocCallManagerAddEventListener */ addEventListener: AddEventListener; /** * @reinterpret Call.DocCallManagerRemoveEventListener */ removeEventListener: RemoveEventListener; } /** * @hidden */ export declare class CallManagerImpl extends BaseModuleImpl implements CallManager { private readonly logger?; private readonly connection; private readonly calls; private readonly onICEConfigServers; addEventListener: AddEventListener; removeEventListener: RemoveEventListener; private readonly dispatchEvent; constructor(initModuleOptions: InitModuleOptions); createCall(destination: string, settings?: CallSettings): Call; getCalls(): Map; transferCall(call1Id: Call["id"], call2Id: Call["id"]): Promise; private addCallListeners; private holdOtherCalls; private subscribeEvents; private handleConnectionConnected; private handleConnectionFailed; private handleConnectionDisconnected; private handleRingOut; private handleStopRinging; private handleStartEarlyMedia; private handleIncomingConnection; handleSipInfo(event: HandleSIPInfo): Promise; private handleOnICEConfig; private handleReInvite; private handleAcceptReInvite; private deleteCall; } export declare const callToken: Token; /** * @function */ export declare const CallLoader: ModuleFactory; /** * Thrown if a call specified by the call id does not exist. * * @folder Errors * @hideconstructor */ export declare class CallNotFoundError extends WebSDKError { constructor(callId: string); } /** * Thrown if a call transfer has failed. * * @folder Errors * @hideconstructor */ export declare class CallTransferFailedError extends WebSDKError { constructor(reason?: string); } /** * Thrown if a call transfer has not been completed in time. * * @folder Errors * @hideconstructor */ export declare class CallTransferTimeoutError extends WebSDKError { constructor(); } export {};