简体中文

回调接口

iOS APIs - 回调接口 | TUTK P2P SDK 开发指南

KY_SetDelegate

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

接口定义

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

参数说明

参数类型说明
delegateid _Nullable实现了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;

参数说明

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

参数类型说明
uidNSString *当前设备的uid
statusKYDeviceState连线状态。详细定义参考:KYStatus 枚举
errorCodeNSIntegerP2P SDK错误码

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

参数类型说明
uidNSString *当前设备的uid
channelNSInteger设备连线的channel(默认为0)
statusKYDeviceState连线状态。详细定义参考:KYStatus 枚举
errorCodeNSIntegerP2P SDK错误码

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

参数类型说明
uidNSString *当前设备的uid
channelNSInteger设备连线的channel(默认为0)
statusNSInteger连线状态。详细定义参考:KYStatus 枚举
errorCodeNSIntegerP2P SDK错误码

Bind状态回调:

参数类型说明
uidNSString *当前设备的uid
statusNSIntegerbind结果。0 成功,other 失败
credentialNSString *连线credential值
errorCodeNSIntegerP2P SDK错误码

上抛采集到的yuv数据:

参数类型说明
uidNSString *当前设备的uid
dataNSData *采集后的yuv数据
timestampuint64_t时间戳
channelNSIntegerav通道

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

参数类型说明
uidNSString *当前设备的uid
isSuccessBOOL是否建立成功
errorCodeNSInteger错误码 (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;

参数说明

参数类型说明
uidNSString *当前设备的uid
isSuccessBOOL是否建立成功

KY_StartListenSuccess

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

接口定义

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

参数说明

参数类型说明
uidNSString *当前设备的uid
isSuccessBOOL是否建立成功

返回码

暂无

KY_UpdateDecodedImage

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

接口定义

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

参数说明

参数类型说明
uidNSString *当前设备的uid
channelNSInteger设备连线的channel(默认为0)
timestampint64_t当前解码成功的帧时间戳
imageUIImage * _Nullable解码成功产生的UIImage

KY_DecodeVideoFramInfo

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

接口定义

- (void)KY_DecodeVideoFramInfo:(NSString * _Nonnull)uid channel:(NSInteger)channel connectMode:(NSInteger)connectMode videoWidth:(NSInteger)videoWidth videoHeight:(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 cmdReturn:(NSInteger)cmdReturn;

注:原始文档中接口定义存在重复参数 `videoWidth`,已修正为 `videoHeight`。

参数说明

参数类型说明
uidNSString *当前设备的uid
channelNSInteger设备连线的channel,默认为0
connectModeNSInteger连线模式 (-1:NONE,0:P2P,1:RELAY,2:LAN)
videoWidthNSInteger视频宽
videoHeightNSInteger视频高
fpsNSIntegerfps
videoBpsNSInteger视频bps
audioBpsNSInteger音频bps
onlineNumNSInteger在线人数
frameCountNSInteger帧数
incompleteFrameCountNSInteger丢帧数
isHWDecodeBOOL是否是硬解
sessionIDNSInteger连线返回的session号
avIndexNSInteger开启通道返回的av通道
cmdNumNSIntegercommand指令类型值
cmdReturnNSIntegercommand指令返回值

注:原始表格中参数 `onlineNm` 和 `avChannelIndex` 与接口定义不一致,已根据接口定义修正为 `onlineNum` 和 `avIndex`。

KY_DidReceiveIOCtrlWithUid

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

接口定义

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

参数说明

参数类型说明
uidNSString *当前设备的uid
channelNSInteger设备连线的channel,默认为0
typeENUM_AVIOCTRL_MSGTYPEcommand指令类型,AVIOCTRLDEFs.h
dataNSData *command对应指令的结构体数据

KY_startVideoToDevice

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

接口定义

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

参数说明

参数类型说明
previewViewUIView *预览视图
previewFormatPreviewFormat编码格式
channelNSInteger通道号
obScreenNSObject *屏幕显示对象

代码示例

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;

参数说明

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

代码示例

[self.camera KY_stopVideoToDevice:self.selectChannel];

KY_preview_switchCamera

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

接口定义

- (void)TK_preview_switchCamera:(AVCaptureDevicePosition)positon;

注:接口命名为 `TK_preview_switchCamera`,可能是一个笔误,应为 `KY_preview_switchCamera`。

参数说明

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

代码示例

[self.camera TK_preview_switchCamera:AVCaptureDevicePositionFront];

KY_preview_changePreviewFormat

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

接口定义

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

参数说明

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

代码示例

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;

参数说明

参数类型说明
avChannelNSIntegerav通道号
isSendVideoBOOL发送上抛

代码示例

[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;

参数说明

参数类型说明
videoDataNSData *视频数据
lengthNSInteger视频数据长度
codecNSInteger视频编码格式
isKeyFrameBOOL是否是关键帧
channelNSIntegerav通道

代码示例

[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;

参数说明

参数类型说明
uidNSString *当前设备的uid
fileNameNSString *文件名称
progressNSInteger文件传输进度
typeFILETransferType传输方式。详细定义参考:KYTransferType 枚举
resultNSInteger传输结果
channelNSInteger通道号

即刻开启您的物联网之旅

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

+86 755 27702549

7×24小时服务热线

法律声明 隐私权条款

关注“TUTK”

TUTK服务尽在掌握

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

TUTK服务尽在掌握

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

返回顶部