简体中文

回调接口

iOS APIs-回调接口

更新日期:2025/5/13


目录


回调接口

KY_SetDelegate


功能描述:
注册/反注册监听回调接口。


接口定义


- (void)KY_SetDelegate:(id _Nullable)delegate;
				


参数说明

参数 类型 说明
delegate 实现了KYCameraDelegate协议的类,nil为反注册


KY_DeviceStatus


功能描述:
指定通道的连线状态回调。


接口定义


指定通道的连线状态回调:
- (void)KY_DeviceStatus:(NSString *)uid  Status:(KYDeviceState)status errorCode:(NSInteger)errorCode;
				



指定通道的连线状态回调(指定通道):
- (void)KY_DeviceStatus:(NSString *)uid withChannel:(NSInteger)channel ChannelStatus:(KYDeviceState)status errorCode:(NSInteger)errorCode;
				



指定通道的连线状态回调 (调试模式):
- (void)KY_DeviceStatus:(NSString *)uid withChannel:(NSInteger)channel debugChannelStatus:(NSInteger)status errorCode:(NSInteger)errorCode;
				



Bind状态回调:
- (void)KY_DeviceStatus:(NSString *)uid didChangeBindStatus:(NSInteger)status credentialInfo:(NSString *)credential errorCode:(NSInteger)errorCode;
				



上抛采集到的yuv数据:
- (void)KY_outPutVideoData:(NSString *)uid data:(NSData *)data timestamp:(uint64_t)timestamp channel:(NSInteger)channel;
				



视频发送通道建立的回调:
- (void)KY_sendVideoSuccess:(NSString *)uid isSuccess:(BOOL)isSuccess ErrorCode:(NSInteger) errorCode;
				


参数说明

指定通道的连线状态回调:

参数 类型 说明
uid string 当前设备的uid
status int 连线状态。详细定义参考:KYStatus 枚举
errorCode int P2P SDK错误码


指定通道的连线状态回调(指定通道):

参数 类型 说明
uid string 当前设备的uid
channel int 设备连线的channel(默认为0)
status int 连线状态。详细定义参考:KYStatus 枚举
errorCode int P2P SDK错误码


指定通道的连线状态回调 (调试模式):

参数 类型 说明
uid string 当前设备的uid
channel int 设备连线的channel(默认为0)
status int 连线状态。详细定义参考:KYStatus 枚举
errorCode int P2P SDK错误码


Bind状态回调:

参数 类型 说明
uid string 当前设备的uid
status int bind结果。0 成功,other 失败
credential string 连线credential值
errorCode int P2P SDK错误码


上抛采集到的yuv数据:

参数 类型 说明
uid string 当前设备的uid
data 采集后的yuv数据
timestamp int64 时间戳
channel int av通道


视频发送通道建立的回调:

参数 类型 说明
uid string 当前设备的uid
isSuccess boolean 是否建立成功
errorCode int 错误码 (success: >=0; fail: <0)


KYStatus 枚举

参数 说明
0 _NONE,初始化连线状态
1 _CONNECTING,设备连线中,未返回状态
2 _CONNECTED,设备已连线,返回状态>= 0
3 _DISCONNECTED,设备未连线,返回状态 -22 AV其它
4 _UNKNOWN_DEVICE,未知设备,返回状态 -15
5 _WRONG_PASSWORD,设备连线密码错误,返回状态 -20009
6 _TIMEOUT,设备连线超时,返回状态-13 -23 -20016 -20011
7 _UNSUPPORTED,不支持设备,返回状态-40
8 _CONNECT_FAILED,设备连线失败 其它
9 _UNKNOWN_LICENSE,设备uid未在license中,返回状态 -10
10 _SLEEP,设备睡眠状态
11 _DEVICE_MAX_SESSION,超过设备最大连线数,返回状态-48
12 _POOR_NETWORKSIGNAL,网络信号差,返回状态 -19 -42
13 _WRONG_AUTHKEY,authkey不正确,返回状态 -46 -68


KY_StartTalkSuccess


