事件回调
本章节介绍了iOS SDK的回调接口HWRtcEngineDelegate的详情。
接口 |
描述 |
---|---|
成功加入房间回调 |
|
加入房间失败回调 |
|
重新加入房间成功回调 |
|
离开房间回调 |
|
用户加入房间回调 |
|
用户离开房间回调 |
|
引擎收到第一帧远端视频流并解码成功回调 |
|
用户角色切换成功回调 |
|
连接状态改变回调 |
|
错误回调 |
|
签名过期回调 |
|
设备状态改变回调(仅macOS) |
|
音频音量改变回调(仅macOS) |
|
音频路由改变回调(仅iOS) |
|
日志上传结果回调 |
|
日志上传进度回调 |
|
远端用户音频流状态改变回调 |
|
远端用户视频流状态改变回调 |
|
音频订阅状态回调 |
|
播放音频文件状态回调 |
|
停止播放音频文件回调 |
|
暂停播放音频文件回调 |
|
恢复播放音频文件回调 |
|
渲染视频帧回调 |
|
渲染音频帧回调 |
|
入会前网络检测状态回调 |
|
入会前网络检测质量状态回调 |
|
开启跨房回调 |
|
结束跨房回调 |
|
视频流详情,2s触发一次回调 |
|
音频流详情,2s触发一次回调 |
|
辅流流详情,2s触发一次回调 |
|
辅流状态回调 |
onJoinSuccess
-(void)onJoinSuccess:(NSString*)roomId userId:(NSString*)userId;
【功能说明】
成功加入房间,触发此回调。
- roomId :房间ID
- userId:用户ID。
onRejoinRoomSuccess
- (void)onRejoinRoomSuccess:(NSString *)roomid userid:(NSString *)userid;
【功能说明】
重新加入房间成功,触发此回调。
- roomid:房间ID。
- userid: 用户ID。
onLeaveRoom
- (void)onLeaveRoom:(HWRtcLeaveReason)leaveReason statsInfo:(HWRtcStatsInfo *)statsInfo;
【功能说明】
离开房间,触发此回调。
- leaveReason : 具体请参见HWRtcLeaveReason
- statsInfo:具体请参见HWRtcStatsInfo
【注意事项】
onUserJoined
- (void)onUserJoined:(NSString*)roomId userId:(NSString*)userId userName:(NSString*)userName;
【功能说明】
远端用户加入房间成功,触发此回调。该回调提示有远端用户加入了房间,并返回新加入用户信息。
【回调参数】
- roomId :房间ID。
- userId:用户ID。
- userName:用户昵称。
onUserOffline
- (void)onUserOffline:(NSString*)roomId userId:(NSString*)userId reason:(NSInteger)reason;
【功能说明】
远端用户离开当前房间,触发此回调。
- roomId :房间ID。
- userId:用户ID。
- reason:预留。
onFirstRemoteVideoDecoded
- (void)onFirstRemoteVideoDecoded:(NSString*)roomId userId:(NSString*)userId width:(int)width height:(int)height;
【功能说明】
引擎收到第一帧远端视频流并解码成功回调。
- roomId: 房间ID。
- userId :用户ID。
- width :视频流宽度。
- height :视频流高度。
onUserRoleChanged
- (void)onUserRoleChanged:(NSString * _Nonnull)roomid oldRole:(HWRtcRole)oldRole newRole:(HWRtcRole)newRole;
【功能说明】
用户房间内角色切换成功,触发此回调。
onConnStateChange
- (void)onConnStateChange:(HWRtcConnStateType)state reason:(HWRtcConnChangeReason)reason description:(NSString*)description;
【功能说明】
网络连接状态发生变化,触发此回调。
- state :网络连接状态,具体请参见HWRtcConnStateType。
- reason:网络连接状态发生变化原因,具体请参见HWRtcConnChangeReason。
- description:错误原因描述。
onError
- (void)onError:(NSString*)errorCode errorMsg:(NSString*)errorMsg;
【功能说明】
发生错误,触发此回调。返回客户端错误码或者服务端错误码。
- errorCode :错误码。
- errorMsg :错误信息。
onDeviceStateChanged
- (void)onDeviceStateChanged:(NSString*)deviceId deviceType:(HWRtcDeviceType)deviceType deviceState:(HWRtcDeviceState)deviceState;
【功能说明】
设备状态发生变化,触发此回调。
- deviceId:设备ID,系统音频播放设备标识可通过getPlaybackDevices获取。
- deviceType:设备类型,具体请参见HWRtcDeviceType。
- deviceState:设备状态,具体请参见HWRtcDeviceState。
【注意事项】
仅支持macOS。
onAudioVolumeChanged
- (void)onAudioVolumeChanged:(HWRtcDeviceType)deviceType volume:(unsigned int)volume;
【功能说明】
音频音量改变,触发此回调。
- deviceType :设备类型,具体请参见HWRtcDeviceType。
- volume:音量
【注意事项】
仅支持macOS。
onAudioRouteChange
- (void)onAudioRouteChange:(HWRtcAudioRoute)audioRoute;
【功能说明】
音频路由发生改变,触发此回调。如房间内插拔耳机触发此回调。
【回调参数】
audioRoute:音频路由类型,具体请参见HWRtcAudioRoute。
【注意事项】
仅支持iOS。
onLogUploadProgress
- (void)onLogUploadProgress:(int)progress;
【功能说明】
日志上传进度回调。
【回调参数】
progress:日志上传进度,取值范围0-100。
onRemoteAudioStateChange
- (void)onRemoteAudioStateChange:(NSString * _Nonnull)roomid userid:(NSString * _Nonnull)userid state:(HWRtcRemoteAudioState)state reason:(HWRtcRemoteAudioStateReason)reason;
【功能说明】
远端用户音频流状态发生改变,会触发此回调。
- roomid:房间ID。
- userid:用户ID。
- state:远端音频流状态,具体请参见HWRtcRemoteAudioState。
- reason:远端音频流状态改变的原因,具体请参见HWRtcRemoteAudioStateReason。
onRemoteVideoStateChange
- (void)onRemoteVideoStateChange:(NSString * _Nonnull)roomid userid:(NSString * _Nonnull)userid state:(HWRtcRemoteVideoState)state reason:(HWRtcRemoteVideoStateReason)reason;
【功能说明】
远端用户视频流状态发生改变,会触发此回调。
- roomid:房间ID。
- userid :用户ID。
- state:远端视频流状态,具体请参见HWRtcRemoteVideoState。
- reason:远端视频流状态改变的原因,具体请参见HWRtcRemoteVideoStateReason。
onUserVolumeStats
- (void)onUserVolumeStats:(NSArray <HWRtcMediaUsersVolumeInfo *> *_Nullable)usersVolumeArray userNumber:(NSUInteger)userNumber totalVolume:(NSUInteger)totalVolume;
【功能说明】
音频订阅状态回调,包括总音量以及各发言人及其对应音量上报显示回调
- usersVolumeArray:回调发言人音量信息,具体请参见HWRtcMediaUsersVolumeInfo。
- userNumber:上报的发言人人数,最多上报4人,包含本地用户。
- totalVolume:总音量。
onStartAudioFile
- (void)onStartAudioFile:(BOOL)isSuccess
【功能说明】
播放音频文件状态回调。
【回调参数】
isSuccess:YES表示播放成功,NO表示播放失败。
onStopAudioFile
- (void)onStopAudioFile:(BOOL)isSuccess
【功能说明】
停止播放音频文件回调。
【回调参数】
isSuccess:YES表示停止播放成功,NO表示停止播放失败。
onPauseAudioFile
- (void)onPauseAudioFile:(BOOL)isSuccess
【功能说明】
暂停播放音频文件回调。
【回调参数】
isSuccess:YES表示暂停播放成功,NO表示暂停播放失败。
onResumeAudioFile
- (void)onResumeAudioFile:(BOOL)isSuccess
【功能说明】
恢复播放音频文件回调。
【回调参数】
isSuccess:YES表示恢复播放成功,NO表示恢复播放失败。
onRenderVideoFrame
- (void)onRenderVideoFrame:(NSString *_Nonnull)roomid meidaDirection:(HWRTCMediaDirection)meidaDirection videoFrame:(HWRtcVideoFrame * _Nonnull)videoFrame;
【功能说明】
渲染视频帧回调。
- roomid:房间ID。
- meidaDirection:媒体方向,具体请参见HWRTCMediaDirection。
- videoFrame:视频帧,具体请参见HWRtcVideoFrame。
onPlaybackAudioFrame
- (void)onPlaybackAudioFrame:(NSString *_Nonnull)roomid meidaDirection:(HWRTCMediaDirection)meidaDirection audioFrame:(HWRtcAudioFrame * _Nonnull)audioFrame;
【功能说明】
音频自渲染回调。需要调用setExternalAudioFrameOutput接口开启音频自渲染,从而触发该回调。
- roomid :房间ID。
- meidaDirection:数据源(本地/远端数据),具体请参见HWRTCMediaDirection。
- audioFrame:音频帧,具体请参见HWRtcAudioFrame。
onNetworkTestResult
- (void)onNetworkTestResult:(HWRTCNetworkTestResult * _Nonnull)result;
【功能说明】
入会前网络检测状态回调。
【回调参数】
HWRTCNetworkTestResult :回调状态主要包括测试成功与否、上行和下行的网络带宽、丢包、延时和抖动,具体请参见HWRTCNetworkTestResult。
onNetworkTestQuality
- (void)onNetworkTestQuality:(int)level;
【功能说明】
入会前网络质量检测回调。
【回调参数】
level:检测网络质量 1-4级,4级网络质量最好。
onConnectOtherRoom
- (void)onConnectOtherRoom:(NSString * _Nonnull)roomId role:(HWRtcRole)role errorCode:(int)errorCode msg:(NSString * _Nonnull)msg;
【功能说明】
开启跨房回调。
【回调参数】
- roomId :房间ID。
- role:角色,具体请参见HWRtcRole。
- errorCode:错误码。
- msg:错误描述。
onDisconnectOtherRoom
- (void)onDisconnectOtherRoom:(NSString * _Nonnull)roomId role:(HWRtcRole)role errorCode:(int)errorCode msg:(NSString * _Nonnull)msg;
【功能说明】
结束跨房回调。
【回调参数】
- roomId :房间ID。
- role:角色,具体请参见HWRtcRole。
- errorCode:错误码。
- msg:错误描述。
onVideoStats
- (void)onVideoStats:(NSArray <HWRtcVideoStatsInfo *> * _Nullable)videoStatsArray remoteVideoInfo:(NSArray <HWRtcVideoStatsInfo *>* _Nullable)remoteVideoStatsInfos;
【功能说明】
视频流详情,2s触发一次回调。
- videoStatsArray :本地视频发流详情,具体请参见HWRtcVideoStatsInfo。
- remoteVideoStatsInfo:远端视频收流详情,具体请参见HWRtcVideoStatsInfo。
onAudioStats
- (void)onAudioStats:(NSArray <HWRtcAudioStatsInfo *> * _Nullable)audioStatsArray remoteAudioInfo:(NSArray <HWRtcAudioStatsInfo *> * _Nullable)remoteAudioStatsInfos;
【功能说明】
音频流详情,2s触发一次回调。
【回调参数】
- audioStatsArray :本地音频发流详情,具体请参见HWRtcAudioStatsInfo。
- remoteAudioStatsInfos:远端音频收流详情,具体请参见HWRtcAudioStatsInfo。
onSubStreamStats
- (void)onSubStreamStats:(NSArray <HWRtcVideoStatsInfo *> * _Nullable)subStreamStatsArray remoteVideoInfo:(NSArray <HWRtcVideoStatsInfo *> * _Nullable)remoteVideoStatsInfos;
【功能说明】
共享流详情,2s触发一次回调。
【回调参数】
- subStreamStatsArray :本地共享流发流详情,具体请参见HWRtcVideoStatsInfo。
- remoteVideoStatsInfos:远端共享流收流详情,具体请参见HWRtcVideoStatsInfo。
