Kalay1.0标准-升级版PSC

Kalay1.0 升级版PSC


IOS API

[TOC]

一、IOTCamera

1.1 初始化接口

> 注:调用TK_initIOTC时返回-10000, 是因为privateKey无效导致,遇到该问题时建议:

  • 确认当前项目使用的包名与privateKey是否与TUTK提供的一致,如不一致,请修改为TUTK提供的包名与privateKey重新运行;
  • 如需更改包名与privateKey,请联系商务或者技术支持人员。

TK_InitIOTCWithLiceseKey

 功能:IOTC初始化,确认privateKey和sdkLicensekey的合法性
 两个Key值需要向TUTK申请
/**
 IOTC初始化

@param licenseKey SDK初始化的Key值
@param privateKey PSC初始化的Key值
@param success 验证成功
@param failure 验证失败
*/
+ (void)TK_InitIOTCWithLiceseKey:(NSString *)licenseKey
                                  privateKey:(NSString *)privateKey
                                       success:(void (^)(void))success
                                        failure:(void (^)(NSError *error))failure;
示例:
     [Camera TK_InitIOTCWithLiceseKey:LICENSEKEY 
                                         privateKey:PRIVATEKEY
                                              success:^{
     } 
                                              failure:^(NSError *error) {
        if (error.code == TUTK_ER_INVALID_ARG) {
            NSLog(@"TK_InitIOTC:false(TUTK_ER_INVALID_ARG)");
        }else if (error.code == TUTK_ER_INVALID_LICENSE_KEY) {
            NSLog(@"TK_InitIOTC:false(TUTK_ER_INVALID_LICENSE_KEY)");
        }else if (error.code == TUTK_ER_MEM_INSUFFICIENT) {
            NSLog(@"TK_InitIOTC:false(TUTK_ER_MEM_INSUFFICIENT)");
        }
    }];

> 注:调用TK_InitIOTCWithLiceseKey时返回-10000, 是因为privateKey无效导致,遇到该问题时建议:

  • 确认当前项目使用的包名与privateKey是否与TUTK提供的一致,如不一致,请修改为TUTK提供的包名与privateKey重新运行;
  • 如需更改包名与privateKey,请联系商务或者技术支持人员。

TK_uninitIOTC

/**
 IOTC反初始化
 */
+ (void)TK_uninitIOTC;
示例:
    [Camera TK_uninitIOTC];

TK_initWithName

/**
 初始化Camera

 @param name camera名称
 @return Camera初始化后的实例对象
 */
- (id)TK_initWithName:(NSString *)name;
示例:
    self.myCamera = [[MyCamera alloc] TK_initWithName:name];

TK_getIOTCameraVersion

/**
 获取IOTCamera版本号

 @return IOTCamera版本号
 */
+ (NSString *)TK_getIOTCameraVersion;
示例:
    [Camera TK_getIOTCameraVersion];

TK_getIOTCAPIsVersion

/**
 获取IOTCAPIs版本号

 @return IOTCAPIs版本号
 */
+ (NSString *)TK_getIOTCAPIsVersion;
示例:
    [Camera TK_getIOTCAPIsVersion];

TK_getAVAPIsVersion

/**
 获取AVAPIs版本号

 @return AVAPIs版本号
 */
+ (NSString *)TK_getAVAPIsVersion;
示例:
    [Camera TK_getAVAPIsVersion];

TK_setMasterRegion: (TKRegion) regin

/**
 设置分区分流方案的地区
 @param regin 设置分流到TKRegion中的哪个地区
 @return TKRegionResult  设置返回值参照下方结构体TKRegionResult
 */
+ (TKRegionResult) TK_setMasterRegion: (TKRegion) regin;

typedef NS_ENUM(NSInteger, TKRegion) 
{
    TKREGION_ALL,
    TKREGION_CN,
    TKREGION_EU,
    TKREGION_US ,
};

typedef NS_ENUM(NSInteger, TKRegionResult) 
{
    TKREGION_ER_NoERROR                     = 0,//set success
    TKREGION_ER_INVALID_ARG                = -46,//the region is invalid
    TKREGION_ER_ALREADY_INITIALIZED   = -3,//IOTC module is already initialized
};
示例:
    [Camera TK_setMasterRegion:TKREGION_CN];

1.2 回调接口

1.2.1 P2PDelegate

didChangeSessionStatus

/**
连线状态回调
 @param camera camera对象
 @param status session连线结果 0 成功 other 失败
 @param errorCode TK_connect连线返回结果 >=0 成功 , other 失败
 */
- (void)camera:(Camera *)camera didChangeSessionStatus:(NSInteger)status errorCode:(NSInteger)errorCode;

didChangeChannelStatus

/**
 指定通道的连线状态回调

 @param camera camera对象
 @param channel av通道
 @param status 连线状态
 @param errorCode TK_start av通道返回结果 0 成功 , other 失败
 */
- (void)camera:(Camera *)camera didChangeChannelStatus:(NSInteger)channel ChannelStatus:(NSInteger)status errorCode:(NSInteger)errorCode;

didChangeBindStatus

/**
Bind状态回调

@param camera camera对象
@param status bind结果 0 成功 other 失败
@param credential 连线credential值
@param errorCode TK_nebulaBind返回结果 >=0 成功 , other 失败
*/
- (void)camera:(Camera *)camera didChangeBindStatus:(NSInteger)status credentialInfo:(NSString *)credential errorCode:(NSInteger)errorCode;

didSendIOCtrlWithType

/**
 指定通道指令发送回调
 @param camera camera对象
 @param type 指令类型
 @param data 指令数据
 @param size 指令数据长度
 @param channel av通道
 @param errorCode 返回错误码
 */
- (void)camera:(Camera *)camera didSendIOCtrlWithType:(NSInteger)type Data:(const char*)data DataSize:(NSInteger)size Channel:(NSInteger)channel errorCode:(NSInteger)errorCode;

didReceiveIOCtrlWithType

/**
 指定通道指令接收回调

 @param camera camera对象
 @param type 指令类型
 @param data 指令数据
 @param size 指令数据长度
 @param channel av通道
 */
