事件回调(IHRTCConnectionEventHandler)
本章节介绍了Android SDK的回调接口IHRTCConnectionEventHandler的详情。
接口 |
描述 |
---|---|
错误回调 |
|
加入房间成功回调 |
|
加入房间失败回调 |
|
重新加入房间回调 |
|
离开房间回调 |
|
用户加入房间回调 |
|
用户离开房间回调 |
|
网络连接状态改变回调 |
|
远端视频流状态变化回调 |
|
远端音频流状态变化回调 |
|
用户角色改变回调 |
|
提示频道远端用户以及自己的音量回调 |
|
辅流加入房间回调 |
|
视频流详情,2s触发一次回调 |
|
音频流详情,2s触发一次回调 |
|
辅流详情,2s触发一次回调 |
|
远端用户第一帧解码成功通知 |
|
远端用户辅流第一帧解码成功通知 |
|
远端用户昵称变更通知 |
|
本端修改昵称结果通知 |
|
签名过期回调 |
|
媒体连接状态变化通知 |
|
用户视频流渲染成功通知回调 |
|
订阅的用户视频流收包信息回调 |
|
加入房间后的网络质量状态回调 |
|
远端视频统计回调 |
|
远端音频统计回调 |
|
远端视频大小流改变回调 |
|
当前会话统计回调 |
|
开始旁路(RTMP)推流回调 |
|
更新旁路(RTMP)推流消息 |
|
停止旁路(RTMP)推流消息 |
|
RTMP推流状态回调 |
|
远端音频最活跃用户回调 |
|
远端麦克风设备状态变更通知 |
onError
void onError(HRTCConnection conn, int error, String msg);
【功能说明】
错误回调。
- conn:回调对应的HRTCConnection实例。
- error:错误码,具体请参见HRTCErrorCode。
- msg:错误描述。
onJoinRoomSuccess
void onJoinRoomSuccess(HRTCConnection conn, String userId);
【功能说明】
成功加入房间回调。
- conn:回调对应的HRTCConnection实例。
- roomId:房间ID。
- userId:用户ID。
onJoinRoomFailure
void onJoinRoomFailure(HRTCConnection conn, int error, String msg);
【功能说明】
加入房间失败回调。
【回调参数】
- conn:回调对应的HRTCConnection实例。
- error:错误码。
- msg:错误信息。
onLeaveRoom
void onLeaveRoom(HRTCConnection conn, HRTCLeaveReason reason, HRTCStatsInfo statsInfo);
【功能说明】
离开房间回调。
- conn:回调对应的HRTCConnection实例。
- reason:自己离开房间的原因,具体请参见HRTCLeaveReason。
- statsInfo:会议期间的统计信息,具体请参见HRTCStatsInfo。
onRemoteUserOnline
void onRemoteUserOnline(HRTCConnection conn, String userId, String userName);
【功能说明】
用户加入房间成功回调,不包括自己。
【回调参数】
- conn:回调对应的HRTCConnection实例。
- userId:用户ID。
- userName:用户名称。
onRemoteUserOffline
void onRemoteUserOffline(HRTCConnection conn, String userId, int reason);
【功能说明】
用户离开房间回调。
【回调参数】
- conn:回调对应的HRTCConnection实例。
- userId:用户ID。
- reason:预留字段。
onConnectionChangedNotify
void onConnectionChangedNotify(HRTCConnection conn, HRTCConnStateTypes connStateTypes, HRTCConnChangeReason connChangeReason, String description);
【功能说明】
网络连接状态改变。
- conn:回调对应的HRTCConnection实例。
- connStateTypes:网络连接状态,具体请参见HRTCConnStateTypes。
- connChangeReason:网络连接状态原因,具体请参见HRTCConnChangeReason。
- description:描述。
onUserRoleChangedNotify
void onUserRoleChangedNotify(HRTCConnection conn, HRTCRoleType oldRole, HRTCRoleType newRole);
【功能说明】
用户角色改变。
- conn:回调对应的HRTCConnection实例。
- oldRole:改变前的角色,具体请参见HRTCRoleType。
- newRole:改变后的角色,具体请参见HRTCRoleType。
onAudioRouteStateChangedNotify
void onAudioRouteStateChangedNotify(HRTCConnection conn, HRTCAudioRoute route);
【功能说明】
音频路由改变。
【回调参数】
- conn:回调对应的HRTCConnection实例。
- route:音频路由,具体请参见HRTCAudioRoute。
onUserAuxiliaryStreamAvailable
void onUserAuxiliaryStreamAvailable(HRTCConnection conn, String userId, boolean available);
【功能说明】
辅流加入房间。
【回调参数】
- conn:回调对应的HRTCConnection实例。
- userId:用户ID。
- available:true为辅流开始推送,false为辅流停止推送。
onVideoStatsNotify
void onVideoStatsNotify(HRTCConnection conn, List<HRTCLocalVideoStats> localStats, List<HRTCRemoteVideoStats> remoteStats);
【功能说明】
视频流详情,2s触发一次回调。
【回调参数】
- conn:回调对应的HRTCConnection实例。
- localStats:本地视频发流详情参数,具体请参见HRTCLocalVideoStats。
- remoteStats:远端视频收流详情参数,具体请参见HRTCRemoteVideoStats。
onAudioStatsNotify
void onAudioStatsNotify(HRTCConnection conn, List<HRTCLocalAudioStats> localStats, List<HRTCRemoteAudioStats> remoteStats);
【功能说明】
音频流详情,2s触发一次回调。
【回调参数】
- conn:回调对应的HRTCConnection实例。
- localStats:本地音频发流详情,具体请参见HRTCLocalAudioStats。
- remoteStats:远端音频收流详情,具体请参见HRTCRemoteAudioStats。
onAuxiliaryStreamStatsNotify
void onAuxiliaryStreamStatsNotify(HRTCConnection conn, List<HRTCLocalVideoStats> localStats, List<HRTCRemoteVideoStats> remoteStats);
【功能说明】
辅流详情,2s触发一次回调。
【回调参数】
- conn:回调对应的HRTCConnection实例。
- localStats:本地辅流的发流详情,具体请参见HRTCLocalVideoStats。
- remoteStats:远端辅流的收流详情,具体请参见HRTCRemoteVideoStats。
onRemoteAudioStateChangedNotify
void onRemoteAudioStateChangedNotify(HRTCConnection conn, String userId, HRTCRemoteAudioStreamState state, HRTCRemoteAudioStreamStateReason reason);
【功能说明】
远端音频流状态变化回调。
【回调参数】
- conn:回调对应的HRTCConnection实例。
- userId:远端用户ID。
- state:远端音频流状态,具体请参见HRTCRemoteAudioStreamState。
- reason:远端音频流状态变化原因,具体请参见HRTCRemoteAudioStreamStateReason。
onRemoteVideoStateChangedNotify
void onRemoteVideoStateChangedNotify(HRTCConnection conn, String userId, HRTCRemoteVideoStreamState state, HRTCRemoteVideoStreamStateReason reason);
【功能说明】
远端视频流状态变化回调。
【回调参数】
- conn:回调对应的HRTCConnection实例。
- userId:远端用户ID。
- state:远端视频流状态,具体请参见HRTCRemoteVideoStreamState。
- reason:远端视频流状态变化原因,具体请参见HRTCRemoteVideoStreamStateReason。
onRejoinRoomSuccess
void onRejoinRoomSuccess(HRTCConnection conn, String userId);
【功能说明】
重新加入房间回调。例如网络异常后重连成功加入房间时触发。
【回调参数】
- conn:回调对应的HRTCConnection实例。
- userId:用户ID。
onUserVolumeStatsNotify
void onUserVolumeStatsNotify(HRTCConnection conn, List<HRTCVolumeInfo> volumeInfos, int totalVolume);
【功能说明】
提示频道远端用户以及自己的音量回调。
- conn:回调对应的HRTCConnection实例。
- volumeInfos:回调发言人信息列表,目前最多支持4人,包括自己,具体请参见HRTCVolumeInfo。
- totalVolume:远端混音后的总音量。
onFirstRemoteVideoDecoded
void onFirstRemoteVideoDecoded(HRTCConnection conn, String userId, int width, int height);
【功能说明】
远端用户第一帧解码成功回调。
【回调参数】
- conn:回调对应的HRTCConnection实例。
- userId:用户ID。
- width:视频宽度。
- height:视频高度。
onFirstRemoteAuxiliaryStreamDecoded
void onFirstRemoteAuxiliaryStreamDecoded(HRTCConnection conn, String roomId, String userId, int width, int height);
【功能说明】
接收到第一帧远端辅流并解码成功,触发此回调。
【回调参数】
- conn:回调对应的HRTCConnection实例。
- roomId:视频流对应的房间ID。
- userId:视频流对应的用户ID。
- width:视频流宽。
- height:视频流高。
onAuthorizationExpired
void onAuthorizationExpired(HRTCConnection conn);
【功能说明】
签名过期回调,需要app调用renewAuthorization更新签名。
【回调参数】
conn:回调对应的HRTCConnection实例。
onRenderSuccessNotify
void onRenderSuccessNotify(HRTCConnection conn, String userId, boolean isAux);
【功能说明】
用户视频流渲染成功通知回调。首帧渲染成功、分辨率变化或视频流中断后恢复触发。
【回调参数】
- conn:回调对应的HRTCConnection实例。
- userId:用户ID。
- isAux:是否辅流。true为是辅流,false为不是辅流。
onMediaStreamRecvPktNotify
void onMediaStreamRecvPktNotify(HRTCConnection conn, List<HRTCStreamPacketInfo> streamPacketInfoList);
【功能说明】
订阅的用户视频流收包信息回调。
【回调参数】
- conn:回调对应的HRTCConnection实例。
- streamPacketInfoList:订阅的用户视频流收包信息,具体请参见HRTCStreamPacketInfo。
onNetworkQualityNotify
void onNetworkQualityNotify(HRTCConnection conn, List<HRTCQualityInfo> upStreamQuality, List<HRTCQualityInfo> downStreamQuality);
【功能说明】
加入房间后,基于流级别的网络质量状态回调,音频流、视频流分开回调。
【回调参数】
- 当远端订阅本端时(本端开始推流),本端才会开始收到网络质量回调。
- conn:回调对应的HRTCConnection实例。
- upStreamQuality:上行网络质量状态,具体请参见HRTCQualityInfo。当前不可用。
- downStreamQuality:下行网络质量状态,具体请参见HRTCQualityInfo。
onMediaConnectStateChangedNotify
void onMediaConnectStateChangedNotify(HRTCConnection conn, HRTCMediaConnStateTypes state, HRTCMediaConnChangeReason reason, String description);
【功能说明】
媒体服务器连接状态变更通知。加入房间过后,收到媒体服务的数据包时,返回Connected消息,超过6s没有收到包,则返回Failed消息。
【回调参数】
- conn:回调对应的HRTCConnection实例。
- state:连接状态,具体请参见HRTCMediaConnStateTypes。
- reason:连接状态变化的原因,具体请参见HRTCMediaConnChangeReason。
- description:连接状态变化原因描述。
onUserNameChangedNotify
void onUserNameChangedNotify(HRTCConnection conn, String oldUserName, String newUserName);
【功能说明】
调用changeUserName接口成功后,上报此事件通知修改昵称结果。
【回调参数】
- conn:回调对应的HRTCConnection实例。
- oldUserName:修改前的昵称。
- newUserName:修改后的昵称。
onRemoteUserNameChangedNotify
void onRemoteUserNameChangedNotify(HRTCConnection conn, String userId, String userName);
【功能说明】
远端用户修改昵称后,通知本端昵称变更。
【回调参数】
- conn:回调对应的HRTCConnection实例。
- userId:修改昵称的用户id。
- userName:修改后的昵称。
onRemoteVideoStatsNotify
void onRemoteVideoStatsNotify(HRTCConnection conn, List<HRTCRemoteVideoStats> remoteStats);
【功能说明】
远端视频流详情,2s触发一次回调。
【回调参数】
- conn:回调对应的HRTCConnection实例。
- remoteStats:远端视频收流详情参数,具体请参见HRTCRemoteVideoStats。
onRemoteAudioStatsNotify
void onRemoteAudioStatsNotify(HRTCConnection conn, List<HRTCRemoteAudioStats> remoteStats);
【功能说明】
远端音频流详情,2s触发一次回调。
【回调参数】
- conn:回调对应的HRTCConnection实例。
- remoteStats:远端音频收流详情,具体请参见HRTCRemoteAudioStats。
onVideoResolutionChangedNotify
void onVideoResolutionChangedNotify(HRTCConnection conn, String userid, int width, int height);
【功能说明】
远端视频大小改变回调。
【回调参数】
- conn:回调对应的HRTCConnection实例。
- userId:用户ID。
- width:视频流宽度。
- height:视频流高度。
onStatsNotify
void onStatsNotify(HRTCConnection conn,List<HRTCOnStats> hrtcOnStats);
【功能说明】
当前会话统计回调。
- conn:回调对应的HRTCConnection实例。
- hrtcOnStats:会话统计信息,具体请参见HRTCOnStats。
onStartPublishStream
void onStartPublishStream(HRTCConnection conn,int code, const char* taskId);
【功能说明】
开始旁路(RTMP)推流回调。
- conn:回调对应的HRTCConnection实例。
- code:错误码,0表示成功,非0请参见错误码。
- taskId:任务Id。
onUpdateTransCoding
void onUpdateTransCoding(HRTCConnection conn,int code, const char* taskId);
【功能说明】
更新旁路(RTMP)推流回调。
- conn:回调对应的HRTCConnection实例。
- code:错误码,0表示成功,非0请参见错误码。
- taskId:任务Id。
onStopPublishStream
void onStopPublishStream(HRTCConnection conn,int code, const char* taskId);
【功能说明】
停止旁路(RTMP)推流回调。
- conn:回调对应的HRTCConnection实例。
- code:错误码,0表示成功,非0请参见错误码。
- taskId:任务Id。
onStreamPublishStateChange
void onStreamPublishStateChange(HRTCConnection conn,int code, const char* taskId, const HRTCUrlStatusList * urlStatus);
【功能说明】
RTMP推流状态回调。
- conn:回调对应的HRTCConnection实例。
- code:错误码,0表示成功,非0请参见错误码。
- taskId:任务Id。
- urlStatus:推流的url结果结构体,具体请参见HRTCUrlStatusList。
onTopActiveSpeaker
public void onTopActiveSpeaker(HRTCConnection conn, String userId, boolean noStream);
【功能说明】
上报当前最活跃的用户userId。该回调主要用于0号会场场景(额外订阅uid为0的用户音频)。
【回调参数】
userId:返回当前远端音量最活跃的用户ID。
noStream:该用户是否有视频流。
0号会场模式下,SDK会持续监测(根据一定时间内用户音量大小)当前最活跃的用户,如果最活跃用户发生变化,则触发此回调并上报当前最活跃的用户userId。
onRemoteMicrophoneStateChanged
void onRemoteMicrophoneStateChanged(HRTCConnection conn, String userId, HRTCRemoteMicState state);
【功能说明】
远端麦克风设备状态变更回调。
【回调参数】
- conn: 连接对象。
- userId:用户id。
- state:麦克风设备状态,具体请参见HRTCRemoteMicState。
onRemoteShareStatusChangeNotify
void onRemoteShareStatusChangeNotify(HRTCConnection conn, String userId, boolean isRecving)
【功能说明】
上报下行辅流状态变化通知,接收端探测网络变化,分配给下行辅流,如果有辅流因为带宽不足被停掉或者带宽恢复而恢复,则上报给产品。
【回调参数】
conn: 连接对象。
userId:下行辅流对应的用户ID。
isRecving:是否接受。