type ObjectKey = string | number | symbol; type EmptyObject = Record; type UUID = string; type MediaId = string; type Type = string; type SubType = string; type CommonMIMEType = `${Type}/${SubType}`; type MIMEType = T; /** * Enum that represents the simulcast layers. */ export 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; 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 conference. */ export declare enum ConferenceState { /** * Conference has been created */ Created = "CREATED", /** * Conference is connecting */ Connecting = "CONNECTING", /** * Conference is connected */ Connected = "CONNECTED", /** * Conference is reconnecting after a failure */ Reconnecting = "RECONNECTING", /** * Conference is disconnecting */ Disconnecting = "DISCONNECTING", /** * Conference has been disconnected */ Disconnected = "DISCONNECTED", /** * Conference 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); } 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; type StatsReportInterval = number; declare global { interface Navigator { getBattery?: () => Promise; } } interface BatteryManager extends EventTarget { level: number; charging: boolean; chargingTime: number; dischargingTime: number; } 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 MediaDiff { removedMids: MediaId[]; addedMids: MediaId[]; } /** * Enum that contains reasons why receiving video on the remote video stream has been stopped. */ export declare enum StreamReceiveStopReason { /** * Receiving video on a remote video stream is stopped by the Voximplant Cloud due to a network issue on the device. */ Automatic = "Automatic", /** * Receiving audio or video on a remote stream is stopped by the client via the [Conference.Endpoint.stopReceivingAudio] * or [Conference.Endpoint.stopReceivingVideo] method. */ Manual = "Manual" } /** * @interface * @internal * * Registers a handler for the specified event. * * One event can have more than one handler; handlers are executed in order of registration. */ export type DocEndpointAddEventListener = ( /** * Event name */ eventName: EndpointEvent, /** * Handler function that is triggered when an event of the specified type occurs */ listener: (event: AnyEndpointEvent) => 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 DocEndpointRemoveEventListener = ( /** * Event name */ eventName: EndpointEvent, /** * Handler function to remove from the event target */ listener: (event: AnyEndpointEvent) => void | Promise) => void; /** * Interface that represents a remote participant in a conference. */ export interface Endpoint { /** * Endpoint id. */ id: string; /** * Endpoint user name. */ userName: string; /** * Endpoint user display name. */ displayName: string; /** * Watchable property that allows getting the voice activity status of the remote participant and observing its changes. */ voiceActivityDetected: Watchable; /** * Watchable property that allows getting the remote participant mute status and observing its changes. */ isMicrophoneMuted: Watchable; /** * Whether the endpoint represents the remote participant screen sharing. */ isScreenSharing: boolean; /** * Map of the remote audio and video streams associated with the endpoint. */ streams: Map; /** * @hidden */ midData: Map; /** * Returns array of the remote audio streams associated with the endpoint. */ getAudioStreams: () => RemoteStream[]; /** * Returns the array of the remote video streams associated with the endpoint. */ getVideoStreams: () => RemoteStream[]; /** * Returns the array of the screen sharing video streams associated with the endpoint. */ getScreenSharingStreams: () => RemoteStream[]; /** * Returns the array of all the remote audio streams associated with the endpoint. */ getAnyAudioStreams: () => RemoteStream[]; /** * Returns the array of all the remote audio streams associated with the endpoint. */ getAnyVideoStreams: () => RemoteStream[]; /** * Starts receiving video from the endpoint. * * If the video has been already receiving, this method call is ignored. * * If the request is processed successfully, the [Conference.EndpointEvents.EndpointEvent.StartReceivingVideoStream] event is triggered. */ startReceivingVideo: () => void; /** * Stops receiving video from the endpoint. * * If the request is processed successfully, the [Conference.EndpointEvents.EndpointEvent.StopReceivingVideoStream] event is triggered * with the [Conference.StreamReceiveStopReason.Manual] reason. */ stopReceivingVideo: () => void; /** * Starts receiving audio from the endpoint. * * If the video has been already receiving, this method call is ignored. * * If the request is processed successfully, the [Conference.EndpointEvents.EndpointEvent.StartReceivingAudioStream] event is triggered. */ startReceivingAudio: () => void; /** * Stops receiving audio from the endpoint. * * If the request is processed successfully, the [Conference.EndpointEvents.EndpointEvent.StopReceivingAudioStream] event is triggered * with the [Conference.StreamReceiveStopReason.Manual] reason. */ stopReceivingAudio: () => void; /** * Requests the specified video size for a remote video stream. * * The stream resolution may be changed to the closest to the specified width and height. * * It only makes an impact if the endpoint has enabled the simulcast feature. * * @param width Requested video frame width * @param height Requested video frame height */ requestVideoSize: (width: number, height: number) => void; /** * @hidden */ addMidData: (mid: MediaId, kind: StreamType) => void; /** * @hidden */ updateMidData: (mids: Record) => void; /** * @hidden */ addMedia: (track: MediaStreamTrack, mid: MediaId) => RemoteStream; /** * @hidden */ removeMedia: (mid: MediaId) => RemoteStream; /** * @hidden */ diffMids: (mids: MediaId[]) => MediaDiff; /** * @reinterpret Conference.DocEndpointAddEventListener */ addEventListener: AddEventListener; /** * @reinterpret Conference.DocEndpointRemoveEventListener */ removeEventListener: RemoveEventListener; } /** * @folder EndpointEvents */ export declare enum EndpointEvent { /** * Triggered after an endpoint has added an audio or video stream. * * Listener is called with [Conference.EndpointEvents.EndpointRemoteMediaAdded] and payload: * @cast Conference.EndpointEvents.EndpointRemoteMediaAddedPayload */ RemoteMediaAdded = "RemoteMediaAdded", /** * Triggered after an endpoint has removed an audio or video stream. * * Listener is called with [Conference.EndpointEvents.EndpointRemoteMediaRemoved] and payload: * @cast Conference.EndpointEvents.EndpointRemoteMediaRemovedPayload */ RemoteMediaRemoved = "RemoteMediaRemoved", /** * Triggered when receiving video on a remote video stream is started after previously being stopped. * * Listener is called with [Conference.EndpointEvents.EndpointStartReceivingAudioStream] and payload: * @cast Conference.EndpointEvents.EndpointStartReceivingAudioStreamPayload */ StartReceivingAudioStream = "StartReceivingAudioStream", /** * Triggered when receiving audio on a remote audio stream is stopped. * * Listener is called with [Conference.EndpointEvents.EndpointStopReceivingAudioStream] and payload: * @cast Conference.EndpointEvents.EndpointStopReceivingAudioStreamPayload */ StopReceivingAudioStream = "StopReceivingAudioStream", /** * Triggered when receiving video on a remote video stream is started after previously being stopped. * * The event is triggered if: * - [Conference.Endpoint.startReceivingVideo] has been called and the request has been processed successfully. * - A network issue that caused the Voximplant Cloud to stop receiving video of the remote video stream is gone. * * The event is not triggered if the endpoint client has started sending video via the [Conference.Conference.addStream] API. * * Listener is called with [Conference.EndpointEvents.EndpointStartReceivingVideoStream] and payload: * @cast Conference.EndpointEvents.EndpointStartReceivingVideoStreamPayload */ StartReceivingVideoStream = "StartReceivingVideoStream", /** * Triggered when receiving video on a remote video stream is stopped. * * Receiving video on a remote video stream can be stopped due to: * - [Conference.Endpoint.stopReceivingVideo] has been called and the request has been processed successfully. In this case * the value of the “reason” parameter is [Conference.StreamReceiveStopReason.Manual]. * - Voximplant Cloud has detected a network issue on the client and automatically stopped the video. In this case * the value of the “reason” parameter is [Conference.StreamReceiveStopReason.Automatic]. * * If the receiving video is disabled automatically, it may be automatically enabled as soon as the network condition * on the device is good and there is enough bandwidth to receive the video on this remote video stream. * In this case [Conference.EndpointEvents.EndpointEvent.StartReceivingVideoStream] event is triggered. * * The event is not triggered if the endpoint client has stopped sending video via * the [Conference.Conference.removeStream] API. * * Listener is called with [Conference.EndpointEvents.EndpointStopReceivingVideoStream] and payload: * @cast Conference.EndpointEvents.EndpointStopReceivingVideoStreamPayload */ StopReceivingVideoStream = "StopReceivingVideoStream" } /** * @hidden */ export interface BaseEndpointEvent extends BaseBusEvent { name: Name; payload: Payload; } /** * @interface * @folder EndpointEvents */ export interface EndpointRemoteMediaAddedPayload { /** * Endpoint id. */ endpointId: Endpoint["id"]; /** * Remote audio or video stream. */ stream: RemoteStream; /** * Remote stream type. */ type: StreamType; } /** * @interface * @folder EndpointEvents */ export type EndpointRemoteMediaAdded = BaseEndpointEvent; /** * @interface * @folder EndpointEvents */ export interface EndpointRemoteMediaRemovedPayload { /** * Endpoint id. */ endpointId: Endpoint["id"]; /** * Remote audio or video stream. */ stream: RemoteStream; /** * Remote stream type. */ type: StreamType; } /** * @interface * @folder EndpointEvents */ export type EndpointRemoteMediaRemoved = BaseEndpointEvent; /** * @interface * @folder EndpointEvents */ export interface EndpointStartReceivingAudioStreamPayload { /** * Endpoint id. */ endpointId: Endpoint["id"]; /** * Remote audio stream id. */ streamId: RemoteStream["id"]; } /** * @interface * @folder EndpointEvents */ export type EndpointStartReceivingAudioStream = BaseEndpointEvent; /** * @interface * @folder EndpointEvents */ export interface EndpointStopReceivingAudioStreamPayload { /** * Endpoint id. */ endpointId: Endpoint["id"]; /** * Remote audio stream id. */ streamId: RemoteStream["id"]; /** * Reason for the event, such as receiving audio, is disabled by the client or automatically. */ reason: StreamReceiveStopReason; } /** * @interface * @folder EndpointEvents */ export type EndpointStopReceivingAudioStream = BaseEndpointEvent; /** * @interface * @folder EndpointEvents */ export interface EndpointStartReceivingVideoStreamPayload { /** * Endpoint id. */ endpointId: Endpoint["id"]; /** * Remote video stream id. */ streamId: RemoteStream["id"]; } /** * @interface * @folder EndpointEvents */ export type EndpointStartReceivingVideoStream = BaseEndpointEvent; /** * @interface * @folder EndpointEvents */ export interface EndpointStopReceivingVideoStreamPayload { /** * Endpoint id. */ endpointId: Endpoint["id"]; /** * Remote video stream id. */ streamId: RemoteStream["id"]; /** * Reason for the event, such as receiving video, is disabled by the client or automatically. */ reason: StreamReceiveStopReason; } /** * @interface * @folder EndpointEvents */ export type EndpointStopReceivingVideoStream = BaseEndpointEvent; /** * Type that the union of all endpoint events. * * @folder EndpointEvents */ export type AnyEndpointEvent = EndpointRemoteMediaAdded | EndpointRemoteMediaRemoved | EndpointStartReceivingAudioStream | EndpointStopReceivingAudioStream | EndpointStartReceivingVideoStream | EndpointStopReceivingVideoStream; /** * Enum that represents the reason why screen sharing has failed in a conference. */ export declare enum ScreenSharingFailedCode { /** * Internal error. */ Internal = 500, /** * Screen sharing frames are not sent due to a network connection problem. */ NetworkIssues = 503 } /** * @folder Events * @event */ export declare enum ConferenceEvent { /** * Triggered after a conference has been successfully connected. * * Listener is called with [Conference.Events.ConferenceConnected] and payload: * @cast Conference.Events.ConferenceConnectedPayload */ Connected = "Connected", /** * Triggered if a conference has failed. * * Listener is called with [Conference.Events.ConferenceFailed] and payload: * @cast Conference.Events.ConferenceFailedPayload */ Failed = "Failed", /** * Triggered after a conference has been disconnected. * * Listener is called with [Conference.Events.ConferenceDisconnected] and payload: * @cast Conference.Events.ConferenceDisconnectedPayload */ Disconnected = "Disconnected", /** * Triggered after an endpoint is added to a conference. * * Listener is called with [Conference.Events.ConferenceEndpointAddedPayload] and payload: * @cast Conference.Events.ConferenceEndpointAddedPayload */ EndpointAdded = "EndpointAdded", /** * Triggered after the endpoint is removed from a conference. * * Listener is called with [Conference.Events.ConferenceEndpointRemoved] and payload: * @cast Conference.Events.ConferenceEndpointRemovedPayload */ EndpointRemoved = "EndpointRemoved", /** * Triggered when an INFO message is received within a conference. * * Listener is called with [Conference.Events.ConferenceInfoReceived] and payload: * @cast Conference.Events.ConferenceInfoReceivedPayload */ InfoReceived = "InfoReceived", /** * Triggered when a message is received within a conference. * * Listener is called with [Conference.Events.ConferenceMessageReceived] and payload: * @cast Conference.Events.ConferenceMessageReceivedPayload */ MessageReceived = "MessageReceived", /** * Triggered when conference statistics are available for a conference. * * Listener is called with [Conference.Events.ConferenceStatsReport] and payload: * @cast Conference.Events.ConferenceStatsReportPayload */ StatsReport = "StatsReport", /** * Triggered when screen sharing has started in a conference. * * Listener is called with [Conference.Events.ConferenceScreenSharingStarted] and payload: * @cast Conference.Events.ConferenceScreenSharingStartedPayload */ ScreenSharingStarted = "ScreenSharingStarted", /** * Triggered when screen sharing has failed to start in a conference. * * Listener is called with [Conference.Events.ConferenceScreenSharingFailed] and payload: * @cast Conference.Events.ConferenceScreenSharingFailedPayload */ ScreenSharingFailed = "ScreenSharingFailed" } /** * @hidden */ export interface BaseConferenceEvent extends BaseBusEvent { name: Name; payload: Payload; } /** * @folder Events */ export interface ConferenceConnectedPayload { /** * Conference id */ conferenceId: UUID; /** * Optional headers passed with the event */ headers?: Record; } /** * @interface * @folder Events */ export type ConferenceConnected = BaseConferenceEvent; /** * @folder Events */ export interface ConferenceFailedPayload { /** * Conference id */ conferenceId: UUID; /** * Optional headers passed with the event */ headers?: Record; /** * Conference status code */ code: number; /** * Conference failure reason */ reason: string; } /** * @interface * @folder Events */ export type ConferenceFailed = BaseConferenceEvent; /** * Enum that contains reasons why a conference has been ended. * * @folder Events */ export declare enum ConferenceDisconnectReason { /** * Local party has explicitly ended a conference. */ LocalEnded = "LOCAL_ENDED", /** * Conference has ended by a VoxEngine scenario. */ RemoteEnded = "REMOTE_ENDED", /** * Connection to the Voximplant Cloud has lost and cannot recover during a conference. */ ConnectionLost = "CONNECTION_LOST" } /** * @folder Events */ export interface ConferenceDisconnectedPayload { /** * Conference id */ conferenceId: UUID; /** * Optional headers passed with the event */ headers?: Record; /** * Reason that the conference ended with */ reason: ConferenceDisconnectReason; } /** * @interface * @folder Events */ export type ConferenceDisconnected = BaseConferenceEvent; /** * @folder Events */ export interface ConferenceEndpointAddedPayload { /** * Conference id */ conferenceId: UUID; /** * Endpoint id */ newEndpointId: Endpoint["id"]; } /** * @interface * @folder Events */ export type ConferenceEndpointAdded = BaseConferenceEvent; /** * @folder Events */ export interface ConferenceEndpointRemovedPayload { /** * Conference id */ conferenceId: UUID; /** * Endpoint id */ removedEndpointId: Endpoint["id"]; } /** * @interface * @folder Events */ export type ConferenceEndpointRemoved = BaseConferenceEvent; /** * @folder Events */ export interface ConferenceInfoReceivedPayload { /** * Conference id */ conferenceId: 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 Events */ export type ConferenceInfoReceived = BaseConferenceEvent; /** * @folder Events */ export interface ConferenceMessageReceivedPayload { /** * Conference id */ conferenceId: UUID; /** * Content of the message */ text: string; } /** * @interface * @folder Events */ export type ConferenceMessageReceived = BaseConferenceEvent; /** * @folder Events */ export interface ConferenceStatsReportPayload { /** * Time at which the conference 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 conference at the moment of the statistics collection */ localAudio: LocalAudioStreamStatsReport; /** * Statistics for all active outgoing video streams in a conference at the moment of the statistics collection */ localVideo: LocalVideoStreamStatsReport; /** * Endpoint statistics */ remote: Record; } /** * @interface * @folder Events */ export type ConferenceStatsReport = BaseConferenceEvent; /** * @folder Events */ export interface ConferenceScreenSharingFailedPayload { conferenceId: UUID; /** * Conference screen sharing status code */ code: ScreenSharingFailedCode; /** * Conference screen sharing failure reason */ reason: string; } /** * @interface * @folder Events */ export type ConferenceScreenSharingFailed = BaseConferenceEvent; /** * @folder Events */ export interface ConferenceScreenSharingStartedPayload { /** * Conference id */ conferenceId: UUID; } /** * @interface * @folder Events */ export type ConferenceScreenSharingStarted = BaseConferenceEvent; /** * Type that the union of all conference events. * * @folder Events */ export type AnyConferenceEvent = ConferenceConnected | ConferenceFailed | ConferenceDisconnected | ConferenceEndpointAdded | ConferenceEndpointRemoved | ConferenceInfoReceived | ConferenceMessageReceived | ConferenceStatsReport | ConferenceScreenSharingStarted | ConferenceScreenSharingFailed; /** * @interface * @internal * * Registers a handler for the specified event. * * One event can have more than one handler; handlers are executed in order of registration. */ export type DocConferenceAddEventListener = ( /** * Event name */ eventName: ConferenceEvent, /** * Handler function that is triggered when an event of the specified type occurs */ listener: (event: AnyConferenceEvent) => 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 DocConferenceRemoveEventListener = ( /** * Event name */ eventName: ConferenceEvent, /** * Handler function to remove from the event target */ listener: (event: AnyConferenceEvent) => void | Promise) => void; export interface Conference { /** * Conference id. */ readonly id: UUID; /** * Whether the simulcast feature is enabled in the conference call. */ readonly isSimulcast: boolean; /** * Conference endpoint id of this client. */ endpointId: ReadonlyWatchable; /** * Conference name. */ readonly conferenceName: string; /** * Watchable property that allows getting the current conference state and observing its changes. */ state: ReadonlyWatchable; /** * Watchable property that allows getting the local audio and video streams that are currently being sent. */ localStreams: ReadonlyWatchable>; /** * Watchable property that allows getting the array of the endpoints associated with the conference and observing * its changes. */ endpoints: ReadonlyWatchable>; /** * Watchable property that allows getting the voice activity status of the current user and observing its changes. */ voiceActivityDetected: ReadonlyWatchable; /** * Conference duration in milliseconds. */ get duration(): number; /** * @reinterpret Conference.DocConferenceAddEventListener */ addEventListener: AddEventListener; /** * @reinterpret Conference.DocConferenceRemoveEventListener */ removeEventListener: RemoveEventListener; /** * Joins a conference. * * Returns a promise that is resolved if the conference connection process has started successfully. A resolved promise * does not mean that the conference is connected. You should subscribe to [Conference.Events.ConferenceEvent.Connected] * to be notified that the current user has joined the conference. */ join: () => Promise; /** * Terminates the conference on the current user. * * @param headers Optional set of headers to be sent. Names should begin with “X-” to be processed by the SDK. */ hangup: (headers?: Record) => void; /** * Watchable property that allows getting the screen sharing sending status and observing its changes. */ hasScreenSharing: ReadonlyWatchable; /** * Starts sending a screen sharing stream to the conference. * * Other conference participants receive the [Conference.Events.ConferenceEvent.EndpointAdded] event. * * @param stream Array of screen sharing streams * @throws [Conference.Errors.ConferenceWrongStateError] if the conference is not in the [Conference.ConferenceState.Connected] state */ startScreenSharing: (stream: LocalScreenSharingStream[]) => Promise; /** * Stops sending a screen sharing stream to the conference. */ stopScreenSharing: () => void; /** * Watchable property that allows getting the audio mute status and observing its changes. */ isMicrophoneMuted: ReadonlyWatchable; /** * Mutes the audio in the conference. */ muteMicrophone: () => void; /** * Unmutes the audio in the conference. */ unmuteMicrophone: () => void; /** * Sends an INFO message within the conference. * * @param mimeType MIME type of the info * @param body Custom string data * @param extraHeaders 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, extraHeaders?: Record) => void; /** * Sends a message within the conference. * * Implemented atop of SIP INFO for communication between the conference endpoint and the Voximplant Cloud, * and is separated from Voximplant messaging API. * @param message Message text */ sendMessage: (message: string) => void; /** * Starts sending an audio or video stream to the conference. * * Returns a promise that is resolved when the operation is completed. * * @throws * • [Conference.Errors.ConferenceWrongStateError] if the conference is in [Conference.ConferenceState.Failed], * [Conference.ConferenceState.Disconnecting], or [Conference.ConferenceState.Disconnected] state * * * • [Core.SharedErrors.StreamUpdateFailedError] if the operation has failed * * * • [Core.SharedErrors.InactiveStreamError] if the stream is not active * * @param stream Audio or video stream */ addStream: (stream: LocalStream) => Promise; /** * Stops sending audio or video stream to the conference. * * Returns a promise that is resolved when the operation is completed. * * @throws * • [Conference.Errors.ConferenceWrongStateError] if the conference is in [Conference.ConferenceState.Failed], * [Conference.ConferenceState.Disconnecting], or [Conference.ConferenceState.Disconnected] state * * * • [Core.SharedErrors.StreamUpdateFailedError] if the operation has failed * * @param stream Audio or video stream */ removeStream: (stream: LocalStream) => Promise; /** * Replaces the local audio or video stream that is currently being sent to the conference with another local audio or video stream. * * Returns a promise that is resolved when the operation is completed. * * @throws * • [Conference.Errors.ConferenceWrongStateError] if the conference is in [Conference.ConferenceState.Failed], * [Conference.ConferenceState.Disconnecting], or [Conference.ConferenceState.Disconnected] state * * * • [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 newStream New local stream * @param oldStream Stream to replace */ replaceStream: (newStream: LocalStream, oldStream?: LocalStream) => Promise; } /** * Conference settings with additional conference parameters, such as the preferred video codec, custom data, extra headers, etc. */ export interface ConferenceSettings { /** * Сonference name. For SIP compatibility reasons it should be a non-empty string. */ conferenceName: string; /** * 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; /** * Whether the audio should be muted when the user joins a conference. */ muteAudio?: boolean; /** * Conference 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 [Conference.Events.ConferenceEvent.StatsReport] event, [Conference.ConferenceSettings.reportStats] should be set to true. */ statsReportInterval?: StatsReportInterval; /** * Whether the [Conference.Events.ConferenceStatsReport] event should be triggered for a call. * * The default value is false. */ reportStats?: boolean; /** * Whether the simulcast feature is enabled in a conference call. * * Applicable only for video conferences. * * The default value is true. */ simulcast?: boolean; /** * Preferred video codec for a particular call that these settings are applied to. * * The default value is [Core.VideoCodec.Auto]. */ preferredVideoCodec?: VideoCodec; } export interface ConferenceManager extends BaseModule { /** * Creates a conference instance. * * The conference should be than started via the [Conference.Conference.join] method. * * @param settings Conference settings with additional conference parameters, such as preferred video codec, custom data, extra headers, etc. * @throws [Core.SharedErrors.RequiredParameterError] if the conference name is undefined or an empty string */ createConference: (settings: ConferenceSettings) => Conference; /** * Returns a map of actual conferences with their ids. */ getConferences: () => Map; } /** * Thrown if an operation cannot be done because a conference is in an incorrect state. * * @folder Errors * @hideconstructor */ export declare class ConferenceWrongStateError extends WebSDKError { constructor(state: ConferenceState, operation?: string); } /** * Thrown if an internal error has occurred. * * @folder Errors * @hideconstructor */ export declare class ConferenceInternalError extends WebSDKError { constructor(message: string); } /** * @hidden */ export declare class ConferenceManagerImpl extends BaseModuleImpl implements ConferenceManager { private readonly logger?; private readonly conferences; private readonly connection?; constructor(initModuleOptions: InitModuleOptions); createConference(settings: ConferenceSettings): Conference; getConferences(): Map; private addConference; private addConferenceListeners; private subscribeEvents; private handleSipInfo; private handleConnectionConnected; private handleConnectionFailed; private handleConnectionDisconnected; private handleReInvite; } export declare const conferenceToken: Token; /** * @function */ export declare const ConferenceLoader: ModuleFactory; declare enum ScreenSharingState { Created = "CREATED", Starting = "STARTING", Started = "STARTED", Reconnecting = "RECONNECTING", Stopping = "STOPPING", Stopped = "STOPPED", Failed = "FAILED" } /** * Thrown if the screen sharing has failed to start in a conference. * * @folder Errors * @hideconstructor */ export declare class ScreenSharingFailedError extends WebSDKError { constructor(code: number, reason: string); } /** * Thrown if an internal error has occurred while starting the screen sharing in a conference. * * @folder Errors * @hideconstructor */ export declare class ScreenSharingInternalError extends WebSDKError { constructor(message: string); } /** * Thrown if an operation with the screen sharing in a conference has performed in an incorrect state. * * @folder Errors * @hideconstructor */ export declare class ScreenSharingWrongStateError extends WebSDKError { constructor(state: ScreenSharingState, operation?: string); } export {};