- (void)camera:(Camera *)camera didReceiveIOCtrlWithType:(NSInteger)type Data:(const char*)data DataSize:(NSInteger)size Channel:(NSInteger)channel;

didRecvVideoChannel

/**
指定通道的视频数据接收错误码

  @param camera camera对象 @param channel av通道 @param errorCode avRecvFrameData2 返回结果 大于0 成功 , other 失败 */

  • (void)camera:(Camera *)camera didRecvVideoChannel:(NSInteger)channel errorCode:(NSInteger)errorCode;

didRecvAudioChannel

/**
指定通道的音频数据接收错误码
 @param camera camera对象
 @param channel av通道
 @param errorCode avRecvAudioData av通道返回结果 大于0 成功 , other 失败
 */
- (void)camera:(Camera *)camera didRecvAudioChannel:(NSInteger)channel errorCode:(NSInteger)errorCode;

didStartTalkSuccess

/**
 对讲通道建立成功的回调

 @param camera camera对象
 @param isSuccess 是否建立成功
 @param errorCode 错误码
 */
- (void)camera:(Camera *)camera didStartTalkSuccess:(BOOL)isSuccess ErrorCode:(NSInteger) errorCode;

didStartListenSuccess

/**
 监听通道建立成功的回调

 @param camera camera对象
@param isSuccess 是否建立成功
@param channel av通道
*/
- (void)camera:(Camera *)camera didStartListenSuccess:(BOOL)isSuccess Channel:(NSInteger)channel;

连线状态status

CONNECTION_STATE_NONE = 0; //初始化连线状态
CONNECTION_STATE_CONNECTING = 1; //设备连线中
CONNECTION_STATE_CONNECTED = 2; //设备已连线 >= 0
CONNECTION_STATE_DISCONNECTED = 3; //设备未连线 -22 AV其它
CONNECTION_STATE_UNKNOWN_DEVICE = 4; //未知设备 -15
CONNECTION_STATE_WRONG_PASSWORD = 5; //设备连线密码错误-20009
CONNECTION_STATE_TIMEOUT = 6; //设备连线超时 IOTC -13 -23 AV -20016 -20011
CONNECTION_STATE_UNSUPPORTED = 7; //不支持设备 -40
CONNECTION_STATE_CONNECT_FAILED = 8; //设备连线失败 IOTC其它
CONNECTION_STATE_UNKNOWN_LICENSE = 9; //设备uid未在license中 -10
CONNECTION_STATE_SLEEP = 10; //设备睡眠状态 -64
CONNECTION_STATE_DEVICE_MAX_SESSION   = 11; //超过设备最大连线数 -48
CONNECTION_STATE_POOR_NETWORKSIGNA = 12; //网络信号差 返回状态 -19 -42
CONNECTION_STATE_WRONG_AUTHKEY        = 13      //authKey错误 返回状态 -46 -68

1.2.2 MediaDelegate

didReceiveFrameInfoWithChannel

/**
 指定通道的视频宽高/fps/bps/在线人数/帧数/丢帧数等调试信息回调

 @param camera camera对象
 @param channel av通道
 @param videoWidth 视频宽
 @param videoHeight 视频高
 @param fps fps
 @param videoBps 视频bps
 @param audioBps 音频bps
 @param onlineNm 在线人数
 @param frameCount 帧数
 @param incompleteFrameCount 丢帧数
 @param isHwDecode 是否是硬解
 */
- (void)camera:(Camera *)camera didReceiveFrameInfoWithChannel:(NSInteger)channel videoWidth:(NSInteger)videoWidth VideoHeight:(NSInteger)videoHeight VideoFPS:(NSInteger)fps VideoBPS:(NSInteger)videoBps AudioBPS:(NSInteger)audioBps OnlineNm:(NSInteger)onlineNm FrameCount:(unsigned int)frameCount IncompleteFrameCount:(unsigned int)incompleteFrameCount isHwDecode:(BOOL)isHwDecode;

onDecodeResultWithFrameNum

/**
 当前解码结果相关信息回调

 @param camera camera对象
 @param frameNum         当前frame的Number
 @param isDecodeSuccess  是否解码成功
 @param isDropFrame      是否丢掉当前frame
 @param isIFrame         是否为I帧
 @param isSoft           是否为软解
 */
- (void)camera:(Camera *)camera onDecodeResultWithFrameNum:(NSInteger)frameNum IsDecodeSuccess:(BOOL)isDecodeSuccess IsDropFrame:(BOOL)isDropFrame IsIFrame:(BOOL)isIFrame IsSoft:(BOOL)isSoft;

outputDecodeVideoYUVData

/**
上抛指定通道解码后的yuv数据格式为i420

 @param camera camera对象
 @param data      解码后的yuv数据
 @param outWidth  解码后的数据宽度
@param outHeight 解码后的数据高度
 @param timestamp 时间戳
 @param channel av通道
 */
- (void)camera:(Camera *)camera outputDecodeVideoYUVData:(NSData *)data width:(int)outWidth height:(int)outHeight  timestamp:(uint64_t)timestamp channel:(NSInteger)channel;

didReceiveFrameData

/**
 指定通道接收的视频帧数据回调

 @param camera camera对象
 @param frameData 视频帧数据
 @param size 视频帧数据长度
 @param infoData 视频帧数据信息
 @param channel av通道
 */
    - (void)camera:(Camera *)camera didReceiveFrameData:(const char *)frameData DataSize:(unsigned int)size FrmInfo:(NSData *)infoData Channel:(NSInteger)channel;

didReceiveAudioData

/**
 指定通道接收的音频帧数据回调

 @param camera camera对象
 @param data 音频帧数据
 @param size 音频帧数据长度
 @param infoData 音频帧数据信息
 @param channel av通道
 */
- (void)camera:(Camera *)camera didReceiveAudioData:(const char *)data DataSize:(unsigned int)size FrmInfo:(NSData *)infoData Channel:(NSInteger)channel;

didreportCodecId

/**
 视频帧编码格式回调

 @param camera camera对象
 @param pointer 编码格式指针
 @param channel av通道
 */
- (void)camera:(Camera *)camera didreportCodecId:(NSValue *)pointer Channel:(NSInteger)channel;