功能描述:
对讲通道建立成功的回调。


接口定义


- (void)KY_StartTalkSuccess:(NSString * _Nonnull)uid 
	isSuccess:(BOOL)isSuccess;
				


参数说明

参数 类型 说明
uid string 当前设备的uid
isSuccess boolean 是否建立成功


KY_StartListenSuccess


功能描述:
监听通道建立成功的回调。


接口定义


- (void)KY_StartListenSuccess:(NSString * _Nonnull)uid 
    isSuccess:(BOOL)isSuccess;
				


参数说明

参数 类型 说明
uid string 当前设备的uid
isSuccess boolean 是否建立成功

返回码

暂无


KY_UpdateDecodedImage


功能描述:
获取当前设备指定通道解码后的数据回调。


接口定义


- (void)KY_UpdateDecodedImage:(NSString * _Nonnull)uid 
	channel:(NSInteger)channel 
	timestamp:(int64_t)timestamp 
	image:(UIImage * _Nullable)image;
				


参数说明

参数 类型 说明
uid string 当前设备的uid
channel int 设备连线的channel(默认为0)
timeStamp int64 当前解码成功的帧时间戳
image 解码成功产生的UIImage


KY_DecodeVideoFramInfo


功能描述:
指定通道的视频宽高/fps/bps/在线人数/帧数/丢帧数等调试信息回调。


接口定义


- (void)KY_DecodeVideoFramInfo:(NSString * _Nonnull)uid 
	channel:(NSInteger)channel 
	connectMode:(NSInteger)connectMode 
	videoWidth:(NSInteger)videoWidth 
	videoWidth:(NSInteger)videoHeight 
	fps:(NSInteger)fps 
	videoBps:(NSInteger)videoBps 
	audioBps:(NSInteger)audioBps 
	onlineNum:(NSInteger)onlineNum 
	frameCount:(NSInteger)frameCount 
	incompleteFrameCount:(NSInteger)incompleteFrameCount 
	isHWDecode:(BOOL)isHWDecode 
	sessionID:(NSInteger)sessionID 
	avIndex:(NSInteger)avIndex 
	cmdNum:(NSInteger)cmdNum 
	cmdNum:(NSInteger)cmdReturn;
				


参数说明

参数 类型 说明
uid string 当前设备的uid
channel int 设备连线的channel,默认为0
connectMode int 连线模式 (-1:NONE,0:P2P,1:RELAY,2:LAN)
videoWidth int 视频宽
videoHeight int 视频高
fps int fps
videoBps int 视频bps
audioBps int 音频bps
onlineNm int 在线人数
frameCount int 帧数
incompleteFrameCount int 丢帧数
isHwDecode boolean 是否是硬解
sessionID int 连线返回的session号
avChannelIndex int 开启通道返回的av通道
cmdNum int command指令类型值
cmdReturn int command指令返回值


KY_DidReceiveIOCtrlWithUid


功能描述:
获取设备回复Command的数据信息回调。


接口定义


- (void)KY_DidReceiveIOCtrlWithUid:(NSString * _Nonnull)uid 
	channel:(NSInteger)channel 
	type:(ENUM_AVIOCTRL_MSGTYPE)type 
	data:(NSData * _Nonnull)data;
				


参数说明

参数 类型 说明
uid string 当前设备的uid
channel int 设备连线的channel,默认为0
type command指令类型,AVIOCTRLDEFs.h
data command对应指令的结构体数据


KY_startVideoToDevice


功能描述:
开始预览并发送视频数据。


接口定义


- (void)KY_startVideoToDevice:(UIView *)previewView
	previewFormat:(PreviewFormat)previewFormat
	channel:(NSInteger)channel
	ScreenObject:(NSObject*)obScreen;
				


参数说明

参数 类型 说明
previewView 预览视图
previewFormat 编码格式
channel int 通道号
obScreen object 屏幕显示对象


代码示例


