type ObjectKey = string | number | symbol; type EmptyObject = Record; type MediaId = string; type BaseMediaKind = "audio" | "video"; 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 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 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; } 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); } type ShortLogFunction = (...message: unknown[]) => void; type ScopedLogger = Record<"info" | "debug" | "warn" | "error", ShortLogFunction>; interface SDPService { createOffer: (options?: RTCOfferOptions) => Promise; createAnswer: (options?: RTCAnswerOptions) => Promise; setLocalDescription: (description?: RTCSessionDescriptionInit) => Promise; setRemoteDescription: (description: RTCSessionDescriptionInit) => Promise; getLocalDescription: () => RTCSessionDescription; remoteDescriptionSettled: Promise; getRemoteDescription: () => RTCSessionDescription; configurePreferredVideoCodec: (codec: VideoCodec) => void; } interface TransceiverService { addTransceiver: (trackOrKind: MediaStreamTrack | BaseMediaKind, direction: RTCRtpTransceiverDirection) => RTCRtpTransceiver; replaceTransceiver: (transceiver: RTCRtpTransceiver, track: MediaStreamTrack, direction: RTCRtpTransceiverDirection) => RTCRtpTransceiver; resetSimulcastLayers: (stream: Stream) => Promise; getReceivingTransceiversByKind: (kind: BaseMediaKind) => RTCRtpTransceiver[]; getSendingTransceiversByKind: (kind: BaseMediaKind) => RTCRtpTransceiver[]; getAllTransceivers: () => RTCRtpTransceiver[]; changeDirection: (transceiver: RTCRtpTransceiver, direction: RTCRtpTransceiverDirection) => void; replaceTrack: (transceiver: RTCRtpTransceiver, track: MediaStreamTrack | null) => Promise; findTransceiverByLocalStream: (stream: Stream) => RTCRtpTransceiver | null; findTransceiverByRemoteStream: (stream: RemoteStream) => RTCRtpTransceiver | null; isStreamSending: (stream: Stream) => boolean; } type Mids = Record; interface MidData { mids: Mids; } interface UnholdTransceiversOptions { isLocalAudioDisabled: boolean; } interface OutgoingCallStartOptions { receiveVideo: boolean; } interface IncomingCallStartOptions { incomingRemoteSdp: string; receiveVideo: boolean; preferredVideoCodec?: VideoCodec; } interface PeerConnection { readonly state: Watchable; restartIce: () => void; lastTrackEvent: Watchable; transceiverService: TransceiverService; sdpService: SDPService; setRemoteIceCandidates: (candidatesOfferRaw: string) => Promise; setIceServers: (iceServers: RTCIceServer[]) => void; conferenceStart: (direction?: RTCRtpTransceiverDirection) => Promise; outgoingCallStart: (options: OutgoingCallStartOptions) => Promise; incomingCallStart: (options: IncomingCallStartOptions) => Promise; stop: () => void; addTransceiver: (trackOrKind: MediaStreamTrack | BaseMediaKind, direction: RTCRtpTransceiverDirection, type: StreamType) => RTCRtpTransceiver; replaceTransceiver: (oldTransceiver: RTCRtpTransceiver, track: MediaStreamTrack, direction: RTCRtpTransceiverDirection) => RTCRtpTransceiver; getMidData: () => MidData; findEmptyVideoTransceiver: () => RTCRtpTransceiver | null; getStatistics: () => Promise; resetSimulcastLayers: () => Promise; sendDtmf: (tones: string) => void; addStream: (stream: LocalStream) => void; removeStream: (stream: LocalStream) => void; replaceStream: (newStream: LocalStream, oldStream?: LocalStream) => void; saveTransceiverByStream: (stream: LocalStream) => void; disableTransceiverByStream: (stream: LocalStream, receiveVideo?: boolean) => Promise; stopTransceiverByStream: (stream: LocalStream) => void; replaceStreamInTransceivers: (newStream: LocalStream, oldStream?: LocalStream) => Promise; holdTransceivers: () => void; unholdTransceivers: (options: UnholdTransceiversOptions) => void; } declare global { interface Navigator { getBattery?: () => Promise; } } interface BatteryManager extends EventTarget { level: number; charging: boolean; chargingTime: number; dischargingTime: number; } interface BatteryInfo { exists: boolean; level: number; charging: boolean; energySaving: boolean; } interface Battery { get exists(): boolean; get info(): BatteryInfo; init: () => Promise; readonly level: Watchable; readonly charging: Watchable; readonly energySaving: Watchable; } interface SDPService$1 { createOffer: (options?: RTCOfferOptions) => Promise; createAnswer: (options?: RTCAnswerOptions) => Promise; setLocalDescription: (description?: RTCSessionDescriptionInit) => Promise; setRemoteDescription: (description: RTCSessionDescriptionInit) => Promise; getLocalDescription: () => RTCSessionDescription; remoteDescriptionSettled: Promise; getRemoteDescription: () => RTCSessionDescription; configurePreferredVideoCodec: (codec: VideoCodec) => void; } interface TransceiverService$1 { addTransceiver: (trackOrKind: MediaStreamTrack | BaseMediaKind, direction: RTCRtpTransceiverDirection) => RTCRtpTransceiver; replaceTransceiver: (transceiver: RTCRtpTransceiver, track: MediaStreamTrack, direction: RTCRtpTransceiverDirection) => RTCRtpTransceiver; resetSimulcastLayers: (stream: Stream) => Promise; getReceivingTransceiversByKind: (kind: BaseMediaKind) => RTCRtpTransceiver[]; getSendingTransceiversByKind: (kind: BaseMediaKind) => RTCRtpTransceiver[]; getAllTransceivers: () => RTCRtpTransceiver[]; changeDirection: (transceiver: RTCRtpTransceiver, direction: RTCRtpTransceiverDirection) => void; replaceTrack: (transceiver: RTCRtpTransceiver, track: MediaStreamTrack | null) => Promise; findTransceiverByLocalStream: (stream: Stream) => RTCRtpTransceiver | null; findTransceiverByRemoteStream: (stream: RemoteStream) => RTCRtpTransceiver | null; isStreamSending: (stream: Stream) => boolean; } type Mids$1 = Record; interface MidData$1 { mids: Mids$1; } interface UnholdTransceiversOptions$1 { isLocalAudioDisabled: boolean; } interface OutgoingCallStartOptions$1 { receiveVideo: boolean; } interface IncomingCallStartOptions$1 { incomingRemoteSdp: string; receiveVideo: boolean; preferredVideoCodec?: VideoCodec; } interface PeerConnection$1 { readonly state: Watchable; restartIce: () => void; lastTrackEvent: Watchable; transceiverService: TransceiverService$1; sdpService: SDPService$1; setRemoteIceCandidates: (candidatesOfferRaw: string) => Promise; setIceServers: (iceServers: RTCIceServer[]) => void; conferenceStart: (direction?: RTCRtpTransceiverDirection) => Promise; outgoingCallStart: (options: OutgoingCallStartOptions$1) => Promise; incomingCallStart: (options: IncomingCallStartOptions$1) => Promise; stop: () => void; addTransceiver: (trackOrKind: MediaStreamTrack | BaseMediaKind, direction: RTCRtpTransceiverDirection, type: StreamType) => RTCRtpTransceiver; replaceTransceiver: (oldTransceiver: RTCRtpTransceiver, track: MediaStreamTrack, direction: RTCRtpTransceiverDirection) => RTCRtpTransceiver; getMidData: () => MidData$1; findEmptyVideoTransceiver: () => RTCRtpTransceiver | null; getStatistics: () => Promise; resetSimulcastLayers: () => Promise; sendDtmf: (tones: string) => void; addStream: (stream: LocalStream) => void; removeStream: (stream: LocalStream) => void; replaceStream: (newStream: LocalStream, oldStream?: LocalStream) => void; saveTransceiverByStream: (stream: LocalStream) => void; disableTransceiverByStream: (stream: LocalStream, receiveVideo?: boolean) => Promise; stopTransceiverByStream: (stream: LocalStream) => void; replaceStreamInTransceivers: (newStream: LocalStream, oldStream?: LocalStream) => Promise; holdTransceivers: () => void; unholdTransceivers: (options: UnholdTransceiversOptions$1) => void; } /** * Interface that represents statistics for all active outgoing audio streams. */ export 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; } /** * Statistics for the video stream layers. */ export 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 that represents statistics for an outgoing local video stream. */ export 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 that represents statistics for incoming audio streams. */ export 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 that represents statistics for incoming video streams. */ export 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 that represents the media connectivity statistics. */ export 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 that represents local audio streams reports by a local audio stream id. */ export type LocalAudioStreamStatsReport = Record; /** * Type that represents local video streams reports by a local video stream id. */ export type LocalVideoStreamStatsReport = Record; /** * Type that represents remote audio streams reports by a remote audio stream id. */ export type RemoteAudioStreamStatsReport = Record; /** * Type that represents remote video streams reports by a remote video stream id. */ export type RemoteVideoStreamStatsReport = Record; /** * Interface that represents a statistics report. */ export interface StatisticsReport { /** * 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; }; } /** * @hidden */ export interface Statistics extends BaseModule { report: (pc: PeerConnection$1, screenSharingPC: PeerConnection$1 | null) => Promise; } /** * @hidden */ export declare class StatisticsImpl extends BaseModuleImpl implements Statistics { private readonly logger?; private readonly strategy; constructor(initModuleOptions: InitModuleOptions); private getMidToTrackId; report(pc: PeerConnection, screenSharingPC: PeerConnection | null): Promise; private getRawTrackTypes; } /** * @hidden */ export declare const StatisticsLoader: ModuleFactory; /** * @hidden */ export declare const statisticsToken: Token; /** * @hidden */ export declare const createReadableStats: (stats: StatisticsReport) => StatisticsReport; /** * @hidden */ export type StatsReportInterval = number; /** * @hidden */ export interface OptionalStatisticsReporterSettings { reportStats?: boolean; statsReportInterval?: StatsReportInterval; } /** * @hidden */ export interface StatisticsReporterSettings { reportStats: boolean; statsReportInterval: StatsReportInterval; logDelay: number; } /** * @hidden */ export interface OnStatisticsReportOptions { forceLog?: boolean; } /** * @hidden */ export interface StatisticsReporterOptions { pc: PeerConnection; settings: OptionalStatisticsReporterSettings; } /** * @hidden */ export interface StatisticsReporter { readonly settings: StatisticsReporterSettings; register: () => void; unregister: () => Promise; onReport?: (stats: StatisticsReport, options?: OnStatisticsReportOptions) => void; setScreenSharingPC: (pc: PeerConnection | null) => void; } /** * @hidden */ export declare class StatisticsReporterImpl implements StatisticsReporter { private pc; private readonly battery; private readonly logger?; private readonly statistics?; private readonly isMobile; private screenSharingPC; private registeredInterval; readonly settings: StatisticsReporterSettings; readonly onReport?: (stats: StatisticsReport, options?: OnStatisticsReportOptions) => void; constructor(options: StatisticsReporterOptions, container?: Container); register(): void; unregister(): Promise; private report; private get intervalToUse(); private initBattery; private updateInterval; setScreenSharingPC(pc: PeerConnection | null): void; } /** * @hidden */ export declare enum StatisticsReportInterval { Min = 500, Default = 1000, LowBattery = 10000 } /** * @hidden */ export declare const STATISTICS_LOG_MIN_DELAY = 5000; /** * @hidden */ export declare const roundStatsInterval: (interval: StatsReportInterval) => StatsReportInterval; /** * @hidden */ export declare const getStatsReportInterval: (interval: StatsReportInterval | undefined, logger?: ScopedLogger) => StatsReportInterval; /** * @hidden */ export declare const parseStatisticsReporterSettings: (settings: OptionalStatisticsReporterSettings, logger?: ScopedLogger) => StatisticsReporterSettings; /** * @hidden */ export declare const isEnergySavingInterval: (battery: Battery, isMobile: boolean) => boolean; export {};