didRecvAudioOutput

/**
 输出解码后的音频数据

 @param camera camera对象
 @param pcmData pcm音频数据
 @param channel av通道
 */
- (void)camera:(Camera *)camera didRecvAudioOutput:(NSData *)pcmData Channel:(int)channel;

didSendAudioOutput

/**
 输出Mic采集的音频数据

 @param camera camera对象
 @param audioData 音频数据
 @param length 音频数据长度
 @param codec 设备端音频编码格式
 @param channel av通道
 */
- (void)camera:(Camera *)camera didSendAudioOutput:(NSData *)audioData Length:(NSInteger)length Codec:(NSInteger)codec Channel:(NSInteger)channel;

1.3 连线接口

1.3.1 P2P

TK_connect

/**
开始连接设备
@param uid 设备UID
*/
- (void)TK_connect:(NSString *)uid;

/**
 开始连接设备

 @param uid 设备UID
 @param authKey 设备连线的key
 */
- (void)TK_connect:(NSString *)uid authKey:(NSString *)authKey;
示例:
    [self.camera TK_connect:@"device uid" authKey:@"device authKey"];

TK_LanSearch

/**
 搜索本地局域网内的设备

 @param num 搜索到设备的数量
 @param timeoutVal 搜索超时时间
 @return 搜索到的设备信息结构体
 */
+ (LanSearch_t *)TK_LanSearch:(int *)num timeout:(int)timeoutVal;
示例:
    [Camera TK_LanSearch:&num timeout:3000];

1.3.2 Nebula

TK_nebulaBind

/**
 Nebula bind设备
 @param udid 设备udid 40码
 @param bindType 绑定类型,PinCode\Credential\Local
 @param bindKey 与绑定类型相关,填入数据分别为pin code\ credential \ null
*/
- (void)TK_nebulaBind: (NSString *)udid bindType: (BINDTYPE )bindType bindKey: (NSString *)bindKey;
示例:
    [self.myControl TK_nebulaBind:uid bindType:AP_BIND bindKey:@"888888ii"];

TK_nebulaConnect

/**
Nebula 连线设备
 @param udid 设备udid 40码
 @param credential credential
 @param identity 认证码
 @param deviceToken 设备token
 @param realm realm
 @param isWakeup 是否自动唤醒
 @param isNebulaOnly 是否只支持Nebula
 */
- (void)TK_nebulaConnect: (NSString *)udid credential: (NSString *) credentia identity: (NSString *)identity deviceToken: (NSString *)deviceToken realm: (NSString *)realm isWakeup: (BOOL)isWakeup isNebulaOnly: (BOOL)isNebulaOnly;
示例:
    [self TK_nebulaConnect:uid credential:self.dev_credential deviceToken:TOKEN realm:REALM isWakeup:YES isNebulaOnly:YES];;
/**
Nebula 连线设备
 @param udid 设备udid 40码
 @param credential credential
 @param deviceToken 设备token
 @param realm realm  

  */

  • (void)TK_NebulaConnect: (NSString )udid credential: (NSString )credential deviceToken: (NSString )deviceToken realm: (NSString )realm;
示例:
    [self TK_nebulaConnect:uid credential:self.dev_credential deviceToken:TOKEN realm:REALM];

TK_NebulaLanSearchTimeout

/**
Nebula 局域网扫描设备
 @param timeout 超时时间
 @param responseBlock 搜索结果
 */
- (void)TK_nebulaLanSearchTimeout:(NSInteger)timeout responseBlock:(nonnull UDIDInfoBlock)responseBlock;
示例:
    [myCamera TK_nebulaLanSearchTimeout:5 responseBlock:^(st_UDIDInfo * _Nonnull uuidInfo, int num) {
                dispatch_async(dispatch_get_main_queue(), ^{
                    if (num <= 0) {
                        if (block) block(nil);
                        return;
                    }
                    NSDictionary *dict = @{
                        @"uid": [NSString stringWithFormat:@"%s",uuidInfo->udid],
                    };
                    [dataSource addObject:dict];
                    if (block) block(dataSource);
                    return;
                });
            }];

TK_nebulaSsidListReq

/**
 Nebula 获取设备ssid list
 @param max_ap_count 最大搜索数量
 @param responseBlock 搜索结果

  */

  • (void)TK_nebulaSsidListReq:(int)max_ap_count responseBlock:(ArrayBlock)responseBlock;
示例:
    [self.myCamera TK_nebulaSsidListReq:(int)maxCount responseBlock:^(NSArray * _Nonnull arr) {
        responseBlock(arr);
    }];

TK_nebulaSetWifiReq

/**
 Nebula 设置wifi
 @param ssid     Wifi名称
 @param password 密码
 @param enctype  加密类型
 */
- (void)TK_nebulaSetWifiReq:(NSString *)ssid password:(NSString *)password enctype:(int)enctype responseBlock:(DictionaryBlock)responseBlock;
示例:
    [self.myCamera TK_nebulaSetWifiReq:ssid password:password enctype:(int)enctype responseBlock:^(NSDictionary * _Nonnull dic) {
        responseBlock(dic);
    }];

TK_nebulaSetRegionReq

/**
Nebula 设置region
 @param region 区域设置
 @param responseBlock 结果回调

  */

  • (void)TK_nebulaSetRegionReq:(int)region responseBlock:(DictionaryBlock)responseBlock;
示例:
    [self TK_nebulaSetRegionReq:REGION_CN responseBlock:^(NSDictionary * _Nonnull dic) {
        responseBlock(dic);
    }];

1.3.3 共有接口

TK_disconnect

/**
 断开设备连线
 */
- (void)TK_disconnect;
示例:
    [self.camera TK_disconnect];

TK_start

/**
开启AV通道
@param channel av通道号
@param viewPassword 设备密码
*/
- (void)TK_start:(NSInteger)channel viewPassword:(NSString *)viewPassword;

/**
 开启AV通道

 @param channel av通道号
 @param viewAccount 设备用户名
 @param viewPassword 设备密码/token
 @param authType     设备密码验证类型
 @param mode  加密模式 SIMPLE(0), DTLS(1), AUTO(2);
 */