PreviewFormat *format = (PreviewFormat *)malloc(sizeof(PreviewFormat));
format->resolution = PreviewResolution_Low;
format->fps = PreviewFPS_Low;
format->gop = PreviewGOP_Low;
format->orientation = AVCaptureVideoOrientationPortrait;
format->bitrate = PreviewBitRate_Low;

[self.camera KY_startVideoToDevice:self.preView previewFormat:*format channel:self.selectChannel ScreenObject:self];
				


KY_stopVideoToDevice


功能描述:
停止预览并发送视频数据。


接口定义


- (void)KY_stopVideoToDevice:(NSInteger)channel;
				


参数说明

参数 类型 说明
channel int 设备连线的channel,默认为0


代码示例


[self.camera KY_stopVideoToDevice:self.selectChannel];
				


KY_preview_switchCamera


功能描述:
切换前后摄像头。


接口定义


- (void)TK_preview_switchCamera:(AVCaptureDevicePosition)positon;
				


参数说明

参数 类型 说明
positon 设置摄像头


代码示例


[self.camera TK_preview_switchCamera:AVCaptureDevicePositionFront];
				


KY_preview_changePreviewFormat


功能描述:
更改采集的视频质量等级。


接口定义


- (void)KY_preview_changePreviewFormat:(PreviewFormat)previewFormat
	presetBlock:(PresetBlock)presetBlock;
				


参数说明

参数 类型 说明
previewFormat 编码格式
presetBlock 回调是否支持


代码示例


PreviewFormat *format = (PreviewFormat *)malloc(sizeof(PreviewFormat));
format->resolution = PreviewResolution_Low;
format->fps = PreviewFPS_Low;
format->gop = PreviewGOP_Low;
format->orientation = AVCaptureVideoOrientationPortrait;
format->bitrate = PreviewBitRate_Low;

[self.camera KY_preview_changePreviewFormat:format presetBlock:^{
}];
				


KY_isVideoOutputavChannel


功能描述:
采集视频数据上抛。


接口定义


- (void)KY_isVideoOutputavChannel:(NSInteger)avChannel
    isSendVideo:(BOOL)isSendVideo;
				


参数说明

参数 类型 说明
avChannel int av通道号
isSendVideo boolean 发送上抛


代码示例


[self.camera KY_isVideoOutputavChannel:0 isSendVideo:YES];
				


KY_sendVideo


功能描述:
client端开启发送视频。


接口定义


- (void) KY_sendVideo:(NSData *)videoData
	Length:(NSInteger)length
	Codec:(NSInteger)codec
	isKeyFrame:(BOOL)isKeyFrame
	channel:(NSInteger)channel;
				


参数说明

参数 类型 说明
videoData 视频数据
length int 视频数据长度
codec int 视频编码格式
isKeyFrame boolean 是否是关键帧
channel int av通道


代码示例


[self.camera KY_sendVideo:data Length:data.length Codec:MEDIA_CODEC_VIDEO_H264 isKeyFrame:isKeyFrame channel:channell];
				


KY_downloadUploadWithUid


功能描述:
输出文件下载或上传的数据结果。


接口定义


- (void)KY_downloadUploadWithUid:(NSString *)uid fileName:(NSString *)fileName progress:(NSInteger)progress loadType:(FILETransferType)type result:(NSInteger)result channel:(NSInteger)channel;
				


参数说明

参数 类型 说明
uid string 当前设备的uid
fileName string 文件名称
progress int 文件传输进度
type 传输方式。详细定义参考:传输方式。详细定义参考:KYTransferType 枚举
result int 传输结果
channel int 通道号


即刻开启您的物联网之旅

联系解决方案专家
Kalay App
解决方案
新闻动态
公司动态
行业资讯
媒体报道
永续发展
经营者的话
社会参与
环境永续
公司治理

+86 755 27702549

7×24小时服务热线

法律声明 隐私权条款

关注“TUTK”

TUTK服务尽在掌握

© 2022 物联智慧科技(深圳)有限公司版权所有粤ICP备14023641号
在线咨询
扫一扫

TUTK服务尽在掌握

全国免费服务热线
+86 755 27702549

返回顶部