设备管理
3.4.2 事件回调(IHRTCEngineEventHandler)
本章节介绍了Android SDK的回调接口IHRTCEngineEventHandler的详情。
表3-13 回调接口
接口 描述
onError
错误回调onJoinRoomSuccess
加入房间成功回调onJoinRoomFailure
加入房间失败回调onLeaveRoom
离开房间回调onRemoteUserOnline
用户加入房间回调onRemoteUserOffline
用户离开房间回调onConnectionChangedNotify
网络连接状态改变回调onLogUploadResult
日志上传结果回调onLogUploadProgress
日志上传进度回调onUserRoleChangedNotify
用户角色改变回调onAudioRouteStateChangedNotify
音频路由改变回调onUserAuxiliaryStreamAvailable
辅流加入房间回调接口 描述
onRenderExternalVideoFrame
回调远端的视频原始数据流onPlaybackExternalAudioFrame
回调远端的音频原始数据流onVideoStatsNotify
视频流详情,2s触发一次回调onAudioStatsNotify
音频流详情,2s触发一次回调onAuxiliaryStreamStatsNotify
辅流详情,2s触发一次回调onRemoteAudioStateChangedNotify
远端音频流状态变化回调onRemoteVideoStateChangedNotify
远端视频流状态变化回调onRejoinRoomSuccess
重新加入房间回调onUserVolumeStatsNotify
提示频道远端用户以及自己的音量回调onNetworkTestQuality
会前网络探测质量上报回调onNetworkTestResult
会前网络探测结果上报回调onFirstRemoteVideoDecoded
远端用户第一帧解码成功回调onFirstRemoteAuxiliaryStreamDecod
ed
收到第一帧远端辅流并解码成功回调onAuthorizationExpired
签名过期回调onNetworkQualityNotify
加入房间后的网络质量状态回调onLocalAudioStateChangedNotify
本地音频流状态变化回调onLocalVideoStateChangedNotify
本地视频流状态变化回调onScreenShareStarted
辅流开启回调onScreenShareStopped
辅流改变回调onMediaConnectStateChangedNotif
y
媒体连接状态变化通知onUserNameChangedNotify
本端修改昵称结果通知onRemoteUserNameChangedNotify
远端用户昵称变更通知onFirstLocalAudioFrameNotify
本地音频首帧发送回调onFirstLocalVideoFrameNotify
本地视频首帧渲染回调onLocalVideoStatsNotify
本端视频统计回调onRemoteVideoStatsNotify
远端视频统计回调onLocalAudioStatsNotify
本端音频统计回调onRemoteAudioStatsNotify
远端音频统计回调onVideoResolutionChangedNotify
远端视频大小流改变回调接口 描述
onStatsNotify
当前会话统计回调onAudioMixStateChangedNotify
音频文件播放状态改变回调onAudioFileFinished
音频文件播放结束回调onAudioClipFinished
音效文件播放结束回调onSeiSendMsgSuccess
音频SEI信息发送成功回调onSeiRecvMsg
接收音频SEI信息回调onStartPublishStream
开始旁路(RTMP)推流回调onUpdateTransCoding
更新旁路(RTMP)推流消息onStopPublishStream
停止旁路(RTMP)推流消息onStreamPublishStateChangedNotif
y
RTMP推流状态回调onRemoteCommandPacket
媒体通道Cmd命令数据包接收onLocalAudioMutedStatusDetected
本端禁音状态回调onTopActiveSpeaker
远端音频最活跃用户回调onError
void onError(int error, String msg);
【功能说明】
错误回调。
【回调参数】
● error:错误码,具体请参见HRTCErrorCode。
● msg:错误描述。
onJoinRoomSuccess
void onJoinRoomSuccess(String roomId, String userId);
【功能说明】
成功加入房间回调。
【回调参数】
● roomId:房间ID。
● userId:用户ID。
onJoinRoomFailure
void onJoinRoomFailure(int error, String msg);
【功能说明】
加入房间失败回调。
【回调参数】
● error:错误码。
● msg:错误信息。
onLeaveRoom
void onLeaveRoom(HRTCLeaveReason reason, HRTCStatsInfo statsInfo);
【功能说明】
离开房间回调。
【回调参数】
● reason:自己离开房间的原因,具体请参见HRTCLeaveReason。
● statsInfo:会议期间的统计信息,具体请参见HRTCStatsInfo。
onRemoteUserOnline
void onRemoteUserOnline(String roomId, String userId, String userName);
【功能说明】
用户加入房间成功回调,不包括自己。
【回调参数】
● roomId:房间ID。
● userId:用户ID。
● userName:用户名称。
onRemoteUserOffline
void onRemoteUserOffline(String roomId, String userId, int reason);
【功能说明】
用户离开房间回调。
【回调参数】
● roomId:房间ID。
● userId:用户ID。
● reason:预留字段。
onConnectionChangedNotify
void onConnectionChangedNotify(HRTCConnStateTypes connStateTypes, HRTCConnChangeReason connChangeReason, String description);
【功能说明】
网络连接状态改变。
【回调参数】
● connStateTypes:网络连接状态,具体请参见HRTCConnStateTypes。
● connChangeReason:网络连接状态原因,具体请参见
HRTCConnChangeReason。
● description:描述。
onLogUploadResult
void onLogUploadResult(int result);
【功能说明】
日志上传结果回调。
【回调参数】
result:日志上传结果,0表示成功,1表示失败。
onLogUploadProgress
void onLogUploadProgress(int progress);
【功能说明】
日志上传进度回调。
【回调参数】
progress:进度,取值范围为[0,100]。
onUserRoleChangedNotify
void onUserRoleChangedNotify(String roomId, HRTCRoleType oldRole, HRTCRoleType newRole);
【功能说明】
用户角色改变。
【回调参数】
● roomId:发生角色切换的房间号。
● oldRole:改变前的角色,具体请参见HRTCRoleType。
● newRole:改变后的角色,具体请参见HRTCRoleType。
onAudioRouteStateChangedNotify
void onAudioRouteStateChangedNotify(HRTCAudioRoute route);
【功能说明】
音频路由改变。
【回调参数】
route:音频路由,具体请参见HRTCAudioRoute。
onUserAuxiliaryStreamAvailable
void onUserAuxiliaryStreamAvailable(String roomId, String userId, boolean available);
【功能说明】
辅流加入房间。
【回调参数】
● roomId:房间ID。
● userId:用户ID。
● available:true表示辅流开始推送,false表示辅流停止推送,提示用户关闭共 享。
onRenderExternalVideoFrame
void onRenderExternalVideoFrame(String roomId, HRTCMediaDirection direction, String userId, HRTCVideoFrame videoFrame);
【功能说明】
回调远端的视频原始数据流。
【回调参数】
● roomId:房间ID。
● userId:用户ID。
● videoFrame:视频数据。
● direction: 数据源,本地数据,远端数据,具体请参见HRTCMediaDirection。
onPlaybackExternalAudioFrame
void onPlaybackExternalAudioFrame(String roomId,HRTCMediaDirection direction, HRTCAudioFrame audioFrame);
【功能说明】
回调远端的音频原始数据流。
【回调参数】
● roomId:房间ID。
● audioFrame:音频数据。
● direction: 数据源,本地数据,远端数据,具体请参见HRTCMediaDirection。
onVideoStatsNotify
void onVideoStatsNotify(List<HRTCLocalVideoStats> localStats, List<HRTCRemoteVideoStats> remoteStats);
【功能说明】
视频流详情,2s触发一次回调。
【回调参数】
● localStats:本地视频发流详情参数,具体请参见HRTCLocalVideoStats。
● remoteStats:远端视频收流详情参数,具体请参见HRTCRemoteVideoStats。
注意
只有本地一个用户入会时,不回调该方法。
onAudioStatsNotify
void onAudioStatsNotify(List<HRTCLocalAudioStats> localStats, List<HRTCRemoteAudioStats> remoteStats);
【功能说明】
音频流详情,2s触发一次回调。
【回调参数】
● localStats:本地音频发流详情,具体请参见HRTCLocalAudioStats。
● remoteStats:远端音频收流详情,具体请参见HRTCRemoteAudioStats。
onAuxiliaryStreamStatsNotify
void onAuxiliaryStreamStatsNotify(List<HRTCLocalVideoStats> localStats, List<HRTCRemoteVideoStats>
remoteStats);
【功能说明】
辅流详情,2s触发一次回调。
【回调参数】
● localStats:本地辅流的发流详情,具体请参见HRTCLocalVideoStats。
● remoteStats:远端辅流的收流详情,具体请参见HRTCRemoteVideoStats。
onRemoteAudioStateChangedNotify
void onRemoteAudioStateChangedNotify(String userId, HRTCRemoteAudioStreamState state, HRTCRemoteAudioStreamStateReason reason);
【功能说明】
远端音频流状态变化回调。
【回调参数】
● userId:远端用户ID。
● state:远端音频流状态,具体请参见HRTCRemoteAudioStreamState。
● reason:远端音频流状态变化原因,具体请参见
HRTCRemoteAudioStreamStateReason。
onRemoteVideoStateChangedNotify
void onRemoteVideoStateChangedNotify(String userId, HRTCRemoteVideoStreamState state, HRTCRemoteVideoStreamStateReason reason);
【功能说明】
远端视频流状态变化回调。
【回调参数】
● userId:远端用户ID。
● state:远端视频流状态,具体请参见HRTCRemoteVideoStreamState。
● reason:远端视频流状态变化原因,具体请参见
HRTCRemoteVideoStreamStateReason。
onRejoinRoomSuccess
void onRejoinRoomSuccess(String roomId, String userId);
【功能说明】
重新加入房间回调。例如,网络异常后重连成功加入房间时触发。
【回调参数】
● roomId:房间ID。
● userId:用户ID。
onUserVolumeStatsNotify
void onUserVolumeStatsNotify(List<HRTCVolumeInfo> volumeInfos, int totalVolume);
【功能说明】
提示频道远端用户以及自己的音量回调。
【回调参数】
● volumeInfos:回调发言人信息列表,目前最多支持4人,包括自己,具体请参见
HRTCVolumeInfo。
● totalVolume:远端混音后的总音量。
onNetworkTestQuality
void onNetworkTestQuality(HRTCNetworkQualityLevel level);
【功能说明】
会前网络探测质量上报,探测成功后每隔两秒刷新该level值。
【回调参数】
level:具体请参见HRTCNetworkQualityLevel。
onNetworkTestResult
void onNetworkTestResult(HRTCNetworkTestResult networkTestResult);
【功能说明】
会前网络探测结果上报,如果探测成功,该回调会在探测30s后上报,如果失败随时上 报。
【回调参数】
networkTestResult:网络探测结果数据,具体请参见HRTCNetworkTestResult。
onFirstRemoteVideoDecoded
void onFirstRemoteVideoDecoded(String roomId, final String userId, int width, int height);
【功能说明】
远端用户第一帧解码成功回调。
【回调参数】
● roomId:房间ID。
● userId:用户ID。
● width:视频宽度。
● height:视频高度。
onFirstRemoteAuxiliaryStreamDecoded
void onFirstRemoteAuxiliaryStreamDecoded(String roomId, String userId, int width, int height);
【功能说明】
接收到第一帧远端辅流并解码成功,触发此回调。
【回调参数】
● roomId:视频流对应的房间ID。
● userId:视频流对应的用户ID。
● width:视频流宽。
● height:视频流高。
onAuthorizationExpired
void onAuthorizationExpired();
【功能说明】
签名过期回调,需要app调用renewAuthorization更新签名。
【回调参数】
无
onNetworkQualityNotify
void onNetworkQualityNotify(List<HRTCQualityInfo> upStreamQuality, List<HRTCQualityInfo>
downStreamQuality);
【功能说明】
加入房间后,基于流级别的网络质量状态回调。音频流、视频流分别回调。
【回调参数】
● 本端开始推流后,本端才会开始收到网络质量回调。
● upStreamQuality:上行网络质量状态,具体请参见HRTCQualityInfo。当前不 可用。
● downStreamQuality:下行网络质量状态,具体请参见HRTCQualityInfo。
onLocalAudioStateChangedNotify
void onLocalAudioStateChangedNotify(HRTCLocalAudioStreamState state, HRTCLocalAudioStreamStateReason reason);
【功能说明】
本地音频流状态变化回调。
【回调参数】
● state:本地音频流状态,具体请参见HRTCLocalAudioStreamState。
● reason:本地音频流状态变化原因,具体请参见
HRTCLocalAudioStreamStateReason。
onLocalVideoStateChangedNotify
void onLocalVideoStateChangedNotify(HRTCLocalVideoStreamState state, HRTCLocalVideoStreamStateReason reason);
【功能说明】
本地视频流状态变化回调。
【回调参数】
● state:本地视频流状态,具体请参见HRTCLocalVideoStreamState。
● reason:本地视频流状态变化原因,具体请参见
HRTCLocalVideoStreamStateReason
onScreenShareStarted
void onScreenShareStarted();
【功能说明】
屏幕流共享开启,触发此回调。
onScreenShareStopped
void onScreenShareStopped(int reason)
【功能说明】
屏幕流共享状态改变,触发此回调。
【回调参数】
reason:屏幕共享状态改变原因。
注意
● SDK 1.7.1及以上版本支持。
● reason:预留参数。
onMediaConnectStateChangedNotify
void onMediaConnectStateChangedNotify(HRTCMediaConnStateTypes state, HRTCMediaConnChangeReason reason, String description);
【功能说明】
媒体服务器连接状态变更通知。
【回调参数】
● state:连接状态,具体请参见HRTCMediaConnStateTypes。
● reason:连接状态变化的原因,具体请参见HRTCMediaConnChangeReason。
● description:连接状态变化原因描述。
注意
加入房间过后,收到媒体服务的数据包时,返回Connected消息,超过6s没有收到包,
则返回Failed消息。
onUserNameChangedNotify
void onUserNameChangedNotify(String oldUserName, String newUserName);
【功能说明】
调用changeUserName接口成功后,上报此事件通知修改昵称结果。
【回调参数】
● oldUserName:修改前昵称。
● newUserName:修改后昵称。
onRemoteUserNameChangedNotify
void onRemoteUserNameChangedNotify(String userId, String userName);
【功能说明】
远端用户修改昵称后,通知本端昵称变更。
【回调参数】
● userId:修改昵称的用户id。
● userName:修改后的昵称。
onFirstLocalAudioFrameNotify
void onFirstLocalAudioFrameNotify(int elapsed);
【功能说明】
本地音频首帧发送回调。
【回调参数】
elapsed:从入会到本地音频首帧发送所用的时间,单位为ms。
onFirstLocalVideoFrameNotify
void onFirstLocalVideoFrameNotify(int elapsed);
【功能说明】
本地视频首帧渲染回调。
【回调参数】
elapsed:从开始采集到本地视频首帧渲染所用的时间,单位为ms。
onLocalVideoStatsNotify
void onLocalVideoStatsNotify(List<HRTCLocalVideoStats> localStats);
【功能说明】
本端视频流详情,2s触发一次回调。
【回调参数】
localStats:本地视频发流详情参数,具体请参见HRTCLocalVideoStats。
onRemoteVideoStatsNotify
void onRemoteVideoStatsNotify(List<HRTCRemoteVideoStats> remoteStats);
【功能说明】
远端视频流详情,2s触发一次回调。
【回调参数】
remoteStats:远端视频收流详情参数,具体请参见HRTCRemoteVideoStats。
onLocalAudioStatsNotify
void onLocalAudioStatsNotify(List<HRTCLocalAudioStats> localStats);
【功能说明】
本端音频流详情,2s触发一次回调。
【回调参数】
localStats:本地音频发流详情,具体请参见HRTCLocalAudioStats。
onRemoteAudioStatsNotify
void onRemoteAudioStatsNotify(List<HRTCRemoteAudioStats> remoteStats);
【功能说明】
远端音频流详情,2s触发一次回调。
【回调参数】
remoteStats:远端音频收流详情,具体请参见HRTCRemoteAudioStats。
onVideoResolutionChangedNotify
void onVideoResolutionChangedNotify(String userid, int width, int height);
【功能说明】
远端视频大小改变回调。
【回调参数】
● userId:用户ID。
● width:视频流宽度。
● height:视频流高度。
onStatsNotify
void onStatsNotify(List<HRTCOnStats> hrtcOnStats);
【功能说明】
当前会话统计回调。
【回调参数】
hrtcOnStats:会话统计信息,具体请参见HRTCOnStats。
onAudioMixStateChangedNotify
void onAudioMixStateChangedNotify(HRTCAudioFileState state, HRTCAudioFileReason reason, long value);
【功能说明】
音频文件播放状态改变回调。
【回调参数】
● state:音频文件播放状态,具体请参见HRTCAudioFileState。
● reason:音频文件播放状态变化原因,具体请参见HRTCAudioFileReason。
● value:state为HRTC_AUDIO_FILE_OPEN_COMPLETED表示音频文件的时长,单 位为ms;state为HRTC_AUDIO_FILE_POSITION_UPDATE表示当前播放的位置,
单位为ms。其他情况下,value值无意义。
onAudioFileFinished
void onAudioFileFinished();
【功能说明】
音频文件播放结束回调。
【回调参数】
无
onAudioClipFinished
void onAudioClipFinished(int soundId);
【功能说明】
音效文件播放结束回调。
【回调参数】
soundId:音效ID,取值>= 0。
onSeiSendMsgSuccess
void onSeiSendMsgSuccess(String message);
【功能说明】
音频SEI信息发送成功回调。
【回调参数】
message:发送SEI信息的内容。
onSeiRecvMsg
void onSeiRecvMsg(String userId, String message);
【功能说明】
接收音频SEI信息回调。
【回调参数】
● userId:用户ID。
● message:接收SEI信息的内容。
onError
virtual void onError(IHRTCConnection* conn, int error, const char* msg)
【功能说明】
发生错误,触发此回调。返回客户端错误码或者服务端错误码。
【回调参数】
● conn:连接对象。
● error:错误码,具体请参见HRTCErrorCode。
● msg:错误描述。
onConnectionChangedNotify
virtual void onConnectionChangedNotify(IHRTCConnection* conn, HRTCConnStateType state, HRTCConnChangeReason reason, const char* description)
【功能说明】
连接状态改变回调。
【回调参数】
● conn:连接对象。
● state:连接状态类型,具体请参见HRTCConnStateTypes。
● reason:连接状态改变原因,具体请参见HRTCConnChangeReason。
● description:连接状态改变描述。
onAuthorizationExpired
virtual void onAuthorizationExpired(IHRTCConnection* conn);
【功能说明】
鉴权签名过期回调,需要app调用renewAuthorization更新签名。
【回调参数】
conn:连接对象。
onJoinRoomSuccess
virtual void onJoinRoomSuccess(IHRTCConnection* conn, const char* userId)
【功能说明】
成功加入房间,触发此回调。
【回调参数】
● conn:连接对象。
● userId:新加入房间的用户ID。
onJoinRoomFailure
virtual void onJoinRoomFailure(IHRTCConnection* conn, int error, const char* msg)
【功能说明】
加入房间失败,触发此回调。
【回调参数】
● conn:连接对象。
● error:错误码,具体请参见HRTCErrorCode。
● msg:错误描述。
onRejoinRoomSuccess
virtual void onRejoinRoomSuccess(IHRTCConnection* conn, const char* userId)
【功能说明】
重新加入房间回调。例如,网络异常后重连成功加入房间触发。
重新加入房间回调。例如,网络异常后重连成功加入房间触发。