- (void)TK_start:(NSInteger)channel viewAccount:(NSString *)viewAccount viewPassword:(NSString *)viewPassword authType:(TKAuthType)authType securityMode:(AvSecurityMode)mode;
    示例:
    [self.myCamera TK_start:0 viewAccount:@"admin" viewPassword:@"000000" authType:TKAuthType_Password is_playback:FALSE];

TK_stop

/**
 关闭AV通道

 @param channel av通道号
 */
- (void)TK_stop:(NSInteger)channel;
    示例:[self.myCamera TK_stop:0];
#### TK_getConnectionStateOfChannel
/**
 获取指定通道的连线状态

 @param channel av通道
 @return 连线状态值
 */
- (NSInteger)TK_getConnectionStateOfChannel:(NSInteger)channel;
    示例:[self.myCamera TK_getConnectionStateOfChannel:0];

TK_getViewAccountOfChannel

/**
 获取指定通道的用户名

 @param channel 指定通道
 @return 获取的用户名
 */
- (NSString *)TK_getViewAccountOfChannel:(NSInteger)channel;
    示例:
    [self.myCamera TK_getViewAccountOfChannel:0];

TK_getViewPasswordOfChannel

/**
 获取指定通道的密码

 @param channel 指定通道
 @return 获取的密码
 */
- (NSString *)TK_getViewPasswordOfChannel:(NSInteger)channel;
    示例:
    [self.myCamera TK_getViewPasswordOfChannel:0];

TK_getServiceTypeOfChannel

/**
 获取指定通道的ServiceTYpe

 @param channel av通道
 @return serviceType值
 */
- (unsigned int)TK_getServiceTypeOfChannel:(NSInteger)channel;

typedef NS_ENUM(NSInteger, TKAuthType)
{
    TKAuthType_Password                  = 0,  //密码
    TKAuthType_Token                       = 1   //Token
};
    示例:
    [self.myCamera TK_getServiceTypeOfChannel:0];

1.4 视频处理接口

TK_StartAVFilterWithChannel

/**
 是否开启解码滤镜
 contrast 对比度-2.0-2.0间的浮点数,默认为0
 brightness 亮度-1.0-1.0间的浮点数,默认为0
 saturation 饱和度0-3.0间的浮点数,默认为1
 gamma 0.1-10.0间的浮点数,默认为1
 gamma_r   红色值必须是一个0.1-10.0间的浮点数,默认为1
 gamma_g   绿色值必须是一个0.1-10.0间的浮点数,默认为1
 gamma_b   蓝色值必须是一个0.1-10.0间的浮点数,默认为1
 @param channel av通道
 @param filterCMD 滤镜命令 (例:eq=contrast=0.9:brightness=0.1:saturation=1 )
 @param isOn 是否开启滤镜
 */
- (void)TK_StartAVFilterWithChannel:(NSInteger)channel filterCMD:(NSString *)filterCMD isOn:(BOOL)isOn
    示例:
    [myCamera TK_StartAVFilterWithChannel:selectedChannel
                                                        filterCMD:@"eq=contrast=0.9:brightness=0.1:saturation=1"
                                                                isOn:YES];

TK_startShow

/**
 开始接收、解码并显示画面

 @param channel av通道
 @param obScreen 屏幕显示对象
 */
- (void)TK_startShow:(NSInteger)channel ScreenObject:(NSObject*)obScreen;
    示例:
    [myCamera TK_startShow:0 ScreenObject:self];
/**
开始视频接收、解码并播放
@param channel av通道
@param obScreen 屏幕显示对象
@param isDecodeAndRender 是否解码并渲染
@param isSWDecode 是否软解
@param isDropFrame 是否丢P帧
@param type 输出数据类型
*/
- (void)TK_startShow:(NSInteger)channel ScreenObject:(NSObject*)obScreen isDecode:(BOOL)isDecodeAndRender isSWDecode:(BOOL)isSWDecode isDropFrame:(BOOL)isDropFrame renderType:(RENDERTYPE)type;

