事件回调
本章节介绍了Windows SDK的回调接口IHRTCEngineEventHandler的详情。
接口 |
描述 |
---|---|
析构函数。 |
|
错误回调。 |
|
成功加入房间回调。 |
|
加入房间失败回调。 |
|
离开房间回调。 |
|
远端用户加入当前房间回调。 |
|
远端用户离开当前房间回调。 |
|
引擎收到第一帧远端视频流并解码成功回调。 |
|
网络连接状态发生变化回调。 |
|
设备状态发生变化回调。 |
|
音频设备音量发生变化回调。 |
|
日志上传结果回调。 |
|
日志上传进度回调。 |
|
用户角色切换成功回调。 |
|
共享流开启回调。 |
|
共享流关闭回调。 |
|
远端开启/停止共享流回调。 |
|
视频流详情,2s触发一次回调。 |
|
音频流详情,2s触发一次回调。 |
|
共享流详情,2s触发一次回调。 |
|
鉴权签名过期回调。 |
|
开启跨房回调。 |
|
结束跨房回调。 |
|
远端音频流状态变化回调。 |
|
远端视频流状态变化回调。 |
|
共享流自渲染回调。 |
|
视频自渲染回调。 |
|
音频自渲染回调。 |
|
重新加入房间回调。 |
|
播放音频文件回调。 |
|
停止播放音频文件回调。 |
|
暂停播放音频文件回调。 |
|
恢复播放音频文件回调。 |
|
网络探测信号质量回调。 |
|
网络探测详细结果回调。 |
|
音频订阅状态回调。 |
onError
virtual void onError(int error, const char* msg)
【功能说明】
发生错误,触发此回调。返回客户端错误码或者服务端错误码。
【回调参数】
- error:错误码,具体请参见HRTCErrorCode。
- msg:错误描述。
onJoinRoomSuccess
virtual void onJoinRoomSuccess(const char* roomId, const char* userId)
【功能说明】
成功加入房间,触发此回调。
【回调参数】
- roomId:新加入的房间ID。
- userId:新加入房间的用户ID。
onJoinRoomFailure
virtual void onJoinRoomFailure(int error, const char* msg)
【功能说明】
加入房间失败,触发此回调。
【回调参数】
- error:错误码,具体请参见HRTCErrorCode。
- msg:错误描述。
onLeaveRoom
virtual void onLeaveRoom(HRTCLeaveReason reason, const HRTCStatsInfo &statsInfo)
【功能说明】
离开房间,触发此回调。

