UNPKG

@agora-js/media

Version:
1,378 lines (1,309 loc) 236 kB
import { AgoraRTCError } from '@agora-js/shared'; import { CheckVisibleResult } from '@agora-js/shared'; import { ElectronDesktopCapturerSource } from '@agora-js/shared'; import { EventEmitter } from '@agora-js/shared'; import { IAudioProcessor } from 'agora-rte-extension'; import type { IAudioProcessorContext } from 'agora-rte-extension'; import { IBaseProcessor } from 'agora-rte-extension'; import type { IProcessorContext } from 'agora-rte-extension'; import { isElectron } from '@agora-js/shared'; import type { Kind } from 'agora-rte-extension'; import type { NetworkQuality } from '@agora-js/shared'; import type { ProcessorStats } from 'agora-rte-extension'; import { PromiseMutex } from '@agora-js/shared'; import { RequiredOnlyOneOf } from '@agora-js/shared'; import { SDKStore } from '@agora-js/shared'; import { UID } from '@agora-js/shared'; import { Usage } from 'agora-rte-extension'; import type { UsageWithDirection } from 'agora-rte-extension'; export declare const __TRACK_LIST__: Track[]; export declare function addTrack(track: Track): void; export declare interface AgoraRTCCompatibility { /** 是否支持标准的无插件屏幕共享 API */ getDisplayMedia: boolean; /** 是否支持通过 chrome 插件采集屏幕 */ getStreamFromExtension: boolean; /** 是否支持 unified-plan */ supportUnifiedPlan: boolean; /** 是否支持配置最小码率 */ supportMinBitrate: boolean; /** 是否支持修改 RTCRtpSender 的参数 */ supportSetRtpSenderParameters: boolean; /** 浏览器是否支持开启大小流 */ supportDualStream: boolean; /** WebAudio 是否支持输出 MediaStream */ webAudioMediaStreamDest: boolean; /** RTCRtpSender 是否支持 replaceTrack */ supportReplaceTrack: boolean; /** 是否支持 WebGL */ supportWebGL: boolean; /** 是否支持通过 WebAudio 实现回声消除 */ webAudioWithAEC: boolean; /** 是否支持 CanvasCaptureMediaStreamTrack.requestFrame */ supportRequestFrame: boolean; /** 是否支持屏幕共享音频 */ supportShareAudio: boolean; /** 是否支持使用RTCRtpEncodingParameters设置小流参数*/ supportDualStreamEncoding: boolean; /** 是否支持Datachannel*/ supportDataChannel: boolean; /** 是否支持PeerConnection.setConfiguration*/ supportPCSetConfiguration: boolean; /** 是否支持WebRTC Encoded Transform*/ supportWebRTCEncodedTransform: boolean; /** 是否支持WebRTC Insertable Stream */ supportWebRTCInsertableStream: boolean; /** 是否支持requestVideoFrameCallback, 用于计算卡顿率 */ supportRequestVideoFrameCallback: boolean; /** 是否支持WebCrypto */ supportWebCrypto: boolean; } /** * @internal */ declare class AgoraRTCPlayer extends VideoPlayer { private container?; private slot; constructor(config: PlayerConfig); updateConfig(config: PlayerConfig): void; updateVideoTrack(track?: MediaStreamTrack): void; play(sessionId?: string): void; getCurrentFrame(): ImageData; getCurrentFrameToUint8Array(type: string, quality?: number): Promise<ImageTypedData>; destroy(): void; private createElements; private mountedVideoElement; private unmountedVideoElement; protected resetVideoElement(): void; getContainerElement(): HTMLDivElement | undefined; } /** * 当前通话的统计信息,可以通过 [AgoraRTCClient.getRTCStats]{@link IAgoraRTCClient.getRTCStats} 获取。 * @public */ /** @en * Statistics of the call, which can be retrieved by calling [AgoraRTCClient.getRTCStats]{@link IAgoraRTCClient.getRTCStats}. */ export declare interface AgoraRTCStats { /** * 在当前频道内的时长,单位为秒。 */ /** @en * Call duration in seconds. */ Duration: number; /** * 音视频总接收码率,单位为 bps,瞬间值。 */ /** @en * The total bitrate (bps) of the received audio and video, represented by an instantaneous value. */ RecvBitrate: number; /** * 接收字节数,累计值。 */ /** @en * The total number of bytes received, represented by an aggregate value. */ RecvBytes: number; /** * 音视频总发送码率,单位为 bps,瞬间值。 */ /** @en * The total bitrate (bps) of the sent audio and video, represented by an instantaneous value. */ SendBitrate: number; /** * 发送字节数,累计值。 */ /** @en * The total number of bytes sent, represented by an aggregate value. */ SendBytes: number; /** * 通信场景下,该值为当前频道内的用户人数。 * * 直播场景下,如果本地用户为主播,该值为当前频道内的主播人数;如果本地用户为观众,该值为当前频道内的主播人数 + 1。 */ /** @en * The number of users in the channel. * * - Communication profile: The number of users in the channel. * - Live Broadcast profile: * - If the local user is an audience: The number of users in the channel = The number of hosts in the channel + 1. * - If the local user is a host: The number of users in the channel = The number of hosts in the channel. */ UserCount: number; /** * SDK 到声网边缘服务器的 RTT (Round-Trip Time),单位 ms。 */ /** @en * RTT (Round-Trip Time) between the SDK and Agora's edge server, in ms. */ RTT: number; /** * 上行可用带宽估计,单位为 Kbps。 */ /** @en * The estimated bandwidth (Kbps) of the uplink network. */ OutgoingAvailableBandwidth: number; } export declare enum AUDIO_CONTEXT_EVENT { IOS_15_16_INTERRUPTION_START = "ios15_16-interruption-start", IOS_15_16_INTERRUPTION_END = "ios15_16-interruption-end", IOS_INTERRUPTION_START = "ios-interruption-start", IOS_INTERRUPTION_END = "ios-interruption-end", STATE_CHANGE = "state-change" } /** @en * @ignore */ export declare const AUDIO_ENCODER_CONFIG_SETTINGS: { speech_low_quality: AudioEncoderConfiguration; speech_standard: AudioEncoderConfiguration; music_standard: AudioEncoderConfiguration; standard_stereo: AudioEncoderConfiguration; high_quality: AudioEncoderConfiguration; high_quality_stereo: AudioEncoderConfiguration; }; export declare enum AUDIO_TRACK_EVENT { UPDATE_TRACK_SOURCE = "update-track-source" } declare class AudioBufferSource extends AudioSource { private audioBuffer; protected sourceNode?: AudioBufferSourceNode; /** * 开始播放的时间(context 时间) */ private startPlayTime; /** * 开始播放的时间 (buffer 时间) */ private startPlayOffset; /** * 暂停播放的时间 (buffer 时间) */ private pausePlayTime; private options; private currentLoopCount; private currentPlaybackSpeed; set currentState(state: AudioSourceState); get currentState(): AudioSourceState; private _currentState; constructor(buffer: AudioBuffer, options?: AudioSourceOptions); createWebAudioDiagram(): GainNode; get duration(): number; get playbackSpeed(): number; /** * 计算当前播放时间的公式是 * ((当前时间 - 开始播放时间) * 当前播放速度 + 开始播放的 offset)% 总时长 * 如果发现播放被暂停了,返回暂停那一刻记录的 currentTime * 如果发现播放还没开始,返回 0 */ get currentTime(): number; updateOptions(options: AudioSourceOptions): void; startProcessAudioBuffer(): void; /** * AudioSourceNode 并没有提供 pause 方法 * 一个 AudioSourceNode stop 后也不能再 start 了 * 所以只能删掉这个 AudioSourceNode 创建新的来实现 */ pauseProcessAudioBuffer(): void; /** * 同 pause,需要重新创建 AudioSourceNode * @time 单位是秒 */ seekAudioBuffer(time: number): void; /** * 会从暂停的位置开始播放 */ resumeProcessAudioBuffer(): void; stopProcessAudioBuffer(): void; destroy(): void; /** * 与native setAudioMixingPlaybackSpeed对齐,推荐范围[50-400] */ setAudioBufferPlaybackSpeed(speed: number): void; private startSourceNode; private createSourceNode; private handleSourceNodeEnded; private reset; } export declare const audioContextState: AudioState; /** * 理论上来说任何情况下 SDK 都不会使用 <audio> 标签去播放音频,统一使用 WebAudio * * 但是在 Chrome 上,使用 WebAudio 会导致回声消除失效 * * 在找到可行方案之前,仅在这个情况下会使用 <audio> 标签 * https://bugs.chromium.org/p/chromium/issues/detail?id=687574 */ declare class AudioElementPlayCenter { onAutoplayFailed?: () => void; private elementMap; private elementStateMap; private elementsNeedToResume; private sinkIdMap; constructor(); setSinkID(trackId: string, deviceID: string): Promise<void>; play(track: MediaStreamTrack, trackId: string, volume: number, sessionId?: string): void; updateTrack(trackId: string, track: MediaStreamTrack): void; isPlaying(trackId: string): boolean; setVolume(trackId: string, volume: number): void; stop(trackId: string): void; private bindAudioElementEvents; getPlayerState(trackId: string): string; /** * 监听页面事件,自动恢复音频播放 */ private autoResumeAudioElement; autoResumeAfterInterruption: (force?: boolean) => void; private autoResumeAfterInterruptionOnIOS15_16; } export declare const audioElementPlayCenter: AudioElementPlayCenter; /** * 定义音频编码配置的对象。 * * 用于创建音频流时指定自定义的编码配置。 * * 你可以在 [AgoraRTC.createCustomAudioTrack]{@link IAgoraRTC.createCustomAudioTrack}、 * [AgoraRTC.createMicrophoneAudioTrack]{@link IAgoraRTC.createMicrophoneAudioTrack} 或 * [AgoraRTC.createBufferSourceAudioTrack]{@link IAgoraRTC.createBufferSourceAudioTrack} 方法中传入该配置对象来自定义本地音频的编码配置。 */ /** @en * * `AudioEncoderConfiguration` is the interface that defines the audio encoder configurations. * * You can customize the audio encoder configurations when calling [AgoraRTC.createCustomAudioTrack]{@link IAgoraRTC.createCustomAudioTrack}, [AgoraRTC.createMicrophoneAudioTrack]{@link IAgoraRTC.createMicrophoneAudioTrack} or [AgoraRTC.createBufferSourceAudioTrack]{@link IAgoraRTC.createBufferSourceAudioTrack}. */ export declare interface AudioEncoderConfiguration { /** * 音频采样率,单位为 Hz。 */ /** @en * Sample rate of the audio (Hz). */ sampleRate?: number; /** * 音频采样大小。 */ /** @en * Sample size of the audio. */ sampleSize?: number; /** * 是否开启立体声。 */ /** @en * Whether to enable stereo. */ stereo?: boolean; /** * 音频码率,单位为 Kbps。 */ /** @en * Bitrate of the audio (Kbps). */ bitrate?: number; } /** * SDK 预设的 [AudioEncoderConfiguration]{@link AudioEncoderConfiguration} 配置。 * * 你可以在以下方法中传入预设值来控制本地音频的编码配置: * - [AgoraRTC.createCustomAudioTrack]{@link IAgoraRTC.createCustomAudioTrack} * - [AgoraRTC.createMicrophoneAudioTrack]{@link IAgoraRTC.createMicrophoneAudioTrack} * - [AgoraRTC.createBufferSourceAudioTrack]{@link IAgoraRTC.createBufferSourceAudioTrack} * * 下表列出了 SDK 所有内置的音频属性配置,SDK 默认使用 `"music_standard"`。 * * | 音频属性 | 配置 | * | -------- | --------------- | * |`"speech_low_quality"`|16 kHz 采样率,单声道,编码码率约 24 Kbps| * |`"speech_standard"`|32 kHz 采样率,单声道,编码码率约 24 Kbps| * |`"music_standard"`|48 kHz 采样率,单声道,编码码率约 32 Kbps| * |`"standard_stereo"`|48 kHz 采样率,双声道,编码码率约 64 Kbps| * |`"high_quality"`|48 kHz 采样率,单声道, 编码码率约 128 Kbps| * |`"high_quality_stereo"`|48 kHz 采样率,双声道,编码码率约 192 Kbps| * @public */ /** @en * The preset audio encoder configurations. * * You can pass the preset video encoder configurations when calling the following methods: * - [AgoraRTC.createCustomAudioTrack]{@link IAgoraRTC.createCustomAudioTrack} * - [AgoraRTC.createMicrophoneAudioTrack]{@link IAgoraRTC.createMicrophoneAudioTrack} * - [AgoraRTC.createBufferSourceAudioTrack]{@link IAgoraRTC.createBufferSourceAudioTrack} * * The following table lists all the preset audio profiles. The SDK uses `"music_standard"` by default. * * | Audio Profile | Configurations | * | -------- | --------------- | * |`"speech_low_quality"`|Sample rate 16 kHz, mono, encoding bitrate 24 Kbps| * |`"speech_standard"`|Sample rate 32 kHz, mono, encoding bitrate 24 Kbps| * |`"music_standard"`|Sample rate 48 kHz, mono, encoding bitrate 32 Kbps| * |`"standard_stereo"`|Sample rate 48 kHz, stereo, encoding bitrate 64 Kbps| * |`"high_quality"`|Sample rate 48 kHz, mono, encoding bitrate 128 Kbps| * |`"high_quality_stereo"`|Sample rate 48 kHz, stereo, encoding bitrate 192 Kbps| Kbps. * @public */ export declare type AudioEncoderConfigurationPreset = keyof typeof AUDIO_ENCODER_CONFIG_SETTINGS; export declare interface AudioMetadata { value: Uint8Array; } export declare interface AudioPlaybackOptions { /** * 控制人声是否要被播放,默认为 `true` */ origin?: boolean; /** * 控制混音背景音乐是否要被播放,默认为 `true` */ mixing?: boolean; /** * 控制音效是否要被播放,默认为 `true` */ effect?: boolean; } export declare class AudioProcessorContext extends EventEmitter implements IAudioProcessorContext { private constraintsMap; private statsRegistry; private readonly audioContext; private readonly trackId; private readonly direction; private usageRegistry; private _chained; set chained(chained: boolean); get chained(): boolean; constructor(audioContext: AudioContext, trackId: string, direction: "local" | "remote"); getConstraints(): Promise<MediaTrackConstraints>; getAudioContext(): AudioContext; requestApplyConstraints(constraints: MediaTrackConstraints, processor: IBaseProcessor): Promise<void>; requestRevertConstraints(processor: IBaseProcessor): Promise<void>; registerStats(processor: IBaseProcessor, type: string, cb: () => any): void; unregisterStats(processor: IBaseProcessor, type: string): void; gatherStats(): ProcessorStats[]; registerUsage(processor: IBaseProcessor, cb: () => Usage): void; unregisterUsage(processor: IBaseProcessor): void; gatherUsage(): Promise<UsageWithDirection[]>; getDirection(): "local" | "remote"; } export declare class AudioProcessorDestination extends EventEmitter implements IAudioProcessor { name: string; ID: string; private inputTrack?; private inputNode?; private readonly audioProcessorContext; _source?: IAudioProcessor; constructor(audioProcessorContext: AudioProcessorContext); get kind(): Kind; get enabled(): boolean; pipe(): IAudioProcessor; unpipe(): void; enable(): void; disable(): void; reset(): void; updateInput(inputOptions: { track?: MediaStreamTrack; node?: AudioNode; context: IAudioProcessorContext; }): void; } declare abstract class AudioSource extends EventEmitter { outputNode: GainNode; outputTrack?: MediaStreamTrack; isPlayed: boolean; protected abstract sourceNode?: AudioNode; context: AudioContext; private audioBufferNode?; private destNode?; private audioOutputLevel; protected volumeLevelAnalyser: VolumeLevelAnalyser; private _processedNode; get processSourceNode(): AudioNode | undefined; set processedNode(node: AudioNode | undefined); get processedNode(): AudioNode | undefined; /** * 用于播放的节点,默认情况下直接连到音频输出 */ protected playNode: AudioNode; protected isDestroyed: boolean; protected onNoAudioInput?: () => void; /** * 表示当前输入音频是否有问题 * 目前只会在 Safari 下判断这个情况 * * 连续 5 帧出现数据为 0 的情况 */ protected isNoAudioInput: boolean; private _noAudioInputCount; constructor(); startGetAudioBuffer(bufferSize: number): void; stopGetAudioBuffer(): void; createOutputTrack(): MediaStreamTrack; play(dest?: AudioNode): void; stop(): void; /** * 获取当前音量 * @returns 当前音量,范围 [0, 1] */ getAccurateVolumeLevel(): number; /** * 在检查 1s 内这个 track 是否有音量 * @param times 递归时候使用的参数,计算递归次数 * @returns 是否有音量的检查结果 */ checkHasAudioInput(times?: number): Promise<boolean>; /** * 获取音源的设置音量(通过 GainNode 得出的 * 范围是 [0. Infinity], 1 表示原始音量 */ getAudioVolume(): number; setVolume(level: number): void; destroy(): void; protected disconnect(): void; protected connect(): void; } export declare enum AudioSourceEvents { AUDIO_SOURCE_STATE_CHANGE = "audio_source_state_change", /** 第一次收到 MediaStreamTrack 的数据 */ RECEIVE_TRACK_BUFFER = "receive_track_buffer", ON_AUDIO_BUFFER = "on_audio_buffer", UPDATE_SOURCE = "update_source" } /** * 音频数据源处理的设置。用于 [startProcessAudioBuffer]{@link IBufferSourceAudioTrack.startProcessAudioBuffer}。 */ /** @en * Options for processing the audio buffer. You need to set the options for processing the audio buffer when calling [startProcessAudioBuffer]{@link IBufferSourceAudioTrack.startProcessAudioBuffer}. */ export declare interface AudioSourceOptions { /** * 设置循环播放的次数。 */ /** @en * How many times the audio loops. */ cycle?: number; /** * 设置是否无限循环。 */ /** @en * Whether to loop the audio infinitely. */ loop?: boolean; /** * 设置开始播放的时间。 */ /** @en * The playback position (seconds). */ startPlayTime?: number; } /** * 音频源数据处理状态,通过 [BufferSourceAudioTrack.on("source-state-change")]{@link IBufferSourceAudioTrack.event_source_state_change} 获取。 * * - `"stopped"`: 音频源数据处理停止。可能是因为数据处理完毕,也可能是手动触发了停止。 * - `"playing"`: 音频源数据正在处理。 * - `"paused"`: 音频源数据暂停处理。 * @public */ /** @en * Processing state of the audio buffer: * - `"stopped"`: The SDK stops processing the audio buffer. Reasons may include: * - The SDK finishes processing the audio buffer. * - The user manually stops the processing of the audio buffer. * - `"playing"`: The SDK is processing the audio buffer. * - `"paused"`: The SDK pauses processing the audio buffer. * * You can get the state with [BufferSourceAudioTrack.on("source-state-change")]{@link IBufferSourceAudioTrack.event_source_state_change}. */ export declare type AudioSourceState = "stopped" | "playing" | "paused"; declare class AudioState extends EventEmitter { prevState: AudioContextState | "interrupted" | undefined; curState: AudioContextState | "interrupted" | undefined; currentTime?: number; currentTimeStuckAt?: number; private interruptDetectorTrack?; get duringInterruption(): boolean; private onLocalAudioTrackMute; private onLocalAudioTrackUnmute; /** * only be called on iOS 15, 16 * */ bindInterruptDetectorTrack(track: MicrophoneAudioTrack): void; /** * only be called on iOS 15, 16 * */ unbindInterruptDetectorTrack(track: MicrophoneAudioTrack): void; } export declare function audioTimerLoop(callback: (time: number) => any, frequency: number): () => void; /** * 创建音频轨道时的配置参数。 */ /** @en * Configurations for the audio track of screen sharing. */ export declare interface AudioTrackInitConfig { /** * 是否开启回声消除: * - `true`: 开启回声消除。 * - `false`: 不开启回声消除。 */ /** @en * Whether to enable acoustic echo cancellation: * - `true`: Enable acoustic echo cancellation. * - `false`: Do not enable acoustic echo cancellation. */ AEC?: boolean; /** * 是否开启自动增益: * - `true`: 开启自动增益。 * - `false`: 不开启自动增益。 */ /** @en * Whether to enable audio gain control: * - `true`: Enable audio gain control. * - `false`: Do not enable audio gain control. */ AGC?: boolean; /** * 是否开启噪声抑制: * - `true`: 开启噪声抑制。 * - `false`: 不开启噪声抑制。 */ /** @en * Whether to enable automatic noise suppression: * - `true`: Enable automatic noise suppression. * - `false`: Do not automatic noise suppression. */ ANS?: boolean; } declare class AudioTrackSource extends AudioSource { protected sourceNode: MediaStreamAudioSourceNode; track: MediaStreamTrack; clonedTrack?: MediaStreamTrack; private audioElement; private isCurrentTrackCloned; private isRemoteTrack; private originVolumeLevelAnalyser?; get isFreeze(): boolean; constructor(track: MediaStreamTrack, isRemoteTrack?: boolean, originTrack?: MediaStreamTrack); /** * 在 ios 12 上,如果 context 在 suspend 的状态下创建了 MediaStreamSource * 当 context running 后 MediaStreamSource 是无法继续使用的 * 需要重新构建 WebAudio 节点 */ private rebuildWebAudio; updateTrack(track: MediaStreamTrack): void; destroy(): void; createMediaStreamSourceNode(track: MediaStreamTrack): MediaStreamAudioSourceNode; updateOriginTrack(originTrack: MediaStreamTrack): void; getOriginVolumeLevel(): number; } declare class AutoPlayGestureEventEmitter extends EventEmitter { onAutoplayFailed?: () => void; onAudioAutoplayFailed?: () => void; } export declare const autoPlayGestureEventEmitter: AutoPlayGestureEventEmitter; /** * @ignore * * 美颜选项,用于 [setBeautyEffect]{@link ILocalVideoTrack.setBeautyEffect}。 * @public */ /** @en * @ignore * * Image enhancement options. You need to set the image enhancement options when calling [setBeautyEffect]{@link ILocalVideoTrack.setBeautyEffect}. */ export declare interface BeautyEffectOptions { /** * 平滑度。 * * 取值范围为 [0.0, 1.0],其中 0.0 表示原始平滑等级,默认值为 0.5。可用来实现祛痘、磨皮等视觉效果。 */ /** @en * * The smoothness level. * * The value range is [0.0, 1.0]. The original smoothness level is 0.0. The default value is 0.5. This parameter is usually used to remove blemishes. */ smoothnessLevel?: number; /** * 亮度。 * * 取值范围为 [0.0, 1.0],其中 0.0 表示原始亮度,默认值为 0.7。可用来实现美白等视觉效果。 */ /** @en * The brightness level. * * The value range is [0.0, 1.0]. The original brightness level is 0.0. The default value is 0.7. */ lighteningLevel?: number; /** * 红色度。 * * 取值范围为 [0.0, 1.0],其中 0.0 表示原始红色度,默认值为 0.1。可用来实现红润肤色等视觉效果。 */ /** @en * The redness level. * * The value range is [0.0, 1.0]. The original redness level is 0.0. The default value is 0.1. This parameter adjusts the red saturation level. */ rednessLevel?: number; /** * 亮度明暗对比度,与 {@link lighteningLevel} 参数搭配使用。可设为: * - 0: 明暗对比弱。 * - 1: (默认) 原始明暗对比度。 * - 2: 明暗对比强。 */ /** @en * The contrast level. Use this together with {@link lighteningLevel}. * - 0: Low contrast level. * - 1: (Default) The original contrast level. * - 2: High contrast level. */ lighteningContrastLevel?: 0 | 1 | 2; } export declare interface BeautyWebGLParameters { denoiseLevel?: number; lightLevel?: number; rednessLevel?: number; lighteningContrastLevel?: number; } export declare const blob2Uint8Array: (blob: Blob) => Promise<Uint8Array>; export declare class BufferSourceAudioTrack extends LocalAudioTrack implements IBufferSourceAudioTrack { source: string | File | AudioBuffer | null; private _bufferSource; get __className__(): string; constructor(source: string | File | AudioBuffer, bufferSource: AudioBufferSource, encodingConfig?: AudioEncoderConfiguration, trackId?: string); get currentState(): AudioSourceState; get duration(): number; get playbackSpeed(): number; getCurrentTime(): number; startProcessAudioBuffer(options?: AudioSourceOptions): void; pauseProcessAudioBuffer(): void; seekAudioBuffer(time: number): void; resumeProcessAudioBuffer(): void; stopProcessAudioBuffer(): void; close(): void; setAudioBufferPlaybackSpeed(speed: number): void; } /** * 通过本地音频文件/在线音频文件/`AudioBuffer`方式创建音频流时的配置参数,用于 [AgoraRTC.createBufferSourceAudioTrack]{@link IAgoraRTC.createBufferSourceAudioTrack}。 */ /** @en * Configurations for the audio track from an audio file or `AudioBuffer` object. Set these configurations when calling [AgoraRTC.createBufferSourceAudioTrack]{@link IAgoraRTC.createBufferSourceAudioTrack}. */ export declare interface BufferSourceAudioTrackInitConfig { /** * 音频数据源,支持 3 种类型: * - `File`: 浏览器标准的 [File](https://developer.mozilla.org/en-US/docs/Web/API/File) 对象,表示一个本地文件。 * - `string`: 表示从线上 HTTPS 地址获取在线音频文件(请确保音频在线地址支持 HTTPS 和 CORS)。 * - `AudioBuffer`: 浏览器标准的 [AudioBuffer](https://developer.mozilla.org/en-US/docs/Web/API/AudioBuffer) 对象表示 PCM 原始数据。 */ /** @en * The type of the audio source: * - `File`: An [File](https://developer.mozilla.org/en-US/docs/Web/API/File) object, representing a local audio file. * - `string`: The online audio file retrieved from an HTTPS address. Ensure the address supports HTTPS and CORS. * - `AudioBuffer`: An [AudioBuffer](https://developer.mozilla.org/en-US/docs/Web/API/AudioBuffer) object, representing the raw data in PCM format. */ source: File | string | AudioBuffer; /** * 是否缓存线上文件: * - `true`: 缓存线上文件。 * - `false`: (默认)不缓存线上文件。 */ /** @en * Whether to cache the online file: * - `true`: Cache the online file. * - `false`: (default) Do not cache the online file. */ cacheOnlineFile?: boolean; /** * 控制音频的编码配置。 * * 你可以通过 [[AudioEncoderConfigurationPreset]] 传入 SDK 内置的编码配置;也可以通过传入一个 [[AudioEncoderConfiguration]] 来自定义音频编码配置。 * * > Firefox 不支持设置音频编码码率。 */ /** @en * The audio encoder configurations. * * You can set the audio encoder configurations in either of the following ways: * - Pass the preset audio encoder configurations by using [[AudioEncoderConfigurationPreset]]. * - Pass your customized audio encoder configurations by using [[AudioEncoderConfiguration]]. * * > Firefox does not support setting the audio encoding rate. */ encoderConfig?: AudioEncoderConfiguration | AudioEncoderConfigurationPreset; } export declare class CameraVideoTrack extends LocalVideoTrack implements ICameraVideoTrack { private _config; private _originalConstraints; private _constraints; _enabled: boolean; _deviceName: string; get __className__(): string; constructor(track: MediaStreamTrack, config: CameraVideoTrackInitConfig, constraints: MediaTrackConstraints, scalabilityConfig?: SVCConfiguration, optimizationMode?: OptimizationMode, trackId?: string); setDevice(deviceId: string | RequiredOnlyOneOf<{ facingMode: VideoFacingModeEnum; deviceId: string; }>): Promise<void>; private _setDeviceById; /** * 通过 facingMode 设置设备 * @param facingMode https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackSettings/facingMode */ private _setDeviceByFacingModel; setEnabled(enabled: boolean, skipChangeState?: boolean): Promise<void>; setEncoderConfiguration(config: VideoEncoderConfiguration | VideoEncoderConfigurationPreset, doNotRenegoation?: boolean): Promise<void>; protected _getDefaultPlayerConfig(): Partial<PlayerConfig>; protected onTrackEnded(): void; renewMediaStreamTrack(newConstraints?: MediaTrackConstraints): Promise<void>; tryResumeVideoForIOS15_16WeChat: () => Promise<void>; close(): void; clone(config?: VideoEncoderConfiguration | VideoEncoderConfigurationPreset, cloneTrack?: boolean): CameraVideoTrack; bindProcessorContextEvents(): void; } /** * 创建摄像头视频流时的配置对象,用于 [AgoraRTC.createCameraVideoTrack]{@link IAgoraRTC.createCameraVideoTrack}。 */ /** @en * Configurations for the video track from the video captured by a camera. Set these configurations when calling [AgoraRTC.createCameraVideoTrack]{@link IAgoraRTC.createCameraVideoTrack}. */ export declare interface CameraVideoTrackInitConfig { /** * 控制视频的编码配置。 * * 你可以通过以下方式设置该属性: * - 通过 [[VideoEncoderConfigurationPreset]] 传入 SDK 内置的编码配置。 * - 通过传入一个 [[VideoEncoderConfiguration]] 对象来自定义视频编码配置。 * - 不传或留空,使用 SDK 的默认值 `"480p_1"`(分辨率 640 × 480、帧率 15 fps、码率 500 Kbps)。 */ /** @en * The video encoder configurations. * * You can set the video encoder configurations in either of the following ways: * - Pass the preset video encoder configurations by using [[VideoEncoderConfigurationPreset]]. * - Pass your customized video encoder configurations by using [[VideoEncoderConfiguration]]. * - Leave this property empty to use the SDK's default value, `"480p_1"` (resolution: 640 × 480, frame rate: 15 fps, bitrate: 500 Kbps). */ encoderConfig?: VideoEncoderConfiguration | VideoEncoderConfigurationPreset; /** * 指定使用前置/后置摄像头来采集视频。 * * 在移动设备上,可以设置该参数选择使用前置或后置摄像头: * - `"user"`: 前置摄像头 * - `"environment"`: 后置摄像头 */ /** @en * Whether to user the front camera or the rear camera. * * You can use this parameter to choose between the front camera and the rear camera on a mobile device: * - `"user"`: The front camera. * - `"environment"`: The rear camera. */ facingMode?: VideoFacingModeEnum; /** * 指定摄像头的设备 ID。 * * 你可以通过 [AgoraRTC.getCameras]{@link IAgoraRTC.getCameras} 来获取当前的摄像头设备列表。 */ /** @en * Specifies the camera ID. * * You can get a list of the available cameras by calling [AgoraRTC.getCameras]{@link IAgoraRTC.getCameras}. */ cameraId?: string; /** * @自从 * <br>&emsp;&emsp;&emsp;*4.2.0* * * 设置视频传输优化模式。 * * 你可以在视频通话、视频直播或屏幕共享过程中调用此方法动态调整视频的传输优化模式。例如你想要把屏幕共享内容从演示文稿切换为视频时,你可以将传输优化模式从 `"detail"` 切换为 `"motion"`,确保视频画面在网络波动时不会出现卡顿。 * * > 注意事项:该方法只支持 Chrome 浏览器。 * * @param mode 视频传输优化模式: * - `"detail"`: 清晰优先。 * - 浏览器会自动根据你的采集分辨率和帧率设定一个最小码率。即使遭遇网络波动,发送码率也不会低于这个值,从而确保清晰的视频画面。 * - 大部分情况下,浏览器不会降低发送分辨率,但是可能会降低帧率。 * - `"motion"`: 自 4.21.0 开始,浏览器默认开启流畅优先模式。 * - 浏览器不会启用最小码率策略。遭遇网络波动时,发送端会降低码率来确保接收端的视频画面不会出现中断和卡顿。 * - 大部分情况下,浏览器不会降低帧率,但是可能会降低发送分辨率。 */ /** @en * @since * <br>&emsp;&emsp;&emsp;*4.2.0* * * Sets the video transmission optimization mode. * * You can call this method during a video call, a live streaming or screen sharing to dynamically change the optimization mode. For example, during the screen sharing, before you change the shared content from text to video, you can change the optimization mode from `"detail"` to `"motion"` to ensure smoothness in poor network conditions. * * > Note: This method supports Chrome only. * * @param mode The video transmission optimization mode: * - `"detail"`: Prioritizes video quality. * - The browser ensures high-quality images by automatically calculating a minimum bitrate based on the capturing resolution and frame rate. No matter how poor the network condition is, the sending bitrate will never be lower than the minimum value. * - In most cases, the browser does not reduce the sending resolution, but may reduce the frame rate. * - `"motion"`: Since v4.21.0, the browser prioritizes video smoothness. * - In poor network conditions, the browser reduces the sending bitrate to minimize video freezes. * - In most cases, the browser does not reduce the frame rate, but may reduce the sending resolution. * - `"balanced"`: The default optimization mode. * - For screen sharing video streams, the SDK default optimization strategy is quality-first. * - For other video streams, the SDK default optimization strategy is balanced between quality and smoothness. Under poor network conditions, both the frame rate and resolution will be adjusted. */ optimizationMode?: OptimizationMode; /** * @ignore * @自从 * <br>&emsp;&emsp;&emsp;*4.18.0* * * SVC (可伸缩视频编码)配置。 * * 你可以通过 {@link SVCConfigurationPreset} 传入 SDK 预设的 SVC 编码配置,也可以通过 {@link SVCConfiguration} 传入自定义的 SVC 编码配置。 */ /** @en * @ignore * * @since * <br>&emsp;&emsp;&emsp;*4.18.0* * * Configurations for Scalable Video Coding (SVC). * * You can set the configurations using one of the following options: * - Use the preset SVC configurations provided by the SDK through {@link SVCConfigurationPreset}. * - Use your custom SVC configurations through {@link SVCConfiguration}. */ scalabiltyMode?: SVCConfiguration | SVCConfigurationPreset; } export declare function checkMediaStreamTrackResolution(track: MediaStreamTrack): Promise<[number, number]>; export declare function checkTrackState(): (target: any, propertyKey: any, descriptor: PropertyDescriptor) => TypedPropertyDescriptor<any> | undefined; /** * `<video>` 标签的可见状态信息。 * * 可通过以下方法或事件获取: * - [localVideoTrack.on("video-element-visible-status")]{@link ILocalVideoTrack.event_video_element_visible_status} * - [localVideoTrack.getVideoElementVisibleStatus]{@link ILocalVideoTrack.getVideoElementVisibleStatus} * - [remoteVideoTrack.on("video-element-visible-status")]{@link IRemoteVideoTrack.event_video_element_visible_status_2} * - [remoteVideoTrack.getVideoElementVisibleStatus]{@link IRemoteVideoTrack.getVideoElementVisibleStatus} * * 包含以下字段: * - `visible`: Boolean 型,`<video>` 标签是否可见。 * - `reason`: 仅当 `visible` 为 `false` 时有效,不可见原因: * - `"SIZE"`: `<video>` 尺寸太小,导致 `<video>` 完全不可见或很难看到。 * - `"STYLE"`: `<video>` 或其祖先元素的 CSS 样式导致 `<video>` 不可见、颜色暗淡或模糊不清。 * - `"POSITION"`: `<video>` 或其祖先元素被定位到视口区域外,导致 `<video>` 只有小面积区域在视口内或全部不在视口内。 * - `"COVERED"`: `<video>` 被其他元素遮挡。 */ /** @en * The visibility of the `<video>` tag. * * Get the visibility of the `<video>` tag through the following methods and events: * - [localVideoTrack.on("video-element-visible-status")]{@link ILocalVideoTrack.event_video_element_visible_status} * - [localVideoTrack.getVideoElementVisibleStatus]{@link ILocalVideoTrack.getVideoElementVisibleStatus} * - [remoteVideoTrack.on("video-element-visible-status")]{@link IRemoteVideoTrack.event_video_element_visible_status_2} * - [remoteVideoTrack.getVideoElementVisibleStatus]{@link IRemoteVideoTrack.getVideoElementVisibleStatus} * * This object contains the following parameters: * - `visible`: Boolean, whether the `<video>` tag is visible or not. * - `reason`: This parameter is only valid when `visible` is `false`, which indicates the reason: * - `"SIZE"`: The size of `<video>` is too small to see. * - `"STYLE"`: The CSS styles of `<video>` or its ancestor element cause `<video>` to be invisible. * - `"POSITION"`: The `<video>` tag or its ancestor element are positioned outside the viewport. * - `"COVERED"`: The `<video>` tag is covered by other elements. */ export declare type CheckVideoVisibleResult = CheckVisibleResult; /** * 约束对象,一般用于在 [[VideoEncoderConfiguration]] 中指定采集分辨率/帧率的范围。 */ /** @en * Specifies a constraint for a property, such as the resolution or bitrate for video capture in [[VideoEncoderConfiguration]]. */ export declare interface ConstrainLong { /** * 采集设备最终输出的值下限。 */ /** @en * The lower limit of the property. */ min?: number; /** * 采集设备最终输出的值上限。 */ /** @en * The upper limit of the property. */ max?: number; /** * 期望采集设备最终输出的值,如果设备不支持指定的值,会尽量输出一个最靠近的值。 */ /** @en * An ideal value of a property. If the video capture device cannot output this value, it outputs the closest value instead. */ ideal?: number; /** * 严格指定采集设备最终输出的值,如果设备不支持指定的值,采集会失败。 */ /** @en * A required value of a property. If the video capture device cannot output this value, the video capture fails. */ exact?: number; } export declare function createBufferSourceAudioTrack(config: BufferSourceAudioTrackInitConfig): Promise<BufferSourceAudioTrack>; export declare function createCameraVideoTrack(config?: CameraVideoTrackInitConfig): Promise<CameraVideoTrack>; export declare function createCustomAudioTrack(config: CustomAudioTrackInitConfig): LocalAudioTrack; export declare function createCustomVideoTrack(config: CustomVideoTrackInitConfig): LocalVideoTrack; export declare function createMicrophoneAndCameraTracks(audioConfig?: MicrophoneAudioTrackInitConfig, videoConfig?: CameraVideoTrackInitConfig): Promise<[MicrophoneAudioTrack, CameraVideoTrack]>; export declare function createMicrophoneAudioTrack(config?: MicrophoneAudioTrackInitConfig): Promise<MicrophoneAudioTrack>; export declare function createMixingAudioTrack(trackList: LocalAudioTrack[]): MixingAudioTrack; export declare function createScreenVideoTrack(config: ScreenVideoTrackInitConfig, withAudio: "enable"): Promise<[LocalVideoTrack, LocalAudioTrack]>; export declare function createScreenVideoTrack(config?: ScreenVideoTrackInitConfig, withAudio?: "disable"): Promise<LocalVideoTrack>; export declare function createScreenVideoTrack(config: ScreenVideoTrackInitConfig, withAudio: "auto" | ScreenAudioTrackInitConfig): Promise<[LocalVideoTrack, LocalAudioTrack] | LocalVideoTrack>; /** * 创建自定义音频轨道时的配置参数,用于 [AgoraRTC.createCustomAudioTrack]{@link IAgoraRTC.createCustomAudioTrack}。 */ /** @en * Configurations for the custom audio track. Set these configurations when calling [AgoraRTC.createCustomAudioTrack]{@link IAgoraRTC.createCustomAudioTrack}. */ export declare interface CustomAudioTrackInitConfig { /** * 你自己维护的 [MediaStreamTrack](https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack) 对象。 */ /** @en * Your [MediaStreamTrack](https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack) object. */ mediaStreamTrack: MediaStreamTrack; /** * 控制音频的编码配置。 * * 你可以通过 [[AudioEncoderConfigurationPreset]] 传入 SDK 内置的编码配置;也可以通过传入一个 [[AudioEncoderConfiguration]] 来自定义音频编码配置。 * * > Firefox 不支持设置音频编码码率。 */ /** @en * The audio encoder configurations. * * You can set the audio encoder configurations in either of the following ways: * - Pass the preset audio encoder configurations by using [[AudioEncoderConfigurationPreset]]. * - Pass your customized audio encoder configurations by using [[AudioEncoderConfiguration]]. * * > Firefox does not support setting the audio encoding rate. */ encoderConfig?: AudioEncoderConfiguration | AudioEncoderConfigurationPreset; } /** * 创建自定义视频轨道时的配置参数,用于 [AgoraRTC.createCustomVideoTrack]{@link IAgoraRTC.createCustomVideoTrack}。 */ /** @en * Configurations for the custom video track. Set these configurations when calling [AgoraRTC.createCustomVideoTrack]{@link IAgoraRTC.createCustomVideoTrack}. */ export declare interface CustomVideoTrackInitConfig { /** * 这里填写您自己维护的 [MediaStreamTrack](https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack) 对象 */ /** @en * Your [MediaStreamTrack](https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack) object. */ mediaStreamTrack: MediaStreamTrack; /** * @自从 * <br>&emsp;&emsp;&emsp;*4.17.1* * * 视频的分辨率宽。 * * 支持传入 `number`,或一个约束对象,如 `{ max: 1280, min: 720 }`。 * * 关于约束对象的详细说明可以参考 [ConstrainLong]{@link ConstrainLong}。 */ /** @en * @since * <br>&emsp;&emsp;&emsp;*4.17.1* * * Width of the video. * * You can pass a `number`, or a constraint such as `{ max: 1280, min: 720 }`. * * For more details about the constraint, see [ConstrainLong]{@link ConstrainLong}. */ width?: number | ConstrainLong; /** * @自从 * <br>&emsp;&emsp;&emsp;*4.17.1* * * 视频的分辨率高。 * * 支持传入 `number`,或一个约束对象,如 `{ max: 1280, min: 720 }`。 * * 关于约束对象的详细说明可以参考 [ConstrainLong]{@link ConstrainLong}。 */ /** @en * @since * <br>&emsp;&emsp;&emsp;*4.17.1* * * Height of the video. * * You can pass a `number`, or a constraint such as `{ max: 1280, min: 720 }`. * * For more details about the constraint, see [ConstrainLong]{@link ConstrainLong}. */ height?: number | ConstrainLong; /** * @自从 * <br>&emsp;&emsp;&emsp;*4.17.1* * * 视频帧率,单位为 fps。 * * 支持传入 `number`,或一个约束对象,如 `{ max: 30, min: 5 }`。 * * 关于约束对象的详细说明可以参考 [ConstrainLong]{@link ConstrainLong}。 */ /** @en * @since * <br>&emsp;&emsp;&emsp;*4.17.1* * * Frame rate of the video (fps). * * You can pass a `number`, or a constraint such as `{ max: 30, min: 5 }`. * * For details about the constraint, see [ConstrainLong]{@link ConstrainLong}. */ frameRate?: number | ConstrainLong; /** * 指定发送这个视频轨道时的最小码率,单位为 Kbps。 */ /** @en * The minimum bitrate of sending the video track (Kbps). */ bitrateMin?: number; /** * 指定发送这个视频轨道时的最大码率,单位为 Kbps。 */ /** @en * The maximum bitrate of sending the video track (Kbps). */ bitrateMax?: number; /** * @自从 * <br>&emsp;&emsp;&emsp;*4.2.0* * * 设置视频传输优化模式。 * * 你可以在视频通话、视频直播或屏幕共享过程中调用此方法动态调整视频的传输优化模式。例如你想要把屏幕共享内容从演示文稿切换为视频时,你可以将传输优化模式从 `"detail"` 切换为 `"motion"`,确保视频画面在网络波动时不会出现卡顿。 * * > 注意事项:该方法只支持 Chrome 浏览器。 * * @param mode 视频传输优化模式: * - `"balanced"`: 使用默认的传输优化模式: * - 对于屏幕共享视频流,浏览器默认的优化策略为清晰优先。 * - 对于其他视频流,浏览器默认的优化策略为兼顾清晰和流畅,弱网条件下,帧率和分辨率都会被调整。 * - `"detail"`: 清晰优先。 * - 浏览器会自动根据你的采集分辨率和帧率设定一个最小码率。即使遭遇网络波动,发送码率也不会低于这个值,从而确保清晰的视频画面。 * - 大部分情况下,浏览器不会降低发送分辨率,但是可能会降低帧率。 * - `"motion"`: 自 4.21.0 开始,浏览器默认开启流畅优先模式 * - SDK 不会启用最小码率策略。遭遇网络波动时,发送端会降低码率来确保接收端的视频画面不会出现中断和卡顿。 * - 大部分情况下,SDK 不会降低帧率,但是可能会降低发送分辨率。 */ /** @en * @since * <br>&emsp;&emsp;&emsp;*4.2.0* * * Sets the video transmission optimization mode. * * You can call this method during a video call, a live streaming or screen sharing to dynamically change the optimization mode. For example, during the screen sharing, before you change the shared content from text to video, you can change the optimization mode from `"detail"` to `"motion"` to ensure smoothness in poor network conditions. * * > Note: This method supports Chrome only. * * @param mode The video transmission optimization mode: * - `"balanced"`: Uses the default optimization mode. * - For a screen-sharing video track, the default transmission optimization strategy is to prioritizes clarity. * - For the other types of video tracks, the SDK may reduce the frame rate or the sending resolution in poor network conditions. * - `"detail"`: Prioritizes video quality. * - The SDK ensures high-quality images by automatically calculating a minimum bitrate based on the capturing resolution and frame rate. No matter how poor the network condition is, the sending bitrate will never be lower than the minimum value. * - In most cases, the SDK does not reduce the sending resolution, but may reduce the frame rate. * - `"motion"`: Since 4.21.0, the SDK prioritizes video smoothness. * - In poor network conditions, the SDK reduces the sending bitrate to minimize video freezes. * - In most cases, the SDK does not reduce the frame rate, but may reduce the sending resolution. */ optimizationMode?: OptimizationMode; /** * @ignore * @自从 * <br>&emsp;&emsp;&emsp;*4.18.0* * * SVC (可伸缩视频编码)配置。 * * 你可以通过 {@link SVCConfigurationPreset} 传入 SDK 预设的 SVC 编码配置,也可以通过 {@link SVCConfiguration} 传入自定义的 SVC 编码配置。 */ /** @en * @ignore * * @since * <br>&emsp;&emsp;&emsp;*4.18.0* * * Configurations for Scalable Video Coding (SVC). * * You can set `scalabiltyMode` using one of the following options: * - Use the preset SVC configurations provided by the SDK through {@link SVCConfigurationPreset}. * - Use your custom SVC configurations through {@link SVCConfiguration}. */ scalabiltyMode?: SVCConfiguration | SVCConfigurationPreset; } export declare abstract class DataChannel extends EventEmitter implements IDataChannel { readonly trackMediaType: TrackMediaType.DATA; private _version; private _type; _config: IDataChannelConfig; /** 原始的 DataChannel 对象 */ _originDataChannel?: RTCDataChannel; protected _dataStreamPacketHeader: ArrayBuffer; protected _dataStreamPacketHandler: IDataStream; private _datachannelEventMap; constructor(config: IDataChannelConfig, datachannel?: RTCDataChannel); useDataStream(dataStream: IDataStream): void; get id(): number; get ordered(): boolean; get maxRetransmits(): number; get metadata(): string; get readyState(): RTCDataChannelState; get _originDataChannelId(): number | null; getChannelId(): number; getConfig(): IDataChannelConfig; _close(): void; _waitTillOpen(): Promise<void>; _updateOriginDataChannel(datachannel: RTCDataChannel): void; private _initPacketHeader; private _bandDataChannelEvents; private _unbindDataChannelEvents; } export declare enum DataChannelEvents { OPEN = "open", MESSAGE = "message", CLOSE = "close", CLOSING = "closing", ERROR = "error" } export declare function decodeAudioData(buffer: ArrayBuffer): Promise<AudioBuffer>; export declare const DEFAULT_LOCAL_AUDIO_TRACK_STATS: LocalAudioTrackStats; export declare const DEFAULT_LOCAL_VIDEO_TRACK_STATS: LocalVideoTrackStats; export declare const DEFAULT_NETWORK_QUALITY_STATS: NetworkQuality; export declare const DEFAULT_REMOTE_AUDIO_TRACK_STATS: RemoteAudioTrackStats; export declare const DEFAULT_REMOTE_VIDEO_TRACK_STATS: RemoteVideoTrackStats; export declare interface DenoiserStats { ns: number; ebn: number; ean: number; vl: number; } /** * 是否支持Audio标签 setSinkId * Firefox 116 以上也支持此接口,但是会出现回声问题 * 仅支持PC 端 Chrome / Edge,且不支持移动端 */ export declare function detectSupportAudioElementSetSinkId(): boolean; /** * 音视频采集设备的信息。 * * - 音频采集设备信息可通过 [onMicrophoneChanged]{@link onMicrophoneChanged} 获取。 * - 视频采集设备信息可通过 [onCameraChanged]{@link onCameraChanged} 获取。 * - 音频播放设备信息可通过 [onPlaybackDeviceChanged]{@link onPlaybackDeviceChanged} 获取。 * @public */ /** @en * Information of the media input device. * * - You can get the audio sampling device information through [onMicrophoneChanged]{@link onMicrophoneChanged}. * - You can get the video capture device information through [onCameraChanged]{@link onCameraChanged}. * - You can get the audio playback device information through [onPlaybackDeviceChanged]{@link onPlaybackDeviceChanged}. */ export declare interface DeviceInfo { /** * 采集设备的插拔状态更新时间,UNIX 时间戳,单位为 ms。 */ /** @en * The latest time when the state of the media input device was updated. * * A Unix timestamp in milliseconds. */ updateAt: number; /** * SDK 首次检测到采集设备的时间,UNIX 时间戳,单位为 ms。 */ /** @en * The time when the SDK first detects the media input device. * * A Unix timestamp in milliseconds. */ initAt: number; /** * 采集设备当前的插拔状态。 */ /** @en * The state of the capture device. */ state: DeviceState; /** * 采集设备的设备信息,详见 [MediaDeviceInfo](https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo)。 */ /** @en * Device information of the media input device. See [MediaDeviceInfo](https://developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo) for details. */ device: MediaDeviceInfo; } export declare class DeviceManager extends EventEmitter { private _state; get state(): DeviceManagerState; set state(state: DeviceManagerState); private isAccessMicrophonePermission; private isAccessCameraPermission; private lastAccessMicrophonePermission; private lastAccessCameraPermission; private checkdeviceMatched; /** * 记录所有枚举到的设备和这些设备最后出现的时间 */ private deviceInfoMap; constructor(); enumerateDevices(audio: boolean, video: boolean, skipPermissionCheck?: boolean): Promise<MediaDeviceInfo[]>; getRecordingDevices(skipPermissionCheck?: boolean): Promise<MediaDeviceInfo[]>; getCamerasDevices(skipPermissionCheck?: boolean): Promise<MediaDeviceInfo[]>; getSpeakers(skipPermissionCheck?: boolean): Promise<MediaDeviceInfo[]>; searchDeviceIdByName(deviceName: string): string | null; getDeviceById(deviceId: string): Promise<MediaDeviceInfo>; private init; private updateDevicesInfo; /** 检查媒体设备信息是否可用,判断标准为 deviceId 和 label 不能为空 */ private checkMediaDeviceInfoIsOk; } export declare const deviceManager: DeviceManager; export declare enum DeviceManagerEvent { STATE_CHANGE = "state_change", RECORDING_DEVICE_CHANGED = "recordingDeviceChanged", PLAYOUT_DEVICE_CHANGED = "playoutDeviceChanged", CAMERA_DEVICE_CHANGED = "cameraDeviceChanged" } export declare enum DeviceManagerState { IDLE = "IDLE", INITING = "INITING", INITEND = "INITEND" } /** * 采集设备当前的插拔状态。 * - `"ACTIVE"`: 该设备已经插入。 * - `"INACTIVE"`: 该设备已经被拔出。 * @public */ /** @en * The state of the media input device. * - `"ACTIVE"`: The device is plugged in. * - `"INACTIVE"`: The device is unplugged. */ export declare type DeviceState = "ACTIVE" | "INACTIVE"; export declare const emptyImage2TypedArray: (type: string) => Promise<ImageTypedData>; /** * @ignore * * 通过 [setBeautyEffect]{@link ILocalVideoTrack.setBeaut