///
import { BrowserDeviceManager } from 'media-device';
import { default as default_2 } from 'eventemitter3';
import { IScreenConstraints } from 'media-device';
declare interface AliEngineCameraCapturerConfiguration {
width?: number;
height?: number;
frameRate?: number;
maxSendFrameRate?: number;
bitrate?: number;
cameraDirection?: AliRtcCameraDirection;
deviceId?: string;
}
declare interface AliRtcAIAgentParam {
/*! ai agent id */
agentId: string;
/*! ai agent的区域 */
region: string;
/*! 启动ai agent的action */
action: string;
/*! 启动ai agent的参数 */
params: string;
}
export declare enum AliRtcAudioTrack {
/** 无麦克风 */
AliRtcAudioTrackNo = 0,
/** 麦克风 */
AliRtcAudioTrackMic = 1,
/** 第二音频流 */
AliRtcAudioTrackDual = 2
}
export declare interface AliRtcAuthInfo {
/** 频道ID */
channelId: string;
/** 用户ID */
userId: string;
/** 应用ID */
appId: string;
/** 随机串 */
nonce?: string;
/** 时间戳 */
timestamp: number;
/** 令牌 */
token: string;
/** 会议id */
sessionId?: string;
/** 角色鉴权值 */
role?: AliRtcSdkTokenRole;
}
declare interface AliRtcBeautyConfig {
whiteningLevel: number;
/*! 磨皮等级[0-1.0] */
smoothnessLevel: number;
}
declare enum AliRtcCameraDirection {
/** 无效 */
CAMERA_INVALID = -1,
/** 后置 */
CAMERA_REAR = 0,
/** 前置 */
CAMERA_FRONT = 1
}
export declare enum AliRtcCapabilityProfile {
Default = 0,
Human = 1,
Robot = 2
}
export declare type AliRtcChannelParam = {
userName?: string;
capabilityProfile?: AliRtcCapabilityProfile;
robotUserId?: string;
};
export declare interface AliRtcCheckResult {
support: boolean;
detail: {
isWebRTCSupported: boolean;
isH264EncodeSupported: boolean;
isH264DecodeSupported: boolean;
isBrowserSupported: boolean;
isScreenShareSupported: boolean;
isSendMediaExtensionMsgSupported: boolean;
};
}
export declare enum AliRtcConnectionStatus {
/** 初始化完成 */
AliRtcConnectionStatusInit = 0,
/** 网络连接断开 */
AliRtcConnectionStatusDisconnected = 1,
/** 建立网络连接中 */
AliRtcConnectionStatusConnecting = 2,
/** 网络已连接 */
AliRtcConnectionStatusConnected = 3,
/** 重新建立网络连接中 */
AliRtcConnectionStatusReconnecting = 4,
/** 网络连接失败 */
AliRtcConnectionStatusFailed = 5
}
export declare enum AliRtcConnectionStatusChangeReason {
/** 未知原因 */
AliRtcConnectionChangedDummyReason = 0,
/** 媒体通道变更 */
AliRtcConnectionMediaPathChanged = 1,
/** 心跳超时 */
AliRtcConnectionSignalingHeartbeatTimeout = 2,
/** 心跳恢复 */
AliRtcConnectionSignalingHeartbeatAlive = 3,
/** DNS解析成功 */
AliRtcConnectionSignalingHttpDnsResolved = 4,
/** DNS解析失败 */
AliRtcConnectionSignalingHttpDnsFailure = 5,
/** GSLB请求失败 */
AliRtcConnectionSignalingGslbFailure = 6,
/** GSLB请求成功 */
AliRtcConnectionSignalingGslbSuccess = 7,
/** 加入频道失败 */
AliRtcConnectionSignalingJoinRoomFailure = 8,
/** 加入频道成功 */
AliRtcConnectionSignalingJoinRoomSuccess = 9,
/** 离开频道 */
AliRtcConnectionSignalingLeaveRoom = 10,
/** 信令建立连接 */
AliRtcConnectionSignalingConnecting = 11,
/** 网络连接中断 */
AliRtcConnectionChangedNetworkInterrupted = 12
}
export declare class AliRtcDataChannelMsg {
data: ArrayBuffer;
networkTime: number;
futureOrProgress: number;
type: AliRtcDataMsgType;
constructor(data: ArrayBuffer, type?: AliRtcDataMsgType, networkTime?: number, progress?: number);
toBuffer(): ArrayBuffer;
static parse(buffer: ArrayBuffer): AliRtcDataChannelMsg | undefined;
}
export declare enum AliRtcDataMsgType {
AliEngineDataMsgNone = 0,
AliEngineDataMsgMusicProgress = 1,
AliEngineDataMsgCustom = 2
}
declare type AliRtcDualVideoPluginOptions = VideoScalerOptions;
declare class AliRtcEngine_2 extends default_2 {
private config?;
/**
* @ignore
*/
static logName: string;
/**
* @ignore
*/
static logError: boolean;
/**
* 检查浏览器是否支持 WebRTC
* @param {string} direction
* @returns {Promise}
*/
static isSupported: (direction?: "sendrecv" | "recvonly" | "sendonly") => Promise;
/**
* 检查当前设备浏览器是否支持 H265 解码
* @returns {Promise}
*/
static checkH265Decode: () => Promise;
/**
* 检查当前设备浏览器是否支持 H265 编码
* @returns {Promise}
*/
static checkH265Encode: () => Promise;
/**
* 检查浏览器是否支持开启大小流
* @returns {boolean}
*/
static isDualVideoStreamSupported: typeof VideoScalerFactory.isSupport;
/**
* 获取摄像头列表
* @returns {Promise}
*/
static getCameraList: () => Promise;
/**
* 获取麦克风列表
* @returns {Promise}
*/
static getMicrophoneList: () => Promise;
/**
* 获取扬声器列表
* @returns {Promise}
*/
static getSpeakerList: () => Promise;
static getSdkVersion(): string;
/**
* 设置日志等级
* @param level
*/
static setLogLevel(level: AliRtcLogLevel): void;
/**
* @brief 设置信令加速域名(全局生效,需在 {@link joinChannel} 之前调用)
* @param domain 加速域名,如 'esars.rtn.aliyuncs.com';传空字符串或 undefined 时恢复为默认域名 'rs.rtn.aliyuncs.com'
* @details 该配置为全局静态配置,对所有实例生效。传入非法域名时不做任何设置,保持当前域名。
*/
static setSignalAccelerateDomain(domain?: string): void;
private static _instances;
private static _instanceCounter;
readonly instanceId: string;
private _globalEnv;
/**
* @brief 创建新的 AliRtcEngine 实例(多实例模式)
* @param config 实例配置
* @returns 新创建的 AliRtcEngine 实例
* @details 每次调用都会创建一个新的独立实例,适用于需要同时管理多个用户的场景
*/
static createInstance(config?: AliRtcEngineConfig): AliRtcEngine_2;
/**
* @brief 获取所有活跃的实例
* @returns 实例列表
*/
static getAllInstances(): AliRtcEngine_2[];
/**
* @brief 根据实例ID获取实例
* @param instanceId 实例ID
* @returns AliRtcEngine实例或undefined
*/
static getInstanceById(instanceId: string): AliRtcEngine_2 | undefined;
/**
* @brief 销毁所有实例
*/
static destroyAll(): Promise;
private static _instance?;
/**
* @brief 获取AliRtcEngine实例
* @param key key 可选参与,用于创建多个实例
* @details 该方法为同步调用,以单例的形式提供对象创建。
*/
static getInstance(config?: AliRtcEngineConfig): AliRtcEngine_2;
static AliRtcSdkChannelProfile: typeof AliRtcSdkChannelProfile;
static AliRtcSdkClientRole: typeof AliRtcSdkClientRole;
static AliRtcVideoStreamType: typeof AliRtcVideoStreamType;
static AliRtcVideoTrack: typeof AliRtcVideoTrack;
static AliRtcAudioTrack: typeof AliRtcAudioTrack;
static AliRtcPublishState: typeof AliRtcPublishState;
static AliRtcSubscribeState: typeof AliRtcSubscribeState;
static AliRtcRawDataStreamType: typeof AliRtcRawDataStreamType;
static AliRtcLogLevel: typeof AliRtcLogLevel;
static AliRtcEngineLocalDeviceType: typeof AliRtcEngineLocalDeviceType;
static AliRtcEngineLocalDeviceExceptionType: typeof AliRtcEngineLocalDeviceExceptionType;
static AliRtcConnectionStatus: typeof AliRtcConnectionStatus;
static AliRtcConnectionStatusChangeReason: typeof AliRtcConnectionStatusChangeReason;
static AliRtcPlugin: typeof AliRtcPlugin;
static AliRtcPluginTrackType: typeof AliRtcPluginTrackType;
static AliRtcImageHolderPlugin: typeof AliRtcImageHolderPlugin;
static AliRtcLiveTranscodingParam: typeof AliRtcLiveTranscodingParam;
static AliRtcLiveTranscodingEncodeParam: typeof AliRtcLiveTranscodingEncodeParam;
static AliRtcLiveTranscodingMixParam: typeof AliRtcLiveTranscodingMixParam;
static AliRtcLiveTranscodingSingleParam: typeof AliRtcLiveTranscodingSingleParam;
static AliRtcTranscodingClockWidget: typeof AliRtcTranscodingClockWidget;
static AliRtcTranscodingImage: typeof AliRtcTranscodingImage;
static AliRtcTranscodingText: typeof AliRtcTranscodingText;
static AliRtcTranscodingUser: typeof AliRtcTranscodingUser;
static AliRtcLiveTranscodingMixMode: typeof AliRtcLiveTranscodingMixMode;
static AliRtcLiveTranscodingStreamType: typeof AliRtcLiveTranscodingStreamType;
static AliRtcLiveTranscodingSourceType: typeof AliRtcLiveTranscodingSourceType;
static AliRtcLiveTranscodingTaskProfile: typeof AliRtcLiveTranscodingTaskProfile;
static AliRtcLiveTranscodingAudioSampleRate: typeof AliRtcLiveTranscodingAudioSampleRate;
static AliRtcLiveTranscodingSegmentType: typeof AliRtcLiveTranscodingSegmentType;
static AliRtcLiveTranscodingFontType: typeof AliRtcLiveTranscodingFontType;
static AliRtcLiveTranscodingCropMode: typeof AliRtcLiveTranscodingCropMode;
static AliRtcLiveTranscodingMediaProcessMode: typeof AliRtcLiveTranscodingMediaProcessMode;
static AliRtcLiveTranscodingState: typeof AliRtcLiveTranscodingState;
static AliRtcLiveTranscodingErrorCode: typeof AliRtcLiveTranscodingErrorCode;
static AliRtcTrascodingPublishTaskStatus: typeof AliRtcTrascodingPublishTaskStatus;
static AliRtcDataChannelMsg: typeof AliRtcDataChannelMsg;
static AliRtcDataMsgType: typeof AliRtcDataMsgType;
/**
* @brief 销毁 {@link AliRtcEngine}实例
* @details 调用该方法将会释放所有内部使用的资源,当完成音视频通信之后都建议调用该方法释放实例.调用该方法后,你将不能再使用 {@link AliRtcEngine} 的其他方法和任何回调,如需要再次使用需要重新调用 {@link AliRtcEngine.getInstance} 或 {@link AliRtcEngine.createInstance} 方法创建一个新的实例。
* @note 该方法为同步调用,需要等待内部资源释放之后才能执行其他方法
*/
destroy(): Promise;
/**
* C1: 配置 tracer 的实例方法
* @param config 引擎配置
* @note tracer 是模块级的类包装器,只应由第一个实例配置一次
*/
private configureTracer;
/**
* C2: 同步全局环境配置
* @details 在关键操作前调用此方法,确保该实例使用正确的环境配置
* 注意: AliRTS.ENV 是外部库的全局配置,多实例并发场景下可能存在竞争
*/
private syncGlobalEnv;
protected channelProfile: AliRtcSdkChannelProfile;
protected clientRole: AliRtcSdkClientRole;
protected signalingManager: SignalingManager;
protected bizControl: BizControl;
protected liveTranscoding: AliRtcLiveTranscoding;
protected maxSignalingReconnectDuration?: number;
protected slsReporter: SLSReporter;
protected connectState: AliRtcConnectionStatus;
protected networkError: boolean;
private _audioOnlyMode;
private _destroyed;
private _authInfoWillExpireTimer;
private _authInfoExpiredTimer;
private _serverCheckAuthInfoTimestamp;
private _localCheckAuthInfoTimestamp;
private _proxyAiTid;
private _agentParam;
sessionId?: string;
constructor(config?: AliRtcEngineConfig, instanceId?: string);
/**
* 获取当前频道号,已经入会成功返回频道号,否则返回undefined
*/
get channel(): string | undefined;
/**
* 获取当前用户的 userId,已经入会成功返回自己的 userId,否则返回 undefined
*/
get userId(): string | undefined;
get remoteUsers(): RemoteUser[];
get publisher(): LocalUser;
get publishAudioStream(): LocalStream | undefined;
get isPublishing(): boolean;
private get currentRoleCanPublish();
/**
* @brief 推流前校验当前是否具备推流条件
* @details 互动直播模式下非主播角色(clientRole 非 Interactive)不允许推流;或推流地址为空时无法推流。
* 这两种情况直接报错,避免观众角色静默开启本地采集却无法真正推流。
* @param mediaType 推流媒体类型描述,用于错误信息
*/
private checkPublishable;
/**
* 监听 Publisher 事件
*/
private addPublisherListeners;
private occurError;
/**
* 监听 UM 事件
*/
private addBizControlListeners;
/**
* 添加信令处理
* @returns {void}
*/
private addSignalingManagerListeners;
private backToUnpublishStatus;
/**
* 处理入会远程的用户
* @param {JoinInfo[]} userJoinInfo
* @returns {void}
*/
private handleUsersJoin;
/**
* 本地用户设备状态变化,通过信令发送给其他人
* @param {string} status
* @returns {void}
*/
protected onLocalDeviceStatusChange(status: string): void;
/**
* 网络恢复后,重推;
*/
private resumePublishForNetworkRecovery;
/**
* 处理房间信令重连成功/心跳恢复
* @returns {void}
*/
protected onNetworkRecovery(users?: JoinInfo[]): Promise;
private resumeSubList;
/**
* 重新订阅远端用户
* @param {string} userId
* @returns {Promise}
*/
retrySubscribe(userId: string): Promise;
/**
* 处理网络异常
* @param {AliRtcError} err
* @returns {void}
*/
protected onNetworkError(): void;
/**
* 处理错误
* @param {AliRtcError} err
* @returns {void}
*/
protected onError(err: AliRtcError): void;
/**
* 是否开启大小流
* @param {boolean} enabled
* @param {AliRtcDualVideoPluginOptions} [options]
*/
setEnableDualVideoStream(enabled: boolean, options?: AliRtcDualVideoPluginOptions): void;
/**
* 对本地流的操作预检查
*/
private hadPushStream;
/**
* 获取当前使用的麦克风 deviceId
* @returns {string | undefined}
*/
getCurrentMicDeviceId(): string | undefined;
/**
* 设置频道模式
* @param {AliRtcSdkChannelProfile} channelProfile 频道类型,默认值为 AliEngineCommunication
* @note 该接口只可以在加入频道之前调用,会议中不可以重新设置,离开频道后可以重新设置
*/
setChannelProfile(channelProfile: AliRtcSdkChannelProfile): void;
private startDefaultDevices;
private startPublish;
/**
* 设置用户角色
* @param {AliRtcSdkClientRole} clientRole 用户角色类型,默认值为 {@link AliRtcSdkClientRole.AliRtcSdkLive}(观众角色)
* @note 非通信模式下角色类型才有效
*/
setClientRole(clientRole: AliRtcSdkClientRole): Promise;
/**
* 获取用户角色
* @returns {AliRtcSdkClientRole}
*/
getCurrentClientRole(): AliRtcSdkClientRole;
/**
* 是否开启纯音频模式
* @param {boolean} audioOnly
* - true:只有音频推流和拉流
* - false(默认值):音视频都支持
* @note 只可以在 {@link joinChannel} 之前设置
*/
setAudioOnlyMode(audioOnly: boolean): void;
setAudioRedEnabled(audioRedEnabled: boolean): void;
setVideoCodec(videoCodec: CodecType): void;
/**
* 设定鉴权信息过期事件定时器
* @param expireTimestamp 鉴权信息过期时间
* @param serverTimestamp 入会时服务端时间
*/
private setCheckAuthInfoTimer;
/**
* 清除鉴权信息过期事件定时器
*/
private clearCheckAuthInfoTimer;
/**
* @brief 加入频道
* @details 该方法让用户加入频道,一个频道内可以加入多个用户进行互相通话。
* @details 一般在调用该方法前会根据场景先选择频道模式,通过调用 {@link setChannelProfile} 实现,默认频道模式为通信模式 {@link AliRtcSdkChannelProfile.AliRtcSdkCommunication}
* ``` javascript
* // 设置频道为互动模式
* engine.setChannelProfile(AliRtcSdkChannelProfile.AliRtcInteractiveLive);
* // 设置角色为主播角色
* engine.setClientRole(AliRtcSdkClientRole.AliRtcSdkInteractive);
* ```
* @param {AliRtcAuthInfo | string} authInfoOrToken (多参数/单参数) 认证信息,从App Server获取。
* @param {string} userName 任意用于显示的用户名称。不是User ID
* @param {any} extraData 入会自定义数据
* @note
* - 异步接口,方法执行成功则为成功入会
* - 正常情况一个AppId对应一个App,只有同一个AppId的应用可进行互相通话,不同AppId和channelID不同都不能互通
* - 当入会成功后,会触发远端用户收到 {@link AliRtcEngineEventListener.remoteUserOnLineNotify} 回调
* - 如果已在会中想重新入会,需要先调用 {@link leaveChannel} 离会,且确保方法执行成功
* - 用户加入频道后,默认订阅频道内所有其他用户的音视频流,默认推送音视频流到远端,因此将会产生计费,如果想要取消默认订阅可以 {@link joinChannel} 前调用 {@link setDefaultSubscribeAllRemoteAudioStreams} 和 {@link setDefaultSubscribeAllRemoteVideoStreams}
*/
joinChannel(authInfoOrToken: AliRtcAuthInfo | string, userNameOrParam?: string | AliRtcChannelParam, extraData?: any): Promise;
/**
* @brief 加入频道
* @details 该方法让用户加入频道,一个频道内可以加入多个用户进行互相通话。
* @details 一般在调用该方法前会根据场景先选择频道模式,通过调用 {@link setChannelProfile} 实现,默认频道模式为通信模式 {@link AliRtcSdkChannelProfile.AliRtcSdkCommunication}
* ``` javascript
* // 设置频道为互动模式
* engine.setChannelProfile(AliRtcSdkChannelProfile.AliRtcInteractiveLive);
* // 设置角色为主播角色
* engine.setClientRole(AliRtcSdkClientRole.AliRtcSdkInteractive);
* ```
* @param token 认证信息,从App Server获取。
* @param channelParam 入会参数,详见{@link AliRtcChannelParam}
* @param agentParam AI代理参数,详见{@link AliRtcAIAgentParam}
* @note
* - 异步接口,方法执行成功则为成功入会
* - 正常情况一个AppId对应一个App,只有同一个AppId的应用可进行互相通话,不同AppId和channelID不同都不能互通
* - 当入会成功后,会触发远端用户收到 {@link AliRtcEngineEventListener.remoteUserOnLineNotify} 回调
* - 如果已在会中想重新入会,需要先调用 {@link leaveChannel} 离会,且确保方法执行成功
* - 用户加入频道后,默认订阅频道内所有其他用户的音视频流,默认推送音视频流到远端,因此将会产生计费,如果想要取消默认订阅可以 {@link joinChannel} 前调用 {@link setDefaultSubscribeAllRemoteAudioStreams} 和 {@link setDefaultSubscribeAllRemoteVideoStreams}
*/
joinAIChannel(token: string, channelParam: AliRtcChannelParam, agentParam: AliRtcAIAgentParam): Promise;
/**
* @brief 离开频道
* @details 离开频道时会停止推流和拉流,并释放相关资源。调用该方法后会触发以下行为:
* - 停止音视频流的推送和订阅
* - 释放音视频设备资源
* - 触发远端用户收到 {@link AliRtcEngineEventListener.remoteUserOffLineNotify} 回调
* @note 如果当前不在频道内,调用 leaveChannel 不会对实例产生任何影响
* @note 该方法为异步调用,需要等待内部资源释放后才能再次调用 {@link joinChannel}
*/
leaveChannel(): Promise;
/**
* 检查当前是否在频道中
* @returns {boolean}
* - true:在频道中
* - false:不在频道中
*/
isInCall(): boolean;
/**
* 刷新鉴权信息
* @param {AliRtcRefreshAuthInfo | string} authInfoOrToken
*/
refreshAuthInfo(authInfoOrToken: AliRtcRefreshAuthInfo | string): Promise;
/**
* 检查当前是否纯音频模式
* @returns {boolean}
* - true:纯音频模式
* - false:音视频模式
*/
isAudioOnly(): boolean;
/**
* @brief 是否推送音频流
* @param enabled 是否开启/关闭本地音频流推送
* - true: 开启音频流推送
* - false: 关闭音频流推送
* @note SDK默认设置推送音频流,在加入频道前也可以调用此接口修改默认值,并在加入频道成功时生效
* @note 加入频道后调用不会停止本地音频采集
*/
publishLocalAudioStream(enabled: boolean): Promise;
/**
* @brief 查询是否设置推送音频流
* @return
* - true: 已设置推送
* - false: 未设置推送
* @note SDK默认设置推送音频流,如果需要取消推送音频流,可以通过 {@link publishLocalAudioStream}方法设置为不推送
*/
isLocalAudioStreamPublished(): boolean;
/**
* 设置是否默认接收音频流
* @param sub
* - true: 接收用户的音频流
* - false: 停止接收用户的音频流
* @note 入会前入会后均可调用。如果在加入频道后调用 setDefaultSubscribeAllRemoteAudioStreams(false),会接收不到设置后加入频道的用户的音频流。
* @note 停止接收音频流后,如果想要恢复接收,请调用 {@link subscribeRemoteAudioStream},并指定你想要接收的远端用户ID;
* @note 如果想恢复接收多个用户的音频流,则需要多次调用 {@link subscribeRemoteAudioStream}。setDefaultSubscribeAllRemoteAudioStreams(true) 只能恢复接收后面加入频道的用户的音频流。
*/
setDefaultSubscribeAllRemoteAudioStreams(sub: boolean): void;
/**
* 停止/恢复接收所有远端音频流
* @param sub
* - true: 接收所有用户的音频流
* - false: 停止接收所有用户的音频流
* @note 该接口作为订阅远端音频流的总开关,如果设置为false,则不仅当前会议中所有远端音频流都会停止订阅,后续入会的新用户也将不再订阅(即使设置了setDefaultSubscribeAllRemoteAudioStreams(true))
*/
subscribeAllRemoteAudioStreams(sub: boolean): void;
/**
* 手动拉音频流
* @param uid uid
* @param sub,默认为 true
* - true: 接收指定用户的音频流
* - false: 停止接收指定用户的音频流
* @note 如果之前有调用过 subscribeAllRemoteAudioStreams(false) 对所有远端音频进行静音,在调用本 API 之前请确保你已调用 subscribeAllRemoteAudioStreams(true)。
* @note {@link subscribeAllRemoteAudioStreams} 是全局控制,{@link subscribeRemoteAudioStream} 是精细控制。
*/
subscribeRemoteAudioStream(uid: string, sub: boolean): void;
/**
* 手动恢复远端用户音频流
* @param uid
* 用于在自动播放失败等场景恢复播放
*/
resumeRemoteAudioStream(uid: string): void;
stopRemoteAudioPlay(uid: string): void;
/**
* @brief 是否推送本地视频流
* @param enabled 是否开启/关闭本地视频流推送
* - true: 开启视频流推送
* - false: 关闭视频流推送
* @note SDK默认设置推送视频流,在加入频道前也可以调用此接口修改默认值,并在加入频道成功时生效
* @note 加入频道后调用不会停止本地视频采集
*/
publishLocalVideoStream(enabled: boolean): Promise;
/**
* @brief 查询是否设置推送视频流
* @return
* - true: 已设置推送
* - false: 未设置推送
* @note SDK默认设置推送视频流,如果需要取消推送视频流,可以通过 {@link publishLocalVideoStream} 方法设置为不推送
*/
isLocalVideoStreamPublished(): boolean;
/**
* 设置默认订阅的相机流格式,大流或小流,会覆盖单人的大小流设置
* @param {AliRtcVideoStreamType} streamType 流类型
* @note 仅支持传入 1 (默认大流)、2(默认小流),传入其他无效
* @note 当无默认类型的相机流,但有另一个,将拉取另一个
*/
setRemoteDefaultVideoStreamType(streamType: AliRtcVideoStreamType): void;
/**
* 设置某一用户默认订阅的相机流格式,大流或小流
* @param userId 远端用户ID
* @param {AliRtcVideoStreamType} streamType 流类型
* @note 仅支持传入 1 (默认大流)、2(默认小流),传入其他无效
* @note 当无默认类型的相机流,但有另一个,将拉取另一个
*/
setRemoteUserVideoStreamType(userId: string, streamType: AliRtcVideoStreamType): void;
/**
* 设置是否默认接收视频流
* @param sub
* - true: 接收用户的视频流
* - false: 不接收用户的视频流
* @note 入会前入会后均可调用。如果在加入频道后调用 setDefaultSubscribeAllRemoteVideoStreams(false),会接收不到设置后加入频道的用户的视频流。
* @note 停止接收视频流后,如果想要恢复接收,请调用 {@link subscribeRemoteVideoStream},并指定你想要接收的远端用户ID;
* @note 如果想恢复接收多个用户的视频流,则需要多次调用 {@link subscribeRemoteVideoStream};setDefaultSubscribeAllRemoteVideoStreams(true) 只能恢复接收后面加入频道的用户的视频流。
*/
setDefaultSubscribeAllRemoteVideoStreams(sub: boolean): void;
/**
* 停止/恢复接收所有远端视频流
* @param sub
* - true: 接收所有用户的视频流
* - false: 停止接收所有用户的视频流
* @note 该接口作为订阅远端视频流的总开关,如果设置为false,则不仅当前会议中所有远端视频流都会停止订阅,后续入会的新用户也将不再订阅(即使设置了setDefaultSubscribeAllRemoteVideoStreams(true))
*/
subscribeAllRemoteVideoStreams(sub: boolean): void;
/**
* 合并订阅远端音视频流
* @param uid uid
* @param videoTrack 视频流类型
* @param subVideo 是否订阅视频
* @param subAudio 是否订阅音频
* @return
*/
subscribeRemoteMediaStream(uid: string, videoTrack: AliRtcVideoTrack, subVideo: boolean, subAudio: boolean): void;
/**
* @brief 手动恢复远端用户视频流
* @param uid
* @param videoTrack
* 用于在自动播放失败等场景恢复播放
*/
resumeRemoteMediaStream(uid: string, videoTrack: AliRtcVideoTrack): void;
/**
* @brief 订阅目标频道,指定用户的流
* @param channelId 目标频道
* @param uid 用户ID,从App server分配的唯一标示符
* @param track 订阅的视频流类型
* @param sub_audio 是否订阅远端用户的音频流
* - true:订阅指定用户的音频流
* - false:停止订阅指定用户的音频流
* @param sub 是否订阅远端用户的流
* - true:订阅指定用户的流
* - false:停止订阅指定用户的流
*/
/**
* @brief 获取远端在线用户列表
* @return 当前频道内所有在线用户userid列表
* @note 若当前频道ChannelProfile设置为 {@link AliRtcSdkChannelProfile.AliRtcSdkInteractiveLive} 模式,只有设置角色为 {@link AliRtcSdkClientRole.AliRtcSdkInteractive} 的用户为在线用户,本方法不返回角色为 {@link AliRtcSdkClientRole.AliRtcSdkLive} 的用户
*/
getOnlineRemoteUsers(): string[];
/**
* @brief 查询远端用户状态
* @details 通过 uid 查询指定远端用户的状态信息.
* @param uid 用户ID。从App server分配的唯一标示符
* @return 返回一个远端用户对象。详见{@link RemoteUser}
*/
getUserInfo(uid: string): AliRtcRemoteUserInfo | undefined;
/**
* @brief 查询用户是否在线
* @param uid 用户ID,从App server分配的唯一标示符。不可为NULL
* @return
* - true: 用户在线
* - false: 用户不在线
* @note 根据特定的UserID,查询该用户是否在线。
*/
isUserOnline(uid: string): boolean;
/**
* @brief 开始屏幕共享
* @param config 开启屏幕共享的配置
* @note 可以通过 config 选择是否开启音频或使用外部自定义 MediaStream
* @note 自定义 MediaStream 仅支持一个视频流和一个音频流
*/
startScreenShare(config?: AliRtcScreenShareStartConfig): Promise;
/**
* @brief 停止屏幕共享
*/
stopScreenShare(): Promise;
/**
* @brief 设置屏幕流视频编码属性
* @details 该方法用于设置屏幕流视频编码属性对应的视频参数,如分辨率、帧率、码率、等 所有设置的参数都有相应的范围限制,如果设置的参数不在有效范围内,SDK会自动调节
* @param config 预定义的屏幕共享编码属性,
* @note
* - 该方法在入会前和入会后都可以调用,如果每次入会只需要设置一次屏幕流视频编码属性,建议在入会前调用
*/
setScreenShareConfiguration(config: AliRtcScreenShareConfiguration): Promise;
/**
* @brief 设置屏幕流采集内容提示
* @param contentHint 设置屏幕流内容提示,用于提升在不同内容场景下的视频编码质量 [参考文档](https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/contentHint)
*/
setScreenShareContentHint(contentHint: string): Promise;
/**
* @brief 是否推送屏幕分享
* @param enabled 是否开启/关闭本地屏幕分享推送
* - true: 开启屏幕分享推送
* - false: 关闭屏幕分享推送
* @param config 开启屏幕共享的配置
* @note SDK默认设置推送屏幕分享,在加入频道前也可以调用此接口修改默认值,并在加入频道成功时生效
* @note 加入频道后调用不会停止本地屏幕采集
*/
publishLocalScreenShareStream(enabled: boolean, config?: AliRtcScreenShareStartConfig): Promise;
/**
* @brief 查询是否设置推送屏幕分享
* @return
* - true: 已设置推送
* - false: 未设置推送
* @note SDK默认设置不推送屏幕分享,如果需要推送屏幕共享,可以通过{@link startScreenShare}方法开启屏幕共享推送
*/
isScreenSharePublished(): boolean;
/**
* @brief 设置共享音频的音量大小
* @param volume 共享音频音量大小,取值范围[0, 100]
*/
setAudioShareVolume(volume: number): void;
/**
* 开启音量检测功能
* @param {number} interval 检测间隔,单位: ms
* @note 建议设置为300ms~500ms,取值 ≤0 表示不启用音量检测功能
*/
enableAudioVolumeIndication(interval: number): void;
/**
* 停止/恢复本地音频数据发送
* @param {boolean} mute 停止或恢复本地音频数据发送
* - true:静音本地音频
* - false(默认值):取消静音
*/
muteLocalMic(mute?: boolean): void;
/**
* 停止/恢复远端指定用户的音频流的播放
* @param {string} uid 用户ID, 从 App server 分配的唯一标示符
* @param {boolean} mute 停止或恢复远端的音频播放
* - true:停止播放
* - false(默认值):恢复播放
* @note 拉流和解码不受影响,支持 {@link joinChannel} 之前和之后设置
*/
muteRemoteAudioPlaying(uid: string, mute?: boolean): void;
/**
* 停止/恢复远端的所有音频流的播放
* @param {boolean} mute 停止或恢复远端的音频播放
* - true:停止播放
* - false(默认值):恢复播放
* @note 拉流和解码不受影响,支持 {@link joinChannel} 之前和之后设置
*/
muteAllRemoteAudioPlaying(mute?: boolean): void;
/**
* @brief 开启音频采集
* @details 此接口可以控制提前打开音频采集,如果不设置,则SDK会自动控制音频采集设备:
* - 如果打开推送音频流{@link publishLocalAudioStream},SDK在入会后会打开音频采集
* - 如果关闭推送音频流{@link publishLocalAudioStream},SDK在入会后不会打开音频采集
* @param {IAudioConstraints} audioConstraints 音频采集参数
*/
startAudioCapture(audioConstraints?: MediaTrackConstraints): Promise;
/**
* @brief 设置音频采集参数
* @param constraints 音频采集参数
*/
setAudioConstraints(constraints: MediaTrackConstraints): Promise;
/**
* 关闭音频采集
* @note 调用此接口后,入会后、离会再入会,采集设备保持关闭状态
*/
stopAudioCapture(): void;
/**
* 切换麦克风
* @param {string} deviceId 麦克风设备ID
* @param {MediaStreamAudioTrack} audioTrack 音频轨道
* @note 传入 audioTrack 则会使用传入的音频轨道
*/
switchMicrophone(deviceId: string, audioTrack?: MediaStreamAudioTrack): Promise;
/**
* 设置录音音量
* @param {VolumeSettings} volumeSettings 录音音量,取值范围[0,100]
* - 0:静音
* - <100:减小音量
* - >100:放大音量
*/
setRecordingVolume(volume: number): void;
/**
* @brief 设置播放音量
* @param volume 播放音量,取值范围[0,100], 0:静音;100:原始音量
* @note 注意此方法与 {@link setRemoteAudioVolume} 相互影响,以后调用的一个为准
*/
setPlayoutVolume(volume: number): void;
/**
* @brief 设置播放音量
* @param userId 用户ID
* @param volume 播放音量,取值范围[0,100], 0:静音;100:原始音量
* @note 注意此方法与 {@link setPlayoutVolume} 相互影响,以后调用的一个为准
*/
setRemoteAudioVolume(userId: string, volume: number): void;
/**
* 设置麦克风 profile
*
* @param {AudioProfileKey} profileKey
* @return {Promise}
*/
setAudioProfile(profileKey: AudioProfileKey): Promise;
/**
* @brief 获取当前用户或远端用户的音频轨道
* @param {string} userId 远端用户 userId,不传或为空时返回本地音频轨道
* @return {Promise} 音频轨道,如果不存在则返回 undefined
*
*/
getAudioTrack(userId?: string): Promise;
/**
* 为本地预览设置渲染元素和视频流
* @param {AliRtcLocalView} view 渲染元素,null 则为停止显示
* @param {AliRtcVideoTrack} track 视频流类型
*/
setLocalViewConfig(view: AliRtcLocalView, track: AliRtcVideoTrack): Promise;
/**
* @brief 采集偏好设置
* @param cameraCapturerConfiguration 偏好设置
* - width: 设置采集分辨率宽度 默认 1280
* - height: 设置采集分辨率高度 默认 720
* - frameRate: 设置采集帧率 默认 30
* - bitrate: 设置采集码率 默认 2000
* - cameraDirection: 设置采集方向,前置或后置摄像头
* - deviceId: 设置采集相机ID
*/
setCameraCapturerConfiguration(cameraCapturerConfiguration: AliEngineCameraCapturerConfiguration): Promise;
/**
* @brief 设置摄像头采集内容提示
* @param contentHint 设置视频内容提示,用于提升在不同内容场景下的视频编码质量 [参考文档](https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/contentHint)
*/
setCameraCapturerContentHint(contentHint: string): Promise;
/**
* 禁用或启用摄像头采集
* @param enabled
* - true : 启用摄像头采集
* - false : 禁用摄像头采集
*/
enableLocalVideo(enabled?: boolean): Promise;
/**
* 是否将停止摄像头流数据发送
* @param mute
* - true:停止发送摄像头流数据
* - false:表示恢复正常
*/
muteLocalCamera(mute: boolean): Promise;
/**
* 是否将停止屏幕共享流数据发送
* @param mute
* - true:停止发送屏幕共享流数据
* - false:表示恢复正常
*/
muteLocalScreen(mute: boolean): Promise;
/**
* 设置远端视频显示视图
* @param {AliRtcLocalView} view 渲染元素
* @param {AliRtcVideoTrack} track 视频流类型
* @param {string} uid 用户ID, 从App server分配的唯一标示符
* @note 支持joinChannel之前和之后切换窗口。如果 view 传入 null,则停止显示
*/
setRemoteViewConfig(view: AliRtcLocalView, uid: string, track: AliRtcVideoTrack): void;
/**
* 检查camera是否打开
* @return {boolean}
* - true: 摄像头已打开
* - false: 摄像头没有打开
* @note 该接口用于检查当前camera的状态
*/
isCameraOn(): boolean;
/**
* 切换摄像头
* @param {string} deviceId 摄像头设备ID
* @param {MediaStreamVideoTrack} videoTrack 视频流
* @note 若不传 deviceId 则前后摄像头切换,传入 videoTrack 则会使用传入的 videoTrack
*/
switchCamera(deviceId?: string, videoTrack?: MediaStreamVideoTrack): Promise;
/**
* 获取摄像头设备ID
* @return {string} 摄像头设备ID
*/
getCurrentCameraDeviceId(): string | undefined;
/**
* @brief 开启摄像头预览
* @details 开启摄像头预览并自动打开摄像头
* @note 如果没有调用{@link setLocalViewConfig}设置显示的view,则无法预览,但不影响推流。
* 可以在{@link joinChannel}之前就开启预览会自动打开摄像头。
*/
startPreview(): Promise;
/**
* @brief 开启屏幕共享预览
* @details 开启屏幕共享预览并自动打开屏幕共享
* @param config 开启屏幕共享的配置
* @note 如果没有调用{@link setLocalViewConfig}设置显示的view,则无法预览,但不影响推流。
* 可以在{@link joinChannel}之前就开启预览会自动打开屏幕共享。
*/
startPreviewScreen(config?: AliRtcScreenShareStartConfig): Promise;
/**
* @brief 停止本地视频预览
*/
stopPreview(): Promise;
/**
* @brief 停止本地屏幕共享预览
*/
stopPreviewScreen(): Promise;
/**
* @brief 获取当前用户或远端用户的视频轨道
* @param {AliRtcVideoTrackConfig} config 视频轨道配置
* @return {MediaStreamTrack} 视频轨道
*
*/
getVideoTrack(config: AliRtcVideoTrackConfig): Promise;
/**
* @brief 开启旁路直播
* @details SDK提供了开启旁路直播的功能,可以把实时音视频流经过混流、混音处理转为标准直播流并推送至指定CDN供应商
* @param streamUrl 推流地址
* @param transcoding 推流所需参数, 详细定义见{@link AliRtcLiveTranscodingParam}
*/
startPublishLiveStream(streamUrl: string, transcoding: AliRtcLiveTranscodingParam): Promise;
/**
* @brief 更新旁路直播相关参数
* @details SDK提供了更新旁路直播的功能,用于实时更新旁路直播参数
* @param streamUrl 推流地址
* @param transcoding 推流所需参数, 详细定义见{@link AliRtcLiveTranscodingParam}
*/
updatePublishLiveStream(streamUrl: string, transcoding: AliRtcLiveTranscodingParam): Promise;
/**
* @brief 使用任务ID更新旁路直播相关参数
* @details SDK提供了更新旁路直播的功能,用于实时更新旁路直播参数
* @param taskId 任务ID,通过 {@link startPublishLiveStream} 返回
* @param transcoding 推流所需参数, 详细定义见{@link AliRtcLiveTranscodingParam}
* @return
* - 0 : 成功
* - 非0 : 失败
* - ERR_INNER(-1) : SDK内部错误,可能的情况为SDK未初始化或者SDK销毁后调用
* - 其他 : 返回值参考官网错误码
*/
updatePublishLiveStreamWithTaskId(taskId: string, transcoding: AliRtcLiveTranscodingParam): Promise;
/**
* @brief 停止旁路直播
* @details SDK提供了停止旁路直播的功能
* @param streamUrl 推流地址
*/
stopPublishLiveStream(streamUrl: string): Promise;
/**
* @brief 使用任务ID停止旁路直播
* @details SDK提供了停止旁路直播的功能
* @param taskId 任务ID,通过 {@link startPublishLiveStream} 返回
*/
stopPublishLiveStreamWithTaskId(taskId: string): Promise;
/**
* 获取旁路直播状态
* @param streamUrl 推流地址
* @return 路直播状态
*/
/**
* @brief 设置是否启用媒体扩展信息
* @param enabled 是否启用媒体扩展,需要在加入房间之前调用
*/
setEnableMediaExtensionMsg(enabled: boolean): void;
/**
* @brief 发送媒体扩展信息
* @details SDK提供了发送和接收媒体扩展信息的功能,接收端参考 {@link AliRtcEngineEventListener.mediaExtensionMsgReceived},使用场景:
* - 使用媒体扩展信息传递时间戳,计算端到端的网络延迟,或者跟自身其他业务做数据同步
* - 使用媒体扩展信息传递描述信息。目前可以传递最多 4k Byte数据,可以用来传输少量数据,建议使用Json或者纯字符串;
* - 内部使用SEI扩展协议来实现;
*
* @param message 媒体扩展信息,长度限制为最大4K字节
* @param repeatCount 重复次数,代表消息冗余度,用于防止网络丢包导致的消息丢失,-1为无限传输
*
* @note 启用此能力会增加客户端性能开销,如有需求需要在加入房间之前调用 setEnableMediaExtensionMsg
* @note 使用媒体扩展信息时需要复用音视频数据通道,因此必须控制自定义消息的发送频率和消息数据长度,使用限制如下:
* - 每秒最多发送profile条消息,因为sei信息是放到h264/h265流中传输,有视频帧编码才能附加扩展信息;
* - 为了不影响媒体数据的传输质量,自定义消息体长度限制为4k Byte,可以用来传输少量信息;
* - sendMediaExtensionMsg函数中repeatCount参数为自定义消息冗余度,若大于1,则会发送多次,
* - 防止网络丢包导致的消息丢失,此时房间里的其他人也会收到多次相同的消息,需要去重
* - 发送的自定义消息,在旁路直播时,房间里的订阅者也一样会收到
* - 同一时间只有一条MediaExtensionMsg在传输,多次调用sendMediaExtensionMsg,新调用的数据会覆盖前一次的数据;
*/
sendMediaExtensionMsg(message: ArrayBuffer, repeatCount: number): Promise;
/**
* @brief 发送媒体扩展信息
* @details SDK提供了发送和接收媒体扩展信息的功能,接收端参考 {@link AliRtcEngineEventListener.mediaExtensionMsgReceived},使用场景:
* - 使用媒体扩展信息传递时间戳,计算端到端的网络延迟,或者跟自身其他业务做数据同步
* - 使用媒体扩展信息传递描述信息。目前可以传递最多 4k Byte数据,可以用来传输少量数据,建议使用Json或者纯字符串;
* - 内部使用SEI扩展协议来实现;
*
* @param message 媒体扩展信息,长度限制为最大4K字节
* @param repeatCount 重复次数,代表消息冗余度,用于防止网络丢包导致的消息丢失,-1为无限传输
* @param payloadType [5, 100..254]范围 payloadType=5等于使用sendMediaExtensionMsg 接口
*
* @note 启用此能力会增加客户端性能开销,如有需求需要在加入房间之前调用 setEnableMediaExtensionMsg
* @note 使用媒体扩展信息时需要复用音视频数据通道,因此必须控制自定义消息的发送频率和消息数据长度,使用限制如下:
* - 每秒最多发送profile条消息,因为sei信息是放到h264/h265流中传输,有视频帧编码才能附加扩展信息;
* - 为了不影响媒体数据的传输质量,自定义消息体长度限制为4k Byte,可以用来传输少量信息;
* - sendMediaExtensionMsg函数中repeatCount参数为自定义消息冗余度,若大于1,则会发送多次,
* - 防止网络丢包导致的消息丢失,此时房间里的其他人也会收到多次相同的消息,需要去重
* - 发送的自定义消息,在旁路直播时,房间里的订阅者也一样会收到
* - 同一时间只有一条MediaExtensionMsg在传输,多次调用sendMediaExtensionMsg,新调用的数据会覆盖前一次的数据;
*/
sendMediaExtensionMsgEx(message: ArrayBuffer, repeatCount: number, payloadType: number): Promise;
static Plugin: typeof AliRtcPlugin;
/**
* @brief 开启音视频处理算法插件
* @details RTC采用插件件形式提供音视频增强及特效能力,可通过[官网组件文档](https://help.aliyun.com/document_detail/261183.html) 进行组件下载,参考插件集成文档集成进RTC引擎;
* @param plugin 插件库
* @param option 插件初始化参数值,请阅读插件库接入文档
* @note
* - 入会前入会后均可调用;
* - 如果重复调用会报错;
*/
enablePlugin(plugin: AliRtcPlugin, options?: any): void;
/**
* @brief 关闭音视频处理算法插件
* @param name 插件名称,通过 plugin.name 获取
* @note
* - 入会前入会后均可调用;
* - 重复调用返回错误;
*/
removePlugin(name: string): void;
/**
* @brief 根据插件ID设置插件
* @param name 插件名称,通过 plugin.name 获取
* @param option 插件初始化参数值,请阅读插件库接入文档
*/
setPluginOption(name: string, option: any): void;
getPluginByName(name: string): any;
/**
* @brief 根据插件名称获取插件内部信息
* @param name 插件名称,通过 plugin.name 获取
* @return 插件配置信息,如果插件不存在则返回 undefined
*/
getPluginOption(name: string): any;
/**
* 美颜功能是否有效
* @return
* - true: 美颜功能有效
* - false: 无效
*/
isBeautyAvailable(): boolean;
/**
* 美颜功能是否开启
* @return
* - true: 美颜功能已开启
* - false: 已关闭
*/
isBeautyEnabled(): boolean;
/**
* @brief 开启或关闭美颜功能, 并设置美颜效果参数
* @param enable
* - true: 开启美颜功能
* - false: 关闭美颜功能
* @param config 美颜效果参数
*/
setBeautyEffect(enable: boolean, config: AliRtcBeautyConfig): void;
/**
* @brief 开启/关闭虚拟背景替换功能
* @details 需要集成美颜插件;
* @param enable 是否开启;
* @param path 虚拟背景本地图片路径,支持JPG,PNG 格式;
*
* @note
* - 与背景虚化为替换关系,如开启虚拟背景开关后再次开启背景虚化,则只有背景虚化效果;
*/
enableBackgroundExchange(enable: boolean, path: string): void;
/**
* @brief 开启/关闭虚拟背景虚化功能
* @details 需要集成美颜插件;
* 需要集成美颜插件,背景替换与背景虚化不可同时使用,如开启虚拟背景开关后再次开启背景虚化,则只有背景虚化效果;
* @param enable 是否开启;
*
* @note
* - 与虚拟背景为替换关系,如开启背景虚化开关后再次开启虚拟背景,则只有虚拟背景效果;
*/
enableBackgroundBlur(enable: boolean): void;
setParameter(parameter: string): void;
getParameter(): string;
/**
* @brief 发送 DataChannel 消息
* @param dataChannelMsg 伴奏控制消息
*/
sendDataChannelMessage(dataChannelMsg: AliRtcDataChannelMsg): void;
/**
* @brief 不依赖入会,直接订阅远程流
* @param config 订阅配置对象
* @returns RemoteStreamHandler 远端流处理器实例
*/
subscribeRemoteStream(config: SubscribeRemoteStreamConfig): RemoteStreamHandler;
}
declare interface AliRtcEngineConfig {
env?: AliRtcEnv;
globalEnv?: 'DEFAULT' | 'SEA';
webTrack?: boolean | AliRtcWebTrackConfig;
maxSignalingReconnectDuration?: number;
parameter?: Parameter;
/** 多实例模式下的实例唯一标识 */
instanceId?: string;
}
declare interface AliRtcEngineEventListener {
/**
* @brief 网络连接状态改变
* @param status 连接状态
* @param reason 连接状态变化原因
*/
connectionStatusChange: (status: AliRtcConnectionStatus, reason: AliRtcConnectionStatusChangeReason) => void;
/**
* @brief 本地设备异常回调
* @param deviceType 设备类型, 参考{@link AliRtcEngine.AliRtcEngineLocalDeviceType}
* @param exceptionType 设备异常类型, 参考{@link AliRtcEngine.AliRtcEngineLocalDeviceExceptionType}
* @param msg 异常时携带的信息
* @note 此回调标识了内部无法恢复了设备异常,收到此回调时用户需要检查设备是否可用
*/
localDeviceException: (localDeviceType: AliRtcEngineLocalDeviceType, localDeviceExceptionType: AliRtcEngineLocalDeviceExceptionType, description: string) => void;
/**
* @brief 用户鉴权信息即将过期通知,收到后30秒鉴权过期
* @note 该回调在鉴权信息30秒前触发,收到该回调后应该及时更新鉴权信息,参考 {@link AliRtcEngine.refreshAuthInfo}
*/
/**
* 被服务器踢出/会议结束频道的消息
* @param code 原因参考{@link AliRtcEngine.AliRtcOnByeType}
*/
bye: (code: AliRtcOnByeType) => void;
/**
* @brief 远端用户(通信模式)/(互动模式,主播角色)加入频道回调
* @details 该回调在以下场景会被触发
* - 通信模式:远端用户加入频道会触发该回调,如果当前用户在加入频道前已有其他用户在频道中,当前用户加入频道后也会收到已加入频道用户的回调
* - 互动模式:
* - 远端主播角色用户加入频道会触发该回调,如果当前用户在加入频道前已有其他主播在频道中,当前用户加入频道后也会收到已加入频道主播的回调
* - 远端观众角色调用 {@link AliRtcEngine.setClientRole} 切换为主播角色 {@link AliRtcEngine.AliRtcSdkClientRole.AliRtcSdkInteractive},同时设置了推流时,会触发该回调
*
* @param uid 用户ID,从App server分配的唯一标示符
* @param elapsed 用户加入频道时的耗时
* @note 互动模式下回调行为
* - 主播间可以互相收到加入频道回调
* - 观众可以收到主播加入频道回调
* - 主播无法收到观众加入频道回调
*/
remoteUserOnLineNotify: (uid: string, elapsed: number) => void;
/**
* @brief 远端用户(通信模式)/(互动模式,主播角色)离开频道回调
* @details 该回调在以下场景会被触发
* - 通信模式:远端用户离开频道会触发该回调
* - 互动模式:
* - 远端主播角色 {@link AliRtcEngine.AliRtcSdkClientRole.AliRtcSdkInteractive} 离开频道
* - 远端主播切换调用 {@link AliRtcEngine.setClientRole} 切换为观众角色 {@link AliRtcEngine.AliRtcSdkClientRole.AliRtcSdkLive},会触发该回调
* - 通信模式和互动模式主播角色情况下,当长时间收不到远端用户数据,超时掉线时,会触发该回调
*
* @param uid 用户ID,从App server分配的唯一标示符
* @param reason 用户离线的原因,详见 {@link AliRtcEngine.AliRtcUserOfflineReason}
*/
remoteUserOffLineNotify: (uid: string, aliRtcUserOfflineReason: AliRtcUserOfflineReason) => void;
/**
* @brief 远端用户的音视频流发生变化回调
* @details 该回调在以下场景会被触发
* - 当远端用户从未推流变更为推流(包括音频和视频)
* - 当远端用户从已推流变更为未推流(包括音频和视频)
* - 互动模式下,调用 {@link AliRtcEngine.setClientRole} 切换为主播角色 {@link AliRtcEngine.AliRtcSdkClientRole.AliRtcSdkInteractive},同时设置了推流时,会触发该回调
*
* @param uid 用户ID,从App server分配的唯一标示符
* @param audioTrack 音频流类型,详见 {@link AliRtcEngine.AliRtcAudioTrack}
* @param videoTrack 视频流类型,详见 {@link AliRtcEngine.AliRtcVideoTrack}
* @note 该回调仅在通信模式用户和互动模式下的主播角色才会触发
*/
remoteTrackAvailableNotify: (uid: string, aliRtcAudioTrack: AliRtcAudioTrack, aliRtcVideoTrack: AliRtcVideoTrack) => void;
/**
* @brief 远端用户静音/取消静音回调
* @param uid 远端用户ID
* @param isMute 该用户是否静音
* - true: 静音
* - false: 取消静音
*/
userAudioMuted: (uid: string, isMute: boolean) => void;
/**
* @brief 对端用户发送视频黑帧数据发送通知
* @param uid 执行muteVideo的用户ID
* @param isMute
* - true: 推流黑帧
* - false: 正常推流
* @note 该接口用于对端用户发送视频黑帧数据时的回调
*/
userVideoMuted: (uid: string, isMute: boolean) => void;
/**
* @brief 对端用户发送屏幕黑帧数据发送通知
* @param uid 执行muteVideo的用户ID
* @param isMute
* - true: 推流黑帧
* - false: 正常推流
* @note 该接口用于对端用户发送屏幕黑帧数据时的回调
*/
userScreenMuted: (uid: string, isMute: boolean) => void;
/**
* 音量反馈
* @param {Array} speakers 用户音量对象数组
* @param {string} speaker.userId 用户ID
* @param {number} speaker.volume 音量
* @note userId 为空字符串时代表是本地麦克风采集的音量
*/
audioVolume: (speakers: {
userId: string;
volume: number;
}[]) => void;
/**
* 发布视频流的数据统计
* @param aliRtcStats 统计信息
*/
aliRtcStats: (aliRtcStats: any) => void;
/**
* 音频推流变更回调
* @param track 流标识
* @param oldState 之前的推流状态
* @param newState 当前的推流状态
* @param elapseSinceLastState 状态变更时间间隔(毫秒)
* @param channel 当前频道
*/
audioPublishStateChanged: (oldState: AliRtcPublishState, newState: AliRtcPublishState, elapseSinceLastState: number, channel: string) => void;
/**
* 音频订阅情况变更回调
* @param uid 用户ID
* @param oldState 之前的订阅状态
* @param newState 当前的订阅状态
* @param elapseSinceLastState 状态变更时间间隔(毫秒)
* @param channel 当前频道
*/
audioSubscribeStateChanged: (uid: string, oldState: AliRtcSubscribeState, newState: AliRtcSubscribeState, elapseSinceLastState: number, channel: string) => void;
/**
* 视频推流变更回调
* @param oldState 之前的推流状态
* @param newState 当前的推流状态
* @param elapseSinceLastState 状态变更时间间隔(毫秒)
* @param channel 当前频道
*/
videoPublishStateChanged: (oldState: AliRtcPublishState, newState: AliRtcPublishState, elapseSinceLastState: number, channel: string) => void;
/**
* 次要流推流变更回调
* @param oldState 之前的推流状态
* @param newState 当前的推流状态
* @param elapseSinceLastState 状态变更时间间隔(毫秒)
* @param channel 当前频道
*/
dualStreamPublishStateChanged: (oldState: AliRtcPublishState, newState: AliRtcPublishState, elapseSinceLastState: number, channel: string) => void;
/**
* 屏幕分享推流变更回调
* @param oldState 之前的推流状态
* @param newState 当前的推流状态
* @param elapseSinceLastState 状态变更时间间隔(毫秒)
* @param channel 当前频道
*/
screenSharePublishStateChanged: (oldState: AliRtcPublishState, newState: AliRtcPublishState, elapseSinceLastState: number, channel: string) => void;
/**
* DataChannel 推流变更回调
* @param oldState 之前的推流状态
* @param newState 当前的推流状态
* @param elapseSinceLastState 状态变更时间间隔(毫秒)
* @param channel 当前频道
*/
dataPublishStateChanged: (oldState: AliRtcPublishState, newState: AliRtcPublishState, elapseSinceLastState: number, channel: string) => void;
/**
* 相机流订阅情况变更回调
* @param uid 用户ID
* @param oldState 之前的订阅状态
* @param newState 当前的订阅状态
* @param elapseSinceLastState 状态变更时间间隔(毫秒)
* @param channel 当前频道
*/
videoSubscribeStateChanged: (uid: string, oldState: AliRtcSubscribeState, newState: AliRtcSubscribeState, elapseSinceLastState: number, channel: string) => void;
/**
* 大小流订阅情况变更回调
* @param uid 用户ID
* @param oldStreamType 之前的订阅状态
* @param newStreamType 当前的订阅状态
* @param elapseSinceLastState 状态变更时间间隔(毫秒)
* @param channel 当前频道
*/
subscribeStreamTypeChanged: (uid: string, oldStreamType: AliRtcVideoStreamType, newStreamType: AliRtcVideoStreamType, elapseSinceLastState: number, channel: string) => void;
/**
* 屏幕分享流订阅情况变更回调
* @param uid 用户ID
* @param oldState 之前的订阅状态
* @param newState 当前的订阅状态
* @param elapseSinceLastState 状态变更时间间隔(毫秒)
* @param channel 当前频道
*/
screenShareSubscribeStateChanged: (uid: string, oldState: AliRtcSubscribeState, newState: AliRtcSubscribeState, elapseSinceLastState: number, channel: string) => void;
/**
* DataChannel 订阅情况变更回调
* @param uid 用户ID
* @param oldState 之前的订阅状态
* @param newState 当前的订阅状态
* @param elapseSinceLastState 状态变更时间间隔(毫秒)
* @param channel 当前频道
*/
dataSubscribeStateChanged: (uid: string, oldState: AliRtcSubscribeState, newState: AliRtcSubscribeState, elapseSinceLastState: number, channel: string) => void;
/**
* 收到媒体扩展信息回调
* @param uid 用户ID,媒体信息发送用户的ID
* @param message 媒体扩展信息
* @param payloadType payload类型,sendMediaExtensionMsg返回5,sendMediaExtensionMsgEx发送的会返回具体类型
* @note 当一端通过 {@link AliRtcEngine.sendMediaExtensionMsg} 发送信息后,其他端通过该回调接收数据
*/
mediaExtensionMsgReceived: (uid: string, message: ArrayBuffer, payloadType: number) => void;
/**
* 全链路端到端延迟回调(cumuDelay)
* @param uid 推流端用户ID
* @param msid 媒体流标识,标识该延迟数据对应的具体视频轨道(如 'sophon_video_camera_large'、'sophon_video_screen_share')
* @param totalDelay 全链路总延迟(ms)
* @note 需通过 setParameter('{"net":{"cumuDelay":true}}') 开启,由推流端在视频帧中携带 SEI 数据(payloadType=99),并按已订阅的视频轨道(msid)粒度分别回调
*/
rtcCumuDelayReceived: (uid: string, msid: string, totalDelay: number) => void;
/**
* @brief 用户鉴权信息即将过期通知,收到后30秒鉴权过期
* @note 该回调在鉴权信息30秒前触发,收到该回调后应该及时更新鉴权信息,参考 {@link AliRtcEngine.refreshAuthInfo:}
*/
authInfoWillExpire: () => void;
/**
* @brief 用户调用需要鉴权的接口,服务端返回信息过期
* @note 该回调触发代表鉴权信息已过期,想要继续在会中,需要重新入会,参考 {@link AliRtcEngine.joinChannel:name:onResultWithUserId:}
*/
authInfoExpired: () => {};
/**
* 远程用户的音频自动播放失败
* @param uid
* @note 应该在收到该回调时弹出弹窗引导用户点击页面进行播放,用户点击页面后 SDK 会自动尝试播放
*/
remoteAudioAutoPlayFail: (uid: string) => void;
/**
* 远程用户的视频自动播放失败
* @param uid
* @note 应该在收到该回调时弹出弹窗引导用户点击页面进行播放,用户点击页面后 SDK 会自动尝试播放
*/
remoteVideoAutoPlayFail: (uid: string, videoTrack: AliRtcVideoTrack) => void;
/**
* 远程用户的音频播放出错
* @param uid 用户ID
* @param reason 出错原因,可选
*/
remoteAudioPlayError: (uid: string, reason: string | undefined) => void;
/**
* 远程用户的视频播放出错
* @param uid 用户ID
* @param reason 出错原因,可选
*/
remoteVideoPlayError: (uid: string, reason: string | undefined) => void;
/**
* 远程用户订阅数据通道
* @param uid 用户ID
*/
remoteUserSubscribedDataChannel: (uid: string) => void;
/**
* rtc 传输数据统计
* @param stats 统计信息
*/
rtcStats: (stats: any) => void;
/**
* 发布视频流的数据统计
* @param aliRtcStats 统计信息
*/
rtcLocalVideoStats: (stats: AliRtcLocalVideoStats[]) => void;
/**
* 发布音频流的数据统计
* @param aliRtcStats 统计信息
*/
rtcLocalAudioStats: (stats: AliRtcLocalAudioStats[]) => void;
/**
* 订阅视频流的数据统计
* @param aliRtcStats 统计信息
*/
rtcRemoteVideoStats: (stats: AliRtcRemoteVideoStats[]) => void;
/**
* 订阅远端音频流的数据统计
* @param aliRtcStats 统计信息
*/
rtcRemoteAudioStats: (stats: AliRtcRemoteAudioStats[]) => void;
/**
* @brief 错误通知
* @deprecated 请使用 occurError
* @details 如果engine出现error,通过这个回调通知app
* @param error 错误类型,参考 {@link AliRtcError}
* @param uid 用户 Id,不一定存在
*/
onOccurError: (error: AliRtcError, uid?: string) => void;
/**
* @brief 错误通知
* @details 如果engine出现error,通过这个回调通知app
* @param error 错误类型,参考 {@link AliRtcError}
* @param uid 用户 Id,不一定存在
*/
occurError: (error: AliRtcError, uid?: string) => void;
/**
* @brief 收到数据通道消息
* @param uid 用户ID
* @param message 消息
*/
dataChannelMsg: (uid: string, message: AliRtcDataChannelMsg) => void;
/**
* @brief AI agent处理结果
* @param code 返回code码
* @param action 结果对应的action
* @param result 结果
*/
AIAgentResult: (code: number, action: string, result: string) => void;
/**
* @brief 网络质量回调
* @param event 网络质量信息
* @param event.subscribe 下行网络质量
* @param event.subscribe.rtt 下行网络往返延时(ms)
* @param event.subscribe.loss 下行网络丢包率
* @param event.subscribe.quality 下行网络质量类型
*/
networkQuality: (event: {
subscribe: {
rtt: number;
loss: number;
quality: AliRtcNetworkQuality;
};
}) => void;
/**
* @brief SDK 运行时通报
* @details SDK 在运行过程中,根据设备能力、系统资源、服务端配置等因素,主动向应用层上报需关注的运行时状态。
* 通过 `event.type` 区分不同场景,应用层应按需响应并执行对应的降级或优化策略。
* @param event 通报事件对象
*
* **event.type = 'lowPerformanceDevice'**
* - 触发条件:当前设备型号在服务端下发的低性能设备名单中
* - `event.deviceModel`:当前设备型号
* - 建议操作:降低推拉流视频规格
* - 触发时机:{@link AliRtcEngine.joinChannel} 入会后
*/
sdkAdvisory: (event: {
type: 'lowPerformanceDevice';
deviceModel: string;
}) => void;
}
export declare enum AliRtcEngineLocalDeviceExceptionType {
/** 未知异常类型 */
AliEngineLocalDeviceExceptionTypeUnknown = 0,
/** 麦克风打开失败 */
AliEngineLocalDeviceExceptionTypeMicOpenFail = 1,
/** 麦克风被打断 */
AliEngineLocalDeviceExceptionTypeMicInterrupt = 2,
/** 麦克风无权限 */
AliEngineLocalDeviceExceptionTypeMicAuthFail = 3,
/** 无可用麦克风 */
AliEngineLocalDeviceExceptionTypeMicNotAvailable = 4,
/** 扬声器打开失败 */
AliEngineLocalDeviceExceptionTypeSpeakerOpenFail = 5,
/** 扬声器被打断 */
AliEngineLocalDeviceExceptionTypeSpeakerInterrupt = 6,
/** 无可用扬声器 */
AliEngineLocalDeviceExceptionTypeSpeakerNotAvailable = 7,
/** 音频设备异常 */
AliEngineLocalDeviceExceptionTypeAudioDeviceException = 8,
/** 摄像头打开失败 */
AliEngineLocalDeviceExceptionTypeCameraOpenFail = 9,
/** 摄像头被打断 */
AliEngineLocalDeviceExceptionTypeCameraInterrupt = 10,
/** 摄像头无权限 */
AliEngineLocalDeviceExceptionTypeCameraAuthFail = 11,
/** 显示设备异常 */
AliEngineLocalDeviceExceptionTypeDisplayException = 12,
/** 视频设备异常 */
AliEngineLocalDeviceExceptionTypeVideoDeviceException = 13
}
export declare enum AliRtcEngineLocalDeviceType {
/** 未知设备类型 */
AliEngineLocalDeviceTypeUnknown = 0,
/** 麦克风设备 */
AliEngineLocalDeviceTypeMic = 1,
/** 扬声器设备 */
AliEngineLocalDeviceTypeSpeaker = 2,
/** 音频设备 */
AliEngineLocalDeviceTypeAudioDevice = 3,
/** 摄像头设备 */
AliEngineLocalDeviceTypeCamera = 4,
/** 显示设备 */
AliEngineLocalDeviceTypeDisplay = 5,
/** 视频设备 */
AliEngineLocalDeviceTypeVideoDevice = 6
}
declare enum AliRtcEnv {
pre = "pre",
prod = "prod"
}
declare class AliRtcError extends Error {
_code: number;
_extra?: any;
static fromRtsError(error: any): AliRtcError;
static fromError(error: any, code?: number, fallbackMessage?: string): AliRtcError;
constructor(code: number, message: string, extra?: any);
get code(): number;
set code(code: number);
get reason(): string;
get extra(): any;
}
export declare enum AliRtcErrorCode {
/****************************************************
* 入会错误码
****************************************************/
/** 已经加入频道 */
ERR_JOIN_ALREADY_JOINED = 16843521,
/** AppId不存在,请在控制台创建应用 */
ERR_JOIN_BAD_APPID = 33620481,
/** AppId已失效,请在控制台重新启用应用 */
ERR_JOIN_INVALID_APPID = 33620482,
/**
* 频道不存在,请尝试重新加入频道
* 如会议发起者入会后又很快离会,第二个人随后入会,发现会议已经不存在了。
*/
ERR_JOIN_BAD_CHANNEL = 33620484,
/** 频道已经失效(目前频道有效期为48小时),请重新生成频道鉴权令牌(Token) */
ERR_JOIN_INVALID_CHANNEL = 33620483,
/** Token无效。 请重新生成频道鉴权令牌(Token) */
ERR_JOIN_BAD_TOKEN = 33620485,
/** 加入频道超时,请检查网络连接是否正常 */
ERR_JOIN_TIMEOUT = 16908804,
/** 参数错误,{@link AliRtcAuthInfo}中的字段为空或者timestamp<=0,请检查字段是否完整 */
ERR_JOIN_ERR_JOIN_BAD_PARAMBAD = 16974081,
/** 加入频道失败 */
ERR_JOIN_CHANNEL_FAILED = 16974338,
/****************************************************
* 日志模块错误码
****************************************************/
/** 日志模块已经初始化 */
ERR_LOG_ALREADY_INIT = 16974085,
/** 日志模块根路径错误,请检查路径是否存在或路径是否具有写入权限 */
ERR_LOG_ROOT_PATH_ERROR = 16974086,
/****************************************************
* 音频设备错误码
****************************************************/
/**
* 采集设备初始化失败、采集设备媒体服务异常、音频设备被占用。
* - Mac端和Windows端查看系统设置中音频设备是否有能量条
* - iOS端和Android端确认是否被其他应用占用
* - 如果都正常,请重启设备
*/
ERR_MIC_OPEN_FAIL = 17040388,
/**
* 播放设备初始化失败、播放设备媒体服务异常、音频设备被占用。
* - Mac端和Windows端查看系统设置中音频设备是否有能量条
* - iOS端和Android端确认是否被其他应用占用
* - 如果都正常,请重启设备
*/
ERR_SPEAKER_OPEN_FAIL = 17040389,
/** 系统性能不足、采集设备媒体服务异常、音频设备被占用。建议重启应用或重启设备 */
ERR_MIC_INTERRUPT = 17040390,
/** 系统性能不足,播放设备媒体服务异常,音频设备被占用。建议重启应用或重启设备 */
ERR_SPEAKER_INTERRUPT = 17040391,
/** 麦克风设备未授权,建议去系统设置中,打开麦克风授权,并且重新加入频道 */
ERR_MIC_AUTH_FAIL = 17040392,
/** 无可用的音频采集设备,检查是否接入了可用的麦克风,并检查系统设置中,该设备是否被禁用 */
ERR_MIC_NOT_AVAILABLE = 17040393,
/** 无可用的音频播放设备,检查是否接入了可用的扬声器或耳机,并检查系统设置中,该设备是否被禁用 */
ERR_SPEAKER_NOT_AVAILABLE = 17040400,
/****************************************************
* 视频设备错误码
****************************************************/
/** 采集设备初始化失败,检查系统相机是否可用,移动端App是否占用了相机 */
ERR_CAMERA_OPEN_FAIL = 17039620,
/** 采集设备未授权,建议去系统设置中,打开摄像头授权,并且重新加入频道 */
ERR_CAMERA_AUTH_FAIL = 17039621,
/** 采集过程中出现异常,Mac、Winodows电脑相机采集灯熄灭,设备被强制中断。建议重新加入频道或者重启App */
ERR_CAMERA_INTERRUPT = 17039622,
/** 无可用的视频采集设备,检查是否接入了可用的摄像头,并检查系统设置中,该设备是否被禁用 */
ERR_CAMERA_NOT_AVAILABLE = 17039623,
/** 渲染设备初始化失败,检查Windows端显卡驱动是否需要升级,移动端手机型号或者Android平板盒子等外设是否支持OpenGL */
ERR_VIDEO_DISPLAY_OPEN_FAIL = 17039873,
/** 渲染过程中出现异常,系统异常错误导致渲染引擎报错,重新加入频道或者重启App */
ERR_VIDEO_DISPLAY_INTERRUPT = 1064992,
/****************************************************
* 网络错误码
****************************************************/
/** 媒体通道建立失败,检查网络连接是否正常 */
ERR_ICE_CONNECTION_CONNECT_FAIL = 17105409,
/** 媒体通道重连失败,检查网络连接是否正常 */
ERR_ICE_CONNECTION_RECONNECT_FAI = 17105410,
/** 媒体通道mobility失败,应用层需要重走入会流程 */
ERR_ICE_CONNECTION_MOBILITY_FAIL = 17105411,
/** 信令心跳超时,检查网络连接是否正常 */
ERR_ICE_CONNECTION_HEARTBEAT_TIMEOUT = 16908812,
/**
* 低延时互动直播模式相关错误码
*/
/** 低延时互动直播信令失败 */
ERR_LATENCY_LIVE_COMMUNICATION_FAILED = 17235971,
/** 低延时互动直播媒体设置错误 */
ERR_LATENCY_LIVE_MEIDASETTING_FAILED = 17235972,
/** 低延时互动直播当前房间没有主播推流 */
ERR_LATENCY_LIVE_NONE_BROADCASTER = 17235973,
/** 低延时互动直播错误,应用层需要重新创建新的SDK实例 */
ERR_LATENCY_LIVE_NEED_RESTART = 17235974,
/** 低延时互动直播错误,应用层需要稍等一定时间(自定义间隔)重新创建新的SDK实例 */
ERR_LATENCY_LIVE_NEED_RESTART_AGAIN_LATER = 17235975,
/** 低延迟互动直播服务不可用或者服务降级,客户端应该选择其它方式拉超大方会流,即不从cdn sfu拉流 */
ERR_LATENCY_LIVE_SERVICE_UNAVAILABLE = 17235976,
/** 低延迟互动直播网络中断错误,销毁当前sdk实例重新创建sdk后重新走订阅流程 */
ERR_LATENCY_LIVE_MEDIACONNECTION_INTERRUPTION = 17235977,
/****************************************************
* 推流相关错误码
****************************************************/
/** 推流无效 */
ERR_SDK_PUBLISH_INVAILD = 16974597,
/** 未进入频道推流失败 */
ERR_SDK_PUBLISH_NOT_JOIN_CHANNEL = 16843782,
/** 推送音频流失败 */
ERR_SDK_PUBLISH_AUDIO_STREAM_FAILED = 16843856,
/** 推送视频流失败 */
ERR_SDK_PUBLISH_VIDEO_STREAM_FAILED = 16843857,
/** 推送小流失败 */
ERR_SDK_PUBLISH_DUAL_STREAM_FAILED = 16843858,
/** 推送屏幕共享失败 */
ERR_SDK_PUBLISH_SCEEN_SHARE_FAILED = 16843859,
/** 屏幕共享配置错误 */
ERR_SDK_PUBLISH_SCREEN_SHARE_CONFIG_ERROR = 16843860,
/****************************************************
* 订阅相关错误码
****************************************************/
/** 订阅无效 */
ERR_SDK_SUBSCRIBE_INVAILD = 16974852,
/** 未进入频道订阅错误 */
ERR_SDK_SUBSCRIBE_NOT_JOIN_CHANNEL = 16844112,
/** 订阅音频流失败 */
ERR_SDK_SUBSCRIBE_AUDIO_STREAM_FAILED = 16844113,
/** 订阅视频流失败 */
ERR_SDK_SUBSCRIBE_VIDEO_STREAM_FAILED = 16844114,
/** 订阅小流失败 */
ERR_SDK_SUBSCRIBE_DUAL_STREAM_FAILED = 16844115,
/** 订阅屏幕共享失败 */
ERR_SDK_SUBSCRIBE_SCREEN_SHARE_FAILED = 16844116,
/** 订阅 DataChannel 失败 */
ERR_SDK_SUBSCRIBE_DATA_FAILED = 16844117,
/** 订阅 DataChannel 过程中报错 */
ERR_SDK_SUBSCRIBE_DATA_ERROR = 16844118,
/****************************************************
* 其他错误码
****************************************************/
/** SDK状态错误,建议销毁SDK重新创建实例。 */
ERR_SDK_INVALID_STATE = 16974340,
/** 参数不匹配 */
ERR_INVALID_ARGUMENTS = 16974083,
/** Session已经被移除,建议销毁实例之后重新创建实例并加入频道。 */
ERR_SESSION_REMOVED = 33620229,
/** 互动模式下设置角色错误 */
ERR_SDK_UPDATE_ROLE_CHANNEL = 16908801,
/** SDK内部错误 */
ERR_INNER = -1,
/************************************************************************************/
/******************************** 旁路直播错误码 start ********************************/
/************************************************************************************/
/**
* MPU任务发布成功
*/
ERR_SDK_MPU_TASK_PUBLISH_OK = 0,
/**
* MPU任务流未找到
*/
ERR_SDK_MPU_TASK_STREAM_NOT_FOUND = 17825793,
/**
* MPU任务流已存在
*/
ERR_SDK_MPU_TASK_STREAM_ALREADY_EXIST = 17825794,
/**
* MPU任务无效参数
*/
ERR_SDK_MPU_TASK_INVALID_PARAM = 17825795,
/**
* MPU任务内部错误
*/
ERR_SDK_MPU_TASK_INTERNAL_ERROR = 17825796,
/**
* MPU任务rtmp服务错误
*/
ERR_SDK_MPU_TASK_RTMP_SERVER_ERROR = 17825797,
/**
* MPU任务rtmp流地址错误
*/
ERR_SDK_MPU_TASK_RTMP_STREAM_URL_ERROR = 17825798,
/**
* MPU任务发布超时
*/
ERR_SDK_MPU_TASK_PUBLISH_TIMEOUT = 17825799,
/**
* MPU任务发布成功
*/
ERR_SDK_MPU_TASK_NOT_AUTHORIZED = 17825800,
/************************************************************************************/
/******************************** 旁路直播错误码 end ********************************/
/************************************************************************************/
/************************************************************************************/
/******************************** 跨频道转推错误码 start ******************************/
/************************************************************************************/
/**
* 检测到本地状态不对,没入会,角色错误,频道模式错误
*/
ERR_SDK_CHANNEL_RELAY_STATE_ERROR = 18874369,
/**
* 服务端返回436,源通道模式不匹配
*/
ERR_SDK_CHANNEL_RELAY_SRC_NOT_ALLOW = 18874370,
/**
* 服务端返回437,目标通道不存在或者模式不匹配
*/
ERR_SDK_CHANNEL_RELAY_JOIN_DEST_FAILED = 18874371,
/**
* 服务端返回438,token无效
*/
ERR_SDK_CHANNEL_RELAY_TOKEN_INVALID = 18874372,
/**
* 服务端返651,session不是主播
*/
ERR_SDK_CHANNEL_RELAY_ROLE_ERROR = 18874373,
/**
* 服务端400,参数错误
*/
ERR_SDK_CHANNEL_RELAY_INVALID_PARAM = 18874374,
/**
* 服务端返回440,不能转推到本频道
*/
ERR_SDK_CHANNEL_RELAY_TO_SELF_ERROR = 18874375
}
export declare class AliRtcImageHolderPlugin extends AliRtcPlugin {
private url;
private image?;
private canvas;
private mediaStream?;
private updateableManager;
private updateable;
private hasVideoTrack;
constructor(url: string, fps?: number);
get initOptions(): {
imageUrl: string;
};
setOptions(options: ImageHolderPluginOptions): void;
private drawImageToCanvas;
start(): Promise;
stop(): void;
isSupported(): boolean;
shouldUpdate(_streamInfo: AliRtcLocalStreamInfo): boolean;
process(streamInfo: AliRtcLocalStreamInfo): Promise;
}
declare class AliRtcLiveTranscoding {
authInfo?: AliRtcAuthInfo;
private slsReporter;
constructor(slsReporter: SLSReporter);
private doRequest;
setAuthInfo(authInfo: AliRtcAuthInfo): void;
clear(): void;
startPublishLiveStream(streamUrl: string, transcodingParam: AliRtcLiveTranscodingParam): Promise;
startPublishLiveStreamWithTaskId(taskId: string, transcodingParam: AliRtcLiveTranscodingParam): Promise;
updatePublishLiveStream(streamUrl: string, transcodingParam: AliRtcLiveTranscodingParam): Promise;
updatePublishLiveStreamWithTaskId(taskId: string, transcodingParam: AliRtcLiveTranscodingParam): Promise;
stopPublishLiveStream(streamUrl: string): Promise;
stopPublishLiveStreamWithTaskId(taskId: string): Promise;
refreshAuthInfo(authInfo: AliRtcRefreshAuthInfo): void;
}
export declare enum AliRtcLiveTranscodingAudioSampleRate {
LiveTranscoding_HZ_48000 = 48000,
LiveTranscoding_HZ_44100 = 44100,
LiveTranscoding_HZ_32000 = 32000,
LiveTranscoding_HZ_16000 = 16000,
LiveTranscoding_HZ_8000 = 8000
}
export declare enum AliRtcLiveTranscodingCropMode {
/*! 缩放模式 */
LiveTranscodingOrigin = 0,
/*! 剪裁 */
LiveTranscodingCrop = 1,
/*! 填充 */
LiveTranscodingFill = 2
}
export declare class AliRtcLiveTranscodingEncodeParam {
videoWidth: any;
videoHeight: any;
videoFramerate: number;
videoBitrate: number;
videoGop: number;
audioSamplerate: AliRtcLiveTranscodingAudioSampleRate;
audioBitrate: number;
audioChannels: number;
constructor(videoWidth: number, videoHeight: number, videoFramerate?: number, videoBitrate?: number, videoGop?: number, audioSamplerate?: AliRtcLiveTranscodingAudioSampleRate, audioBitrate?: number, audioChannels?: number);
}
export declare enum AliRtcLiveTranscodingErrorCode {
LiveTranscodingErrorPublishOk = 0,
LiveTranscodingErrorStreamNotFound = 17825793,
LiveTranscodingErrorStreamAlreadyExist = 17825794,
LiveTranscodingErrorInvalidParam = 17825795,
LiveTranscodingErrorInternalError = 17825796,
LiveTranscodingErrorRtmpServerError = 17825797,
LiveTranscodingErrorRtmpStreamUrlError = 17825798,
LiveTranscodingErrorPublishTimeout = 17825799,
LiveTranscodingErrorNotAuthorized = 17825800
}
export declare enum AliRtcLiveTranscodingFontType {
NOTO_SERIF_CJKSC_REGULAR = 0,
ALIBABA_PUHUITI_REGULAR = 1,
ALIBABA_PUHUITI_BOLD = 2,
ALIBABA_PUHUITI_Heavy = 3,
ALIBABA_PUHUITI_LIGHT = 4,
ALIBABA_PUHUITI_MEDIUM = 5
}
export declare enum AliRtcLiveTranscodingMediaProcessMode {
/*! 通用模式 */
LiveTranscodingNormal = 0,
/*! 虚拟背景模式 */
LiveTranscodingVirtualBackground = 1
}
export declare enum AliRtcLiveTranscodingMixMode {
/*! 单路模式 */
LiveTranscodingSingle = 0,
/*! 混流模式 */
LiveTranscodingMix = 1
}
export declare class AliRtcLiveTranscodingMixParam {
taskProfile: AliRtcLiveTranscodingTaskProfile;
encodeParam?: AliRtcLiveTranscodingEncodeParam;
users: AliRtcTranscodingUser[];
backgroundColor: number;
backgrounds: AliRtcTranscodingImage[];
watermarks: AliRtcTranscodingImage[];
clockWidgets: AliRtcTranscodingClockWidget[];
cropMode?: AliRtcLiveTranscodingCropMode;
mediaProcessMode?: AliRtcLiveTranscodingMediaProcessMode;
constructor(taskProfile: AliRtcLiveTranscodingTaskProfile);
}
export declare class AliRtcLiveTranscodingParam {
/*! 旁路模式 */
mixMode: AliRtcLiveTranscodingMixMode;
/*! 路模式单路参数 */
singleParam?: AliRtcLiveTranscodingSingleParam;
/*! 旁路模式混流参数 */
mixParam?: AliRtcLiveTranscodingMixParam;
constructor(mixMode?: AliRtcLiveTranscodingMixMode, singleParam?: AliRtcLiveTranscodingSingleParam, mixParam?: AliRtcLiveTranscodingMixParam);
toJson(type: MPU_TASK_TRANSACTION_TYPE, authInfo: AliRtcAuthInfo, taskId: string, streamUrl?: string, messageId?: string): {
[key: string]: any;
};
}
export declare enum AliRtcLiveTranscodingSegmentType {
/*! 无人像分割 */
LiveTranscodingNoBody = 0,
/*! 人像分割 */
LiveTranscodingBody = 1
}
export declare class AliRtcLiveTranscodingSingleParam {
userId?: string;
streamType?: AliRtcLiveTranscodingStreamType;
sourceType?: AliRtcLiveTranscodingSourceType;
constructor(uid?: string, streamType?: AliRtcLiveTranscodingStreamType, sourceType?: AliRtcLiveTranscodingSourceType);
}
export declare enum AliRtcLiveTranscodingSourceType {
/*! 相机流 */
LiveTranscodingCamera = 0,
/*! 屏幕流 */
LiveTranscodingShareScreen = 1
}
export declare enum AliRtcLiveTranscodingState {
LiveTranscodingState_IDLE = 0,
LiveTranscodingState_CONNNECT = 1,
LiveTranscodingState_RUNNING = 2,
LiveTranscodingState_RECOVERING = 3,
LiveTranscodingState_FAILURE = 4,
LiveTranscodingState_END = 5
}
export declare enum AliRtcLiveTranscodingStreamType {
/*! 原始流 */
LiveTranscodingOrigin = 0,
/*! 音频 */
LiveTranscodingAudio = 1,
/*! 视频 */
LiveTranscodingVideo = 2
}
export declare enum AliRtcLiveTranscodingTaskProfile {
LiveTranscoding_Profile_1IN_1080P = 0,
LiveTranscoding_Profile_1IN_720P = 1,
LiveTranscoding_Profile_1IN_360P = 2,
LiveTranscoding_Profile_2IN_1080P = 3,
LiveTranscoding_Profile_2IN_720P = 4,
LiveTranscoding_Profile_2IN_360P = 5,
LiveTranscoding_Profile_4IN_1080P = 6,
LiveTranscoding_Profile_4IN_720P = 7,
LiveTranscoding_Profile_4IN_360P = 8,
LiveTranscoding_Profile_9IN_1080P = 9,
LiveTranscoding_Profile_9IN_720P = 10,
LiveTranscoding_Profile_9IN_360P = 11,
LiveTranscoding_Profile_12IN_1080P = 12,
LiveTranscoding_Profile_12IN_720P = 13,
LiveTranscoding_Profile_12IN_360P = 14,
LiveTranscoding_Profile_16IN_1080P = 15,
LiveTranscoding_Profile_16IN_720P = 16,
LiveTranscoding_Profile_16IN_360P = 17,
LiveTranscoding_Profile_Mixed = 9999
}
declare interface AliRtcLocalAudioStats {
track: AliRtcAudioTrack;
stats: any;
}
export declare class AliRtcLocalStreamInfo extends default_2 {
type: AliRtcRawDataStreamType;
originVideoTrack?: MediaStreamTrack;
videoSource?: VideoStreamSource;
private _videoMuted;
originAudioTrack?: MediaStreamTrack;
audioSource?: AudioStreamSource;
private _audioMuted;
private _targetVideoTrack?;
private _targetDualVideoTrack?;
private _targetAudioTrack?;
private _publishVideoStream?;
private _publishDualVideoStream?;
private _publishAudioStream?;
private _previewStream?;
plugins: AliRtcPlugin[];
private _profileManager?;
cameraVideoConstraints?: MediaTrackConstraints;
micAudioConstraints?: MediaTrackConstraints;
private get profileManager();
get audioProfile(): AudioProfileKey;
constructor(type: AliRtcRawDataStreamType);
private onVideoTrackEnded;
private onAudioTrackEnded;
updateSource(newStream: LocalStream, newVideoSource?: VideoStreamSource, newAudioSource?: AudioStreamSource): Promise;
get currentProfile(): string;
get currentVideoTrack(): MediaStreamTrack;
get currentDualVideoTrack(): MediaStreamTrack;
get publishVideoStream(): LocalStream;
get publishDualVideoStream(): LocalStream;
get currentAudioTrack(): MediaStreamTrack;
get publishAudioStream(): LocalStream;
get previewStream(): LocalStream | undefined;
/**
* 更新 VideoTrack
* @param videoTrack
*/
updateVideoTrack(videoTrack?: MediaStreamTrack, force?: boolean): Promise;
/**
* 更新 DualVideoTrack
* @param videoTrack
* @param force
*/
updateDualVideoTrack(videoTrack?: MediaStreamTrack, force?: boolean): Promise;
/**
* 更新 AudioTrack
* @param audioTrack
*/
updateAudioTrack(audioTrack?: MediaStreamTrack, force?: boolean): Promise;
/**
* 设置音频流静音
* @param muted
*/
setAudioMuted(muted: boolean): void;
get isAudioMuted(): boolean;
/**
* 设置视频流静音
* @param muted
*/
setVideoMuted(muted: boolean): void;
get isVideoMuted(): boolean;
process(localStreamInfos: AliRtcLocalStreamInfo[]): Promise;
/**
* 停止视频流
*/
stopVideo(): void;
/**
* 停止音频流
*/
stopAudio(): void;
/**
* 停止视频流和音频流
*/
stop(): void;
/**
* 应该在执行完 plugin 后调用
* @param profileName
* @param profileValue
*/
updateVideoProfile(profileName?: string, profileValue?: Partial, skipConstraints?: boolean): Promise;
get videoProfile(): string;
setVideoContentHint(hint?: string): void;
/**
* 应该在执行完 plugin 后调用
* @param profileName
*/
updateAudioProfile(profileKey: AudioProfileKey): Promise;
/**
* 复制视频 profile 到指定 LocalStream
* @param publishStream
*/
cloneVideoProfile(publishStream: LocalStream): Promise;
/**
* 复制音频 profile 到指定 LocalStream
* @param publishStream
*/
cloneAudioProfile(publishStream: LocalStream): Promise;
addPlugin(plugin: AliRtcPlugin): void;
removePlugin(plugin: AliRtcPlugin): boolean;
}
declare interface AliRtcLocalStreamListener {
videotrackended: () => void;
audiotrackended: () => void;
}
declare interface AliRtcLocalVideoStats {
track: AliRtcVideoTrack;
streamType?: AliRtcVideoStreamType;
stats: any;
}
declare type AliRtcLocalView = string | HTMLVideoElement | string[] | HTMLVideoElement[] | null;
export declare enum AliRtcLogLevel {
DEBUG = 0,
INFO = 1,
API = 2,
WARNING = 3,
ERROR = 4,
NONE = 5
}
/**
* @brief 网络质量类型
*/
export declare enum AliRtcNetworkQuality {
/** 网络极好 */
AliRtcNetworkExcellent = 0,
/** 网络好 */
AliRtcNetworkGood = 1,
/** 网络不好 */
AliRtcNetworkPoor = 2,
/** 网络差 */
AliRtcNetworkBad = 3,
/** 网络极差 */
AliRtcNetworkVeryBad = 4,
/** 网络断开 */
AliRtcNetworkDisconnected = 5,
/** 网络未知 */
AliRtcNetworkUnknown = 6
}
/**
* @brief OnBye类型枚举
*/
declare enum AliRtcOnByeType {
/** 当前user被踢出channel */
AliRtcOnByeBeKickedOut = 1,
/** channel已结束,需要离开会议 */
AliRtcOnByeChannelTerminated = 2,
/** 相同userID在其他设备joinChannel,当前设备被下线 */
AliRtcOnByeUserReplaced = 3
}
export declare abstract class AliRtcPlugin extends default_2 {
name: string;
options: any;
type: AliRtcPluginType;
streamType: AliRtcRawDataStreamType;
trackType: AliRtcPluginTrackType;
zIndex: number;
private _isEnable;
protected shouldCache: boolean;
lastInputAudioTrack?: MediaStreamTrack;
lastOutputAudioTrack?: MediaStreamTrack;
lastInputVideoTrack?: MediaStreamTrack;
lastOutputVideoTrack?: MediaStreamTrack;
private _hasCleared;
constructor(name: string, streamType?: AliRtcRawDataStreamType, trackType?: AliRtcPluginTrackType);
get initOptions(): {};
getOptions(): any;
abstract setOptions(options: any): void;
abstract isSupported(version: string): boolean;
init(): Promise;
enable(): void;
disable(): void;
get isEnable(): boolean;
protected audioUpdated(streamInfo: AliRtcLocalStreamInfo): boolean;
protected videoUpdated(streamInfo: AliRtcLocalStreamInfo): boolean;
execute(streamInfo: AliRtcLocalStreamInfo, streamInfos: AliRtcLocalStreamInfo[]): Promise;
abstract shouldUpdate(streamInfo: AliRtcLocalStreamInfo, streamInfos: AliRtcLocalStreamInfo[]): boolean;
abstract process(streamInfo: AliRtcLocalStreamInfo, streamInfos: AliRtcLocalStreamInfo[]): Promise;
clear(_streamInfo?: AliRtcLocalStreamInfo): void;
}
declare interface AliRtcPluginListener {
enabled: () => void;
disabled: () => void;
updated: () => void;
ready: () => void;
overload: (info: any) => void;
error: (error: any) => void;
unsupported: () => void;
}
export declare enum AliRtcPluginTrackType {
AUDIO = 0,
VIDEO = 1,
BOTH = 2
}
export declare enum AliRtcPluginType {
PRE_PROCESSOR = 0,
POST_PROCESSOR = 1
}
export declare enum AliRtcPublishState {
/** 0: SDK初始推流状态 */
AliRtcStatePublishIdle = 0,
/** 1: 未推流状态,可能是因为:
* - 已设置停止推送媒体流
* - 推送媒体流失败
*/
AliRtcStateNoPublish = 1,
/** 2: 推流链接建立过程中 */
AliRtcStatePublishing = 2,
/** 3: 推流成功 */
AliRtcStatePublished = 3,
AliRtcStateReconnecting = 4
}
export declare enum AliRtcRawDataStreamType {
/** 相机流 */
AliRtcSdkStreamTypeCapture = 0,
/** 屏幕共享流 */
AliRtcSdkStreamTypeScreen = 1
}
export declare type AliRtcRefreshAuthInfo = Pick;
declare interface AliRtcRemoteAudioStats {
uid: string;
track: AliRtcAudioTrack;
stats: any;
}
export declare class AliRtcRemoteUserInfo {
private remoteUser;
constructor(remoteUser: RemoteUser);
get userId(): string;
get displayName(): string;
get isMuteAudioPlaying(): boolean;
get hasAudio(): boolean;
get hasCamera(): boolean;
get hasCameraLarge(): boolean;
get hasCameraSmall(): boolean;
get hasScreenShare(): boolean;
get isAudioSubscribing(): boolean;
get isVideoSubscribing(): boolean;
get isVideoLargeSubscribing(): boolean;
get isVideoSmallSubscribing(): boolean;
get isScreenSubscribing(): boolean;
get audioElement(): HTMLAudioElement;
}
declare interface AliRtcRemoteVideoStats {
uid: string;
track: AliRtcVideoTrack;
streamType?: AliRtcVideoStreamType;
stats: any;
}
declare interface AliRtcScreenShareConfiguration {
width?: number;
height?: number;
frameRate?: number;
bitrate?: number;
}
declare interface AliRtcScreenShareStartConfig {
audio?: boolean;
videoTrack?: MediaStreamVideoTrack;
audioTrack?: MediaStreamAudioTrack;
}
export declare enum AliRtcSdkChannelProfile {
/** 普通通信模式 */
AliRtcSdkCommunication = "communication",
/** 直播模式(大方会模式) */
AliRtcSdkInteractiveLive = "interactive_live",
/** 低延迟互动直播模式 */
AliRtcSdkInteractiveWithLowLatencyLive = "cdn_live"
}
export declare enum AliRtcSdkClientRole {
/** 互动角色 */
AliRtcSdkInteractive = "interactive",
/** 观众角色 */
AliRtcSdkLive = "live"
}
/** 角色鉴权 主播pub|观众sub|转推流鉴权(跨房间转推中使用)relay */
declare type AliRtcSdkTokenRole = 'pub' | 'sub' | 'relay';
export declare enum AliRtcSubscribeState {
/** 初始状态 */
AliRtcStateSubscribeIdle = 0,
/** 未订阅 */
AliRtcStateNoSubscribe = 1,
/** 订阅中 */
AliRtcStateSubscribing = 2,
/** 已订阅 */
AliRtcStateSubscribed = 3,
/** 重连中 */
AliRtcStateReconnecting = 4
}
export declare class AliRtcTranscodingClockWidget {
x: number;
y: number;
fontSize: number;
zOrder: number;
fontColor: number;
fontType: AliRtcLiveTranscodingFontType;
constructor(x: number, y: number, fontSize: number);
constructor(x: number, y: number, fontSize: number, zOrder: number);
constructor(x: number, y: number, fontSize: number, zOrder: number, fontColor: number);
constructor(x: number, y: number, fontSize: number, zOrder: number, fontColor: number, fontType: AliRtcLiveTranscodingFontType);
toJson(videoWidth: number, videoHeight: number): {
x: number;
y: number;
fonttype: AliRtcLiveTranscodingFontType;
fontsize: number;
fontcolor: number;
zorder: number;
};
}
export declare class AliRtcTranscodingImage {
static DisplayType: typeof DisplayType;
url: string;
x: number;
y: number;
width: number;
height: number;
alpha: number;
display: DisplayType;
zOrder: number;
constructor(url: string, x: number, y: number, width: number, height: number);
constructor(url: string, x: number, y: number, width: number, height: number, zOrder: number);
constructor(url: string, x: number, y: number, width: number, height: number, zOrder: number, alpha: number);
constructor(url: string, x: number, y: number, width: number, height: number, zOrder: number, alpha: number, display: DisplayType);
toJson(videoWidth: number, videoHeight: number): {
url: string;
alpha: number;
display: DisplayType;
x: number;
y: number;
width: number;
height: number;
zorder: number;
};
}
export declare class AliRtcTranscodingText {
text: string;
x: number;
y: number;
fontSize: number;
zOrder: number;
fontColor: number;
fontType: AliRtcLiveTranscodingFontType;
constructor(text: string, x: number, y: number, fontSize: number);
constructor(text: string, x: number, y: number, fontSize: number, zOrder: number);
constructor(text: string, x: number, y: number, fontSize: number, zOrder: number, fontColor: number);
constructor(text: string, x: number, y: number, fontSize: number, zOrder: number, fontColor: number, fontType: AliRtcLiveTranscodingFontType);
toJson(videoWidth: number, videoHeight: number): {
text: string;
x: number;
y: number;
fonttype: AliRtcLiveTranscodingFontType;
fontsize: number;
fontcolor: number;
zorder: number;
};
}
export declare class AliRtcTranscodingUser {
userId: string;
x: number;
y: number;
width: number;
height: number;
zOrder?: number;
sourceType?: AliRtcLiveTranscodingSourceType;
segmentType: AliRtcLiveTranscodingSegmentType;
images: AliRtcTranscodingImage[];
texts: AliRtcTranscodingText[];
constructor(userId: string, x: number, y: number, width: number, height: number);
constructor(userId: string, x: number, y: number, width: number, height: number, zOrder: number);
constructor(userId: string, x: number, y: number, width: number, height: number, zOrder: number, sourceType: AliRtcLiveTranscodingSourceType);
toJson(index: number, videoWidth: number, videoHeight: number, mediaProcessMode?: AliRtcLiveTranscodingMediaProcessMode): {
[key: string]: any;
};
}
export declare enum AliRtcTrascodingPublishTaskStatus {
/*! 任务开始 */
TrascodingPublishTaskStatusStart = 0,
/*! 任务更新 */
TrascodingPublishTaskStatusUpdate = 1,
/*! 任务已停止 */
TrascodingPublishTaskStatusStop = 2
}
declare enum AliRtcUserOfflineReason {
/** 用户主动离开 */
AliRtcUserOfflineQuit = 0,
/** 因过长时间收不到对方数据包,超时掉线 */
AliRtcUserOfflineDropped = 1,
/** 用户身份从主播切换为观众时触发 */
AliRtcUserOfflineBecomeAudience = 2
}
export declare enum AliRtcVideoStreamType {
/** 无,在OnSubscribeStreamTypeChanged回调表示当前未订阅 */
AliRtcVideoStreamTypeNone = 0,
/** 高码率,高分辨率流(大流) */
AliRtcVideoStreamTypeHigh = 1,
/** 低码率,低分辨率流(小流) */
AliRtcVideoStreamTypeLow = 2
}
export declare enum AliRtcVideoTrack {
/** 无视频流 **/
AliRtcVideoTrackNo = 0,
/** 相机流 **/
AliRtcVideoTrackCamera = 1,
/** 屏幕共享流 **/
AliRtcVideoTrackScreen = 2,
/** 相机流和屏幕共享流 **/
AliRtcVideoTrackBoth = 3
}
declare interface AliRtcVideoTrackConfig {
userId?: string;
streamType: AliRtcRawDataStreamType;
}
declare interface AliRtcWebTrackConfig {
biz: string;
extraParams?: string;
}
declare class AudioLevelMonitor extends default_2 {
private audioContext;
private stream;
private sourceNode?;
private analyser?;
constructor();
getLevel(): number;
/**
* 开启监听 audio level 的变化
*
* @param {MediaStreamTrack} track 音频轨
* @param {number} [interval=1000] 检测间隔,单位毫秒,默认 1000ms
*/
start(track: MediaStreamTrack, interval?: number): void;
stop(): void;
dispose(): void;
}
declare interface AudioLevelMonitorListener {
audioLevel: (level: number) => void;
}
declare class AudioMixer {
protected audioTrackArr: MediaStreamTrack[];
protected useGainNode: boolean;
protected audioContext: AudioContext;
protected audioDestination: MediaStreamAudioDestinationNode;
protected audioSource: MediaStreamAudioSourceNode[];
protected gainNode: GainNode | null;
protected audioTrack: MediaStreamTrack | null;
constructor(props: IAudioMixer);
destroy(): void;
updateTrackList(trackList: MediaStreamTrack[]): void;
getMixedAudioTrack(): MediaStreamTrack;
private connectNode;
private disconnectSourceNode;
}
declare interface AudioMixerPluginOptions {
audio?: number;
screen?: number;
}
/**
* ------------------ 模式 ----- 采样率 ----- 声道 ----- 码率(kbps) -----
*
* standard: 标准音质 48000 单声道 64
*
* high: 高音质 48000 单声道 128
*
* standard-stereo: 立体声音质 48000 双声道 80
*
* high-stereo: 立体声高音质 48000 双声道 192
*/
declare type AudioProfileKey = 'standard' | 'high' | 'standard-stereo' | 'high-stereo';
declare enum AudioStreamSource {
Microphone = 0,
Screen = 1,
Mixed = 2
}
declare class BizControl extends default_2 {
/**
* @ignore
*/
static logName: string;
_loggerInstanceId: string;
protected self: LocalUser;
protected userMap: RemoteUserMap;
private usersViewMap;
rtsManager: RtsManager;
protected localStreamManager: LocalStreamManager;
protected authInfo?: AliRtcAuthInfo;
protected signalingManager: SignalingManager;
pluginManager: PluginManager;
private audioMixerPlugin?;
private dualVideoPlugin?;
private blankAudioPlugin?;
private audioProcessorPlugin?;
protected slsReporter: SLSReporter;
private statsMonitorId?;
private autoSubAudio;
private autoSubVideo;
private autoSubScreen;
private wantSubAudio;
private wantSubVideo;
private wantSubScreen;
private defaultStreamType;
private audioMuted;
private playoutVolume;
private refreshUrlTimer?;
private audioVolumeIndicationInterval;
private indicationTimer;
private parameter;
private audio3AConfig;
private dcReadyHelper?;
private networkQualityTimer?;
constructor(config: BizControlConfig);
private addSignalingManagerListener;
private addRTSListener;
isAutoSubAudio(): boolean;
setAutoSubAudio(value: boolean): void;
isAutoSubVideo(): boolean;
setAutoSubVideo(value: boolean): void;
isAutoSubScreen(): boolean;
setAutoSubScreen(value: boolean): void;
isWantSubAudio(): boolean;
setWantSubAudio(value: boolean): void;
isWantSubVideo(): boolean;
setWantSubVideo(value: boolean): void;
isWantSubScreen(): boolean;
setWantSubScreen(value: boolean): void;
setRemoteDefaultVideoStreamType(type: AliRtcVideoStreamType): void;
setRemoteUserVideoStreamType(userId: string, type: AliRtcVideoStreamType): void;
setAudioMuted(mute: boolean): void;
setLocalViewConfig(view: AliRtcLocalView, track: AliRtcVideoTrack): void;
setRemoteViewConfig(uid: string, view: AliRtcLocalView, track: AliRtcVideoTrack): void;
get channel(): string | undefined;
get userId(): string | undefined;
get remoteUsers(): RemoteUser[];
/**
* 获取推流对象,只能是自己
*/
get publisher(): LocalUser;
get isSubscribing(): boolean;
/**
* 处理远端用户推流状态变化
* @param {string} userId
* @param {string} displayname
* @param {string} callid
* @param {string} pullStreamUrl
* @param {TrackInfo[]} tracks
* @returns {void}
*/
onRemotePublishStateChange(publishInfo: PublishUser, updateSubscribe?: boolean): void;
/** 定期更新所有人的推拉流地址,便于重连
* @param pushStreamUrl 已有的推流地址,根据地址中的过期时间来设置定时器
* @private
*/
private setTimeoutToUpdateAllStreamUrls;
/**
* 登陆成功后初始化用户管理,创建自己
* @param {AliRtcAuthInfo} authInfo
* @param {JoinResult} data
* @returns {Promise}
*/
init(authInfo: AliRtcAuthInfo, data: JoinResult, channelParam: AliRtcChannelParam): void;
leave(): Promise;
/**
* 离会后清除所有数据
* @returns {Promise}
*/
clear(): Promise;
private startStatsMonitor;
private stopStatsMonitor;
/**
* 添加远端用户
* @param {JoinInfo} userJoinInfo
* @param {SubscribeReason} reason
* @returns {void}
*/
addUser(userJoinInfo: JoinInfo, reason: SubscribeReason): RemoteUser;
/**
* 执行添加远端用户
* @param {string} userId
* @param {string} displayName
* @returns {RemoteUser}
*/
private executeAddUser;
/**
* 远端用户设备状态变化
* @param {DeviceStatusChangeType} event
* @param {string} userId
*/
private onRemoteDeviceStatusChange;
/**
* 远端流数据采集上报
* @param {any} stat
*/
private onRemoteStatReport;
/**
* rts 单 PC 订阅超限
*/
private onSubscribeExceeds;
/**
* 移除远端用户
* @param {LeaveInfo} user
* @returns {Promise}
*/
removeLeftUser(user: LeaveInfo): Promise;
/**
* 更新远端用户数据
* @param {JoinInfo[]} users
* @returns {{joinList: JoinInfo[], leaveList: LeaveInfo[], presentList: JoinInfo[]}}
*/
diffUsers(users: JoinInfo[]): {
joinList: JoinInfo[];
leaveList: LeaveInfo[];
presentList: JoinInfo[];
};
/**
* 根据 userId 获取 RemoteUser
* @param {string} userId
* @returns {RemoteUser | undefined}
*/
getRemoteUser(userId: string): RemoteUser | undefined;
/**
* 更新远端用户设备信息
* @param {RemoteUserStatus} user
* @returns {boolean} true: 用户状态改变 false: 用户状态没有改变
*/
updateRemoteUserDeviceStatus(user: RemoteUserStatus): void;
updateAudioWant(uid: string, sub: boolean): void;
updateVideoWant(uid: string, sub: boolean): void;
updateScreenWant(uid: string, sub: boolean): void;
private stopIndication;
private startIndication;
setEnableDualVideoStream(enabled: boolean, options?: AliRtcDualVideoPluginOptions): void;
setAudioVolume(options: AudioMixerPluginOptions): void;
enableAudioVolumeIndication(interval: number): void;
setPlayoutVolume(volume: number): void;
refreshAuthInfo(authInfo: AliRtcRefreshAuthInfo): void;
setEnableMediaExtensionMsg(enable: boolean): void;
setAudioRedEnabled(enable: boolean): void;
setVideoCodec(codec: CodecType): void;
setParameter(parameter: string): void;
updateDynamicConfig(configData: any): void;
setChannelContext(): void;
private setupAudioProcessingPluginIfNeeded;
getParameter(): string;
sendDataChannelMessage(message: AliRtcDataChannelMsg): void;
}
declare interface BizControlConfig {
slsReporter: SLSReporter;
signalingManager: SignalingManager;
parameter?: Parameter;
instanceId?: string;
}
declare interface BizControlListener {
[ClientEventType.RtsSubscribeExceeds]: (userId: string, options?: SubscribeOptions) => void;
[DeviceStatusChange.Remote]: (event: DeviceStatusChangeType, userId: string) => void;
[ClientEventType.PullStreamStats]: (userId: string, stat: any, pullStreamUrl: string) => void;
remoteTrackAvailableChange: (uid: string, aliRtcAudioTrack: AliRtcAudioTrack, aliRtcVideoTrack: AliRtcVideoTrack) => void;
audioSubscribeStateChanged: (uid: string, oldState: AliRtcSubscribeState, newState: AliRtcSubscribeState, elapseSinceLastState: number, channel: string) => void;
videoSubscribeStateChanged: (uid: string, oldState: AliRtcSubscribeState, newState: AliRtcSubscribeState, elapseSinceLastState: number, channel: string) => void;
screenSubscribeStateChanged: (uid: string, oldState: AliRtcSubscribeState, newState: AliRtcSubscribeState, elapseSinceLastState: number, channel: string) => void;
dataSubscribeStateChanged: (uid: string, oldState: AliRtcSubscribeState, newState: AliRtcSubscribeState, elapseSinceLastState: number, channel: string) => void;
userAudioMuted: (uid: string, isMute: boolean) => void;
userVideoMuted: (uid: string, isMute: boolean) => void;
userScreenMuted: (userId: string, isMute: boolean) => void;
audioVolume: (speakers: {
userId: string;
volume: number;
}[]) => void;
remoteUserJoin: (uid: string, elapseSinceLastJoin: number) => void;
rtcLocalVideoStats: (stats: AliRtcLocalVideoStats[]) => void;
rtcLocalAudioStats: (stats: AliRtcLocalAudioStats[]) => void;
rtcRemoteVideoStats: (stats: AliRtcRemoteVideoStats[]) => void;
rtcRemoteAudioStats: (stats: AliRtcRemoteAudioStats[]) => void;
rtcStats: (stats: any) => void;
remoteAudioAutoPlayFail: (uid: string) => void;
remoteVideoAutoPlayFail: (uid: string, track: AliRtcVideoTrack) => void;
remoteAudioPlayError: (uid: string, reason?: string) => void;
remoteVideoPlayError: (uid: string, reason?: string) => void;
remoteSubscribeError: (error: AliRtcError, uid?: string) => void;
occurError: (error: AliRtcError, uid?: string) => void;
remoteDataChannelMessage: (uid: string, message: AliRtcDataChannelMsg) => void;
remoteUserSubscribedDataChannel: (uid: string) => void;
networkQuality: (event: {
subscribe: {
rtt: number;
loss: number;
quality: AliRtcNetworkQuality;
};
}) => void;
}
declare class CanvasRenderer {
private activeRenderer;
private canvas;
private video;
private ms?;
constructor(props: IProps);
get mediaStream(): MediaStream;
start(): void;
stop(): void;
private initCanvas;
private initRenderer;
private render;
resize(width: number, height: number): void;
}
declare enum ClientEventType {
PullStreamStats = "remoteStat",
RtsSubscribeExceeds = "rtsSubscribeExceeds",
UserJoined = "userJoined",
UserLeft = "userLeft",
Bye = "bye",
MuteAudio = "muteAudio",
UnmuteAudio = "unmuteAudio",
MuteVideo = "muteVideo",
UnmuteVideo = "unmuteVideo",
MuteScreen = "muteScreen",
UnmuteScreen = "unmuteScreen",
Error = "error"
}
declare enum CmdType {
Add = 0,
Del = 1,
Update = 2,
None = 100
}
declare enum CodecType {
OPUS = "opus",
H264 = "H264",
H265 = "H265",
AV1 = "AV1",
UNKNOWN = ""
}
/**
* 存储服务器的动态配置,当前是从 rtc 的 diamond 服务器joinchannel 时获取并更新的
* 格式如下:
"data": {
"archCfgs": [
{
"arch": "grtn",
"user_specified": {
"aes_encryption_secret_key": "kajhldwp9fy109126dljbalvjbas//?S",
"appid": "1652f3e6-a35c-4087-8a2e-4f72bb9a2fa4",
"arch": "grtn",
"h5_enable_non_one_pc_default_join_mode": true,
"h5_reuse_sub_trans": true
}
}
]
}
*/
/** 评估结果:'off' | 'probe' | 'direct' */
declare type CompressDecision = 'off' | 'probe' | 'direct';
/**
* DataChannel 信令压缩协商策略状态机
*
* 利用 SCTP 有序可靠传输特性进行协商:
* 1. 先发送压缩格式的心跳(binary frame)
* 2. 紧跟发送普通文本心跳(JSON)
* 3. 若先收到压缩心跳的 response → 服务端支持压缩,协商成功
* 4. 若先收到文本心跳的 response → 服务端丢弃了压缩包,协商失败
*
* 支持最多 5 次重试。
*/
declare enum CompressState {
/** 初始态:等待 DataChannel 建连 */
INIT = "INIT",
/** 已发出压缩+文本心跳对,等待响应 */
PROBING = "PROBING",
/** 协商成功,后续大信令均压缩 */
ENABLED = "ENABLED",
/** 协商失败(连续 5 次探测均失败),本会话锁定文本模式 */
FAILED = "FAILED"
}
declare class CompressStrategy {
private state;
private probeCompressedMsgId;
private probeTextMsgId;
private probeFailCount;
private sendProbeFn;
private safetyTimer;
private readonly MAX_PROBE_ATTEMPTS;
private readonly SAFETY_TIMEOUT;
/**
* DataChannel open 后调用,触发首次探测。
* @returns true 表示状态已切换为 PROBING
*/
startProbe(): boolean;
/**
* 通过规则匹配直接开启压缩,跳过心跳探测流程。
*/
enableDirectly(): void;
/**
* 注册发送探测心跳对的回调,供失败重试时自动触发下一次探测。
*/
setSendProbeFn(fn: () => void): void;
/**
* 查询当前信令是否应该压缩。
* 仅在 ENABLED 状态返回 true。
*/
shouldCompressSignal(): boolean;
/**
* 标记已发出探测心跳对(压缩 + 文本),记录两个 msg_id。
* 启动安全超时计时器,防止 DC 断连时无限等待。
*/
markProbeSent(compressedMsgId: number, textMsgId: number): void;
/**
* 心跳响应回来时调用。利用 SCTP 有序性判断协商结果。
* - 收到压缩心跳 response (msg_id 匹配) → 协商成功
* - 收到文本心跳 response (而压缩心跳还未收到) → 服务端丢弃了压缩包,协商失败
*/
onHeartbeatResponse(msgId: number): void;
/**
* 获取当前状态
*/
getState(): CompressState;
/**
* 释放资源
*/
dispose(): void;
private onProbeFailed;
private clearSafetyTimer;
private log;
}
declare enum ConnectionLatencyStage {
CREATE_ENGINE = "create_engine",
JOIN = "join",
WANT_INSERT_PUB_TASK = "wantInsertPubTask",
INSERT_PUB_TASK = "InsertPubTask",
HANDLE_PUB_TASK = "HandlePubTask",
RECV_NOTIFY_PUBLISH = "RecvNotifyPublish",
INSERT_SUB_TASK = "InsertSubTask",
HANDLE_SUB_TASK = "HandleSubTask",
FIRST_REMOTE = "first_remote"
}
declare enum ConnectionLatencyStatus {
START = "start",
SEND_SIG = "send_sig",
RECV_RST = "recv_rst",
END = "end",
RECEIVED = "received",
DECODED = "decoded",
PLAYED = "played"
}
/**
* websocket链接状态
*/
declare enum CONNECTSTATUS {
DISCONNECTED = 0,
CONNECTING = 1,
CONNECTED = 2
}
/**
* 每一个新增 subAdd 的 Datachannel 都是独立 DataChannelCore
*/
declare class DataChannelCore extends EventEmitter_2 {
static REQUEST_TIMEOUT: number;
private pc;
private datachannel;
private eventHandler;
/** MUTEX: FALSE avail | TRUE occupied */
private mutexSendData;
private timerSendData;
private eventQueue;
private compressStrategy?;
private _onOpen;
private _onClose;
private _onError;
private _onMessage;
private _onClosing;
private _onBufferedAmountLow;
private delayOpen?;
private idle;
/**
* datachannelList 是初始化时从外部传入的引用,每一份 core 都是同步的,只读,用于判断哪个 id 可以被复用
*/
readonly datachannelList: any[];
constructor(props: IProps_2);
getWebrtcDatachannel(): RTCDataChannel;
get isIdle(): boolean;
private markAsIdle;
reuse(): void;
private getNextId;
private createDatachannel;
/**
* 绑定原生事件 listener (open/close/error/message/closing/bufferedamountlow)。
* - createDatachannel: 首次创建时调用一次
* - reuse: 软复用时由 dispose 卸过的 listener 必须重新挂回
* dispose -> unbindNativeListeners 置 null)。与 unbindNativeListeners 成对调用。
*/
private bindNativeListeners;
/**
* 解绑 bindNativeListeners 挂上的所有原生事件 listener,并把引用置 null。
* - dispose: 释放(软删除/硬关闭)时调用
* 与 bindNativeListeners 对应
*/
private unbindNativeListeners;
get id(): number;
get label(): string;
get readyState(): RTCDataChannelState;
/**
* 用于互动消息:仅负责发送数据,不关心返回状态(互动消息场景的发送-返回是业务层逻辑,SDK不解析)
* cname: simpleSend
*/
send(data: any): void;
/**
* 用于心跳消息(异步消息):发送指定type的数据,不排队。
*/
sendAsync(data: any): boolean;
/**
* 用于发送二进制数据(如压缩探测心跳):不排队,不走互斥锁。
*/
sendAsyncBinary(data: Uint8Array): boolean;
/**
* 用于推拉流信令:发送数据并等待返回,且可以排队
*/
sendData(data: any): Promise;
dispose(closeUnderlyingChannel?: boolean): void;
private atomSend;
}
declare interface DeviceStatus {
micOpen: boolean;
micInterrupted: boolean;
audioDisable: boolean;
cameraOpen: boolean;
videoDisable: boolean;
screenShare: boolean;
screenDisable: boolean;
backgroundMode: boolean;
accompanyPlaying: boolean;
}
declare enum DeviceStatusChange {
Local = "local-device-status-change",
Remote = "remote-device-status-change"
}
declare type DeviceStatusChangeType = ClientEventType.MuteAudio | ClientEventType.UnmuteAudio | ClientEventType.MuteScreen | ClientEventType.UnmuteScreen | ClientEventType.MuteVideo | ClientEventType.UnmuteVideo;
declare enum DisplayType {
NOT_DISPLAY = 0,
ALWAYS = 1,
WHEN_NO_VIDEO = 2
}
declare class DynamicConfig {
private config;
private cache;
/** 更新完整 config.data 对象,同时清除缓存 */
updateConfigData(configData: any): void;
/** 获取原始 config 对象 */
getConfigData(): any;
/** 从 archCfgs[arch=grtn].user_specified 中取对应 key 的值(带缓存) */
getDycConf(key: string): T | undefined;
/**
* 评估信令压缩开启方式(两级开关)
* - 'off': 不开启
* - 'probe': 需经心跳探测协商后开启
* - 'direct': 直接开启,跳过探测
*/
getSignalCompressDecision(context: IChannelContext): CompressDecision;
}
/**
* datachannel 状态
*/
declare enum EDatachannelStatus {
/**
* 已关闭
*/
DATACHANNEL_STATUS_CLOSE = 0,
/**
* 已连接,单 PC 信令可用
*/
DATACHANNEL_STATUS_OPEN = 1
}
declare class EventEmitter {
_eventMap: MapToList;
listeners(type: K): MapToList[K];
emit(type: K, ...args: any[]): boolean;
off(type: K, fn: T[K]): this;
removeAllListeners(type?: K): this;
on(type: K, fn: T[K]): this;
once(type: K, fn: T[K]): this;
}
declare class EventEmitter_2 {
_eventMap: MapToList_2;
listeners(type: K): MapToList_2[K];
emit(type: K, ...args: any[]): boolean;
off(type: K, fn: T[K]): this;
removeAllListeners(type?: K): this;
on(type: K, fn: T[K]): this;
once(type: K, fn: T[K]): this;
}
declare interface IAudioMixer {
trackList: MediaStreamTrack[];
useGainNode?: boolean;
}
declare interface IAudioProfile {
sampleRate: number;
channelCount: number;
maxBitrate: number;
}
/** 频道上下文(由上层设置) */
declare interface IChannelContext {
channelId?: string;
userId?: string;
}
declare interface IListenerMap {
[s: string]: any;
}
declare interface IListenerMap_2 {
[s: string]: any;
}
declare interface IListenerMap_3 {
statusChange: (status: EDatachannelStatus) => void;
message: (data: any) => void;
atomSend: (data: any) => void;
atomReceive: (data: any) => void;
error: (error: Error) => void;
dispose: () => void;
}
declare interface ImageHolderPluginOptions {
imageUrl: string;
}
/**
* 【EVENT】- media 媒体事件
*/
declare interface IMediaEvent {
onAutoPlayError: () => void;
onCanPlay: () => void;
onReplaceTrack: () => void;
videoTrackEnded: () => void;
audioTrackEnded: () => void;
mediaElementBinded: () => void;
micAudioTrackEnded: () => void;
screenAudioTrackEnded: () => void;
}
declare interface IProfile {
width: number;
height: number;
frameRate: number;
maxBitrate: number;
}
declare interface IProps {
video: HTMLVideoElement;
}
declare interface IProps_2 {
label?: string;
pc: RTCPeerConnection;
assignId?: boolean;
/**
* 现有的 datachannel List
*/
datachannelList?: any[];
onDatachannelEvent?: (status: EDatachannelStatus) => void;
delayOpen?: boolean;
initOptions?: RTCDataChannelInit;
compressStrategy?: CompressStrategy;
}
/**
* RTSReporter 方法定义接口
*/
declare interface IReporter {
reportVideoProfile(profile: string): void;
reportScreenProfile(profile: string): void;
reportAudioProfile(profile: string): void;
reportEnableAudio(): void;
reportDisableAudio(): void;
reportEnableVideo(): void;
reportDisableVideo(): void;
reportStop(type: number): void;
reportPlay(type: string): void;
}
declare interface IResponse {
version: number;
code: number;
msgtype: MessageType;
tid: string;
isproxy?: boolean;
}
declare interface ISendPackage {
version: number;
msgtype: MessageType;
tid: string;
header: {
appid: string;
channelid: string;
sessionid: string;
userid: string;
displayName?: string;
clientversion?: string;
platform?: string;
};
data: {
seq: number;
l1ip?: string;
status?: string;
clientrole?: string;
configure?: {
clientrole?: AliRtcSdkClientRole;
channelprofile: AliRtcSdkChannelProfile;
};
auth?: SendPackageAuthInfo;
adapt?: PackageAdaptInfo;
sessionid?: string;
pushstreamurl?: string;
users?: any[];
};
}
/**
* 【参数】- LocalStream - 【init()】创建本地流配置参数
*/
declare interface IStreamConfig {
audio?: MediaTrackConstraints | boolean;
video?: MediaTrackConstraints | boolean;
screen?: IScreenConstraints | boolean;
/** 自定义流 */
custom?: boolean;
mediaStream?: MediaStream;
skipProfile?: boolean;
}
/**
* 服务端通知的远端用户信息
*/
declare interface JoinInfo {
displayname: string;
session: string;
userid: string;
callid: string;
clientrole?: string;
subscribe?: {
pullstreamurl: string;
};
tracks?: TrackInfo[];
}
declare interface JoinResult {
l1ip?: string;
l1subip?: string;
pushstreamurl: string;
tid: string;
users: JoinInfo[];
timestamp: number;
config: any;
}
declare interface LeaveInfo {
userid: string;
leavecode: AliRtcUserOfflineReason;
reason: string;
}
declare class LocalProfileManager {
private defaultProfile;
profile?: string;
profileMap: Map;
audioProfile?: AudioProfileKey;
contentHint?: string;
constructor(defaultProfile?: IProfile);
updateProfile(profileKey: string, profileValue?: Partial): void;
get videoProfile(): string;
updateAudioProfile(profileKey: AudioProfileKey): void;
setContentHint(videoTrack: MediaStreamTrack | undefined, contentHint?: string): void;
/**
* 更新源流 Constraints
* 更新 PeerConnectiong Sender 相关配置
* @param stream
*/
setVideoProfile(originVideoTrack: MediaStreamTrack | undefined, target: LocalStream | undefined, skipConstraints?: boolean): Promise;
}
/**
* 推流使用的Stream
*/
declare class LocalStream extends Stream {
protected deviceManager: BrowserDeviceManager;
protected mediastream: MediaStream;
protected videoProfile: string;
protected screenProfile: string;
protected audioProfile: string;
protected pc?: RTCPeerConnection;
protected audioMixer?: AudioMixer;
protected canvasRenderer?: CanvasRenderer;
micAudioTrack?: MediaStreamTrack;
screenAudioTrack?: MediaStreamTrack;
hasVideo: boolean;
hasScreen: boolean;
isCustomStream: boolean;
screenSurfaceType: string | undefined;
VideoProfileMap: Map;
ScreenProfileMap: Map;
AudioProfileMap: Map;
constructor();
get mediaStream(): MediaStream;
get audioTrack(): MediaStreamTrack | undefined;
get videoTrack(): MediaStreamTrack | undefined;
/**
* 对外 API,可以和 hasVideo/hasScreen 并列使用
*/
get hasAudio(): boolean;
getVideoProfile(): string;
getScreenProfile(): string;
getAudioProfile(): string;
/**
* 初始化localstream
* 优先判断video的配置,如果需要使用屏幕共享,需要把video设置为false
* @param config
*/
init(config: IStreamConfig): Promise;
initWithRetry(config: IStreamConfig, res?: () => void, rej?: (reason?: any) => void): Promise;
private initMicAudio;
private initCameraVideo;
private initMicCamera;
private initScreenVideoAudio;
private tryMixMicAndScreenAudio;
private initTracks;
private tryToSetProfile;
private stopAllTracks;
private resetLocalStream;
setEncodeParam(pc: RTCPeerConnection, kind?: string): void;
private setVideoEncodeParams;
private setAudioEncodeParams;
play(element: HTMLVideoElement, config?: {
autoplay?: boolean;
canvasStream?: boolean;
}): void;
setVideoProfile(profile: string): Promise;
setScreenProfile(profile: string): Promise;
setAudioProfile(profile: string): Promise;
enableAudio(): boolean;
disableAudio(): boolean;
enableVideo(): boolean;
disableVideo(): boolean;
stop(): void;
mergeStream(newStream: LocalStream): void;
deleteTracks(trackType: {
video?: boolean;
audio?: boolean;
}): void;
protected createCustomStream(stream?: MediaStream): Promise;
protected releaseMediaStream(): void;
/**
* 同时获取音频和视频的时候,是否需要等待视频获取完成
* @param config
* @protected
*/
protected hasVideoTrackReady(config: IStreamConfig): boolean;
protected hasScreenAudioConfig(config: IStreamConfig): boolean | MediaTrackConstraints;
protected hasAudioTrackReady(config: IStreamConfig): boolean;
/**
* has config mic audio and audio track is ready
*/
protected hasMicAudioAndReady(config: IStreamConfig): MediaStreamTrack;
protected hasScreenAudioAndReady(config: IStreamConfig): MediaStreamTrack;
protected addTrackListener(): void;
protected listenVideoEnded(): void;
private listenAudioEnded;
protected handleVideoTrackEnded(): void;
protected handleAudioTrackEnded(): void;
}
declare type LocalStreamConfig = Omit<_LocalStreamConfig, 'custom'>;
declare interface _LocalStreamConfig extends IStreamConfig {
videoProfile?: string;
screenProfile?: string;
}
/**
* P2 设计方案:getUserMedia 并发控制
*
* 背景:
* getUserMedia() 是浏览器级别的全局资源,同一时间只能有一个活跃的获取操作。
* 多实例同时调用 createLocalStream() 会导致并发竞争:
* - Chrome: 后续请求返回 NotAllowedError
* - Safari: 后续请求返回 NotReadableError
* - Firefox: 后续请求排队但可能超时
*
* 设计方案 1:Promise 队列化
* ```
* class MediaAcquisitionQueue {
* private static queue: Promise = Promise.resolve();
*
* static async enqueue(fn: () => Promise): Promise {
* const prev = MediaAcquisitionQueue.queue;
* let resolve: (v: T) => void;
* MediaAcquisitionQueue.queue = new Promise(r => resolve = r as any);
* await prev;
* try {
* const result = await fn();
* resolve!(result);
* return result;
* } catch (e) {
* resolve!(undefined as any);
* throw e;
* }
* }
* }
* ```
*
* 设计方案 2:指数退避重试
* ```
* async function withRetry(
* fn: () => Promise,
* maxRetries = 3,
* baseDelay = 100
* ): Promise {
* for (let i = 0; i <= maxRetries; i++) {
* try { return await fn(); }
* catch (e) {
* if (i === maxRetries) throw e;
* if (isDeviceBusyError(e)) {
* await delay(baseDelay * Math.pow(2, i));
* } else { throw e; }
* }
* }
* }
* ```
*
* 设计方案 3:跨实例设备锁定(推荐组合使用方案 1 + 3)
* - 维护全局设备占用注册表
* - 请求前检查设备是否被其他实例占用
* - 支持设备共享模式(多实例共用同一摄像头 track)
*
* 迁移路径:
* 在 createLocalStream() 方法中将 AliRTS.createStream() 调用包装到队列中:
* ```
* localStream = await MediaAcquisitionQueue.enqueue(() =>
* AliRTS.createStream({ audio, video, screen, ... })
* );
* ```
*/
declare class LocalStreamManager extends default_2 {
/**
* @ignore
*/
static logName: string;
private pluginManager;
private slsReporter;
private publishingCameraVideoStream;
private publishingScreenVideoStream;
cameraStreamInfo: AliRtcLocalStreamInfo;
screenStreamInfo: AliRtcLocalStreamInfo;
private streamInfos;
private _audioCaptureDisabled;
private _cameraCaptureDisabled;
private _publishLocalAudioStreamEnabled;
private _publishLocalVideoStreamEnabled;
private _publishLocalScreenStreamEnabled;
constructor(pluginManager: PluginManager, slsReporter: SLSReporter);
get hasCamera(): boolean;
get audioCaptureDisabled(): boolean;
set audioCaptureDisabled(closed: boolean);
get cameraCaptureDisabled(): boolean;
set cameraCaptureDisabled(closed: boolean);
setAudioMuted(muted: boolean): void;
get isAudioMuted(): boolean;
setCameraMuted(muted: boolean): void;
get isCameraMuted(): boolean;
setScreenMuted(muted: boolean): void;
get isScreenMuted(): boolean;
get publishLocalAudioStreamEnabled(): boolean;
set publishLocalAudioStreamEnabled(enable: boolean);
get publishLocalVideoStreamEnabled(): boolean;
set publishLocalVideoStreamEnabled(enable: boolean);
get publishLocalScreenStreamEnabled(): boolean;
set publishLocalScreenStreamEnabled(enable: boolean);
updateStreams(): Promise;
private setAvailableCameraDeviceId;
private setAvailableMicrophoneDeviceId;
/**
* 创建 LocalStream
* @param {LocalStreamConfig} params 创建 LocalStream 的配置
* @returns {LocalStream} 当前创建的 LocalStream
*/
createLocalStream(params: LocalStreamConfig): Promise;
/**
* 停止推流,底层调用 rts publishStop,不会导致 DC 马上关闭。适合暂时停推的场景
* @param {StopPublishOptions} options
* @returns {Promise} 如果返回了 audio,则表示需要更新音频流
*/
stopLocalStream(options: StopPublishOptions): Promise;
get publishStreams(): PublishStreamInfo;
createHTTPPublishStream(): Promise<{
publishStream: LocalStream;
videoSmallStream: LocalStream;
screenStream: LocalStream;
vMsid: string;
}>;
/**
* 停止所有流
*/
stop(): void;
/**
* 设置摄像头流 profile
* @param {LocalStream | null} stream
* @param {string} profileKey
* @param {IProfile} profile
*/
setVideoProfile(profileKey?: string, profile?: Partial, skipConstraints?: boolean): Promise;
/**
* 设置摄像头流 content hint
* @param {string} hint
* @note 不传则尝试复用之前的 hint
*/
setVideoContentHint(hint?: string): void;
/**
* 设置音频流 profile
* @param {string} profileKey
*/
setAudioProfile(profileKey: AudioProfileKey): Promise;
/**
* 设置屏幕共享流 profile
* @param {LocalStream} stream
* @param {string} profileKey
* @param {IProfile} profile
*/
setScreenProfile(profileKey?: string, profile?: Partial): Promise;
setScreenContentHint(hint?: string): void;
/**
* 设置 cameraVideoConstraints
* @param {IVideoConstraints} cameraVideoConstraints
*/
setCameraVideoConstraints(cameraVideoConstraints: MediaTrackConstraints): void;
/**
* 设置 micAudioConstraints
* @param {IAudioConstraints} micAudioConstraints
*/
setMicAudioConstraints(micAudioConstraints: MediaTrackConstraints): void;
}
declare interface LocalStreamManagerListener {
trackended: (type: TrackEvent_2) => {};
publishupdate: () => {};
}
declare class LocalUser extends User {
/**
* @ignore
*/
static logName: string;
sessionId: string;
traceId: string;
private _url;
private joinTime;
private publishPromise;
private previewElements;
private screenPreviewElements;
private streamManager;
private dc;
protected streamTracks?: TrackInfo[];
protected publishId: string;
protected signalingManager: SignalingManager;
private shouldPublish;
private monitorTimerId?;
private monitorDataCache;
private candidateDataCache;
private pcMediaStatsMap;
private _cfpsStateMap;
protected slsReporter: SLSReporter;
private audioPubState;
private videoPubState;
private videoSmallPubState;
private screenPubState;
private dataPubState;
private parameter;
constructor(config: LocalUserConfig);
get url(): string;
set url(value: string);
get joined(): boolean;
get isPublishing(): boolean;
get publishStreams(): PublishStreamInfo;
get cameraTrack(): MediaStreamTrack | undefined;
get screenTrack(): MediaStreamTrack | undefined;
get audioTrack(): MediaStreamTrack | undefined;
get hasCamera(): boolean;
get hasMicrophone(): boolean;
get hasScreenShare(): boolean;
get hasCameraTrackInMS(): boolean;
get hasCameraDualTrackInMS(): boolean;
get hasScreenTrackInMS(): boolean;
get hasAudioTrackInMS(): boolean;
get cameraDirection(): string | undefined;
get audioCaptureDisabled(): boolean;
get cameraCaptureDisabled(): boolean;
get publishLocalVideoStreamEnabled(): boolean;
get publishLocalAudioStreamEnabled(): boolean;
get publishLocalScreenStreamEnabled(): boolean;
setPublishLocalAudioStreamEnabled(enable: boolean): void;
setPublishLocalVideoStreamEnabled(enable: boolean): void;
setPublishLocalScreenStreamEnabled(enable: boolean): void;
initInfo(authInfo: AliRtcAuthInfo, pushStreamUrl: string): void;
setVideoProfile(profile?: VideoProfileWithSendFramerate): Promise;
setVideoContentHint(hint: string): void;
setScreenContentHint(hint: string): void;
setAudioProfile(profileKey: AudioProfileKey): Promise;
setScreenProfile(profile?: Partial): Promise;
setCameraDirection(direction: AliRtcCameraDirection): void;
setCameraDeviceId(deviceId: string): void;
muteLocalCamera(mute: boolean): void;
muteLocalMic(mute: boolean): void;
muteLocalScreen(mute: boolean): void;
setMicrophoneDeviceId(deviceId: string): void;
setMicrophoneConstraints(constraints: MediaTrackConstraints): void;
updatePubId(): void;
clearPublishState(): void;
leave(): Promise;
/**
* 销毁,停止推流
* @returns {Promise}
*/
clear(): Promise;
resetElement(element: HTMLVideoElement): void;
setPreviewElement(previewParams: PreviewConfig): void;
startDefaultCameraAndMic(audioOnly?: boolean): Promise;
/**
* 为本地预览设置渲染元素和视频流
* @param {AliRtcLocalView} view 渲染元素,null 则为停止显示
* @param {AliRtcVideoTrack} track 视频流类型
*/
setViewConfig(elements: null | HTMLVideoElement[], track: AliRtcVideoTrack): void;
/**
* 开启摄像头采集
* @param params
* @returns
*/
startCameraCapture(): Promise;
/**
* 关闭摄像头采集
* @note 调用此接口后,入会后、离会再入会,采集设备保持关闭状态
*/
stopCameraCapture(): Promise;
/**
* 开启麦克风采集
* @param params
* @returns
*/
startAudioCapture(): Promise;
/**
* 关闭音频采集
* @note 调用此接口后,入会后、离会再入会,采集设备保持关闭状态
*/
stopAudioCapture(): Promise;
startCameraAndMic(): Promise;
/**
* 预览本地流
* @param {PreviewConfig} previewParams
* @returns {Promise}
*/
preview(previewParams: PreviewConfig): Promise;
/**
* 在所有预览容器中预览当前流
* @param {boolean} screen 是否指定预览辅流
*/
previewAll(previewAllParams?: PreviewAllConfig): Promise;
/**
* 停止预览本地流
*/
stopPreview(previewParams?: StopPreviewConfig): void;
/**
* 恢复推流
* @returns {Promise}
*/
resumePublish(): Promise;
createLocalStream(params: LocalStreamConfig): Promise;
stopLocalStream(options: PublishOptions): Promise;
private compareAndPublish;
private reportAudioProfile;
private reportVideoProfile;
private reportScreenProfile;
private updateDataChannel;
private publishDataChannel;
/**
* 开始推流
* @param isResume 是否是恢复推流
* @returns
*/
startPublish(isResume?: boolean, reason?: PublishReason): Promise;
/**
* 重新执行 progress 并触发 publishupdate
*/
updateStreams(): Promise;
/**
* 对比本地流和正在推流,进行推流更新
* @param isResume 是否是恢复推流
*/
publishUpdate(reason?: PublishReason): Promise;
private syncPublishToRoomServer;
private refreshPushStreamUrl;
/**
* 推流,用于 rts subscribe/publish 被调用后,此时 DataChannel 已存在
* @param {LocalStream} stream
* @returns {Promise}
*/
publishAdd(stream: LocalStream, extra: PublishExtraParams, isResume?: boolean, retryTimes?: number): Promise;
/**
* 替换推流 Track(仅限于替换已存在的 Track 类型)
* @param {LocalStream} stream
* @returns {Promise}
*/
publishReplace(stream: LocalStream, extra?: PublishExtraParams): Promise;
/**
* 停止推某些轨,不销毁 DataChannel 和 LocalStream,用于非销毁场景
* @param {PublishOptions} options
* @returns {Promise}
*/
publishDeleteTracks(options: PublishOptions): Promise;
/**
* 停止推流,不销毁 LocalStream,用于非销毁场景
* @returns {Promise}
*/
publishStop(): Promise;
/**
* 停止推流,销毁 DataChannel,用于销毁的场景
* @returns {Promise}
*/
unPublish(): Promise;
/**
* 事件通知本地的设备使用状态
*/
reportSelfDeviceStatus(): void;
/**
* 从localStream 中获取当前的设备状态
* @returns {string}
*/
private getDeviceStatus;
private onTrackEnd;
private resetPreviewElements;
private resetSecondayPreviewElements;
getMediaStats(id: string): any;
private reportPublishMonitor;
private reportNetwork;
private startStreamMonitor;
/**
* 采集视频采集帧率数据(cfps)
* 递进逻辑:
* 1. Chrome: trackStats.deliveredFrames
* 2. Firefox/Safari: 预览video元素或自建隐藏video元素 (mozPaintedFrames / requestVideoFrameCallback -> rvfc)
*/
private collectCaptureFrameStats;
/**
* 停止本地流数据采集
*/
private stopStreamMonitor;
/**
* 清理指定 msid(不传则全部)的 cfps 状态:
* 移除自建隐藏 video 元素、终止 rvfc 回调、删除缓存状态
* @param msid 不传则清理全部
*/
private clearCfpsState;
/**
* 清除本地流
* @returns {void}
*/
clearStream(): void;
/**
* 获取当前使用的摄像头 deviceId
* @returns {string | undefined}
*/
getCurrentCameraDeviceId(): string | undefined;
/**
* 获取当前使用的摄像头 deviceId
* @returns {string | undefined}
*/
getCurrentMicDeviceId(): string | undefined;
enableAudioVolumeIndication(interval: number): void;
sendSEI(message: ArrayBuffer, repeatCount: number, payloadType: number): Promise;
sendDataChannelMessage(message: AliRtcDataChannelMsg): void;
getStats(): Promise<{
audio: AliRtcLocalAudioStats[];
video: AliRtcLocalVideoStats[];
candidate: any;
}>;
markReconnect(msids?: string[]): void;
markReconnected(msids?: string[]): void;
}
declare interface LocalUserConfig {
rtsManager: RtsManager;
localStreamManager: LocalStreamManager;
slsReporter: SLSReporter;
signalingManager: SignalingManager;
pluginManager: PluginManager;
audioVolumeIndicationInterval: number;
parameter: Parameter;
}
/**
* 日志埋点类,调用LogReporter进行日志埋点
* 在入会之前,会将埋点缓存,入会后以每200ms一条的速度将缓存的埋点按顺序上报
*
* 多实例模式:使用共享的 Tracker 实例,避免并发请求过多导致 ERR_INSUFFICIENT_RESOURCES
*/
declare class LogClient {
private static sharedTrackers;
private static sharedStsData;
private static sharedStsExpiration;
private static sharedUpdateTimers;
private static sharedClientId;
private static instanceCount;
protected param?: any;
protected msgCacheArr: any[];
protected index: number;
protected ntpClock: NTPClient;
private globalEnv;
private envKey;
private stopped;
constructor(globalEnv?: 'DEFAULT' | 'SEA');
private get stsData();
private set stsData(value);
private get stsExpiration();
private set stsExpiration(value);
private createTracker;
private startSTSUpdateTask;
private refreshSTSToken;
private requestSTSToken;
start(info: AliRtcAuthInfo): void;
/**
* 断开连接(幂等方法,重复调用不会出错)
*/
stop(): void;
/**
* 发送一条日志
* @param {any} log
*/
sendReport(log: any): void;
/**
* 初始化公共参数
*/
protected initParam(info: AliRtcAuthInfo): void;
}
declare interface LogInfo {
[key: string]: string | number;
}
declare type MapToList = {
[K in V]: T[K][];
};
declare type MapToList_2 = {
[K in V]: T[K][];
};
declare interface MediaTrackInfo {
ssrc: string;
msid: string;
red: number;
codec: CodecType;
sample?: number;
pt: number;
type?: CmdType;
}
declare enum MessageType {
KEEPALIVE = "keepalive",
JOINCHANNEL = "joinchannel",
NOTIFYJOIN = "notifyjoin",
NOTIFYSTATUS = "notifystatus",
STATUSREPORT = "statusreport",
LEAVECHANNEL = "leavechannel",
NOTIFYLEAVE = "notifyleave",
NOTIFYPUBLISH = "notifypublish",
BYE = "bye",
RECONNECT = "reconnect",
PUBLISH = "publish",
REFRESHURL = "refreshurl",
UNSUBSCRIBE = "unsubscribe",
ROLEUPDATE = "roleupdate"
}
declare enum MPU_TASK_TRANSACTION_TYPE {
MPU_TASK_TRANSACTION_START = 0,
MPU_TASK_TRANSACTION_UPDATE = 1,
MPU_TASK_TRANSACTION_STOP = 2,
MPU_TASK_TRANSACTION_LIST = 3,
MPU_TASK_TRANSACTION_POLLING = 4,
MPU_TASK_TRANSACTION_ACKNOWLEDGE = 5,
MPU_TASK_TRANSACTION_END = 6
}
declare enum MsidType {
Audio = "sophon_audio",
VideoLarge = "sophon_video_camera_large",
VideoSmall = "sophon_video_camera_small",
Screen = "sophon_video_screen_share",
Data = "sophon_data"
}
declare class NTPClient {
private static instances;
private static refCounts;
private ntpClock;
private constructor();
static getInstance(globalEnv?: string): NTPClient;
static releaseInstance(globalEnv?: string): void;
now(): number;
}
declare interface PackageAdaptInfo {
os_name: string;
device_name: string;
brand_name: string;
device_key: string;
os_version: string;
sdk_version: string;
version: string;
}
declare class PackageCreator {
protected authInfo: AliRtcAuthInfo;
protected userName: string;
protected seqIndex: number;
constructor(authInfo: AliRtcAuthInfo, userName: string);
get roleAuth(): SendPackageAuthInfo | undefined;
static get adaptInfo(): PackageAdaptInfo;
refreshAuthInfo(authInfo: AliRtcAuthInfo): void;
getSeqIndex(): number;
/**
* 创建一个心跳包
* @returns
*/
createKeepAlivePackage(): ISendPackage;
/**
* 创建一个用于发送入会消息的Package
* @returns
*/
createJoinPackage(extraData?: any): ISendPackage;
/**
* 创建一个用于发送离会消息的Package
* @returns
*/
createLeavePackage(): ISendPackage;
createStatusPackage(status: string): ISendPackage;
/**
* 创建一个用于发送推流消息的Package
* @returns
*/
createPublishPackage(): ISendPackage;
createRoleUpdatePackage(): ISendPackage;
createReconnectPackage(data?: ReconnectData): ISendPackage;
createRefreshUrlPackage(): ISendPackage;
/**
* 创建一个Response包
* @param {string} tid Notify消息的tid
* @param {MessageType} msgType 消息类型
* @returns {IResponse}
*/
createResponsePackage(tid: string, msgType: MessageType): IResponse;
/**
*
* @param messageType
* @returns
*/
protected createBaseSendPackage(messageType: MessageType): ISendPackage;
}
/**
* SDK 参数配置
*/
declare interface Parameter {
/** 是否在推流信息中报告 L1 IP */
reportL1IP?: boolean;
/** 数据通道配置 */
data?: ParameterData;
/** 是否使用 AudioContext 进行音量控制 */
enableAudioContextPlayoutVolume?: boolean;
/** 网络相关配置 */
net?: ParameterNet;
/** 加入房间模式,如 'Conference'、'AIUser' 等 */
joinMode?: string;
/** 是否启用空白音频(用于保持音频轨道活跃) */
enableBlankAudio?: boolean;
/** 音频 3A 处理配置 */
audio?: ParameterAudio;
/** 订阅相关配置 */
subscribe?: ParameterSubscribe;
/** 支持其他自定义参数 */
[key: string]: any;
}
/**
* 音频 3A 处理配置参数
*/
declare interface ParameterAudio {
/** 是否使用服务端配置的 3A 设置 */
useAudio3AConfigFromServer?: boolean;
/** 是否启用系统回声消除 */
useSysEchoCancellation?: boolean;
/** 是否启用系统噪声抑制 */
useSysNoiseSuppression?: boolean;
/** 是否启用系统自动增益控制 */
useSysAutoGainControl?: boolean;
/** 是否启用智能 AEC */
useAIAEC?: boolean;
/** 是否启用软件 3A 处理 */
enableSoft3A?: boolean;
/** 是否启用旁路软 3A 检查 */
enableSoft3ACheck?: boolean;
/** 是否仅使用硬件 3A */
useHardOnly?: boolean;
/** 是否导出音频数据 */
dumpAudioData?: boolean;
}
/**
* 数据通道配置参数
*/
declare interface ParameterData {
/** 是否启用发布端数据通道 */
enablePubDataChannel?: boolean;
/** 是否启用订阅端数据通道 */
enableSubDataChannel?: boolean;
/**
* 是否允许在没有媒体流的情况下单独发布/订阅数据通道
* 需要配合 GRTN 配置 live_webrtc_signalling_enable_only_establish_h5_datachannel = on
*/
enablePubSubDataWithoutMedia?: boolean;
}
/**
* 网络相关配置参数
*/
declare interface ParameterNet {
/** 是否使用 TCP 传输 */
useTCP?: boolean;
/** 是否启用累积延迟 */
cumuDelay?: boolean;
/** 是否禁用心跳检测 */
disableHeartbeat?: boolean;
/** 心跳探活参数 */
heartbeat?: {
/** 心跳间隔,毫秒数,最小 200,默认 2500 */
interval?: number;
/** 超时时间,毫秒数 */
timeout?: number;
/** 是否启用心跳日志(监听 hebtSent/hebtReceived 事件) */
enableLog?: boolean;
};
/** 数据通道配置 */
datachannelInitOptions?: RTCDataChannelInit;
/** 媒体超时时间(毫秒),有效范围 1000-100000 */
mediaTimeout?: number;
}
/**
* 订阅相关配置参数
*/
declare interface ParameterSubscribe {
/** 是否禁用批量订阅,默认 false(即默认启用 batcher) */
disableBatcher?: boolean;
/** 批量订阅的最大数量 */
maxBatchCount?: number;
}
declare class PluginManager extends default_2 {
private plugins;
add(plugin: AliRtcPlugin, options?: any): void;
remove(name: string): void;
removeAll(): void;
get(name: string): AliRtcPlugin;
has(name: string): boolean;
getAll(): AliRtcPlugin[];
}
declare interface PluginManagerListener {
added: (plugin: AliRtcPlugin) => void;
removed: (plugin: AliRtcPlugin) => void;
updated: (plugin: AliRtcPlugin) => void;
}
declare interface PreviewAllConfig {
primary?: boolean;
screen?: boolean;
}
declare interface PreviewConfig {
videoElement: HTMLVideoElement;
screen?: boolean;
}
declare interface PublishExtraParams {
vMsid?: string;
aMsid?: string;
isVideoSmall?: boolean;
isScreen?: boolean;
isAudio?: boolean;
}
declare interface PublishInfo {
type: PublishType;
userid: string;
sessionid: string;
displayname: string;
pubid?: string;
resume?: boolean;
subscribe: {
signal: string;
pullstreamurl: string;
};
l1ip?: string;
callid: string;
tracks: TrackInfo[];
traceid?: string;
signaltid?: string;
}
declare type PublishOptions = StreamOptions & {
vMsid?: string;
};
declare enum PublishReason {
MANUAL = 0,
JOIN_CHANNEL = 1,
ROLE_CHANGE = 2,
RECONNECT = 3
}
declare interface PublishStreamInfo {
audio?: LocalStream;
video?: LocalStream;
videoSmall?: LocalStream;
screen?: LocalStream;
videoProfile?: LocalProfileManager;
screenProfile?: LocalProfileManager;
}
declare enum PublishType {
Add = "add",
Delete = "delete",
Replace = "replace",
Stop = "stop",
UnPublish = "unpublish"
}
declare interface PublishUser {
callid: string;
clientrole?: string;
displayname: string;
subscribe?: {
pullstreamurl: string;
};
pubid?: string;
tracks?: TrackInfo[];
userid: string;
sessionid?: string;
}
declare interface ReconnectData {
role?: RoleForReconnectData;
auth?: SendPackageAuthInfo;
publish?: {
users: [PublishInfo];
};
}
declare interface RefreshInfo {
pushstreamurl?: string;
users?: RefreshUser[];
}
declare interface RefreshUrlResult extends SignalingResult {
pushstreamurl?: string;
users?: RefreshUser[];
}
declare interface RefreshUser {
userid: string;
subscribe: {
pullstreamurl: string;
};
}
declare interface RemoteMediaTrackInfo extends MediaTrackInfo {
subscribeState?: RemoteTrackSubscribeState;
}
/**
* 播放使用的Stream
*/
declare class RemoteStream extends Stream {
protected recvCanPlay: boolean;
protected autoplay: boolean;
constructor();
set muted(muted: boolean);
get muted(): boolean;
get audioTrack(): MediaStreamAudioTrack;
get videoTrack(): MediaStreamVideoTrack;
get hasVideo(): boolean;
get hasAudio(): boolean;
get mediaStream(): MediaStream;
updateMediaStream(value: MediaStream): void;
getMediaStream(): MediaStream | undefined;
mergeStream(newStream: MediaStream): void;
play(element: HTMLMediaElement, config?: {
autoplay?: boolean;
}): void;
disableVideo(): void;
enableVideo(): void;
disableAudio(): void;
enableAudio(): void;
stop(): void;
/**
* media canplay 事件监听
*/
onCanPlay(): void;
protected release(): void;
protected bindMediaStream(mediastream: MediaStream): void;
protected tryToPlay(): void;
}
/**
* 远端流订阅失败原因
*/
declare enum RemoteStreamErrorReason {
/** 无法获取播放地址 */
FETCH_STREAM_URL_FAILED = "FETCH_STREAM_URL_FAILED",
/** 目标用户没有可用的流 */
NO_STREAM_AVAILABLE = "NO_STREAM_AVAILABLE",
/** 无效的播放元素 */
INVALID_VIEW_ELEMENT = "INVALID_VIEW_ELEMENT",
/** 订阅失败 */
SUBSCRIBE_FAILED = "SUBSCRIBE_FAILED"
}
declare class RemoteStreamHandler extends default_2 {
private config;
private static logName;
private get logName();
private readonly roomServerUrl;
private readonly label;
private rtsInstance?;
private currentStatus;
private latestStreamInfo?;
private preferredL1Ip?;
private usePreferredL1InRetry;
private _remoteStream?;
/**
* 获取代理后的 remoteStream,调用方法时会打印日志
*/
remoteStream?: RemoteStream;
private _prevDownlinkStat?;
private networkQualityTimer?;
constructor(config: SubscribeRemoteStreamConfig);
/**
* 更新连接状态,只有当状态发生变化时才触发事件
*/
private updateConnectionStatus;
/**
* 处理错误,使实例进入不可恢复状态,业务侧应销毁实例
*/
private handleError;
private fetchStreamUrlAndPlay;
/**
* 订阅时支持 prefer media server 超时降级
* 优先使用 window.__ali_prefer_media_server(测试用),其次使用 l1ip
* 如果存在 prefer media server,则设置 3 秒超时,超时后降级到 DNS 解析的 L1 节点
*/
private subscribeWithPreferredL1Fallback;
/**
* 打印 candidate 协议类型
*/
private logCandidateProtocol;
/**
* 创建 RemoteStream 的代理,用于拦截方法调用并打印日志
*/
private createRemoteStreamProxy;
/**
* 启动网络质量检测定时器
*/
private startNetworkQualityTimer;
/**
* 停止网络质量检测定时器
*/
private stopNetworkQualityTimer;
/**
* 获取下行网络质量
*/
private getNetworkQuality;
dispose(): void;
}
declare interface RemoteStreamHandlerEvents {
connectionStatusChange: (status: AliRtcConnectionStatus) => void;
networkQuality: (data: {
rtt: number;
loss: number;
quality: AliRtcNetworkQuality;
}) => void;
error: (reason: RemoteStreamErrorReason, detail: string) => void;
}
declare class RemoteStreamInfo extends default_2 {
/**
* @ignore
*/
static logName: string;
protected audioInfo: RemoteMediaTrackInfo;
protected videoLargeInfo: RemoteMediaTrackInfo;
protected videoSmallInfo: RemoteMediaTrackInfo;
protected screenInfo: RemoteMediaTrackInfo;
protected dataInfo: RemoteMediaTrackInfo;
protected audioVolume: number;
protected audioMuted: boolean;
protected userStatus?: DeviceStatus;
constructor();
/**
* 远端流音频轨道信息
* @returns
*/
getAudioInfo(): RemoteMediaTrackInfo;
/**
* 远端流视频轨道信息
* @returns
*/
getVideoSmallInfo(): RemoteMediaTrackInfo;
/**
* 远端流视频轨道信息
* @returns
*/
getVideoLargeInfo(): RemoteMediaTrackInfo;
/**
* 远端流屏幕共享轨道信息
* @returns
*/
getScreenInfo(): RemoteMediaTrackInfo;
getDataInfo(): RemoteMediaTrackInfo;
get subscribingInfos(): RemoteMediaTrackInfo[];
get hasTrack(): boolean;
/**
* 远端流是否包含音频轨道
* @returns
*/
get hasAudio(): boolean;
/**
* 远端流是否包含视频轨道
* @returns
*/
get hasVideo(): boolean;
/**
* 远端流是否包含视频大流轨道
* @returns
*/
get hasVideoLarge(): boolean;
/**
* 远端流是否包含视频小流轨道
* @returns
*/
get hasVideoSmall(): boolean;
/**
* 远端流是否包含屏幕共享轨道
* @returns
*/
get hasScreen(): boolean;
get hasData(): boolean;
/**
* 是否订阅远端流音频轨道
* @returns
*/
get isAudioSubscribed(): boolean;
get isAudioSubscribing(): boolean;
/**
* 是否订阅远端流视频轨道
* @returns
*/
get isVideoSubscribed(): boolean;
get isVideoSubscribing(): boolean;
/**
* 是否订阅远端流视频大流轨道
* @returns
*/
get isVideoLargeSubscribed(): boolean;
get isVideoLargeSubscribing(): boolean;
/**
* 是否订阅远端流视频小流轨道
* @returns
*/
get isVideoSmallSubscribed(): boolean;
get isVideoSmallSubscribing(): boolean;
/**
* 是否订阅远端流屏幕共享轨道
* @returns
*/
get isScreenSubscribed(): boolean;
get isScreenSubscribing(): boolean;
get isDataSubscribed(): boolean;
get isDataSubscribing(): boolean;
get audioCodec(): CodecType;
get videoCodec(): CodecType;
get audioTrackInfo(): AliRtcAudioTrack;
get videoTrackInfo(): AliRtcVideoTrack;
updateTracks(tracks?: TrackInfo[]): UpdateTracksResult;
protected updateRemoteTrackSsrc(audioSsrc: string, videoLargeSsrc: string, videoSmallSsrc: string, screenSsrc: string, dataSsrc: string): void;
markRemoteTrackSubscribing(option: SubscribeOptions): any;
updateRemoteTrackSubState(option: SubscribeOptions): any;
/**
* 更新远端用户设备状态
* @param status
* @returns {boolean} 状态改变返回true,否则返回false
*/
updateRemoteUserDeviceStatus(status: string): boolean;
}
declare interface RemoteSubscribeOptions {
remoteUser: RemoteUser;
options: SubscribeOptions;
}
declare enum RemoteTrackSubscribeState {
NotSubscribe = 0,
Subscribing = 1,
Subscribed = 2
}
declare class RemoteUser extends User {
/**
* @ignore
*/
static logName: string;
get logName(): string;
remoteCallId: string;
remoteUserInfo: AliRtcRemoteUserInfo;
protected localUser?: LocalUser;
protected lastPubId: string;
protected stream?: RemoteStream;
protected screenStream?: RemoteStream;
private viewMap;
private audioTrack?;
private audioElement?;
protected subscribed: boolean;
protected mediaStream?: MediaStream;
protected secondaryMediaStream?: MediaStream;
protected prevSubConfig?: SubConfig;
protected signalingManager: SignalingManager;
protected slsReporter: SLSReporter;
private wantSubAudio;
private wantSubVideo;
private wantSubScreen;
private defaultVideoStreamType;
private audioMuted;
private playoutVolume;
private playoutGainNode?;
private audioSubState;
private videoSubState;
private videoLargeSubState;
private videoSmallSubState;
private screenSubState;
private dataSubState;
private dc;
private dcMsgWaitingPieces;
streamInfo: RemoteStreamInfo;
private _streamUrl;
private parameter;
private _audioResumeHandler;
private _videoResumeHandler;
private monitorTimerId?;
private monitorDataCache;
traceId: string;
constructor(config: RemoteUserConfig);
get streamUrl(): string;
set streamUrl(value: string);
isWantSubAudio(): boolean;
setWantSubAudio(value: boolean): void;
isWantSubVideo(): boolean;
setWantSubVideo(value: boolean): void;
isWantSubScreen(): boolean;
setWantSubScreen(value: boolean): void;
setRemoteDefaultVideoStreamType(type: AliRtcVideoStreamType): void;
setAudioMuted(value: boolean): void;
getAudioElement(): HTMLAudioElement;
private handleAudioContextSuspended;
setPlayoutVolume(value: number): void;
getAudioMuted(): boolean;
get hasAudioTrack(): boolean;
get audioSSRC(): string;
get hasVideoTrack(): boolean;
get videoSSRC(): string;
get hasVideoLargeTrack(): boolean;
get hasVideoSmallTrack(): boolean;
get hasScreenTrack(): boolean;
get isAudioSubscribing(): boolean;
get isVideoSubscribing(): boolean;
get isVideoLargeSubscribing(): boolean;
get isVideoSmallSubscribing(): boolean;
get isScreenSubscribing(): boolean;
get isDataSubscribing(): boolean;
get audioEnabled(): boolean;
get videoEnabled(): boolean;
get screenEnabled(): boolean;
get getAudioTrack(): MediaStreamAudioTrack;
get getCameraStream(): RemoteStream;
get getScreenStream(): RemoteStream;
setViewConfig(view: AliRtcLocalView, track: AliRtcVideoTrack): void;
/**
* 销毁
* @returns {Promise}
*/
clear(needStopSub?: boolean): Promise;
/**
* 更新远端用户的设备状态
* @param {string} status
* @returns {void}
*/
updateRemoteUserDeviceStatus(status: string): void;
/**
* 更新远端用户的推流状态,已经停止推流的 tracks 要 delete,或者整体 stop
* @param {string} callid
* @param {string} pullStreamUrl
* @param {TrackInfo[]} tracks
* @returns {Promise}
*/
updateRemoteTracks(callid: string, pullStreamUrl: string, _pubid: string, tracks?: TrackInfo[]): Promise;
/**
* 订阅远端流
* @param {SubscribeOptions} options
* @returns {Promise} 返回可播放的 MediaStream,可能为空。如果同时订阅了主流和辅流,只会返回主流对应的 MediaStream
*/
subscribe(options?: SubscribeOptions, reason?: SubscribeReason, startTs?: number): Promise;
/**
* 订阅远端流
* @param {SubscribeOptions} options 订阅配置
* @param {boolean} secondary 是否订阅辅流
* @returns {Promise}
*/
private subscribeProxy;
/**
* 移除对某些轨道的订阅
* @param {UnSubscribeOptions} options 取消订阅轨道配置
* @returns {Promise}
*/
private subscribeDeleteTracks;
/**
* 移除对某些轨道的订阅
* @param {Partial} deleteTrack 删除订阅配置
* @returns {Promise}
*/
private subscribeDeleteProxy;
/**
* 用保存的订阅参数恢复订阅
*/
restore(): void;
resumeAudio(): Promise;
resumeVideo(videoTrack?: AliRtcVideoTrack): Promise;
resumePlay(): void;
/**
* 停止订阅远端流
* @param {string} userId
* @param {UnSubscribeOptions} options
* @returns {Promise}
*/
stopSubscribe(options?: UnSubscribeOptions): Promise;
/**
* 停止对某个拉流 URL 的订阅
* @param {url} pullStreamUrl
* @returns {Promise}
*/
private subscribeDeleteAllTracks;
private updateStream;
private updateScreenStream;
private clearStream;
private clearScreenStream;
private onDataChannelMessage;
private onDataChannelError;
private dataChannelConnected;
private subscribeDataChannel;
private subscribeDeleteDataChannel;
getRetryOptions(): RemoteSubscribeOptions | undefined;
/**
* 尝试更新订阅
* 1. 需要新增订阅的情况:想要订阅 & 没有正在订阅 & 远端有流
*/
updateSubscribe(reason: SubscribeReason): {
addOption: SubscribeOptions;
deleteOption: SubscribeOptions;
};
private handleAutoPlayFailed;
private _removeAudioResumeHandler;
private handleAudioPaused;
private handleVideoPlayFailded;
private _removeVideoResumeHandler;
private playAudio;
stopPlayAudio(): void;
playAll(isScreen?: boolean, isReplace?: boolean): void;
/**
* 播放
*/
private play;
stopPlayAll(isScreen?: boolean): void;
/**
* 是否开启声音
* @param {boolean} enable
* @returns {void}
*/
toggleAudio(enable?: boolean): void;
/**
* 是否开启画面
* @param {boolean} enable
* @returns {void}
*/
toggleVideo(enable?: boolean): void;
/**
* 是否开启画面
* @param {boolean} enable
* @returns {void}
*/
toggleScreen(enable?: boolean): void;
getStats(): Promise<{
audio: AliRtcRemoteAudioStats[];
video: AliRtcRemoteVideoStats[];
}>;
/**
* 开启音量检测
* @param {number} interval 时间间隔
*/
enableAudioVolumeIndication(interval: number): void;
private reportSubscribeMonitor;
private startStreamMonitor;
/**
* 停止本地流数据采集
*/
private stopStreamMonitor;
markReconnect(msids?: string[]): void;
markReconnected(msids?: string[]): void;
}
declare interface RemoteUserConfig {
userId: string;
displayName: string;
rtsManager: RtsManager;
usersViewMap: {
[key: string]: RemoteUserViewMap;
};
slsReporter: SLSReporter;
signalingManager: SignalingManager;
localUser?: LocalUser;
audioVolumeIndicationInterval: number;
playoutVolume: number;
parameter: Parameter;
}
declare interface RemoteUserMap {
[userId: string]: RemoteUser;
}
declare interface RemoteUserStatus {
userid: string;
status: string;
}
declare interface RemoteUserViewMap {
cameraViews: HTMLVideoElement[];
screenViews: HTMLVideoElement[];
}
declare interface RoleForReconnectData {
channelprofile?: AliRtcSdkChannelProfile;
clientrole?: AliRtcSdkClientRole;
}
/**
* RoomServerMessageCenter支持的事件
*/
declare interface RoomServerListener {
onJoinChannelResult: (data: any) => void;
onPublishResult: (code: number, tid: string, description: string) => void;
onNotifyJoin: (users: JoinInfo[]) => void;
onNotifyStatus: (users: RemoteUserStatus[]) => void;
onLeaveResult: (code: number, tid: string) => void;
onRoleUpdateResult: (code: number, tid: string, description: string) => void;
onRefreshUrlResult: (data: any) => void;
onNotifyLeave: (users: LeaveInfo[]) => void;
onNotifyPublish: (users: PublishUser[]) => void;
onStatusReport: (code: number, tid: string, description: string) => void;
onBye: (reason: AliRtcOnByeType, description: string) => void;
onKeepAliveRsp: () => void;
onConnectFail: (err: AliRtcError) => void;
onNetworkError: (err: AliRtcError) => void;
onAuthInvalid: () => void;
onReconnectStart: () => void;
onReconnectFail: (err: AliRtcError) => void;
onReconnectSuccess: (users: JoinInfo[]) => void;
onError: (err: AliRtcError) => void;
onUnknownMessage: (response: any) => void;
}
/**
* RoomServer消息中心
* 负责发送和接收信令数据,消息重发、回复Response
*/
declare class RoomServerMessageCenter extends default_2 {
static logName: string;
protected authInfo: AliRtcAuthInfo;
protected userName: string;
protected channelProfile: AliRtcSdkChannelProfile;
protected clientRole: AliRtcSdkClientRole;
private slsReporter;
protected wsClient: Socket;
protected packageCreator: PackageCreator;
protected keepAliveTimer: number;
protected lastKeepAliveResponseTime: number;
protected maxConnectRetryDuration: number;
protected packageCache: Map;
protected isFirstConnect: boolean;
protected aliveChecker: number;
protected reconnectData?: ReconnectData;
private joinChannelExtraData?;
constructor(authInfo: AliRtcAuthInfo, userName: string, channelProfile: AliRtcSdkChannelProfile, clientRole: AliRtcSdkClientRole, slsReporter: SLSReporter, maxConnectRetryDuration?: number);
get retryCount(): number;
destroy(): void;
/**
* 开始连接信令
* @param roomserverurl
* @param joinChannelExtraData 发送 joinChannel 信令时额外携带的数据
*/
start(roomserverurl: string, joinChannelExtraData?: any): void;
/**
* 开始心跳计时器,并自动发送心跳包
*/
startKeepAlive(): void;
/**
* 停止心跳计时器
*/
stopKeepAlive(): void;
/**
* 发送入会、重连前所缓存信息
*/
sendPkgCache(): void;
/**
* 发送离开房间
*/
leave(): void;
/**
* 透明通道消息上报
* @param status
*/
reportStatus(status: string): void;
/**
* 发送推流消息
*/
publish(_pubInfo: PublishInfo): void;
/**
* 更新角色
*/
roleUpdate(role: string): void;
/**
* 更新推拉流地址
* @param {RefreshInfo} info
*/
refreshUrl(info: RefreshInfo): void;
refreshAuthInfo(authInfo: AliRtcAuthInfo): void;
/**
* 关闭websocket连接,并销毁
*/
close(): void;
/**
* 通过此方法发送数据到业务信令
* 此方法会自动保存发送的package,并做重发.
* response包不要通过此方法发送
* @param pkg
*/
protected sendPackage(pkg: ISendPackage): void;
/**
* 更新重连 payload
* @param {ReconnectData} reconnectData
*/
updateReconnectData(reconnectData?: ReconnectData): void;
/**
* 收到websocket连接成功的消息
* ws连接建立成功后立刻发送join消息
*/
protected onOpen: () => void;
/**
* 收到业务信令消息
* @param event
*/
protected onMessage: (event: MessageEvent) => void;
/**
* 收到错误消息
* @param event
*/
protected onError: (event: Event) => void;
/**
* 连接失败
*/
protected onConnectFail: () => void;
/**
* 鉴权失败
*/
protected onAuthInvalid: () => void;
/**
* 网络异常
*/
protected onNetworkError: () => void;
/**
* 收到websocket断开消息
* @param event
*/
protected onClose: (event: CloseEvent) => void;
protected onKeepAliveRsp(): void;
protected onWillReconnect: () => void;
protected onReconnectStart: () => void;
protected onReconnectFail: () => void;
/**
* 处理 Keepalive 心跳,加速判断网络异常
*/
protected checkAlive(): void;
/**
* 处理收到的业务信令
* @param response
*/
protected onRecvMessage(response: any): void;
/**
* 收到入会消息的response
* @param response
*/
protected onJoinResult(response: any): void;
/**
* 收到离开消息的response
* @param response
*/
protected onLeaveResult(response: any): void;
/**
* 收到publish消息的response
* @param response
*/
protected onPublishResult(response: any): void;
/**
* 收到roleUpdate消息的response
* @param response
*/
protected onRoleUpdateResult(response: any): void;
/**
* 收到 refreshurl 消息的response
* @param response
*/
protected onRefreshUrlResult(response: any): void;
/**
* 收到重联消息的response
* @param response
*/
protected onReconnectResult(response: any): void;
/**
* 收到业务信令下发的消息
* @param response
*/
protected onNotifyJoin(response: any): void;
/**
* 收到业务信令下发的透明通道消息
* @param response
*/
protected onNotifyStatus(response: any): void;
/**
* 收到远端用户离开的通知
* @param response
*/
protected onNotifyLeave(response: any): void;
/**
* 收到远端用户推流的通知
* @param response
*/
protected onNotifyPublish(response: any): void;
/**
* 收到statusreport的response
* @param response
*/
protected onStatusReport(response: any): void;
/**
* 收到被踢出频道的消息
* @param {any} response
*/
protected onBye(response: any): void;
protected onUnknownMessage(response: any): void;
}
declare class RoomServerSignaling extends default_2 {
/**
* @ignore
*/
static logName: string;
protected messageCenter?: RoomServerMessageCenter;
protected authInfo?: AliRtcAuthInfo;
protected userName?: string;
protected channelProfile: AliRtcSdkChannelProfile;
protected clientRole: AliRtcSdkClientRole;
private slsReporter;
protected reconnectData?: ReconnectData;
protected roomServerUri: string;
constructor(channelProfile: AliRtcSdkChannelProfile, clientRole: AliRtcSdkClientRole, slsReporter: SLSReporter, env?: AliRtcEnv);
/**
* 更新重连数据
* @param {ReconnectData} reconnectData
*/
private updateReconnectData;
/**
* 释放资源
*/
reset(): void;
/**
* 加入频道
* @param {AliRtcAuthInfo} authInfo
* @returns
*/
join(authInfo: AliRtcAuthInfo, userName: string, maxSignalingReconnectDuration?: number, joinChannelExtraData?: any): Promise;
/**
* 离开频道
* @returns
*/
leave(): Promise;
/**
* 开始推流
* @param pubInfo
* @returns
*/
publish(pubInfo: PublishInfo): Promise;
roleUpdate(role: AliRtcSdkClientRole): Promise;
setChannelProfile(channelProfile: AliRtcSdkChannelProfile): void;
/**
* 更新推流地址
*/
refreshUrl(info: RefreshInfo): Promise;
/**
* 上报设备状态
* @param status
*/
reportStatus(status: string): Promise;
protected handleSignalError(code: number, description: string, errorCode?: AliRtcErrorCode): AliRtcError;
refreshAuthInfo(authInfo: AliRtcAuthInfo): Promise;
/**
* 初始化MessageCenter,增加事件监听
*/
protected initMessageCenter(): void;
}
declare class RtsManager extends default_2 {
/**
* @ignore
*/
static logName: string;
private rts;
dycConf: DynamicConfig;
private encodedInsertableStreams;
private audioRedEnabled;
private localStreamManager;
private slsReporter;
private _rtsPeerConnectionType;
private connecting;
private connected;
private hasPubWaitingForPcConnect;
private rtsDisconnected;
private _pcTraceId;
private _localJoinTime;
private connectionResolve?;
private connectingPromise?;
private dcResolve?;
private dcReject?;
private dcConnectingPromise?;
private _dcReady;
private _prevDownlinkStat?;
private _publishingTracks;
private parameter;
preferredPubL1Ip?: string;
preferredSubL1Ip?: string;
private httpPublishUrlMap;
private httpSubscribeUrlMap;
private traceIdMap;
private subUrlMap;
private subscribeAddBatcher;
private multiPC?;
isLowPerfDevice: boolean;
/**
* 由 bizControl 注入,用于在 PC 重连的 beforeRetry 中检查订阅 URL 对应的远端用户是否还在频道中。
* 返回 false 表示用户已离会、URL 无效,应终止重连。
*/
isSubscribeUrlValid?: (url: string) => boolean;
/**
* 构造“对端已离会”导致的主动终止错误。打上 aborted 标记,
* 便于上层识别后优雅结束而非作为错误上抛。
*/
private createSubscribeAbortError;
private extractStreamId;
private subscribeAddWithRetry;
constructor(localStreamManager: LocalStreamManager, slsReporter: SLSReporter, parameter: Parameter);
private createRtsInstance;
private addRTSListener;
/**
* 更新鉴权信息,传入一个新的带鉴权的 URL,RTS 会去除鉴权信息做更新
* @param newUrlWithAuth
*/
updateAuth(newUrlWithAuth: string): void;
get pcTraceId(): string;
set localJoinTime(time: number);
setEncodedInsertableStreams(enable: boolean): void;
updateDynamicConfig(configData: any): void;
setChannelContext(context: {
channelId?: string;
userId?: string;
}): void;
setReceiverPreferredVideoCodecH265(): void;
setSenderPreferredVideoCodecH265(): void;
supportVideoCodec(codec: CodecType): boolean;
changeVideoCodec(codec: CodecType): void;
setAudioRedEnabled(enable: boolean): void;
clear(): void;
private startConnect;
private setConnected;
get isConnecting(): boolean;
get isConnected(): boolean;
get rtsPeerConnectionType(): RtsPeerConnectionType;
private suffixHttpUrl;
private getSuffixedUrl;
get publishingTracks(): TrackInfo[];
private getPubMsid;
private updatePublishingTracks;
private httpPublish;
waitPublishSender(streamUrl: string, isAudio?: boolean, msid?: string): Promise;
getPublishVideoStats(streamUrl: string, msid?: string): Promise;
getPublishAudioStats(streamUrl: string, msid?: string): Promise;
publishAdd(publisher: LocalUser, stream: LocalStream, extra?: PublishExtraParams, isResume?: boolean, waitSender?: boolean, reason?: PublishReason): Promise;
publishDelete(streamUrl: string, options: PublishOptions): Promise;
publishReplace(streamUrl: string, stream: LocalStream, extra?: PublishExtraParams): Promise;
publishStop(streamUrl: string): Promise;
publishAddDataChannel(streamUrl: string): Promise;
publishStopDataChannel(streamUrl: string, datachannel: any): Promise;
unpublish(): Promise;
private getMultiPCNetworkQuality;
getSubscribeNetworkQuality(): Promise<{
rtt: number;
loss: number;
quality: AliRtcNetworkQuality;
}>;
/**
* 获取 sub/subAdd config
* @param {ISubscribeConfig | ISubConfigItem} options
* @returns {Omit}
*/
private getSubConfig;
private handleHTTPConfig;
private httpSubscribe;
/**
* 订阅时支持 preferredSubL1Ip 超时降级
* 如果存在 preferredSubL1Ip,则设置 3 秒超时,超时后清除 preferredSubL1Ip,降级到 DNS 解析的 L1 节点
*/
private subscribeWithPreferredL1Fallback;
/**
* 推流时支持 preferredPubL1Ip 超时降级
* 如果存在 preferredPubL1Ip,则设置 3 秒超时,超时后清除 preferredPubL1Ip,降级到 DNS 解析的 L1 节点
*/
private publishWithPreferredL1Fallback;
private subscribeAdd;
subscribeDelete(subscribeOptions: RemoteSubscribeOptions): Promise;
updateSubscribeBatcher(subscribeConfig: {
disableBatcher?: boolean;
maxBatchCount?: number;
}): void;
subscribeAddDataChannel(streamUrl: string): Promise;
subscribeDeleteDatachannel(streamUrl: string, datachannel: any): Promise;
publish(publisher: LocalUser, isResume?: boolean, reason?: PublishReason): Promise<{
traceId: string;
l1ip?: string;
}>;
private reportSubscribeLatency;
subscribe(remoteSubscribeOptions: RemoteSubscribeOptions, reason: SubscribeReason, callId: string, remoteCallId: string, startTs: number): Promise;
getSubscribeVideoStats(streamUrl: string, msid?: string): Promise;
getSubscribeAudioStats(streamUrl: string, msid?: string): Promise;
getStreamByMsid(config: any): LocalStream | RemoteStream;
getDatachannelByMsid(config: {
url: string;
msid?: string;
}): DataChannelCore;
getPCStats(): Promise;
/**
* 获取当前使用的 candidate 协议类型(udp/tcp)
*/
private logCandidateProtocol;
/**
* 获取当前 WebRTC 连接的网关(服务器)IP 地址
* 通过 remote-candidate stats 提取 nominated candidate-pair 对应的远端 IP
*/
getGatewayIp(): Promise;
sendSEI(streamUrl: string, data: ArrayBuffer, repeatCount: number, payloadType: number): Promise;
}
declare interface RtsManagerEventListener {
reconnecting: (type: RtsPeerConnectionType) => {};
disconnected: () => {};
connected: (isReconnected: boolean, type: RtsPeerConnectionType) => {};
subscribeexceeds: () => {};
seimessage: (url: string, payloadType: number, data: ArrayBuffer) => {};
traceIdUpdated: (url: string, traceId: string) => {};
reconnect: (type: RtsReconnectType, url?: string, msids?: string[]) => {};
reconnectFinish: (type: RtsReconnectType, url?: string, msids?: string[]) => {};
}
declare enum RtsPeerConnectionType {
PUBLISH = "publish",
SUBSCRIBE = "subscribe"
}
declare type RtsReconnectType = 'sub' | 'pub' | 'sub-data' | 'pub-data' | 'pc' | 'all';
declare interface SendPackageAuthInfo {
timestamp: number;
nonce?: string;
token: string;
tokenrole: AliRtcSdkTokenRole;
}
declare class SignalingManager extends default_2 {
/**
* @ignore
*/
static logName: string;
protected signaling?: RoomServerSignaling;
protected authInfo?: AliRtcAuthInfo;
protected userName?: string;
protected channelProfile: AliRtcSdkChannelProfile;
protected clientRole: AliRtcSdkClientRole;
protected env: AliRtcEnv;
protected maxSignalingReconnectDuration?: number;
private slsReporter;
constructor(channelProfile: AliRtcSdkChannelProfile, clientRole: AliRtcSdkClientRole, slsReporter: SLSReporter, env?: AliRtcEnv);
reset(): void;
/**
* 向业务信令发送入会
* @param {AliRtcAuthInfo} authInfo
* @returns
*/
join(authInfo: AliRtcAuthInfo, userName?: string, maxSignalingReconnectDuration?: number, timeRecorder?: TimeRecorder, joinChannelExtraData?: any): Promise;
retryJoin(): void;
/**
* 向业务信令发送离会
* @returns
*/
leave(): Promise;
/**
* 推流
* @param pubInfo
* @returns
*/
publish(pubInfo: PublishInfo): Promise;
/**
* 通过透明通道发送设备状态
* @param {string} status
* @returns
*/
reportStatus(status: string): Promise;
/**
* 切换角色
* @param {AliRtcSdkClientRole} role
* @returns
*/
setClientRole(role: AliRtcSdkClientRole): Promise;
/**
* 切换模式
* @param {AliRtcSdkChannelProfile} channelProfile
*/
setChannelProfile(channelProfile: AliRtcSdkChannelProfile): void;
/**
* 更新推流url
* @param {RefreshInfo} info
* @returns
*/
refreshUrl(info: RefreshInfo): Promise;
refreshAuthInfo(authInfo: AliRtcRefreshAuthInfo): Promise;
/**
* 监听业务信令相关的事件
*/
protected initSignaling(): void;
/**
* 收到心跳消息
*/
protected onKeepAliveRsp(): void;
/**
* 收到远端用户入会消息
* @param {JoinInfo[]} users
*/
protected onNotifyJoin(users: JoinInfo[]): void;
/**
* 收到远端用户的透明通道消息
* @param {RemoteUserStatus[]} users
*/
protected onNotifyStatus(users: RemoteUserStatus[]): void;
/**
* 收到远端用户的离会消息
* @param {LeaveInfo[]} users
*/
protected onNotifyLeave(users: LeaveInfo[]): void;
/**
* 收到远端用户推流状态变化消息
* @param {PublishInfo[]} users
*/
protected onNotifyPublish(users: PublishUser[]): void;
/**
* 收到被踢掉消息
* @param {string} reason
* @param {string} description
*/
protected onBye(reason: AliRtcOnByeType, description: string): void;
/**
* 收到连接失败消息
* @param {AliRtcError} err
*/
protected onConnectFail(err: AliRtcError): void;
/**
* 收到网络异常消息
* @param {AliRtcError} err
*/
protected onNetworkError(err: AliRtcError): void;
/**
* 收到网络异常消息
*/
protected onAuthInvalid(): void;
protected onReconnectStart(): void;
/**
* 收到重连成功消息
* @param {JoinInfo[]} users
*/
protected onReconnectSuccess(users: JoinInfo[]): void;
/**
* 收到重连失败消息
*/
protected onReconnectFail(err: AliRtcError): void;
/**
* 收到错误消息
* @param {AliRtcError} err
*/
protected onError(err: AliRtcError): void;
protected onUnknownMessage(message: any): void;
}
declare interface SignalingResult {
tid: string;
code?: number;
message?: string;
}
/**
* 日志埋点类
* 每个埋点暴露对应的接口
*/
declare class SLSReporter {
private engine;
protected logClient: LogClient;
protected authInfo?: AliRtcAuthInfo;
private ntpClock;
private globalEnv;
constructor(engine: WrappedAliRtcEngine, globalEnv?: 'DEFAULT' | 'SEA');
private customFields;
/**
* 设置通用字段
* @param fields 字段键值对
*/
setCustomFields(fields: {
[key: string]: any;
}): void;
/**
* 获取通用字段
* @param key 字段键
* @returns 字段值或undefined
*/
getCustomField(key: string): any;
/**
* 开始建立连接
* @param authInfo
*/
start(info: AliRtcAuthInfo): void;
/**
* 断开连接
*/
stop(): void;
reportPublishAudio3A(callId: string, msid: string, traceId: string, apmJson: string): void;
reportPublishMonitor(callId: string, traceId: string, msid: string, track: MediaStreamTrack | undefined, stats: any[]): void;
reportSubscribeMonitor(callId: string, remoteId: string, traceId: string, msid: string, stats: any[]): void;
reportNetworkMonitor(candidates: any[]): void;
reportLoopAudioDelay(ssrc: string, result: any): void;
reportCumuAudioDelay(audioSSRC: string, result: any): void;
reportCumuVideoDelay(videoSSRC: string, result: any): void;
/**
* 加入房间成功埋点
* @param {number} joinTime
* @param {number} result
* @param {string} tid
*/
reportJoin(result: number, timeRecord: TimeRecorder, tid?: string): void;
/**
* Join 链接细节
*/
reportJoinConnection(logInfo: LogInfo): void;
/**
* 用户离开频道事件埋点
* @param {number} leaveTime
* @param {number} result
* @param {string} tid
*/
reportLeave(leaveTime: number, result: number, tid: string): void;
/**
* 推流事件上报
* @param {string} callid
* @param {boolean} isLargeVideo
* @param {boolean} isSmallVideo
* @param {boolean} isScreenShare
* @param {boolean} isAudio
* @param {number} result
* @param {string} tid
* @param {number} pubTime
*/
reportPublish(isRepublish: boolean, url: string, callid: string, isLargeVideo: boolean, isSmallVideo: boolean, isScreenShare: boolean, isAudio: boolean, result: number | undefined, pcTraceId: string, traceId: string, startTime: number, time?: number): void;
/**
* 首包上报
* @param {string} callid
* @param {number} startTime
* @param {number} publishTime
* @param {number} joinTime
* @param {string} tckid
* @param {string} pcTraceId
* @param {string} traceId
* @param {PublishReason} reason
*/
reportPublishFirstPacket(isRepublish: boolean, callid: string, startTime: number, publishTime: number, joinTime: number, tckid: string, pcTraceId: string, traceId: string, reason: PublishReason): void;
/**
* 停止推流事件上报
* @param {string} callid
* @param {number} unpubTime
* @param {number} result
* @param {string} tid
*/
reportUnpublish(callid: string, unpubTime: number, result: number, tid: string): void;
/**
* 订阅事件埋点
* @param {string} callid
* @param {string} remoteid
* @param {boolean} isLargeVideo
* @param {boolean} isSmallVideo
* @param {boolean} isScreenShare
* @param {boolean} isAudio
* @param {number} result
* @param {string} tid
* @param {number} subTime
*/
reportSubscribe(callid: string, remoteid: string, isLargeVideo: boolean, isSmallVideo: boolean, isScreenShare: boolean, isAudio: boolean, result: number, tid: string, subTime: number, logInfo: LogInfo, successTime?: number): void;
reportSubscribeFirstPacket(isResume: boolean, callid: string, remoteid: string, trackId: string, logInfo: LogInfo): void;
reportSubscribeFirstFrame(isResume: boolean, callid: string, remoteid: string, trackId: string, logInfo: LogInfo): void;
/**
* 停止订阅事件埋点
* @param {string} callid
* @param {string} remoteid
* @param {number} unsubTime
* @param {number} result
* @param {string} tid
*/
reportUnsubscribe(callid: string, remoteid: string, unsubTime: number, result: number, tid: string): void;
reportMute(callid: string, enable: boolean, type: 'audio' | 'video' | 'screen'): void;
/**
* 更新角色埋点
* @param {string|undefined} or 旧的角色
* @param {string} nr 新的角色
*/
reportRoleUpdate(or: string | undefined, nr: string): void;
/**
* 更新角色埋点
* @param {string|undefined} or 旧的角色
* @param {string} nr 新的角色
*/
reportRoleUpdateResult(or: string | undefined, nr: string, ctm: number, result: number): void;
/**
* 设置camera videoprofile
*/
reportVideoProfile(profile: string): void;
/**
* 设置screenshare videoprofile
*/
reportScreenProfile(profile: string): void;
/**
* 错误事件埋点
* @param err
*/
reportError(err: any): void;
/**
* 错误事件埋点
* @param err
*/
reportWarning(msg: string): void;
reportRoomServerEvent(isRequest: boolean, type: string, requestId: string, content: any): void;
reportTranscodingError(result: number, taskid: string): void;
reportBye(result: number): void;
reportAudio(error: any, cost: number, deviceName: string): void;
reportScreen(error: any, cost: number): void;
reportScreenStop(error: any): void;
reportSwitchCamera(deviceId: string): void;
reportPublishProfile(trackId: string, logInfo: LogInfo): void;
reportSDKCreated(startTs: number): void;
reportJoinInvoked(authInfo: AliRtcAuthInfo): void;
reportJoinResult(error: any): void;
reportSTSResult(code: number, startTs: number): void;
reportLeaveInvoked(): void;
reportSEIMessage(payloadType: number, length: number, repeatCount: number, delay: number, isKey: boolean): void;
/**
* 接通耗时事件(12001)
* 用stage和status来区分接通过程中各个时间节点。
* @param state
* @param status
* @param calid
* @param tckid
*/
reportConnectionLatencyEvent(stage: Stage, status: ValidStatusMap[Stage], calid: string, tckid: string, tm?: number, ntptm?: number, http?: boolean): void;
/**
* 日志埋点
* 在埋点中增加tm字段,表示发生埋点的客户端本地时间
* @param {any} param 埋点内容
*/
protected log(param: any): void;
/**
* 将Object转换成string
* @param {any} data
* @returns {string}
*/
protected data2String(data: any): string;
}
/**
* Websocket类
*/
declare class Socket extends default_2 {
/**
* @ignore
*/
static logName: string;
protected ws?: WebSocket;
protected socketStatus: CONNECTSTATUS;
protected wsUrl: string;
protected lastConnectStartTime: number;
protected connectRetryMinTimeGap: number;
protected shouldReconnect: boolean;
connectRetryCount: number;
protected gotErr: boolean;
protected closedByInvoke: boolean;
protected isReconnecting: boolean;
protected networkAvailableChecked: boolean;
private reconnectTimeoutId;
constructor(connectRetryMinTimeGap?: number);
get connectUrl(): string;
/**
* 返回websocket连接的状态
*/
get connectStatus(): CONNECTSTATUS;
/**
* 开始连接
* @param wsUrl
*/
start(wsUrl: string): void;
/**
* 发送消息
* @param pkg
*/
send(pkg: ISendPackage | IResponse): boolean;
/**
* 主动断开连接
*/
close(): void;
markShouldReconnect(shouldReconnect: boolean): void;
reconnect(): void;
/**
* 连接成功
* @param event
*/
protected onOpen(event: Event): void;
/**
* 收到消息
* @param event
*/
protected onMessage(event: MessageEvent): void;
/**
* 收到错误
* @param event
*/
protected onError(event: Event): void;
/**
* 连接断开
* @param event
*/
protected onClose(event: CloseEvent): Promise;
/**
* 初始化websocket
*/
protected initWebSocket(): void;
/**
* 反初始化websocket
*/
protected uninitWebsocket(): void;
}
/**
* Socket的支持的事件
*/
declare interface SocketListener {
onOpen: (event: Event) => void;
onMessage: (event: MessageEvent) => void;
onError: (event: Event) => void;
onClose: (event: CloseEvent) => void;
onConnectFail: () => void;
onAuthInvalid: () => void;
onNetworkError: () => void;
onWillReconnect: () => void;
onReconnectStart: () => void;
onReconnectFail: (event: Event) => void;
}
declare interface StopPreviewConfig {
videoElement?: HTMLVideoElement;
primary?: boolean;
screen?: boolean;
}
declare type StopPublishOptions = StreamOptions;
declare class Stream extends EventEmitter {
protected audiotrack?: MediaStreamTrack;
protected videotrack?: MediaStreamTrack;
protected element?: HTMLMediaElement;
protected mediastream?: MediaStream;
protected traceid: string;
protected reporter?: IReporter;
id: string;
constructor();
set traceId(value: string);
get traceId(): string;
get mediaElement(): HTMLMediaElement | undefined;
setReporter(reporter: IReporter): void;
play(element: HTMLMediaElement): void;
stop(): void;
}
declare interface StreamListener {
[DeviceStatusChange.Remote]: (event: DeviceStatusChangeType) => void;
error: (err: AliRtcError) => void;
}
declare interface StreamOptions {
audio?: boolean;
video?: boolean;
screen?: boolean;
data?: boolean;
}
declare interface SubConfig {
isAudioSubscribing: boolean;
isVideoSubscribing: boolean;
isScreenSubscribing: boolean;
audioEnabled: boolean;
videoEnabled: boolean;
screenEnabled: boolean;
}
declare type SubscribeOptions = StreamOptions & {
aMsid?: string;
vMsid?: string;
};
declare enum SubscribeReason {
InRoom = "inRoom",
Join = "join",
Publish = "publish",
User = "user",
Resume = "resume",
Retry = "retry",
Reconnect = "reconnect"
}
declare interface SubscribeRemoteStreamConfig {
env?: AliRtcEnv;
appId: string;
currentUserId: string;
targetChannelId: string;
targetUserId: string;
token: string;
nonce?: string;
timestamp: number;
/** 角色鉴权标识(可选),传入时 token 需按角色算法生成,并会拼到 querypulluri 的 tokenrole 参数 */
role?: AliRtcSdkTokenRole;
view?: string | HTMLVideoElement;
}
declare interface TimeRecorder {
start: number;
[key: string]: number;
}
declare enum TrackEvent_2 {
VideoTrackEnded = "videoTrackEnded",
AudioTrackEnded = "audioTrackEnded",
ScreenTrackEnded = "screenTrackEnded"
}
declare interface TrackInfo {
ssrc: string;
codec: string;
msid?: MsidType;
type: string;
from?: string | undefined;
userdata?: string;
trackId?: string;
attr?: Record;
pt?: number;
}
declare type UnSubscribeOptions = SubscribeOptions;
declare interface UpdateTracksResult {
restoreSub?: boolean;
}
declare class User extends default_2 {
protected uid: string;
protected name: string;
protected rtsManager: RtsManager;
callId: string;
protected audioLevelMonitor: AudioLevelMonitor;
protected audioVolumeIndicationInterval: number;
constructor(userId: string, displayname: string, rtsManager: RtsManager, interval: number);
get userId(): string;
get displayname(): string;
protected createCallId(forceUpdate?: boolean): void;
setUserInfo(uid: string, displayName: string): void;
refreshUserInfo(uid: string): void;
/**
* 获取音频 level
*/
getAudioLevel(): number;
enableAudioVolumeIndication(interval: number): void;
/**
* 销毁用户,清空数据
*/
clear(): void;
}
declare interface UserListener {
[DeviceStatusChange.Local]: (status: string) => void;
[DeviceStatusChange.Remote]: (event: DeviceStatusChangeType, userId: string) => void;
[ClientEventType.PullStreamStats]: (userId: string, stat: any, pullStreamUrl: string) => void;
[ClientEventType.RtsSubscribeExceeds]: (userId: string, options?: SubscribeOptions) => void;
[TrackEvent_2.VideoTrackEnded]: () => void;
[TrackEvent_2.AudioTrackEnded]: () => void;
[TrackEvent_2.ScreenTrackEnded]: () => void;
remoteTrackAvailableChange: (uid: string, aliRtcAudioTrack: AliRtcAudioTrack, aliRtcVideoTrack: AliRtcVideoTrack) => void;
audioSubscribeStateChanged: (uid: string, oldState: AliRtcSubscribeState, newState: AliRtcSubscribeState, elapseSinceLastState: number) => void;
videoSubscribeStateChanged: (uid: string, oldState: AliRtcSubscribeState, newState: AliRtcSubscribeState, elapseSinceLastState: number) => void;
screenSubscribeStateChanged: (uid: string, oldState: AliRtcSubscribeState, newState: AliRtcSubscribeState, elapseSinceLastState: number) => void;
dataSubscribeStateChanged: (uid: string, oldState: AliRtcSubscribeState, newState: AliRtcSubscribeState, elapseSinceLastState: number) => void;
audioPublishStateChanged: (oldState: AliRtcPublishState, newState: AliRtcPublishState, elapseSinceLastState: number) => void;
videoPublishStateChanged: (oldState: AliRtcPublishState, newState: AliRtcPublishState, elapseSinceLastState: number) => void;
dualStreamPublishStateChanged: (oldState: AliRtcPublishState, newState: AliRtcPublishState, elapseSinceLastState: number) => void;
screenPublishStateChanged: (oldState: AliRtcPublishState, newState: AliRtcPublishState, elapseSinceLastState: number) => void;
dataPublishStateChanged: (oldState: AliRtcPublishState, newState: AliRtcPublishState, elapseSinceLastState: number) => void;
localDeviceException: (localDeviceType: AliRtcEngineLocalDeviceType, localDeviceExceptionType: AliRtcEngineLocalDeviceExceptionType, description: string) => void;
publishDataError: (error: AliRtcError) => void;
remoteAudioAutoPlayFail: (uid: string) => void;
remoteVideoAutoPlayFail: (uid: string, track: AliRtcVideoTrack) => void;
remoteAudioPlayError: (uid: string, reason?: string) => void;
remoteVideoPlayError: (uid: string, reason?: string) => void;
remoteSubscribeError: (error: AliRtcError) => void;
occurError: (error: AliRtcError) => void;
remoteDataChannelMessage: (uid: string, message: AliRtcDataChannelMsg) => void;
}
declare type ValidStatusMap = {
[ConnectionLatencyStage.CREATE_ENGINE]: ConnectionLatencyStatus.START | ConnectionLatencyStatus.END;
[ConnectionLatencyStage.JOIN]: ConnectionLatencyStatus.START | ConnectionLatencyStatus.SEND_SIG | ConnectionLatencyStatus.RECV_RST | ConnectionLatencyStatus.END;
[ConnectionLatencyStage.FIRST_REMOTE]: ConnectionLatencyStatus.RECEIVED | ConnectionLatencyStatus.DECODED | ConnectionLatencyStatus.PLAYED;
[ConnectionLatencyStage.RECV_NOTIFY_PUBLISH]: any;
[ConnectionLatencyStage.HANDLE_PUB_TASK]: ConnectionLatencyStatus.START | ConnectionLatencyStatus.END;
[ConnectionLatencyStage.HANDLE_SUB_TASK]: ConnectionLatencyStatus.START | ConnectionLatencyStatus.END;
};
declare type VideoProfileWithSendFramerate = Partial;
declare interface VideoScaler {
getVideoTrack: () => MediaStreamTrack;
updateOptions: (options: VideoScalerOptions) => void;
dispose: () => void;
}
declare class VideoScalerFactory {
static isSupport(): boolean;
/**
* 获取实例
* @param {MediaStreamTrack} videoTrack
* @param {IProfile} profile
* @return {VideoScaler}
*/
static getInstance(videoTrack: MediaStreamTrack, options: VideoScalerOptions): VideoScaler;
}
declare interface VideoScalerOptions {
width: number;
height: number;
frameRate: number;
}
declare enum VideoStreamSource {
Camera = 0,
Screen = 1,
Image = 2
}
declare const WrappedAliRtcEngine: typeof AliRtcEngine_2;
declare type WrappedAliRtcEngine = InstanceType;
export { WrappedAliRtcEngine as AliRtcEngine }
export default WrappedAliRtcEngine;
export { }
declare global {
interface Window {
AliRTS: any;
define: any;
mozRTCPeerConnection: any;
webkitAudioContext: any;
WeixinJSBridge: any;
}
interface RTCConfiguration {
googCpuOveruseDetection?: boolean;
}
interface RTCRtpParameters {
encodings: RTCRtpEncodingParameters[];
}
}