- APP在调用leaveRoom接口时退到登录界面,或者在收到onLeaveRoom回调,且回调消息不等于HRTC_LEAVE_REASON_USER_LEAVE_ROOM时(防止重复操作)退到登录界面。
- APP只在收到onLeaveRoom消息时退到登录界面。
【回调参数】
- reason:离开的房间原因,具体请参见HRTCLeaveReason。
- statsInfo:卡顿统计信息,具体请参见HRTCStatsInfo。
onUserJoined
virtual void onUserJoined(const char* roomId, const char* userId, const char* userName)
【功能说明】
远端用户加入当前房间,触发此回调。该回调提示有远端用户加入了房间,并返回新加入用户的ID。
【回调参数】
- roomId:新加入房间ID。
- userId:新加入房间的远端用户ID。
- userName:新加入房间的远端用户昵称。
onUserOffline
virtual void onUserOffline(const char* roomId, const char* userId, int reason)
【功能说明】
远端用户离开当前房间,触发此回调。
- roomId:远端用户离开的房间ID。
- userId:离开房间的远端用户ID。
- reason:远端用户离线原因,预留参数。
onFirstRemoteVideoDecoded
virtual void onFirstRemoteVideoDecoded(const char* roomId, const char* userId, int width, int height)
【功能说明】
接收到第一帧远端视频流并解码成功,触发此回调。
【回调参数】
- roomId:视频流对应的房间ID。
- userId:视频流对应的用户ID。
- width:视频流宽。
- height:视频流高。
onConnectStateChange
virtual void onConnectStateChange(HRTCConnStateTypes connType, HRTCConnChangeReason reason, const char* description)
【功能说明】
网络连接状态发生变化,触发此回调。
【回调参数】
- connType:网络连接状态。具体请参见HRTCConnStateTypes。
- reason:网络连接状态发生变化原因。具体请参见HRTCConnChangeReason。
- description:错误原因描述。
onDeviceStateChanged
virtual void onDeviceStateChanged(const char* deviceId, HRTCDeviceType deviceType, HRTCDeviceState deviceState)
【功能说明】
设备状态发生变化,触发此回调。
【回调参数】
- deviceId:系统设备标识,如系统音频播放设备标识可通过getPlaybackDevices获取。
- deviceType:系统设备类型,具体请参见HRTCDeviceType。
- deviceState:系统设备状态,具体请参见HRTCDeviceState。
【注意事项】
通话前插拔设备会上报变化。
onDeviceVolumeChanged
virtual void onDeviceVolumeChanged(HRTCDeviceType deviceType, unsigned int volume, unsigned int muted)
【功能说明】
音频设备音量发生变化,触发此回调。
【回调参数】
- deviceType:系统设备类型,具体请参见HRTCDeviceType。
- volume:音量
- muted:true表示设备静音,false表示设备未静音
【注意事项】
通话前调整音频设备音量和静音会上报变化。
onLogUploadResult
virtual void onLogUploadResult(int result)
【功能说明】
日志上传结果回调。
【回调参数】
result:日志上传结果。
- 0:上传成功
- >0:上传失败
onLogUploadProgress
virtual void onLogUploadProgress(int progress)
【功能说明】
日志上传进度回调。
【回调参数】
progress:日志上传进度。取值范围为[0,100]。
onAgreedStreamAvailable
virtual void onAgreedStreamAvailable(const char* roomId, const char* userId, HRTCStreamType streamType)
【功能说明】
加入房间默认收到的视频流,用于首帧画面快速展示。
【回调参数】
- roomId:新加入房间ID。
- userId:新加入房间的远端用户ID。
- streamType:视频分辨率。具体请参见HRTCStreamType。
onUserRoleChanged
virtual void onUserRoleChanged(const char* roomId, HRTCRoleType oldRole, HRTCRoleType newRole)
【功能说明】
用户角色切换成功,触发此回调。
【回调参数】
- roomId:发生角色切换的房间号。
- oldRole:切换前的角色。具体请参见HRTCRoleType。
- newRole:切换成功后的角色。具体请参见HRTCRoleType。
onScreenCaptureStoped
virtual void onScreenCaptureStoped(int reason)
【功能说明】
屏幕流共享关闭,触发此回调。
【回调参数】
reason:屏幕共享关闭原因。
【注意事项】
reason:预留参数。
onUserSubStreamAvailable
virtual void onUserSubStreamAvailable(const char* roomId, const char* userId, bool available)
【功能说明】
远端开启,停止共享流后,触发此回调。
【回调参数】
- roomId:新加入房间ID。
- userId:新加入房间的远端用户ID。
- available:true表示远端开启屏幕共享,false表示远端停止屏幕共享。
onVideoStats
virtual void onVideoStats(HRTCLocalVideoStats *localStats, unsigned int localStatsCount, HRTCRemoteVideoStats *remoteStats, unsigned int remoteStatsCount)
【功能说明】
视频流详情,2s触发一次回调。
- localStats:本地视频发流详情,具体请参见HRTCLocalVideoStats。
- localStatsCount:本地视频发流数量。
- remoteStats:远端视频收流详情,具体请参见HRTCRemoteVideoStats。
- remoteStatsCount:远端视频收流数量。
onAudioStats
virtual void onAudioStats(HRTCLocalAudioStats *localStats, unsigned int localStatsCount, HRTCRemoteAudioStats *remoteStats, unsigned int remoteStatsCount)
【功能说明】
音频流详情,2s触发一次回调。
【回调参数】
- localStats:本地音频发流详情,具体请参见HRTCLocalAudioStats。
- localStatsCount:本地音频发流数量。
- remoteStats:远端音频收流详情,具体请参见HRTCRemoteAudioStats。
- remoteStatsCount:远端音频收流数量。
onSubStreamStats
virtual void onSubStreamStats(HRTCLocalVideoStats *localStats, unsigned int localStatsCount, HRTCRemoteVideoStats *remoteStats, unsigned int remoteStatsCount)
【功能说明】
共享流详情,2s触发一次回调。
【回调参数】
- localStats:本地共享流发流详情,具体请参见HRTCLocalVideoStats。
- localStatsCount:本地共享流发流数量。
- remoteStats:远端共享流收流详情,具体请参见HRTCRemoteVideoStats。
- remoteStatsCount:远端共享流收流数量。
onConnectOtherRoom
virtual void onConnectOtherRoom(HRTCConnectInfo *connectInfo, int error, const char* msg);
【功能说明】
开启跨房回调。
【回调参数】
- connectInfo:跨房信息,具体请参见HRTCConnectInfo。
- error:跨房调用成功,该值为0;否则>0,错误码。
- msg:错误描述。
onDisconnectOtherRoom
virtual void onDisconnectOtherRoom(HRTCConnectInfo *connectInfo, int error, const char* msg);
【功能说明】
结束跨房回调。
【回调参数】
- connectInfo:跨房信息,具体请参见HRTCConnectInfo。
- error:结束跨房调用成功,该值为0;否则>0,错误码。
- msg:错误描述。
onRemoteAudioStateChanged
virtual void onRemoteAudioStateChanged(const char* userId, HRTCRemoteAudioStreamState state, HRTCRemoteAudioStreamStateReason reason)
【功能说明】
远端音频流状态变化回调。
【回调参数】
- userId:远端用户ID。
- state:远端音频流状态,具体请参见HRTCRemoteAudioStreamState。
- reason:远端音频流状态变化原因,具体请参见HRTCRemoteAudioStreamStateReason。
onRemoteVideoStateChanged
virtual void onRemoteVideoStateChanged(const char* userId, HRTCRemoteVideoStreamState state, HRTCRemoteVideoStreamStateReason reason)
【功能说明】
远端视频流状态变化回调。
【回调参数】
- userId:远端用户ID。
- state:远端视频流状态,具体请参见HRTCRemoteVideoStreamState。
- reason:远端视频流状态变化原因,具体请参见HRTCRemoteVideoStreamStateReason。
onRenderDataFrame
virtual void onRenderDataFrame(const char* roomId, HRTCMediaDirection direction, const char* userId, HRTCVideoFrame& videoFrame)
【功能说明】
共享流自渲染回调。需要调用setExternalDataFrameOutput接口开启共享流自渲染,从而触发该回调。
【回调参数】
- roomId:房间ID。
- direction:数据源,本地数据,远端数据,具体请参见HRTCMediaDirection。
- userId:用户ID。
- videoFrame:共享流详情,具体请参见HRTCVideoFrame。
onRenderVideoFrame
virtual void onRenderVideoFrame(const char* roomId, HRTCMediaDirection direction, const char* userId, HRTCVideoFrame& videoFrame)
【功能说明】
视频自渲染回调。需要调用setExternalVideoFrameOutput接口开启视频自渲染,从而触发该回调。
【回调参数】
- roomId:房间ID。
- direction:数据源,本地数据,远端数据,具体请参见HRTCMediaDirection。
- userId:视频数据对应的远端用户ID。
- videoFrame:视频帧详情,具体请参见HRTCVideoFrame。
onPlaybackAudioFrame
virtual void onPlaybackAudioFrame(const char* roomId, HRTCMediaDirection direction, HRTCAudioFrame& audioFrame)
【功能说明】
音频自渲染回调。需要调用setExternalAudioFrameOutput接口开启音频自渲染,从而触发该回调。
【回调参数】
- roomId:房间ID。
- direction:数据源,本地数据,远端数据,具体请参见HRTCMediaDirection。
- audioFrame:音频帧详情,具体请参见HRTCAudioFrame。
onRejoinRoomSuccess
virtual void onRejoinRoomSuccess(const char* roomId, const char* userId)
【功能说明】
重新加入房间回调。例如网络异常后重连成功加入房间触发。
【回调参数】
- roomId:房间ID。
- userId:用户ID。
onStartAudioFileNotify
virtual void onStartAudioFileNotify(int result)
【功能说明】
播放音频文件回调。
【回调参数】
- 0:播放成功
- >0:播放失败
onStopAudioFileNotify
virtual void onStopAudioFileNotify(int result)
【功能说明】
停止播放音频文件回调。
【回调参数】
- 0:停止播放成功
- >0:停止播放失败
onPauseAudioFileNotify
virtual void onPauseAudioFileNotify(int result)
【功能说明】
暂停播放音频文件回调。
【回调参数】
- 0:暂停播放成功
- >0:暂停播放失败
onResumeAudioFileNotify
virtual void onResumeAudioFileNotify(int result)
【功能说明】
恢复播放音频文件回调。
【回调参数】
- 0:恢复播放成功
- >0:恢复播放失败
onNetworkTestQuality
virtual void onNetworkTestQuality(HRTCNetworkQualityLevel level)
【功能说明】
网络探测回调。
【回调参数】
level:网络质量等级1-4,具体请参见HRTCNetworkQualityLevel。
onNetworkTestResult
virtual void onNetworkTestResult(HRTCNetworkTestResult& networkTestResult)
【功能说明】
会前网络探测结果回调。
【回调参数】
networkTestResult:主要包括测试成功与否、上行和下行的网络带宽、丢包、延时和抖动,具体请参见HRTCNetworkTestResult。
onUserVolumeStats
virtual void onUserVolumeStats(const HRTCVolumeInfo* userVolumes, unsigned int userVolumesCount, unsigned int totalVolume)
【功能说明】
总音量以及各发言人及其对应音量上报显示回调。
【回调参数】
- userVolumes:用户信息,具体请参见HRTCVolumeInfo。
- userVolumesCount:上报的发言人人数,最多上报4人,包含本地用户。
- totalVolume:总音量。
