AgoraRtcEngine 回调
AgoraRtcEngine.on 用于向应用程序发送事件回调通知。
ACTIVE_SPEAKER
监测到最活跃用户回调。
on(evt: EngineEvents.ACTIVE_SPEAKER, cb: (uid: number) => void): this;
成功调用 enableAudioVolumeIndication 后,SDK 会持续监测音量最大的远端用户,并统计该用户被判断为音量最大者的次数。当前时间段内,该次数累积最多的远端用户为最活跃的用户。
- 如果最活跃用户一直是同一位用户,则 SDK 不会再次触发 ACTIVE_SPEAKER 回调。
- 如果最活跃用户有变化,则 SDK 会再次触发该回调并报告新的最活跃用户的 uid。
参数
- uid
- 远端最活跃用户的 ID。
API_CALL_EXECUTED
API 方法已执行回调。
on(evt: EngineEvents.API_CALL_EXECUTED, cb: ( api: string, err: number, result: string) => void ): this;
参数
- err
- 当方法调用失败时 SDK 返回的错误码。详细的错误信息及排查方法请参考错误码和警告码。如果该方法调用成功,SDK 会返回 0。
- api
- SDK 执行的 API 方法。
- result
- SDK 调用 API 的结果。
API_ERROR
发生错误回调(Electron 层)。
on(evt: EngineEvents.API_ERROR, cb: (apiType: ApiTypeEngine, msg: string) => void): this;
Agora SDK 运行过程中,当 Electron 层发生错误时,SDK 会触发该回调。
参数
- apiType
- 内部引擎。可忽略。
- msg
- 错误描述。典型出错原因为调用 API 时传入参数出错,如参数值不符合规范、参数个数不正确。
AUDIO_DEVICE_STATE_CHANGED
音频设备变化回调。
on(evt: EngineEvents.AUDIO_DEVICE_STATE_CHANGED, cb: ( deviceId: string, deviceType: number, deviceState: MEDIA_DEVICE_STATE_TYPE) => void ): this;
该方法提示系统音频设备状态发生改变,比如耳机被拔出。
参数
- deviceId
- 设备 ID。
- deviceType
- 设备类型定义。详见 MEDIA_DEVICE_TYPE。
- deviceState
- 设备状态定义。详见 MEDIA_DEVICE_STATE_TYPE。
AUDIO_DEVICE_VOLUME_CHANGED
回放、音频采集设备或 App 的音量发生改变。
on(evt: EngineEvents.AUDIO_DEVICE_VOLUME_CHANGED, cb: ( deviceType: MEDIA_DEVICE_TYPE, volume: number, muted: boolean) => void ): this;
参数
- deviceType
- 设备类型定义。详见 MEDIA_DEVICE_TYPE。
- volume
- 音量。范围为 [0,255]。
- muted
- 音频设备是否为静音状态:
true
: 音频设备已静音。false
: 音频设备未被静音。
AUDIO_EFFECT_FINISHED
本地音效文件播放已结束回调。
on(evt: EngineEvents.AUDIO_EFFECT_FINISHED, cb: (soundId: number) => void): this;
当播放音效结束后,会触发该回调。
参数
- soundId
- 指定音效的 ID。每个音效均有唯一的 ID。
AUDIO_MIXING_FINISHED
本地音乐文件播放已结束回调。
on(evt: EngineEvents.AUDIO_MIXING_FINISHED, cb: (soundId: number) => void): this;
- 弃用:
- 自 v2.4.0 起废弃,请改用 AUDIO_MIXING_STATE_CHANGED。
当调用 startAudioMixing 播放本地音乐文件结束后,会触发该回调。如果调用 startAudioMixing 失败,会在 ERROR 回调里,返回错误码 WARN_AUDIO_MIXING_OPEN_ERROR。
AUDIO_MIXING_STATE_CHANGED
音乐文件的播放状态已改变回调。
on( evt: EngineEvents.AUDIO_MIXING_STATE_CHANGED, cb: ( state: AUDIO_MIXING_STATE_TYPE, reason: AUDIO_MIXING_REASON_TYPE ) => void ): this;
该回调在音乐文件播放状态发生改变时触发,并报告当前的播放状态和错误码。
参数
- state
- 音乐文件播放状态,详见 AUDIO_MIXING_STATE_TYPE。
- reason
- 错误码,详见 AUDIO_MIXING_ERROR_TYPE。
AUDIO_PUBLISH_STATE_CHANGED
音频发布状态改变回调。
on(evt: EngineEvents.AUDIO_PUBLISH_STATE_CHANGED, cb: ( channel: string, oldState: STREAM_PUBLISH_STATE, newState: STREAM_PUBLISH_STATE, elapseSinceLastState: number ) => void): this;
- 自从
- v3.1.0
参数
- channel
- 频道名。
- oldState
- 之前的发布状态,详见 STREAM_PUBLISH_STATE。
- newState
- 当前的发布状态,详见 STREAM_PUBLISH_STATE。
- elapseSinceLastState
- 两次状态变化时间间隔(毫秒)。
AUDIO_SUBSCRIBE_STATE_CHANGED
音频订阅状态发生改变回调。
on(evt: EngineEvents.AUDIO_SUBSCRIBE_STATE_CHANGED, cb: ( channel: string, uid: number, oldState: STREAM_SUBSCRIBE_STATE, newState: STREAM_SUBSCRIBE_STATE, elapseSinceLastState: number ) => void): this;
- 自从
- v3.1.0
参数
- channel
- 频道名。
- uid
- 远端用户的 ID。
- oldState
- 之前的订阅状态,详见 STREAM_SUBSCRIBE_STATE。
- newState
- 当前的订阅状态,详见 STREAM_SUBSCRIBE_STATE。
- elapseSinceLastState
- 两次状态变化时间间隔(毫秒)。
AUDIO_VOLUME_INDICATION
用户音量提示回调。
on(evt: EngineEvents.AUDIO_VOLUME_INDICATION, cb: ( speakers: AudioVolumeInfo[], speakerNumber: number, totalVolume: number ) => void ): this;
该回调默认禁用,你可以通过 enableAudioVolumeIndication 开启。 开启后,只要频道内有发流用户,SDK 会在加入频道后按 enableAudioVolumeIndication 中设置的时间间隔触发 AUDIO_VOLUME_INDICATION 回调。每次会触发两个 AUDIO_VOLUME_INDICATION 回调,一个报告本地发流用户的音量相关信息,另一个报告 瞬时音量最高的远端用户(最多 3 位)的音量相关信息。
- 本地用户静音后,SDK 立即停止报告本地用户的音量提示回调。
- 瞬时音量最高的远端用户静音后 20 秒,远端的音量提示回调中将不再包含该用户;如果远端所有用户都将自己静音,20 秒后 SDK 停止报告远端用户的音量提示回调。
参数
- speakers
- 用户音量信息,详见 AudioVolumeInfo 数组。如果 speakers 为空,则表示远端用户不发流或没有远端用户。
- totalVolume
-
混音后的总音量,取值范围为 [0,255]。
- 在本地用户的回调中,totalVolume 为本地发流用户的音量。
- 在远端用户的回调中,totalVolume 为瞬时音量最高的远端用户(最多 3 位)混音后的总音量。 如果用户调用了 startAudioMixing,则 totalVolume 为音乐文件和用户声音的总音量。
CAMERA_EXPOSURE_AREA_CHANGED
摄像头曝光区域已改变回调。
on(evt: EngineEvents.CAMERA_EXPOSURE_AREA_CHANGED, cb: ( x: number, y: number, width: number, height: number) => void ): this;
参数
- x
- 发生改变的曝光区域的 x 坐标。
- y
- 发生改变的曝光区域的 y 坐标。
- width
- 发生改变的曝光区域的宽度。
- height
- 发生改变的曝光区域的高度。
CAMERA_FOCUS_AREA_CHANGED
相机对焦区域已改变回调。
on(evt: EngineEvents.CAMERA_FOCUS_AREA_CHANGED, cb: ( x: number, y: number, width: number, height: number) => void ): this;
参数
- x
- 发生改变的对焦区域的 x 坐标。
- y
- 发生改变的对焦区域的 y 坐标。
- width
- 发生改变的对焦区域的宽度。
- height
- 发生改变的对焦区域的高度。
CAMERA_READY
摄像头就绪回调。
on(evt: EngineEvents.CAMERA_READY, cb: () => void): this;
- 弃用:
-
该回调已废弃。请改用 LOCAL_VIDEO_STATE_CHANGED 中的 LOCAL_VIDEO_STREAM_STATE_CAPTURING(1)。
该回调提示已成功打开摄像头,可以开始捕获视频。
CHANNEL_MEDIA_RELAY_EVENT
跨频道媒体流转发事件回调。
on( evt: EngineEvents.CHANNEL_MEDIA_RELAY_EVENT, cb: (code: CHANNEL_MEDIA_RELAY_EVENT) => void ): this;
参数
- code
- 跨频道媒体流转发事件码。详见 CHANNEL_MEDIA_RELAY_EVENT 。
CHANNEL_MEDIA_RELAY_STATE
跨频道媒体流转发状态发生改变回调。
on(evt: EngineEvents.CHANNEL_MEDIA_RELAY_EVENT, cb: ( event: CHANNEL_MEDIA_RELAY_EVENT ) => void): this;
当跨频道媒体流转发状态发生改变时,SDK 会触发该回调,并报告当前的转发状态以及相关的错误信息。
参数
- state
- 跨频道媒体流转发状态。详见 CHANNEL_MEDIA_RELAY_STATE 。
- code
- 跨频道媒体流转发出错的错误码。详见 CHANNEL_MEDIA_RELAY_ERROR 。
CLIENT_ROLE_CHANGED
直播场景下用户角色已切换回调。
on(evt: EngineEvents.CLIENT_ROLE_CHANGED, cb: ( oldRole: CLIENT_ROLE_TYPE, newRole: CLIENT_ROLE_TYPE) => void ): this;
该回调是由本地用户在加入频道后调用 setClientRoleWithOptions 改变用户角色触发的。
参数
- oldRole
- 切换前的角色: CLIENT_ROLE_TYPE。
- newRole
- 切换后的角色: CLIENT_ROLE_TYPE。
CONNECTION_BANNED
网络连接已被服务器禁止回调。
on(evt: EngineEvents.CONNECTION_BANNED, cb: () => void): this;
- 弃用:
- 请改用 CONNECTION_STATE_CHANGED。
CONNECTION_INTERRUPTED
网络连接中断回调。
on(evt: EngineEvents.CONNECTION_INTERRUPTED, cb: () => void): this;
- 弃用:
- 请改用 CONNECTION_STATE_CHANGED 回调。
- CONNECTION_INTERRUPTED 回调一定是发生在成功加入频道后,且 SDK 刚失去和服务器连接超过 4 秒时触发。
- CONNECTION_LOST 回调是无论是否成功加入频道,只要 10 秒内和服务器无法建立连接都会触发。
CONNECTION_LOST
网络连接中断,且 SDK 无法在 10 秒内连接服务器回调。
on(evt: EngineEvents.CONNECTION_LOST, cb: () => void): this;
SDK 在调用 joinChannel 后,无论是否加入成功,只要 10 秒和服务器无法连接就会触发该回调。如果 SDK 在断开连接后,20 分钟内还是没能重新加入频道,SDK 会停止尝试重连。
CONNECTION_STATE_CHANGED
网络连接状态已改变回调。
on(evt: EngineEvents.CONNECTION_STATE_CHANGED, cb: ( state: CONNECTION_STATE_TYPE, reason: CONNECTION_CHANGED_REASON_TYPE ) => void): this;
- 自从
- v2.3.2
该回调在网络连接状态发生改变的时候触发,并告知用户当前的网络连接状态和引起网络状态改变的原因。
参数
- state
- 当前网络连接状态。详见 CONNECTION_STATE_TYPE。
- reason
- 引起当前网络连接状态改变的原因。详见 CONNECTION_CHANGED_REASON_TYPE。
ERROR
发生错误回调。
on(evt: EngineEvents.ERROR, cb: (err: number, msg: string) => void): this;
该回调方法表示 SDK 运行时出现了(网络或媒体相关的)错误。通常情况下,SDK 上报的错误意味着 SDK 无法自动恢复,需要 App 干预或提示用户。 比如启动通话失败时,SDK 会上报 ERR_START_CALL 错误。App 可以提示用户启动通话失败,并调用 leaveChannel 退出频道。
参数
- err
- 错误代码,详见 错误码和警告码。
- msg
- 错误描述。
FIRST_LOCAL_AUDIO_FRAME
已发送本地音频首帧回调。
on(evt: EngineEvents.FIRST_LOCAL_AUDIO_FRAME, cb: (elapsed: number) => void): this;
- 弃用:
- 该回调自 v3.1.0 废弃,请改用 FIRST_LOCAL_AUDIO_FRAME_PUBLISHED 回调。
参数
- elapsed
- 从调用 joinChannel 方法直至该回调被触发的时间。
FIRST_LOCAL_AUDIO_FRAME_PUBLISHED
已发布本地音频首帧回调。
on(evt: EngineEvents.FIRST_LOCAL_AUDIO_FRAME_PUBLISHED, cb: ( elapsed: number ) => void): this;
- 自从
- v3.1.0
- 开启本地音频的情况下,调用 joinChannel 成功加入频道后。
- 调用muteLocalAudioStream(
true
),再调用 muteLocalAudioStream(false
) 后。 - 调用 disableAudio,再调用 enableAudio 后。
参数
- elapsed
- 从调用 joinChannel 方法到触发该回调的时间间隔(毫秒)。
FIRST_LOCAL_VIDEO_FRAME
已显示本地视频首帧回调。
on(evt: EngineEvents.FIRST_LOCAL_VIDEO_FRAME, cb: ( width: number, height: number, elapsed: number) => void ): this;
本地视频首帧显示在本地视图上时,SDK 会触发此回调。
参数
- width
- 本地渲染视频的宽 (px) 。
- height
- 本地渲染视频的高 (px)。
- elapsed
- 从调用 joinChannel 到发生此事件过去的时间(毫秒)。如果在 joinChannel 前调用了 startPreview,则是从 startPreview 到发生此事件过去的时间。
FIRST_LOCAL_VIDEO_FRAME_PUBLISHED
已发布本地视频首帧回调。
on(evt: EngineEvents.FIRST_LOCAL_VIDEO_FRAME_PUBLISHED, cb: ( elapsed: number ) => void): this;
- 自从
- v3.1.0
- 开启本地视频的情况下,调用 joinChannel 成功加入频道后。
- 调用 muteLocalVideoStream(
true
),再调用 muteLocalVideoStream(false
) 后。 - 调用 disableVideo,再调用 enableVideo 后。
参数
- elapsed
- 从调用 joinChannel 方法到触发该回调的时间间隔(毫秒)。
FIRST_REMOTE_AUDIO_DECODED
已解码远端音频首帧的回调。
on(evt: EngineEvents.FIRST_REMOTE_AUDIO_DECODED, cb: ( uid: number, elapsed: number) => void ): this;
- 弃用:
- 该回调自 v3.0.0 起废弃。请改用 REMOTE_AUDIO_STATE_CHANGED 。
- 远端用户首次上线后发送音频。
- 远端用户音频离线再上线发送音频。音频离线指本地在 15 秒内没有收到音频包,可能有如下原因:
- 远端用户离开频道
- 远端用户掉线
- 远端用户调用 muteLocalAudioStream 方法停止发送音频流
- 远端用户调用 disableAudio 方法关闭音频
参数
- uid
- 远端用户 ID 。
- elapsed
- 从本地用户调用 joinChannel 直至该回调触发的延迟,单位为毫秒。
FIRST_REMOTE_AUDIO_FRAME
已接收远端音频首帧回调。
on(evt: EngineEvents.FIRST_REMOTE_AUDIO_FRAME, cb: ( uid: number, elapsed: number) => void ): this;
- 弃用:
- 从 v3.0.0,该回调已废弃。请改用 REMOTE_AUDIO_STATE_CHANGED 。
参数
- uid
- 发送音频帧的远端用户的用户 ID。
- elapsed
- 从调用 joinChannel 方法直至该回调被触发的时间。
FIRST_REMOTE_VIDEO_DECODED
已接收到远端视频并完成解码回调。
on(evt: EngineEvents.FIRST_REMOTE_VIDEO_DECODED, cb: ( uid: number, width: number, height: number, elapsed: number) => void ): this;
- 弃用:
- 自 v2.9.0 起废弃,请改用 REMOTE_VIDEO_STATE_CHANGED 回调中的:
- REMOTE_VIDEO_STATE_STARTING (1)。
- REMOTE_VIDEO_STATE_DECODING (2)。
- 远端用户首次上线后发送视频。
- 远端用户视频离线再上线后发送视频。出现这种中断的可能原因包括:
- 远端用户离开频道。
- 远端用户掉线。
- 远端用户调用 muteLocalVideoStream 方法停止发送本地视频流。
- 远端用户调用 disableVideo 方法关闭视频模块。
参数
- uid
- 用户 ID,指定是哪个用户的视频流。
- width
- 视频流宽(px)。
- height
- 视频流高(px)。
- elapsed
- 从本地调用 joinChannel 开始到该回调触发的延迟(毫秒)。
FIRST_REMOTE_VIDEO_FRAME
已显示首帧远端视频回调。
on(evt: EngineEvents.FIRST_REMOTE_VIDEO_FRAME, cb: ( uid: number, width: number, height: number, elapsed: number) => void ): this;
远端视频首帧显示在视图上时,触发此回调。 App 可在此回调中获知出图时间(elapsed)。
参数
- uid
- 用户 ID,指定是哪个用户的视频流。
- width
- 视频流宽(px)。
- height
- 视频流高(px)。
- elapsed
- 从本地调用 joinChannel 到发生此事件过去的时间(毫秒)。
JOINED_CHANNEL
成功加入频道回调。
on( evt: EngineEvents.JOINED_CHANNEL, cb: (channel: string, uid: number, elapsed: number) => void ): this;
该回调方法表示该客户端成功加入了指定的频道。
参数
- channel
- 频道名。
- uid
- 加入频道的用户 ID。
- elapsed
- 从本地调用 joinChannel 开始到发生此事件过去的时间(毫秒)。
LASTMILE_PROBE_RESULT
通话前网络上下行 Last mile 质量探测报告回调。
on(evt: EngineEvents.LASTMILE_PROBE_RESULT, cb: (result: LastmileProbeResult) => void): this;
- 自从
- v2.4.0
在调用 startLastmileProbeTest 之后,SDK 会在约 30 秒内返回该回调。
参数
- result
- 上下行 Last mile 质量探测结果。 详见: LastmileProbeResult。
LASTMILE_QUALITY
网络上下行 last mile 质量报告回调。
on(evt: EngineEvents.LASTMILE_QUALITY, cb: (quality: QUALITY_TYPE) => void): this;
该回调描述本地用户在加入频道前的 last mile 网络探测的结果,其中 last mile 是指设备到 Agora 边缘服务器的网络状态。
在调用 enableLastmileTest 之后,该回调函数每 2 秒触发一次。
参数
- quality
- Last mile 网络质量,详见 QUALITY_TYPE 。
LEAVE_CHANNEL
离开频道回调。
on(evt: EngineEvents.LEAVE_CHANNEL, cb: (stats: RtcStats) => void): this;
App 调用 leaveChannel 方法时,SDK 提示 app 离开频道成功。在该回调方法中,app 可以得到此次通话的总通话时长、SDK 收发数据的流量等信息。
参数
- stats
- 通话的统计数据: RtcStats。
LOCAL_AUDIO_STATE_CHANGED
本地音频状态发生改变回调。
on(evt: EngineEvents.LOCAL_AUDIO_STATE_CHANGED, cb: ( state: number, error: number ) => void): this;
- 自从
- v2.9.0
本地音频的状态发生改变时(包括本地麦克风采集状态和音频编码状态), SDK 会触发该回调报告当前的本地音频状态。在本地音频出现故障时,该回调可以帮助你了解当前音频的状态以及出现故障的原因,方便你排查问题。
参数
- state
- 当前的本地音频状态。详见 LOCAL_AUDIO_STREAM_STATE。
- error
- 本地音频出错原因。详见 LOCAL_AUDIO_STREAM_ERROR。
LOCAL_AUDIO_STATS
通话中本地音频流的统计信息回调。
on(evt: EngineEvents.LOCAL_AUDIO_STATS, cb: (stats: LocalAudioStats) => void): this;
SDK 每 2 秒触发该回调一次。
参数
- stats
- 本地音频统计数据。详见 LocalAudioStats。
LOCAL_PUBLISH_FALLBACK_TO_AUDIO_ONLY
本地发布流已回退为音频流回调。
on(evt: EngineEvents.LOCAL_PUBLISH_FALLBACK_TO_AUDIO_ONLY, cb: (isFallbackOrRecover: boolean) => void): this;
如果你调用了 setLocalPublishFallbackOption 接口并将 option 设置为 STREAM_FALLBACK_OPTION_AUDIO_ONLY ,当上行网络环境不理想、本地发布的媒体流回退为音频流时,或当上行网络改善、媒体流恢复为音视频流时,会触发该回调。
参数
- isFallbackOrRecover
-
true
: 由于网络环境不理想,本地发布的媒体流已回退为音频流;false
: 由于网络环境改善,发布的音频流已恢复为音视频流。
LOCAL_USER_REGISTERED
本地用户成功注册 User Account 回调。
on(evt: EngineEvents.LOCAL_USER_REGISTERED, cb: ( uid: number, userAccount: string) => void ): this;
- 自从
- v2.8.0
本地用户成功调用 registerLocalUserAccount 方法注册用户 User Account,或调用 joinChannelWithUserAccount 加入频道后,SDK 会触发该回调, 并告之本地用户的 UID 和 User Account。
参数
- uid
- 本地用户的 ID。
- userAccount
- 本地用户的 User Account。
LOCAL_VIDEO_STATE_CHANGED
本地视频状态发生改变回调。
on(evt: EngineEvents.LOCAL_VIDEO_STATE_CHANGED, cb: ( localVideoState: number, error: number ) => void): this;
- 自从
- v2.4.1
本地视频的状态发生改变时,SDK 会触发该回调返回当前的本地视频状态。你可以通过该回调了解当前视频的状态以及出现故障的原因,方便排查问题。
LOCAL_VIDEO_STREAM_STATE_FAILED
,错误码为 LOCAL_VIDEO_STREAM_ERROR_CAPTURE_FAILURE
: - 应用退到后台,系统回收摄像头。
- 摄像头正常启动,但连续 4 秒都没有输出采集的视频。
摄像头输出采集的视频帧时,如果连续 15 帧中,所有视频帧都一样,SDK 触发 LOCAL_VIDEO_STATE_CHANGED 回调,状态为 LOCAL_VIDEO_STREAM_STATE_CAPTURING
,错误码为 LOCAL_VIDEO_STREAM_ERROR_CAPTURE_FAILURE
。注意,帧重复检测仅针对分辨率大于 200 × 200、帧率大于等于 10 fps、码率小于 20 Kbps 的视频帧。
参数
- localVideoState
- 本地视频状态,详见 LOCAL_VIDEO_STREAM_STATE。
- error
- 本地视频出错原因,详见 LOCAL_VIDEO_STREAM_ERROR。
LOCAL_VIDEO_STATS
本地视频流统计信息回调。
on(evt: EngineEvents.LOCAL_VIDEO_STATS, cb: (stats: LocalVideoStats) => void): this;
该回调描述本地设备发送视频流的统计信息,每 2 秒触发一次。
参数
- stats
- 本地视频流统计信息。详见 LocalVideoStats。
MEDIA_ENGINE_START_CALL_SUCCESS
媒体引擎成功启动的回调。
on(evt: EngineEvents.MEDIA_ENGINE_START_CALL_SUCCESS, cb: () => void): this;
METADATA_RECEIVED
接收端已收到 Metadata。
on(evt: EngineEvents.RECEIVE_METADATA, cb: ( metadata: Metadata ) => void): this;
参数
- metadata
- 接收到的 Metadata。
MICROPHONE_ENABLED
麦克风状态已改变回调。
on(evt: EngineEvents.MICROPHONE_ENABLED, cb: (enabled: boolean) => void): this;
- 弃用:
-
自 v2.9.0 起废弃,请改用 LOCAL_AUDIO_STATE_CHANGED 回调的:
- LOCAL_AUDIO_STREAM_STATE_STOPPED(0)。
- LOCAL_AUDIO_STREAM_STATE_RECORDING(1)。
该回调是由本地用户调用 enableLocalAudio 方法开启或关闭本地音频采集触发的。
参数
- enabled
-
麦克风状态:
true
:麦克风已启用。false
:麦克风已禁用。
NETWORK_QUALITY
通话中每个用户的网络上下行 last mile 质量报告回调。
on(evt: EngineEvents.NETWORK_QUALITY, cb: ( uid: number, txquality: QUALITY_TYPE, rxquality: QUALITY_TYPE ) => void ): this;
该回调描述每个用户在通话中的 last mile 网络状态,其中 last mile 是指设备到 Agora 边缘服务器的网络状态。
该回调每 2 秒触发一次。如果远端有多个用户,该回调每 2 秒会被触发多次。
参数
- uid
- 用户 ID。表示该回调报告的是持有该 ID 的用户的网络质量。当 uid 为 0 时,返回的是本地用户的网络质量。
- txQuality
- 该用户的上行网络质量,基于发送码率、上行丢包率、平均往返时延和网络抖动计算。该值代表当前的上行网络质量,帮助判断是否可以支持当前设置的视频编码属性。假设上行码率是 1000 Kbps,那么支持直播场景下 640 × 480 的分辨率、15 fps 的帧率没有问题,但是支持 1280 × 720 的分辨率就会有困难。详见 QUALITY_TYPE。
- rxQuality
- 该用户的下行网络质量,基于下行网络的丢包率、平均往返延时和网络抖动计算。详见 QUALITY_TYPE。
NETWORK_TYPE_CHANGED
本地网络类型发生改变回调。
on(evt: EngineEvents.NETWORK_TYPE_CHANGED, cb: (type: NETWORK_TYPE) => void): this;
- 自从
- v2.4.1
本地网络连接类型发生改变时,SDK 会触发该回调,并在回调中明确当前的网络连接类型。 你可以通过该回调获取正在使用的网络类型;当连接中断时,该回调能辨别引起中断的原因是网络切换还是网络条件不好。
参数
- type
- 本地网络连接类型。详见 NETWORK_TYPE。
READY_TO_SEND_METADATA
发送端已准备好发送 Metadata。
on(evt: EngineEvents.READY_TO_SEND_METADATA, cb: (metadata: Metadata) => void): this;
当 SDK 准备好发送 Metadata 时,会触发该回调。
收到该回调后,你可以调用 sendMetadata 发送媒体附属信息。
参数
- metadata
- 用户想要发送的 Metadata。
REJOIN_CHANNEL_SUCCESS
成功重新加入频道回调。
on(evt: EngineEvents.REJOIN_CHANNEL_SUCCESS, cb: ( channel: string, uid: number, elapsed: number) => void ): this;
有时候由于网络原因,客户端可能会和服务器失去连接,SDK 会进行自动重连,自动重连成功后触发此回调方法。
参数
- channel
- 频道名。
- uid
- 重新加入频道的用户 ID。
- elapsed
- 从本地开始重连到发生此事件过去的时间(毫秒)。
REMOTE_AUDIO_MIXING_BEGIN
远端音乐文件播放已开始回调。
on(evt: EngineEvents.REMOTE_AUDIO_MIXING_BEGIN, cb: () => void): this;
当远端有用户调用 startAudioMixing 播放本地音乐文件,会触发该回调。
REMOTE_AUDIO_MIXING_END
远端音乐文件播放已结束回调。
on(evt: EngineEvents.REMOTE_AUDIO_MIXING_END, cb: () => void): this;
详细描述
当远端有用户播放本地音乐文件结束,会触发该回调。
REMOTE_AUDIO_STATE_CHANGED
远端音频流状态发生改变回调。
on(evt: EngineEvents.REMOTE_AUDIO_STATE_CHANGED, cb: ( uid: number, state: REMOTE_AUDIO_STATE, reason: REMOTE_AUDIO_STATE_REASON, elapsed: number ) => void): this;
- 自从
- v2.9.0
远端用户(通信场景)或主播(直播场景)的音频状态发生改变时,SDK 会触发该回调向本地用户报告当前的远端音频流状态。
参数
- uid
- 发生音频状态改变的远端用户 ID。
- state
- 远端音频流状态,详见 REMOTE_AUDIO_STATE。
- reason
- 远端音频流状态改变的具体原因,详见 REMOTE_AUDIO_STATE_REASON。
- elapsed
- 从本地用户调用 joinChannel 方法到发生本事件经历的时间,单位为毫秒。
REMOTE_AUDIO_STATS
通话中远端音频流的统计信息回调。
on(evt: EngineEvents.REMOTE_AUDIO_STATS, cb: (stats: RemoteAudioStats) => void): this;
该回调针对每个发送音频流的远端用户/主播每 2 秒触发一次。如果远端有多个用户/主播发送音频流,该回调每 2 秒会被触发多次。
参数
- stats
- 接收到的远端音频统计数据,详见 RemoteAudioStats。
REMOTE_AUDIO_TRANSPORT_STATS
通话中远端音频流传输的统计信息回调。
on(evt: EngineEvents.REMOTE_AUDIO_TRANSPORT_STATS, cb: ( uid: number, delay: number, lost: number, rxKBitRate: number) => void ): this;
- 弃用:
- 该回调已被废弃,请改用 REMOTE_AUDIO_STATS。
该回调描述远端用户通话中端到端的网络统计信息,通过音频包计算,用客观的数据,如丢包、 网络延迟等,展示当前网络状态。通话中,当用户收到远端用户/主播发送的音频数据包后 ,会每 2 秒触发一次该回调。
参数
- uid
- 用户 ID,指定是哪个用户/主播的音频包。
- delay
- 音频包从发送端到接收端的延时(毫秒)。
- lost
- 音频包从发送端到接收端的丢包率 (%)。
- rxKBitrate
- 远端音频包的接收码率(Kbps)。
REMOTE_SUBSCRIBE_FALLBACK_TO_AUDIO_ONLY
远端订阅流已回退为音频流回调。
on( evt: EngineEvents.REMOTE_SUBSCRIBE_FALLBACK_TO_AUDIO_ONLY, cb: (uid: number, isFallbackOrRecover: boolean) => void ): this;
如果你调用了 setRemoteSubscribeFallbackOption 接口并将 option 设置为 STREAM_FALLBACK_OPTION_AUDIO_ONLY,当下行网络环境不理想、仅接收远端音频流时,或当下行网络改善、恢复订阅音视频流时,会触发该回调。
参数
- uid
- 远端用户的用户 ID。
- isFallbackOrRecover
-
true
: 由于网络环境不理想,远端订阅流已回退为音频流;false
: 由于网络环境改善,订阅的音频流已恢复为音视频流。
REMOTE_VIDEO_STATE_CHANGED
远端视频状态发生改变回调。
on(evt: EngineEvents.REMOTE_VIDEO_STATE_CHANGED, cb: ( uid: number, state: REMOTE_VIDEO_STATE, reason: REMOTE_VIDEO_STATE_REASON, elapsed: number ) => void ): this;
- 自从
- v2.9.0
参数
- uid
- 发生视频状态改变的远端用户 ID。
- state
- 远端视频流状态,详见 REMOTE_VIDEO_STATE。
- reason
- 远端视频流状态改变的具体原因,详见 REMOTE_VIDEO_STATE_REASON。
- elapsed
- 从本地用户调用 joinChannel 方法到发生本事件经历的时间,单位为毫秒。
REMOTE_VIDEO_STATS
通话中远端视频流的统计信息回调。
on(evt: EngineEvents.REMOTE_VIDEO_STATS, cb: (stats: RemoteVideoStats) => void): this;
该回调描述远端用户在通话中端到端的视频流统计信息, 针对每个远端用户/主播每 2 秒触发一次。如果远端同时存在多个用户/主播, 该回调每 2 秒会被触发多次。
参数
- stats
- 远端视频统计数据。详见 RemoteVideoStats。
REMOTE_VIDEO_TRANSPORT_STATS
通话中远端视频流传输的统计信息回调。
on(evt: EngineEvents.REMOTE_VIDEO_TRANSPORT_STATS, cb: ( uid: number, delay: number, lost: number, rxKBitRate: number) => void ): this;
- 弃用:
- 该回调已被废弃,请改用 REMOTE_VIDEO_STATS。
该回调描述远端用户通话中端到端的网络统计信息,通过视频包计算,用客观的数据,如丢包、 网络延迟等,展示当前网络状态。
通话中,当用户收到远端用户/主播发送的视频数据包后,会每 2 秒触发一次该回调。
参数
- uid
- 用户 ID,指定是哪个用户/主播的视频包。
- delay
- 视频包从发送端到接收端的延时(毫秒)。
- lost
- 视频包从发送端到接收端的丢包率 (%)。
- rxKBitRate
- 远端视频包的接收码率(Kbps)。
REQUEST_TOKEN
Token 已过期回调。
on(evt: EngineEvents.REQUEST_TOKEN, cb: () => void): this;
在通话过程中如果 Token 已失效,SDK 会触发该回调,提醒 app 更新 Token。
当收到该回调时,你需要重新在服务端生成新的 Token,然后调用 joinChannel 重新加入频道。
RTC_STATS
当前通话统计信息回调。
on(evt: EngineEvents.RTC_STATS, cb: (stats: RtcStats) => void): this;
SDK 定期向 App 报告当前通话的统计信息,每两秒触发一次。
参数
- stats
-
RTC 引擎统计数据,详见 RtcStats 。
RTMP_STREAMING_EVENT
RTMP/RTMPS 推流事件回调。
on(evt: EngineEvents.RTMP_STREAMING_EVENT, cb: ( url: string, eventCode: RTMP_STREAMING_EVENT) => void ): this;
- 自从
- v3.1.0
参数
- url
- RTMP/RTMPS 推流 URL。
- eventCode
- RTMP/RTMPS 推流事件码。详见 RTMP_STREAMING_EVENT。
RTMP_STREAMING_STATE_CHANGED
RTMP/RTMPS 推流状态发生改变回调。
on( evt: EngineEvents.RTMP_STREAMING_STATE_CHANGED, cb: ( url: string, state: RTMP_STREAM_PUBLISH_STATE, errCode: RTMP_STREAM_PUBLISH_ERROR ) => void ): this;
该回调返回本地用户调用 addPublishStreamUrl 或 removePublishStreamUrl 方法的结果。 RTMP/RTMPS 推流状态发生改变时,SDK 会触发该回调,并在回调中明确状态发生改变的 URL 地址及当前推流状态。该回调方便推流用户了解当前的推流状态;推流出错时,你可以通过返回的错误码了解出错的原因,方便排查问题。
参数
- url
- 推流状态发生改变的 URL 地址。
- state
- 当前的推流状态,详见 RTMP_STREAM_PUBLISH_STATE 。当推流状态为 RTMP_STREAM_PUBLISH_STATE_FAILURE (4) 时,你可以在 errorCode 参数中查看返回的错误信息。
- errCode
- 推流错误信息,详见 RTMP_STREAM_PUBLISH_ERROR 。
STREAM_INJECT_STATUS
输入在线媒体流状态回调。
on(evt: EngineEvents.STREAM_INJECTED_STATUS, cb: ( url: string, uid: number, status: INJECT_STREAM_STATUS) => void ): this;
参数
- url
- 在线媒体流的地址。
- uid
- 用户 ID。
- status
- 输入的在线媒体流状态: INJECT_STREAM_STATUS 。
STREAM_MESSAGE
接收到对方数据流消息的回调。
on( evt: EngineEvents.STREAM_MESSAGE, cb: (uid: number, streamId: number, data: string) => void ): this;
该回调表示本地用户收到了远端用户调用 sendStreamMessage 方法发送的流消息。
参数
- uid
- 发送消息的用户 ID。
- streamId
- 接收到的消息的 Stream ID。
- data
- 接收到的数据。
STREAM_MESSAGE_ERROR
接收对方数据流消息发生错误的回调。
on( evt: EngineEvents.STREAM_MESSAGE, cb: (uid: number, streamId: number, data: string) => void ): this;
该回调表示本地用户未收到远端用户调用 sendStreamMessage 方法发送的流消息。
参数
- uid
- 发送消息的用户 ID。
- streamId
- 接收到的消息的 Stream ID。
- code
- 发生错误的错误码。详见错误码和警告码。
- missed
- 丢失的消息数量。
- cached
- 数据流中断时,后面缓存的消息数量。
STREAM_PUBLISHED
旁路推流已开启回调。
on(evt: EngineEvents.STREAM_PUBLISHED, cb: (url: string, error: number) => void): this;
- 弃用:
- v3.0.0
此方法已废弃,请改用 RTMP_STREAMING_STATE_CHANGED。
该回调用于通知主播推流状态。
参数
- url
- 主播推流的 URL 地址。
- error
-
推流错误码。
ERR_OK
(0): 推流成功。ERR_FAILED
(1): 推流失败。ERR_INVALID_ARGUMENT
(2): 参数错误。如果你在调用 addPublishStreamUrl 前没有调用 setLiveTranscoding 配置 LiveTranscoding ,SDK 会回调ERR_INVALID_ARGUMENT
。ERR_TIMEDOUT
(10): 推流超时未成功。ERR_ALREADY_IN_USE
(19): 推流地址已推流。ERR_ENCRYPTED_STREAM_NOT_ALLOWED_PUBLISH
(130): 推流已加密不能推流。ERR_PUBLISH_STREAM_CDN_ERROR
(151): CDN 相关错误。请调用 removePublishStreamUrl 方法删除原来的推流地址,然后调用 addPublishStreamUrl 方法重新推流到新地址。ERR_PUBLISH_STREAM_NUM_REACH_LIMIT
(152): 单个主播的推流地址数目达到上限 10。请删掉一些不用的推流地址再增加推流地址。ERR_PUBLISH_STREAM_NOT_AUTHORIZED
(153): 操作不属于主播自己的流,如更新其他主播的流参数、停止其他主播的流。请检查应用业务逻辑。ERR_PUBLISH_STREAM_INTERNAL_SERVER_ERROR
(154): 推流服务器出现错误。请调用 removePublishStreamUrl 重新推流。ERR_PUBLISH_STREAM_FORMAT_NOT_SUPPORTED
(156): 推流地址格式有错误。请检查推流地址格式是否正确。
STREAM_UNPUBLISHED
旁路推流已停止回调。
on(evt: EngineEvents.STREAM_UNPUBLISHED, cb: (url: string) => void): this;
- 弃用:
- v3.0.0
此方法已废弃,请改用 RTMP_STREAMING_STATE_CHANGED。
参数
- url
- 被删除的 RTMP/RTMPS 推流地址。
TOKEN_PRIVILEGE_WILL_EXPIRE
Token 服务将在30s内过期回调。
on(evt: EngineEvents.TOKEN_PRIVILEGE_WILL_EXPIRE, cb: (token: string) => void): this;
在通话过程中如果 Token 即将失效,SDK 会提前 30 秒触发该回调,提醒 app 更新 Token。
当收到该回调时,你需要重新在服务端生成新的 Token,然后调用 renewToken 将新生成的 Token 传给 SDK。
参数
- token
- 即将服务失效的 Token。
TRANSCODING_UPDATED
旁路推流转码设置已被更新回调。
on(evt: EngineEvents.TRANSCODING_UPDATED, cb: () => void): this;
setLiveTranscoding 方法中的直播参数 LiveTranscoding 更新时,TRANSCODING_UPDATED 回调会被触发并向主播报告更新信息。
USER_ENABLE_LOCAL_VIDEO
远端用户开/关本地视频采集回调。
on(evt: EngineEvents.USER_ENABLE_LOCAL_VIDEO, cb: ( uid: number, enabled: boolean) => void ): this;
该回调是由远端用户调用 enableLocalVideo 方法开启或关闭视频采集触发的。
参数
- uid
- 用户 ID,提示是哪个用户的视频流。
- enabled
- 远端用户是否启用视频采集:
true
: 该用户已启用视频功能。启用后,其他用户可以接收到该用户的视频流。false
: 该用户已关闭视频功能。关闭后,该用户仍然可以接收其他用户的视频流,但其他用户接收不到该用户的视频流。
USER_ENABLE_VIDEO
远端用户开/关视频模块回调。
on(evt: EngineEvents.USER_ENABLE_VIDEO, cb: (uid: number, enabled: boolean) => void): this;
关闭视频功能是指该用户只能进行语音通话,不能显示、发送自己的视频,也不能接收、显示别人的视频。
该回调是由远端用户调用 enableVideo 或 disableVideo 方法开启或关闭视频模块触发的。
参数
- uid
- 用户 ID,提示是哪个用户的视频流。
- enabled
-
true
: 该用户已启用视频功能。false
: 该用户已关闭视频功能。
USER_INFO_UPDATED
远端用户信息已更新回调。
on( evt: EngineEvents.USER_INFO_UPDATED, cb: (uid: number, userInfo: UserInfo) => void ): this;
- 自从
- v2.8.0
远端用户加入频道后, SDK 会获取到该远端用户的 UID 和 User Account,然后缓存一个包含了远端用户 UID 和 User Account 的 Mapping 表,并在本地触发该回调。
参数
- uid
- 远端用户 ID。
- userInfo
- 标识用户信息的 UserInfo 对象,包含用户 UID 和 User Account。详见 UserInfo 类。
USER_JOINED
远端用户(通信场景)/主播(直播场景)加入当前频道回调。
on(evt: EngineEvents.USER_JOINED, cb: (uid: number, elapsed: number) => void): this;
- 通信场景下,该回调提示有远端用户加入了频道。如果加入之前,已经有其他用户在频道中了,新加入的用户也会收到这些已有用户加入频道的回调。
- 直播场景下,该回调提示有主播加入了频道。如果加入之前,已经有主播在频道中了,新加入的用户也会收到已有主播加入频道的回调。Agora 建议连麦主播不超过 17 人。
- 远端用户/主播调用 joinChannel 方法加入频道。
- 远端用户加入频道后调用 setClientRoleWithOptions 将用户角色改变为主播。
- 远端用户/主播网络中断后重新加入频道。
- 主播通过调用 addInjectStreamUrl 方法成功输入在线媒体流。
参数
- uid
- 新加入频道的远端用户/主播 ID。
- elapsed
- 从本地用户调用 joinChannel 到该回调触发的延迟(毫秒)。
USER_MUTE_AUDIO
远端用户停止/恢复发送音频流回调。
on(evt: EngineEvents.USER_MUTE_AUDIO, cb: (uid: number, muted: boolean) => void): this;
该回调是由远端用户调用 muteLocalAudioStream 方法关闭或开启音频发送触发的。
参数
- uid
- 用户 ID。
- muted
- 该用户是否静音:
true
: 该用户已将音频静音;false
: 该用户取消了音频静音。
USER_MUTE_VIDEO
远端用户暂停/恢复发送视频流回调。
on(evt: EngineEvents.USER_MUTE_VIDEO, cb: (uid: number, muted: boolean) => void): this;
该回调是由远端用户调用 muteLocalVideoStream 方法关闭或开启视频发送触发的。
参数
- uid
- 远端用户 ID。
- muted
- 该用户是否暂停发送其视频流
true
: 该用户已暂停发送其视频流;false
: 该用户已恢复发送其视频流。
USER_OFFLINE
远端用户(通信场景)/主播(直播场景)离开当前频道回调。
on( evt: EngineEvents.USER_OFFLINE, cb: (uid: number, reason: USER_OFFLINE_REASON_TYPE) => void ): this;
- 正常离开:远端用户/主播会发送类似“再见”的消息。接收此消息后,判断用户离开频道。
- 超时掉线:在一定时间内(通信场景为 20 秒,直播场景稍有延时),用户没有收到对方的任何数据包,则判定为对方掉线。在网络较差的情况下,有可能会误报。我们建议使用 Agora 云信令 SDK 来做可靠的掉线检测。
参数
- uid
- 离线用户或主播的用户 ID。
- reason
- 离线原因: USER_OFFLINE_REASON_TYPE。
VIDEO_DEVICE_STATE_CHANGED
视频设备变化回调。
on(evt: EngineEvents.VIDEO_DEVICE_STATE_CHANGED, cb: ( deviceId: string, deviceType: number, deviceState: number) => void ): this;
该回调提示系统视频设备状态发生改变,比如被拔出或移除。如果设备已使用外接摄像头采集,外接摄像头被拔开后,视频会中断。
参数
- deviceId
- 设备 ID。
- deviceType
- 设备类型。详见 MEDIA_DEVICE_TYPE。
- deviceState
- 设备状态。详见 MEDIA_DEVICE_STATE_TYPE。
VIDEO_PUBLISH_STATE_CHANGED
视频发布状态改变回调。
on(evt: EngineEvents.VIDEO_PUBLISH_STATE_CHANGED, cb: ( channel: string, oldState: STREAM_PUBLISH_STATE, newState: STREAM_PUBLISH_STATE, elapseSinceLastState: number ) => void): this;
- 自从
- v3.1.0
参数
- channel
- 频道名。
- oldState
- 之前的发布状态,详见 STREAM_PUBLISH_STATE。
- newState
- 当前的发布状态,详见 STREAM_PUBLISH_STATE。
- elapseSinceLastState
- 两次状态变化时间间隔(毫秒)。
VIDEO_SIZE_CHANGED
本地或远端视频大小和旋转信息发生改变回调。
on( evt: EngineEvents.VIDEO_SIZE_CHANGED, cb: (uid: number, width: number, height: number, rotation: number) => void ): this;
参数
- uid
- 图像尺寸和旋转信息发生变化的用户的用户 ID(本地用户的 uid 为 0)。
- width
- 视频流的宽度(像素)。
- height
- 视频流的高度(像素)。
- rotation
- 旋转信息,取值范围 [0,360)。
VIDEO_STOPPED
视频功能已停止回调。
on(evt: EngineEvents.VIDEO_STOPPED, cb: () => void): this;
- 弃用:
- 从 v2.4.1 起废弃。请改用 LOCAL_VIDEO_STATE_CHANGED 回调中的 LOCAL_VIDEO_STREAM_STATE_STOPPED(0)。
App 如需在停止视频后对 view 做其他处理(比如显示其他画面),可以在这个回调中进行。
VIDEO_SUBSCRIBE_STATE_CHANGED
视频订阅状态发生改变回调。
on(evt: EngineEvents.VIDEO_SUBSCRIBE_STATE_CHANGED, cb: ( channel: string, uid: number, oldState: STREAM_SUBSCRIBE_STATE, newState: STREAM_SUBSCRIBE_STATE, elapseSinceLastState: number ) => void): this;
- 自从
- v3.1.0
参数
- channel
- 频道名。
- uid
- 远端用户的 ID。
- oldState
- 之前的订阅状态,详见 STREAM_SUBSCRIBE_STATE。
- newState
- 当前的订阅状态,详见 STREAM_SUBSCRIBE_STATE。
- elapseSinceLastState
- 两次状态变化时间间隔(毫秒)。
WARNING
发生警告回调。
on(evt: EngineEvents.WARNING, cb: (warn: number, msg: string) => void): this;
该回调方法表示 SDK 运行时出现了(网络或媒体相关的)警告。通常情况下,SDK 上报的警告信息 App 可以忽略,SDK 会自动恢复。比如和服务器失去连接时,SDK 可能会上报 WARN_OPEN_CHANNEL_TIMEOUT 警告,同时自动尝试重连。
参数
- warn
- 警告代码,详见错误码和警告码。
- msg
- 警告描述。
VIDEO_SOURCE_API_CALL_EXECUTED
API 方法已执行回调。
on( evt: VideoSourceEvents.VIDEO_SOURCE_API_CALL_EXECUTED, cb: (api: string, err: number, result: string) => void ): this;
双实例回调。
参数
- err
- 当方法调用失败时 SDK 返回的错误码。详细的错误信息及排查方法请参考错误码和警告码。如果该方法调用成功,SDK 会返回 0。
- api
- SDK 执行的 API 方法。
- result
- SDK 调用 API 的结果。
VIDEO_SOURCE_API_ERROR
发生错误回调(Electron 层)。
on( evt: VideoSourceEvents.VIDEO_SOURCE_API_ERROR, cb: (apiType: ApiTypeEngine, msg: string) => void ): this;
双实例回调。
Agora SDK 运行过程中,当 Electron 层发生错误时,SDK 会触发该回调。
参数
- apiType
- 内部引擎。可忽略。
- msg
- 错误描述。典型出错原因为调用 API 时传入参数出错,如参数值不符合规范、参数个数不正确。
VIDEO_SOURCE_AUDIO_DEVICE_STATE_CHANGED
音频设备变化回调。
on( evt: VideoSourceEvents.VIDEO_SOURCE_AUDIO_DEVICE_STATE_CHANGED, cb: (deviceId: string, deviceType: number, deviceState: MEDIA_DEVICE_STATE_TYPE) => void ): this;
双实例回调。
该方法提示系统音频设备状态发生改变,比如耳机被拔出。
参数
- deviceId
- 设备 ID。
- deviceType
- 设备类型定义。详见 MEDIA_DEVICE_TYPE。
- deviceState
- 设备状态定义。详见 MEDIA_DEVICE_STATE_TYPE。
VIDEO_SOURCE_AUDIO_PUBLISH_STATE_CHANGED
音频发布状态改变回调。
on( evt: VideoSourceEvents.VIDEO_SOURCE_AUDIO_PUBLISH_STATE_CHANGED, cb: ( channel: string, oldState: STREAM_PUBLISH_STATE, newState: STREAM_PUBLISH_STATE, elapseSinceLastState: number ) => void ): this;
双实例回调。
参数
- channel
- 频道名。
- oldState
- 之前的发布状态,详见 STREAM_PUBLISH_STATE。
- newState
- 当前的发布状态,详见 STREAM_PUBLISH_STATE。
- elapseSinceLastState
- 两次状态变化时间间隔(毫秒)。
VIDEO_SOURCE_AUDIO_SUBSCRIBE_STATE_CHANGED
音频订阅状态发生改变回调。
on( evt: VideoSourceEvents.VIDEO_SOURCE_AUDIO_SUBSCRIBE_STATE_CHANGED, cb: ( channel: string, uid: number, oldState: STREAM_SUBSCRIBE_STATE, newState: STREAM_SUBSCRIBE_STATE, elapseSinceLastState: number ) => void ): this;
双实例回调。
参数
- channel
- 频道名。
- uid
- 远端用户的 ID。
- oldState
- 之前的订阅状态,详见 STREAM_SUBSCRIBE_STATE。
- newState
- 当前的订阅状态,详见 STREAM_SUBSCRIBE_STATE。
- elapseSinceLastState
- 两次状态变化时间间隔(毫秒)。
VIDEO_SOURCE_CAMERA_READY
摄像头就绪回调。
on(evt: VideoSourceEvents.VIDEO_SOURCE_CAMERA_READY, cb: () => void): this;
- 弃用:
-
请改用 VIDEO_SOURCE_LOCAL_VIDEO_STATE_CHANGED 中的 LOCAL_VIDEO_STREAM_STATE_CAPTURING(1)。
双实例回调。
该回调提示已成功打开摄像头,可以开始捕获视频。
VIDEO_SOURCE_CONNECTION_BANNED
网络连接已被服务器禁止回调。
on(evt: VideoSourceEvents.VIDEO_SOURCE_CONNECTION_BANNED, cb: () => void): this;
VIDEO_SOURCE_CONNECTION_INTERRUPTED
网络连接中断回调。
on(evt: VideoSourceEvents.VIDEO_SOURCE_CONNECTION_INTERRUPTED, cb: () => void): this;
双实例回调。
- 弃用:
- 请改用 VIDEO_SOURCE_CONNECTION_STATE_CHANGED 回调。
- VIDEO_SOURCE_CONNECTION_INTERRUPTED 回调一定是发生在成功加入频道后,且 SDK 刚失去和服务器连接超过 4 秒时触发。
- VIDEO_SOURCE_CONNECTION_LOST 回调是无论是否成功加入频道,只要 10 秒内和服务器无法建立连接都会触发。
VIDEO_SOURCE_CONNECTION_LOST
网络连接中断,且 SDK 无法在 10 秒内连接服务器回调。
on(evt: VideoSourceEvents.VIDEO_SOURCE_CONNECTION_LOST, cb: () => void): this;
双实例回调。
SDK 在调用 videoSourceJoinChannel 后,无论是否加入成功,只要 10 秒和服务器无法连接就会触发该回调。如果 SDK 在断开连接后,20 分钟内还是没能重新加入频道,SDK 会停止尝试重连。
VIDEO_SOURCE_CONNECTION_STATE_CHANGED
网络连接状态已改变回调。
on( evt: VideoSourceEvents.VIDEO_SOURCE_CONNECTION_STATE_CHANGED, cb: ( state: CONNECTION_STATE_TYPE, reason: CONNECTION_CHANGED_REASON_TYPE ) => void ): this;
双实例回调。
该回调在网络连接状态发生改变的时候触发,并告知用户当前的网络连接状态和引起网络状态改变的原因。
参数
- state
- 当前网络连接状态。详见 CONNECTION_STATE_TYPE。
- reason
- 引起当前网络连接状态改变的原因。详见 CONNECTION_CHANGED_REASON_TYPE。
VIDEO_SOURCE_ERROR
发生错误回调( Native 层)。
on(evt: VideoSourceEvents.VIDEO_SOURCE_ERROR, cb: (err: number, msg: string) => void): this;
双实例回调。
该回调方法表示 SDK 运行时出现了(网络或媒体相关的)错误。通常情况下,SDK 上报的错误意味着 SDK 无法自动恢复,需要 App 干预或提示用户。 比如启动通话失败时,SDK 会上报 ERR_START_CALL 错误。App 可以提示用户启动通话失败,并调用 leaveChannel 退出频道。
参数
- err
- 错误代码,详见 错误码和警告码。
- msg
- 错误描述。
VIDEO_SOURCE_FIRST_LOCAL_VIDEO_FRAME
已显示本地视频首帧回调。
on( evt: VideoSourceEvents.VIDEO_SOURCE_FIRST_LOCAL_VIDEO_FRAME, cb: (width: number, height: number, elapsed: number) => void ): this;
双实例回调。
本地视频首帧显示在本地视图上时,SDK 会触发此回调。
参数
- width
- 本地渲染视频的宽 (px) 。
- height
- 本地渲染视频的高 (px)。
- elapsed
- 从调用 videoSourceJoinChannel 到发生此事件过去的时间(毫秒)。如果在 videoSourceJoinChannel 前调用了 videoSourceStartPreview,则是从 videoSourceStartPreview 到发生此事件过去的时间。
VIDEO_SOURCE_FIRST_REMOTE_AUDIO_FRAME
已接收远端音频首帧回调。
on( evt: VideoSourceEvents.VIDEO_SOURCE_FIRST_REMOTE_AUDIO_FRAME, cb: (uid: number, elapsed: number) => void ): this;
- 弃用:
- 请改用 VIDEO_SOURCE_REMOTE_AUDIO_STATE_CHANGED 。
参数
- uid
- 发送音频帧的远端用户的用户 ID。
- elapsed
- 从调用 videoSourceJoinChannel 方法直至该回调被触发的时间。
VIDEO_SOURCE_JOIN_CHANNEL_SUCCESS
成功加入频道回调。
on( evt: VideoSourceEvents.VIDEO_SOURCE_JOIN_CHANNEL_SUCCESS, cb: (channel: string, uid: number, elapsed: number) => void ): this;
双实例回调。
该回调方法表示该客户端成功加入了指定的频道。
参数
- channel
- 频道名。
- uid
- 加入频道的用户 ID。
- elapsed
- 从本地调用 videoSourceJoinChannel 开始到发生此事件过去的时间(毫秒)。
VIDEO_SOURCE_LOCAL_AUDIO_STATE_CHANGED
本地音频状态发生改变回调。
on( evt: VideoSourceEvents.VIDEO_SOURCE_LOCAL_AUDIO_STATE_CHANGED, cb: (state: number, error: number) => void ): this;
双实例回调。
本地音频的状态发生改变时(包括本地麦克风采集状态和音频编码状态), SDK 会触发该回调报告当前的本地音频状态。在本地音频出现故障时,该回调可以帮助你了解当前音频的状态以及出现故障的原因,方便你排查问题。
参数
- state
- 当前的本地音频状态。详见 LOCAL_AUDIO_STREAM_STATE。
- error
- 本地音频出错原因。详见 LOCAL_AUDIO_STREAM_ERROR。
VIDEO_SOURCE_LOCAL_AUDIO_STATS
通话中本地音频流的统计信息回调。
on( evt: VideoSourceEvents.VIDEO_SOURCE_LOCAL_AUDIO_STATS, cb: (stats: LocalAudioStats) => void ): this;
双实例回调。
SDK 每 2 秒触发该回调一次。
参数
- stats
- 本地音频统计数据。详见 LocalAudioStats。
VIDEO_SOURCE_LOCAL_VIDEO_STATE_CHANGED
本地视频状态发生改变回调。
on( evt: VideoSourceEvents.VIDEO_SOURCE_LOCAL_VIDEO_STATE_CHANGED, cb: (localVideoState: number, error: number) => void ): this;
双实例回调。
本地视频的状态发生改变时,SDK 会触发该回调返回当前的本地视频状态。你可以通过该回调了解当前视频的状态以及出现故障的原因,方便排查问题。
LOCAL_VIDEO_STREAM_STATE_FAILED
,错误码为 LOCAL_VIDEO_STREAM_ERROR_CAPTURE_FAILURE
: - 应用退到后台,系统回收摄像头。
- 摄像头正常启动,但连续 4 秒都没有输出采集的视频。
摄像头输出采集的视频帧时,如果连续 15 帧中,所有视频帧都一样,SDK 触发 VIDEO_SOURCE_LOCAL_VIDEO_STATE_CHANGED 回调,状态为 LOCAL_VIDEO_STREAM_STATE_CAPTURING
,错误码为 LOCAL_VIDEO_STREAM_ERROR_CAPTURE_FAILURE
。注意,帧重复检测仅针对分辨率大于 200 × 200、帧率大于等于 10 fps、码率小于 20 Kbps 的视频帧。
参数
- localVideoState
- 本地视频状态,详见 LOCAL_VIDEO_STREAM_STATE。
- error
- 本地视频出错原因,详见 LOCAL_VIDEO_STREAM_ERROR。
VIDEO_SOURCE_LOCAL_VIDEO_STATS
本地视频流统计信息回调。
on( evt: VideoSourceEvents.VIDEO_SOURCE_LOCAL_VIDEO_STATS, cb: (stats: LocalVideoStats) => void ): this;
双实例回调。
该回调描述本地设备发送视频流的统计信息,每 2 秒触发一次。
参数
- stats
- 本地视频流统计信息。详见 LocalVideoStats。
VIDEO_SOURCE_MEDIA_ENGINE_START_CALL_SUCCESS
媒体引擎成功启动的回调。
on(evt: VideoSourceEvents.VIDEO_SOURCE_MEDIA_ENGINE_START_CALL_SUCCESS, cb: () => void): this;
VIDEO_SOURCE_NETWORK_QUALITY
通话中每个用户的网络上下行 last mile 质量报告回调。
on( evt: VideoSourceEvents.VIDEO_SOURCE_NETWORK_QUALITY, cb: (uid: number, txquality: QUALITY_TYPE, rxquality: QUALITY_TYPE) => void ): this;
双实例回调。
该回调描述每个用户在通话中的 last mile 网络状态,其中 last mile 是指设备到 Agora 边缘服务器的网络状态。
该回调每 2 秒触发一次。如果远端有多个用户,该回调每 2 秒会被触发多次。
参数
- uid
- 用户 ID。表示该回调报告的是持有该 ID 的用户的网络质量。当 uid 为 0 时,返回的是本地用户的网络质量。
- txQuality
- 该用户的上行网络质量,基于发送码率、上行丢包率、平均往返时延和网络抖动计算。该值代表当前的上行网络质量,帮助判断是否可以支持当前设置的视频编码属性。假设上行码率是 1000 Kbps,那么支持直播场景下 640 × 480 的分辨率、15 fps 的帧率没有问题,但是支持 1280 × 720 的分辨率就会有困难。详见 QUALITY_TYPE。
- rxQuality
- 该用户的下行网络质量,基于下行网络的丢包率、平均往返延时和网络抖动计算。详见 QUALITY_TYPE。
VIDEO_SOURCE_NETWORK_TYPE_CHANGED
本地网络类型发生改变回调。
on( evt: VideoSourceEvents.VIDEO_SOURCE_NETWORK_TYPE_CHANGED, cb: (type: NETWORK_TYPE) => void ): this;
双实例回调。
本地网络连接类型发生改变时,SDK 会触发该回调,并在回调中明确当前的网络连接类型。 你可以通过该回调获取正在使用的网络类型;当连接中断时,该回调能辨别引起中断的原因是网络切换还是网络条件不好。
参数
- type
- 本地网络连接类型。详见 NETWORK_TYPE。
返回值
VIDEO_SOURCE_LEAVE_CHANNEL
离开频道回调。
on(evt: VideoSourceEvents.VIDEO_SOURCE_LEAVE_CHANNEL, cb: (stats: RtcStats) => void): this;
双实例回调。
App 调用 videoSourceLeaveChannel 方法时,SDK 提示 app 离开频道成功。在该回调方法中,app 可以得到此次通话的总通话时长、SDK 收发数据的流量等信息。
参数
- stats
- 通话的统计数据: RtcStats。
VIDEO_SOURCE_REJOIN_CHANNEL_SUCCESS
成功重新加入频道回调。
on( evt: VideoSourceEvents.VIDEO_SOURCE_REJOIN_CHANNEL_SUCCESS, cb: (channel: string, uid: number, elapsed: number) => void ): this;
双实例回调。
有时候由于网络原因,客户端可能会和服务器失去连接,SDK 会进行自动重连,自动重连成功后触发此回调方法。
参数
- channel
- 频道名。
- uid
- 重新加入频道的用户 ID。
- elapsed
- 从本地开始重连到发生此事件过去的时间(毫秒)。
VIDEO_SOURCE_REMOTE_AUDIO_STATE_CHANGED
远端音频流状态发生改变回调。
on( evt: VideoSourceEvents.VIDEO_SOURCE_REMOTE_AUDIO_STATE_CHANGED, cb: ( uid: number, state: REMOTE_AUDIO_STATE, reason: REMOTE_AUDIO_STATE_REASON, elapsed: number ) => void ): this;
双实例回调。
远端用户(通信场景)或主播(直播场景)的音频状态发生改变时,SDK 会触发该回调向本地用户报告当前的远端音频流状态。
参数
- uid
- 发生音频状态改变的远端用户 ID。
- state
- 远端音频流状态,详见 REMOTE_AUDIO_STATE。
- reason
- 远端音频流状态改变的具体原因,详见 REMOTE_AUDIO_STATE_REASON。
- elapsed
- 从本地用户调用 videoSourceJoinChannel 方法到发生本事件经历的时间,单位为毫秒。
VIDEO_SOURCE_REMOTE_AUDIO_STATS
远端用户的音频统计数据。
on( evt: VideoSourceEvents.VIDEO_SOURCE_REMOTE_AUDIO_STATS, cb: (stats: RemoteAudioStats) => void ): this;
双实例回调。
该回调针对每个发送音频流的远端用户/主播每 2 秒触发一次。如果远端有多个用户/主播发送音频流,该回调每 2 秒会被触发多次。
参数
- stats
- 接收到的远端音频统计数据,详见 RemoteAudioStats。
VIDEO_SOURCE_REMOTE_AUDIO_TRANSPORT_STATS
通话中远端音频流传输的统计信息回调。
on( evt: VideoSourceEvents.VIDEO_SOURCE_REMOTE_AUDIO_TRANSPORT_STATS, cb: (uid: number, delay: number, lost: number, rxKBitRate: number) => void ): this;
- 弃用:
- 请改用 VIDEO_SOURCE_REMOTE_AUDIO_STATS。
双实例回调。
该回调描述远端用户通话中端到端的网络统计信息,通过音频包计算,用客观的数据,如丢包、 网络延迟等,展示当前网络状态。通话中,当用户收到远端用户/主播发送的音频数据包后 ,会每 2 秒触发一次该回调。
参数
- uid
- 用户 ID,指定是哪个用户/主播的音频包。
- delay
- 音频包从发送端到接收端的延时(毫秒)。
- lost
- 音频包从发送端到接收端的丢包率 (%)。
- rxKBitrate
- 远端音频包的接收码率(Kbps)。
VIDEO_SOURCE_REMOTE_VIDEO_STATE_CHANGED
远端视频状态发生改变回调。
on( evt: VideoSourceEvents.VIDEO_SOURCE_REMOTE_VIDEO_STATE_CHANGED, cb: ( uid: number, state: REMOTE_VIDEO_STATE, reason: REMOTE_VIDEO_STATE_REASON, elapsed: number ) => void ): this;
双实例回调。
参数
- uid
- 发生视频状态改变的远端用户 ID。
- state
- 远端视频流状态,详见 REMOTE_VIDEO_STATE。
- reason
- 远端视频流状态改变的具体原因,详见 REMOTE_VIDEO_STATE_REASON。
- elapsed
- 从本地用户调用 videoSourceJoinChannel 方法到发生本事件经历的时间,单位为毫秒。
VIDEO_SOURCE_REMOTE_VIDEO_STATS
通话中远端视频流的统计信息回调。
on( evt: VideoSourceEvents.VIDEO_SOURCE_REMOTE_VIDEO_STATS, cb: (stats: RemoteVideoStats) => void ): this;
双实例回调。
该回调描述远端用户在通话中端到端的视频流统计信息, 针对每个远端用户/主播每 2 秒触发一次。如果远端同时存在多个用户/主播, 该回调每 2 秒会被触发多次。
参数
- stats
- 远端视频统计数据。详见 RemoteVideoStats。
VIDEO_SOURCE_REMOTE_VIDEO_TRANSPORT_STATS
通话中远端视频流传输的统计信息回调。
on( evt: VideoSourceEvents.VIDEO_SOURCE_REMOTE_VIDEO_TRANSPORT_STATS, cb: (uid: number, delay: number, lost: number, rxKBitRate: number) => void ): this;
- 弃用:
- 请改用 VIDEO_SOURCE_REMOTE_VIDEO_STATS。
双实例回调。
该回调描述远端用户通话中端到端的网络统计信息,通过视频包计算,用客观的数据,如丢包、 网络延迟等,展示当前网络状态。
通话中,当用户收到远端用户/主播发送的视频数据包后,会每 2 秒触发一次该回调。
参数
- uid
- 用户 ID,指定是哪个用户/主播的视频包。
- delay
- 视频包从发送端到接收端的延时(毫秒)。
- lost
- 视频包从发送端到接收端的丢包率 (%)。
- rxKBitRate
- 远端视频包的接收码率(Kbps)。
VIDEO_SOURCE_REQUEST_TOKEN
Token 已过期回调。
on(evt: VideoSourceEvents.VIDEO_SOURCE_REQUEST_TOKEN, cb: () => void): this;
双实例回调。
在通话过程中如果 Token 已失效,SDK 会触发该回调,提醒 app 更新 Token。
当收到该回调时,你需要重新在服务端生成新的 Token,然后调用 videoSourceJoinChannel 重新加入频道。
VIDEO_SOURCE_RTC_STATS
当前通话统计信息回调。
on(evt: VideoSourceEvents.VIDEO_SOURCE_RTC_STATS, cb: (stats: RtcStats) => void): this;
双实例回调。
SDK 定期向 App 报告当前通话的统计信息,每两秒触发一次。
参数
- stats
-
RTC 引擎统计数据,详见 RtcStats 。
VIDEO_SOURCE_TOKEN_PRIVILEGE_WILL_EXPIRE
Token 服务将在30s内过期回调。
on( evt: VideoSourceEvents.VIDEO_SOURCE_TOKEN_PRIVILEGE_WILL_EXPIRE, cb: (token: string) => void ): this;
双实例回调。
在通话过程中如果 Token 即将失效,SDK 会提前 30 秒触发该回调,提醒 app 更新 Token。
当收到该回调时,你需要重新在服务端生成新的 Token,然后调用 videoSourceRenewToken 将新生成的 Token 传给 SDK。
参数
- token
- 即将服务失效的 Token。
VIDEO_SOURCE_USER_ENABLE_LOCAL_VIDEO
远端用户开/关本地视频采集回调。
on( evt: VideoSourceEvents.VIDEO_SOURCE_USER_ENABLE_LOCAL_VIDEO, cb: (uid: number, enabled: boolean) => void ): this;
双实例回调。
该回调是由远端用户调用 enableLocalVideo 方法开启或关闭视频采集触发的。
参数
- uid
- 用户 ID,提示是哪个用户的视频流。
- enabled
- 远端用户是否启用视频采集:
true
: 该用户已启用视频功能。启用后,其他用户可以接收到该用户的视频流。false
: 该用户已关闭视频功能。关闭后,该用户仍然可以接收其他用户的视频流,但其他用户接收不到该用户的视频流。
VIDEO_SOURCE_USER_ENABLE_VIDEO
远端用户开/关视频模块回调。
on( evt: VideoSourceEvents.VIDEO_SOURCE_USER_ENABLE_VIDEO, cb: (uid: number, enabled: boolean) => void ): this;
双实例回调。
关闭视频功能是指该用户只能进行语音通话,不能显示、发送自己的视频,也不能接收、显示别人的视频。
该回调是由远端用户调用 videoSourceEnableVideo 或 videoSourceDisableVideo 方法开启或关闭视频模块触发的。
参数
- uid
- 用户 ID,提示是哪个用户的视频流。
- enabled
-
true
: 该用户已启用视频功能。false
: 该用户已关闭视频功能。
VIDEO_SOURCE_USER_OFFLINE
远端用户(通信场景)/主播(直播场景)离开当前频道回调。
on( evt: VideoSourceEvents.VIDEO_SOURCE_USER_OFFLINE, cb: (uid: number, reason: USER_OFFLINE_REASON_TYPE) => void ): this;
双实例回调。
- 正常离开:远端用户/主播会发送类似“再见”的消息。接收此消息后,判断用户离开频道。
- 超时掉线:在一定时间内(通信场景为 20 秒,直播场景稍有延时),用户没有收到对方的任何数据包,则判定为对方掉线。在网络较差的情况下,有可能会误报。我们建议使用 Agora 云信令 SDK 来做可靠的掉线检测。
参数
- uid
- 离线用户或主播的用户 ID。
- reason
- 离线原因: USER_OFFLINE_REASON_TYPE。
VIDEO_SOURCE_VIDEO_DEVICE_STATE_CHANGED
视频设备变化回调。
on( evt: VideoSourceEvents.VIDEO_SOURCE_VIDEO_DEVICE_STATE_CHANGED, cb: (deviceId: string, deviceType: number, deviceState: number) => void ): this;
双实例回调。
该回调提示系统视频设备状态发生改变,比如被拔出或移除。如果设备已使用外接摄像头采集,外接摄像头被拔开后,视频会中断。
参数
- deviceId
- 设备 ID。
- deviceType
- 设备类型。详见 MEDIA_DEVICE_TYPE。
- deviceState
- 设备状态。详见 MEDIA_DEVICE_STATE_TYPE。
VIDEO_SOURCE_VIDEO_PUBLISH_STATE_CHANGED
视频发布状态改变回调。
on( evt: VideoSourceEvents.VIDEO_SOURCE_VIDEO_PUBLISH_STATE_CHANGED, cb: ( channel: string, oldState: STREAM_PUBLISH_STATE, newState: STREAM_PUBLISH_STATE, elapseSinceLastState: number ) => void ): this;
双实例回调。
参数
- channel
- 频道名。
- oldState
- 之前的发布状态,详见 STREAM_PUBLISH_STATE。
- newState
- 当前的发布状态,详见 STREAM_PUBLISH_STATE。
- elapseSinceLastState
- 两次状态变化时间间隔(毫秒)。
VIDEO_SOURCE_VIDEO_SIZE_CHANGED
本地或远端视频大小和旋转信息发生改变回调。
on( evt: VideoSourceEvents.VIDEO_SOURCE_VIDEO_SIZE_CHANGED, cb: (uid: number, width: number, height: number, rotation: number) => void ): this;
双实例回调。
参数
- uid
- 图像尺寸和旋转信息发生变化的用户的用户 ID(本地用户的 uid 为 0)。
- width
- 视频流的宽度(像素)。
- height
- 视频流的高度(像素)。
- rotation
- 旋转信息,取值范围 [0,360)。
VIDEO_SOURCE_VIDEO_STOPPED
视频功能已停止回调。
on(evt: VideoSourceEvents.VIDEO_SOURCE_VIDEO_STOPPED, cb: () => void): this;
- 弃用:
- 请改用 VIDEO_SOURCE_LOCAL_VIDEO_STATE_CHANGED 回调中的 LOCAL_VIDEO_STREAM_STATE_STOPPED(0)。
双实例回调。
App 如需在停止视频后对 view 做其他处理(比如显示其他画面),可以在这个回调中进行。
VIDEO_SOURCE_VIDEO_SUBSCRIBE_STATE_CHANGED
视频订阅状态发生改变回调。
on( evt: VideoSourceEvents.VIDEO_SOURCE_VIDEO_SUBSCRIBE_STATE_CHANGED, cb: ( channel: string, uid: number, oldState: STREAM_SUBSCRIBE_STATE, newState: STREAM_SUBSCRIBE_STATE, elapseSinceLastState: number ) => void ): this;
双实例回调。
参数
- channel
- 频道名。
- uid
- 远端用户的 ID。
- oldState
- 之前的订阅状态,详见 STREAM_SUBSCRIBE_STATE。
- newState
- 当前的订阅状态,详见 STREAM_SUBSCRIBE_STATE。
- elapseSinceLastState
- 两次状态变化时间间隔(毫秒)。
VIDEO_SOURCE_WARNING
发生警告回调。
on(evt: VideoSourceEvents.VIDEO_SOURCE_WARNING, cb: (warn: number, msg: string) => void): this;
双实例回调。
该回调方法表示 SDK 运行时出现了(网络或媒体相关的)警告。通常情况下,SDK 上报的警告信息 App 可以忽略,SDK 会自动恢复。比如和服务器失去连接时,SDK 可能会上报 WARN_OPEN_CHANNEL_TIMEOUT 警告,同时自动尝试重连。
参数
- warn
- 警告代码,详见错误码和警告码。
- msg
- 警告描述。