typedef NS_ENUM(NSInteger, RENDERTYPE)
{

    OUTPUT_EMPTY = 0,  //仅接收、解码、渲染,输出数据为空     OUTPUT_YUV = 1,   //接收、解码、渲染,并输出yuv数据(耗时)     OUTPUT_RGB_8888 = 2,//接收、解码、渲染,并输出RGB_8888数据(耗时)     OUTPUT_RGB_565 = 3//接收、解码、渲染,并输出RGB_565数据(耗时) };

    示例:
    [myCamera TK_startShow:0 ScreenObject:self isDecode:YES isSWDecode:YES isDropFrame:NO renderType:OUTPUT_YUV];

TK_stopShow

/**
 停止接收、解码和画面显示

 @param channel av通道
 */
- (void)TK_stopShow:(NSInteger)channel;
    示例:
    [self.myCamera TK_stopShow:0];

TK_getVideoCodecId

/**
 获取当前视频格式,在调用TK_StartShow并且出图后调用
 @param channel av通道
 */
- (NSInteger)TK_getVideoCodecId:(NSInteger)channel;
    示例:
    [self.myCamera TK_getVideoCodecId:0];

TK_setDecocdeDelayTime

/**
 设置最大延迟时间,调整解码每帧时间间隔

@param channel av通道 @param delayTime 最大延迟时间(ms) @param durationTime 解码时间间隔(ms) 0 ~ 30 */

  • (void)TK_setDecocdeDelayTime:(NSInteger)delayTime durationTime:(NSInteger)durationTime channel:(NSInteger)channel;

    示例:
    [self.camera TK_setDecocdeDelayTime:1500 durationTime:15 channel:0];

    1.5 音频处理接口

    TK_startSoundToPhone

    /** 开始接收、解码并监听设备声音

    @param channel av通道 */

  • (void)TK_startSoundToPhone:(NSInteger)channel;
    示例:
    [self.myCamera TK_startSoundToPhone:0];
/**
开始接收、解码并监听设备声音
@param channel av通道
@param isDecodeAndPlay 是否解码并播放
*/
    示例:
    [self.myCamera TK_startSoundToPhone:0 isDecodeAndPlay:YES];

TK_stopSoundToPhone

/**
 停止接收、解码和监听设备声音

 @param channel av通道
 */
- (void)TK_stopSoundToPhone:(NSInteger)channel;
    示例:
    [self.myCamera TK_stopSoundToPhone:0];

TK_startSoundToDevice

/**
 开始对讲(发送声音到设备)

 @param channel av通道
 @param isResend 是否开启重送
 */
- (void)TK_startSoundToDevice:(NSInteger)channel isResend:(BOOL)isResend;
    示例:
    [self.myCamera TK_stopSoundToPhone:0];
/**
开始对讲(发送声音到设备)

@param channel      av通道
@param isResend     是否开取重传
@param captureSize  手机端采集音频的大小
*/
- (void)TK_startSoundToDevice:(NSInteger)channel isResend:(BOOL)isResend captureSize:(NSInteger)captureSize;
    示例:
    [self.myCamera TK_startSoundToDevice:0 isResend:YES];
    示例:
    [self.myCamera TK_startSoundToDevice:0 isResend:YES captureSize:320];

TK_stopSoundToDevice

/**
 停止对讲

 @param channel av通道
 */
- (void)TK_stopSoundToDevice:(NSInteger)channel;
    示例:
    [self.myCamera TK_stopSoundToDevice:0];

TK_playAECAudio

/**
 播放回音消除后的音频数据

 @param aecData aec音频数据
 @param channel av通道
 */
- (void)TK_playAECAudio:(NSData *)aecData Channel:(NSInteger)channel;
    示例:
    [self.myCamera TK_playAECAudio:pcmData Channel:channel];

TK_sendAecAudio

/**
 发送回音消除后的音频数据

 @param aecAudioData aec音频数据
 @param length  aec音频数据长度
 @param codec 设备端音频编码格式
 @param channel av通道
 */
- (void)TK_sendAecAudio:(NSData *)aecAudioData Length:(NSInteger)length Codec:(NSInteger)codec Channel:(NSInteger)channel;
    示例:
    [self.myCamera TK_sendAecAudio:audioData Length:[audioData length] Codec:codec Channel:channel];

TK_startSendAudioChannel

/** 
开启对讲发送

  @param channel av通道
 */
- (void)TK_startSendAudioChannel:(NSInteger)channel;
    示例:
    [self.myCamera TK_startSendAudioChannel:1];

TK_stopSendAudioChannel

/** 
关闭对讲发送

 @param channel av通道
 @param isResend 是否重送
 */
- (void)TK_startSendAudioChannel:(NSInteger)channel isResend:(BOOL)isResend;
    示例:
    [self.myCamera TK_stopSendAudioChannel:1];

TK_setAudioSessionPlayMode

/** 
设置音频播放模式,默认为Speaker

 @param mode 播放模式 // TKAudioSessionPlayModeSpeaker | TKAudioSessionPlayModeReceiver
 */
- (void)TK_setAudioSessionPlayMode:(TKAudioSessionPlayMode)mode;
    示例:
    [self.myCamera TK_setAudioSessionPlayMode:TKAudioSessionPlayModeSpeaker];

TK_setAudioSpeakFormatsChannel

/** 
设置音频采集格式

 @param mChannel av通道
 @param mFormatID 音频格式 // ENUM_CODECID | MEDIA_CODEC_AUDIO_PCM
@param mSampleRate 采样率 // ENUM_AUDIO_SAMPLERATE | AUDIO_SAMPLE_8K
@param mChannelsPer 声道数 // ENUM_AUDIO_CHANNEL 0 | 1
 @param mBitsPer 采样点占用位数 // ENUM_AUDIO_DATABITS AUDIO_DATABITS_8 | AUDIO_DATABITS_16
 */
- (void)TK_setAudioSpeakFormatsChannel:(NSInteger)mChannel formatID:(ENUM_CODECID)mFormatID sampleRate:(ENUM_AUDIO_SAMPLERATE)mSampleRate channelsPer:(ENUM_AUDIO_CHANNEL)mChannelsPer bitsPer:(ENUM_AUDIO_DATABITS)mBitsPer;
    示例:
    [self.myCamera TK_setAudioSpeakFormatsChannel:0 formatID:MEDIA_CODEC_AUDIO_PCM sampleRate:AUDIO_SAMPLE_8K channelsPer:1 bitsPer:AUDIO_DATABITS_16];

TK_getAudioOutputCodecId

/**
 获取当前监听音频格式,在调用TK_startSoundToPhone后使用
 @param channel av通道
 */
- (NSInteger)TK_getAudioOutputCodecId:(NSInteger)channel;
    示例:
    [self.myCamera TK_getAudioOutputCodecId:0];

TK_getAudioInputCodecId

/**
 获取当前对讲音频格式,在发送Command: 32A 后使用
@param channel av通道
 */
- (NSInteger)TK_getAudioInputCodecId:(NSInteger)channel;
    示例:
    [self.myCamera TK_getAudioInputCodecId:0];

1.6 录像与截图

TK_initVideoGenerator

/**
 本地录像功能初始化

 @param url 沙盒路径
 */
-(void)TK_initVideoGenerator:(NSURL*)url;
    示例:
    NSString *path= [CommonUtility pathForDocumentsResource:recordFileName];
    NSURL* url = [NSURL fileURLWithPath:path];
    [self.myCamera TK_initVideoGenerator:url channel:selectedChannel];

TK_startRecordingForChannel

/**
 指定通道并开始录像

 @param path 沙盒路径
 @param channel av通道
 */
-(void)TK_startRecording:(NSString *)path Channel:(NSInteger)channel;
    示例:
    [self.myCamera TK_startRecordingForChannel:0  withDuration:180];

TK_stopRecording

/**
 停止录像
 */
-(void)TK_stopRecording;
    示例:
    [self.myCamera TK_stopRecording:0];

TK_getChannel

/**
 填充指定通道的视频数据

 @param channel av通道
 @param imgData 视频buffer
 @param size 视频buffer长度
 @param codec_id 视频编码格式
 @param width 视频画面宽度
 @param height 视频画面长度
 @return 实际填充的数据长度
 */
-(unsigned int)TK_getChannel:(NSInteger)channel Snapshot:(char *)imgData DataSize:(unsigned int)size ImageType:(unsigned int*)codec_id WithImageWidth:(unsigned int *)width ImageHeight:(unsigned int *)height;

TK_getSnapShotImageWithChannel

/**
 获取截图图片

 @param channel av通道
 @return 截图图片
 */
- (UIImage *)TK_getSnapShotImageWithChannel:(NSInteger)channel;
    示例:
    [self.myCamera TK_getSnapShotImageWithChannel:0];

1.7 指令发送

1.7.1 P2P

TK_sendIOCtrlToChannel

/**
 给指定通道发送指令

 @param channel av通道
 @param type 指令类型
 @param buff 指令内容
 @param buffer_size 指令内容大小
 */
- (void)TK_sendIOCtrlToChannel:(NSInteger)channel Type:(NSInteger)type Data:(char *)buff DataSize:(NSInteger)buffer_size;
    示例:
    SMsgAVIoctrlGetSupportStreamReq *s = (SMsgAVIoctrlGetSupportStreamReq *)malloc(sizeof(SMsgAVIoctrlGetSupportStreamReq));
    memset(s, 0, sizeof(SMsgAVIoctrlGetSupportStreamReq));
    [self.myCamera TK_sendIOCtrlToChannel:channel
                         Type:IOTYPE_USER_IPCAM_GETSUPPORTSTREAM_REQ
                         Data:(char *)s
                     DataSize:sizeof(SMsgAVIoctrlGetSupportStreamReq)];
    free(s);

TK_sendJsonIOCtrlToChannel

/**
给指定通道发送指令
@param channel av通道
@param data 指令数据
@param responseBlock 指令回复
@param timeout 超时时间
*/
- (void)TK_sendJsonIOCtrlToChannel:(NSInteger)channel data:(NSData *)data responseBlock:(nonnull DataBlock)responseBlock timeout:(NSInteger)timeout;
    示例:
    NSString *url = [NSString stringWithFormat:@"%@%@?stoken=%@",vsaasURL, self.uid, deviceToken];
//    NSString *accessToken = [NSString stringWithFormat:@"Bearer %@",amToken];
    NSDictionary *header = @{@"Authentication": vsaasToken,
                             @"User-Agent": @"TUTK Device"};
    NSDictionary *args   = @{@"url": url};
    NSDictionary *param  = @{@"func": @"setCloudRecordingEndpoint",
                             @"args": args,
                             @"header": header};
    NSError *error = nil;
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:param options:NSJSONWritingPrettyPrinted error:&error];
    NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    NSData *requsetData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
    [self.myCamera TK_sendJsonIOCtrlToChannel:channel data:requsetData responseBlock:^(NSData *data) {
        completion(data);
    } timeout:5];

1.7.2 Nebula

TK_nebulaSendData

/**
Nebula 发送指令及回调
 @param jsonData 指令数据
 @param udid 设备udid 40码
 @param responseBlock 响应数据
 @param timeout 超时时间 单位s
 */
- (void)TK_nebulaSendData: (NSString *)jsonData udid: (NSString *)udid responseBlock: (DataBlock)responseBlock timeout: (NSInteger)timeout;
 示例:   
     NSDictionary *func = @{
        @"func":@"getChannelNames",
    };
    NSError *error = nil;
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:func options:NSJSONWritingPrettyPrinted error:&error];
    NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    [self.myCamera TK_nebulaSendData:jsonString udid:uid responseBlock:^(NSData *data) {
        responseData(data);
    } timeout:5];

二、指令封装

2.1 TK_commandNebulaSsidListReq

/**  AP获取WiFi列表
    @param maxCount 列表数量
    @param responseBlock 获取WiFiList回调
*/
-(void)TK_commandNebulaSsidListReq:(NSInteger)maxCount responseWifiListBlock:(void(^)(NSArray *wifiList))responseBlock;

2.2 TK_commandNebulaSetWifiReq

/**  AP设置WiFi
    @param ssid WiFi ssid
    @param password WiFi密码
    @param enctype 加密类型
    @param responseBlock 设置WiFi回调
*/
-(void)TK_commandNebulaSetWifiReq:(NSString *)ssid password:(NSString *)password enctype:(NSInteger)enctype responseSetWifiBlock:(void(^)(NSDictionary *resultDict))responseBlock;

2.3 TK_commandSupportStreamWithChannel

/**  获取设备通道数
    @param channel av通道
    @param completion 设备通道回调
*/
-(void)TK_commandSupportStreamWithChannel:(NSInteger)channel completion:(void(^)(KalayCommandSupportStream *))completion;

2.4 TK_commandListWifiWithChannel

/**  获取WiFi列表
    @param channel av通道
    @param completion WiFi列表回调
*/
-(void)TK_commandListWifiWithChannel:(NSInteger)channel completion:(void(^)(KalayCommandListWifi *))completion;

2.5 TK_commandSetWifiWithChannel

/**  设置设备WiFi网络
@param channel av通道
@param ssid 连接的WiFi SSID
@param password WiFi SSID 密码
@param enctype // 参考ENUM_AP_MODE
@param mode // 参考ENUM_AP_ENCTYPE
@param completion 设备WiFi回调
*/
-(void)TK_commandSetWifiWithChannel:(NSInteger)channel ssid:(NSString *)ssid password:(NSString *)password enctype:(NSInteger)enctype mode:(NSInteger)mode completion:(void(^)(KalayCommandSetWifi *))completion;

2.6 TK_commandGetWifiWithChannel

/**  获取设备当前WiFi网络
    @param channel av通道
    @param completion 当前WiFi回调
*/
    -(void)TK_commandGetWifiWithChannel:(NSInteger)channel completion:(void(^)(KalayCommandGetWifi *))completion;

2.7 TK_commandGetAudioOutFormatWithChannel

/**  获取设备音频格式
    @param channel av通道
*/
-(void)TK_commandGetAudioOutFormatWithChannel:(NSInteger)channel;

2.8 TK_commandCallWithChannel

/**  获取门铃呼叫
    @param channel av通道
    @param completion 门铃
*/
-(void)TK_commandCallWithChannel:(NSInteger)channel answer:(NSInteger)answer completion:(void(^)(KalayCommandCall *))completion;

2.9 TK_commandDeviceInfoWithChannel

/**  获取设备信息
@param channel av通道
    @param completion 设备信息回调
*/
-(void)TK_commandDeviceInfoWithChannel:(NSInteger)channel completion:(void(^)(KalayCommandDeviceInfo *))completion;

2.10 TK_commandGetRecordWithChannel

/**  获取设备SD卡录像模式
    @param channel av通道
    @param completion 获取录像模式回调
*/
-(void)TK_commandGetRecordWithChannel:(NSInteger)channel completion:(void(^)(KalayCommandGetRecord *))completion;

2.11 TK_commandSetRecordWithChannel

/**  设置设备SD卡录像模式
    @param channel av通道
    @param parameter 请求参数
    @param completion 设置录像模式
*/
-(void)TK_commandSetRecordWithChannel:(NSInteger)channel parameter:(NSDictionary *)parameter completion:(void(^)(KalayCommandSetRecord *))completion;

2.12 TK_commandGetStreamWithChannel

/**  获取设备解析度
    @param channel av通道
    @param completion 获取解析度回调
*/
-(void)TK_commandGetStreamWithChannel:(NSInteger)channel completion:(void(^)(KalayCommandGetStream *))completion;

2.13 TK_commandSetStreamWithChannel

/**  设置设备解析度
    @param channel av通道
    @param quality // 参考ENUM_QUALITY_LEVEL
    @param completion 设置解析度回调
*/
-(void)TK_commandSetStreamWithChannel:(NSInteger)channel quality:(NSInteger)quality completion:(void(^)(KalayCommandSetStream *))completion;

2.14 TK_commandGetMotionDetectWithChannel

/**  获取设备位移侦测之灵敏度
    @param channel av通道
    @param completion 获取移侦测之灵敏度回调
*/
-(void)TK_commandGetMotionDetectWithChannel:(NSInteger)channel completion:(void(^)(KalayCommandGetMotionDetect *))completion;

2.15 TK_commandSetMotionDetectWithChannel

/**  设置设备位移侦测之灵敏度
    @param channel av通道
    @param sensitivity 0(禁用) ~ 100(最大)
    @param completion 设置位移侦测之灵敏度回调
*/
-(void)TK_commandSetMotionDetectWithChannel:(NSInteger)channel sensitivity:(NSInteger)sensitivity completion:(void(^)(KalayCommandSetMotionDetect *))completion;

2.16 TK_commandSetPasswdWithChannel

/**  设置设备密码
    @param channel av通道
    @param oldpasswd 旧密码
    @param newpasswd 新密码
    @param completion 设置设备密码回调
*/
-(void)TK_commandSetPasswdWithChannel:(NSInteger)channel oldpasswd:(NSString *)oldpasswd newpasswd:(NSString *)newpasswd completion:(void(^)(KalayCommandSetPasswd  *))completion;

2.17 TK_commandSetVideoModeWithChannel

/**  设置画面镜像/翻转状态
    @param channel av通道
    @param mode // 参考 ENUM_VIDEO_MODE
    @param completion 设置画面翻转状态回调
*/
-(void)TK_commandSetVideoModeWithChannel:(NSInteger)channel mode:(NSInteger)mode completion:(void(^)(KalayCommandSetVideoMode *))completion;

2.18 TK_commandGetVideoModeWithChannel

/**  获取画面镜像/翻转状态
    @param channel av通道
    @param completion 获取画面翻转状态回调
*/
-(void)TK_commandGetVideoModeWithChannel:(NSInteger)channel completion:(void(^)(KalayCommandGetVideoMode *))completion;

2.19 TK_commandGetChannelNameWithChannel

/**  格式化SD卡
    @param channel av通道
    @param storage //(例如sdcard插槽= 0,内部闪存= 1,...)
    @param completion 格式化SD卡回调
*/
-(void)TK_commandFormatExtStorageWithChannel:(NSInteger)channel storage:(NSInteger)storage completion:(void(^)(KalayCommandFormatExtStorage *))completion;

/**  获取通道名称
    @param channel av通道
    @param completion 获取通道名称回调
*/
-(void)TK_commandGetChannelNameWithChannel:(NSInteger)channel completion:(void(^)(KalayCommandGetChannelName *))completion;

2.20 TK_commandSetChannelNameWithChannel

/**  设置通道名称
    @param channel av通道
    @param channelName 通道名称
    @param completion 设置通道名称回调
*/
-(void)TK_commandSetChannelNameWithChannel:(NSInteger)channel channelName:(NSString *)channelName completion:(void(^)(KalayCommandSetChannelName *))completion;

2.21 TK_commandTimeSyncWithChannel

/**  获取当前设备名称
    @param channel av通道
    @param deviceName 设备名称
    @param completion 获取设备名称回调
*/
-(void)TK_commandPushDeviceNameWithChannel:(NSInteger)channel deviceName:(NSString *)deviceName completion:(void(^)(KalayCommandPushDeviceName *))completion;

2.22 TK_commandTimeSyncWithChannel

/**  同步时间
    @param channel av通道
    @param completion 同步时间回调
*/
-(void)TK_commandTimeSyncWithChannel:(NSInteger)channel completion:(void(^)(KalayCommandTimeSync *))completion;

2.23 TK_commandPtzWithChannel

/**  设备云台控制
    @param channel av通道
    @param ptz // 参考ENUM_PTZCMD
    @param completion 云台控制回调
*/
-(void)TK_commandPtzWithChannel:(NSInteger)channel ptz:(NSInteger)ptz completion:(void(^)(KalayCommandPtz *))completion;

2.24 TK_commandOTAWithChannel

/**  设备OTA升级
    @param channel av通道
    @param fileChecksum 文件
    @param url 升级URL
    @param fileSize 文件大小
    @param completion OTA升级回调
*/
-(void)TK_commandOTAWithChannel:(NSInteger)channel fileChecksum:(NSString *)fileChecksum url:(NSString *)url fileSize:(NSInteger)fileSize completion:(void(^)(KalayCommandOTA *))completion;

2.25 TK_commandDeviceSupportOTAWithChannel

/**  获取设备是否支持OTA
   @param channel av通道
   @param completion 设备OTA回调
*/
-(void)TK_commandDeviceSupportOTAWithChannel:(NSInteger)channel completion:(void(^)(KalayCommandDeviceSupportOTA *))completion;

2.26 TK_commandDeviceSupportCloudWithChannel

/**  获取设备是否支持云存储
    @param channel av通道
    @param completion 设备云存储回调
*/
-(void)TK_commandDeviceSupportCloudWithChannel:(NSInteger)channel completion:(void(^)(KalayCommandDeviceSupportCloud *))completion;

2.27 TK_commandSetCloudWithChannel

/**  设置设备云存储录像状态
    @param channel av通道
    @param isOn // 1 开启, 0 关闭
   @param completion 设置云存储录像状态回调
*/
-(void)TK_commandSetCloudWithChannel:(NSInteger)channel isOn:(NSInteger)isOn completion:(void(^)(KalayCommandSetCloud *))completion;

2.28 TK_commandGetCloudWithChannel

/**  获取设备云存储录像状态
    @param channel av通道
    @param completion 获取云存储录像状态回调
*/
-(void)TK_commandGetCloudWithChannel:(NSInteger)channel completion:(void(^)(KalayCommandGetCloud *))completion;

2.29 TK_commandSetHumanDetectionWithChannel

/**  设置设备人形侦测开关
    @param channel av通道
    @param isOn // 1 开启, 0 关闭
    @param completion 设置设备人形侦测开关回调
*/
-(void)TK_commandSetHumanDetectionWithChannel:(NSInteger)channel isOn:(NSInteger)isOn completion:(void(^)(KalayCommandSetHumanDetection *))completion;

2.30 TK_commandGetHumanDetectionWithChannel

/**  获取设备人形侦测开关
    @param channel av通道
    @param completion 获取设备人形侦测开关回调
*/
-(void)TK_commandGetHumanDetectionWithChannel:(NSInteger)channel completion:(void(^)(KalayCommandGetHumanDetection *))completion;

2.31 TK_commandSetNightVisionWithChannel

/**  设置设备夜视开关
   @param channel av通道
    @param isOn // 1 开启, 0 关闭
    @param completion 设置设备夜视回调
*/
-(void)TK_commandSetNightVisionWithChannel:(NSInteger)channel isOn:(NSInteger)isOn completion:(void(^)(KalayCommandSetNightVision *))completion;

2.32 TK_commandGetNightVisionWithChannel

/**  获取设备夜视开关
    @param channel av通道
    @param completion 获取设备夜视回调
*/
-(void)TK_commandGetNightVisionWithChannel:(NSInteger)channel completion:(void(^)(KalayCommandGetNightVision *))completion;

2.33 TK_commandSetSummerTimeWithChannel

/**  设置设备夏令时开关
    @param channel av通道
    @param isOn // 1 开启, 0 关闭
    @param completion 设置设备夏令时回调
*/
-(void)TK_commandSetSummerTimeWithChannel:(NSInteger)channel isOn:(NSInteger)isOn completion:(void(^)(KalayCommandSetSummerTime *))completion;

2.34 TK_commandGetSummerTimeWithChannel

/**  获取设备夏令时开关
    @param channel av通道
    @param completion 获取设备夏令时回调
*/
-(void)TK_commandGetSummerTimeWithChannel:(NSInteger)channel completion:(void(^)(KalayCommandGetSummerTime *))completion;

2.35 TK_commandListEventWithChannel

/**  获取事件列表
    @param channel av通道
    @param event // 参考ENUM_EVENTTYPE
    @param stStartTime 开始时间
    @param stEndTime 结束时间
    @param completion 事件列表回调
*/
-(void)TK_commandListEventWithChannel:(NSInteger)channel event:(NSInteger)event stStartTime:(STimeDay)stStartTime stEndTime:(STimeDay)stEndTime completion:(void(^)(KalayCommandListEvent *))completion;

2.36 TK_commandPlayRecordWithChannel

/**  事件回播控制播放
    @param channel av通道
    @param parameter 回放参数 /**  { 事件时间 & ENUM_PLAYCONTROL }
    @param completion 控制播放回调
*/
-(void)TK_commandPlayRecordWithChannel:(NSInteger)channel parameter:(NSDictionary *)parameter completion:(void(^)(KalayCommandPlayRecord *))completion;

2.37 TK_commandGetPlaybackWithChannel

/**  获取事件回放进度控制
    @param channel av通道
    @param stTimeDay 事件时间
    @param completion 获取事件回放进度回调
*/
-(void)TK_commandGetPlaybackWithChannel:(NSInteger)channel stTimeDay:(STimeDay)stTimeDay completion:(void(^)(KalayCommandGetPlayback *))completion;

2.38 TK_commandSetRecordProgessWithChannel

/**  设置事件回放进度控制
    @param channel av通道
   @param progressTime 时间(秒)
   @param completion 设置事件回放进度回调
*/
-(void)TK_commandSetRecordProgessWithChannel:(NSInteger)channel stTimeDay:(STimeDay)stTimeDay progressTime:(NSInteger)progressTime completion:(void(^)(KalayCommandSetRecordProgess *))completion;

2.39 TK_commandGetEventDateWithChannel

/**  获取有SD卡事件的日期
    @param channel av通道
    @param event // 参考ENUM_EVENTTYPE
    @param stStartTime 开始时间
    @param stEndTime 结束时间
    @param completion 事件的日期回调
*/
-(void)TK_commandGetEventDateWithChannel:(NSInteger)channel event:(NSInteger)event stStartTime:(STimeDay)stStartTime stEndTime:(STimeDay)stEndTime completion:(void(^)(KalayCommandGetEventDate *))completion;

2.40 TK_commandGetStorageInfoWithChannel

/**  获取SD内存大小(4x)使用
    @param channel av通道
    @param value // ["sdcard", "usb"]
    @param completion SD内存回调
*/
-(void)TK_commandGetStorageInfoWithChannel:(NSInteger)channel value:(NSString *)value completion:(void(^)(KalayCommandSDInfo *))completion;

页面列表

ITEM_HTML