KalayRN(简中版)

RN版本


IOS API

[TOC]

一、IOTCamera

1.1 初始化接口

TK_InitIOTC

/**
 IOTC初始化

 @param privateKey 客户私有key(有效期内使用才有效)
 @param success 验证成功
 @param failure 验证失败
 */
+ (void)TK_InitIOTC:(NSString *)privateKey
            success:(void (^)(void))success
            failure:(void (^)(NSError *error))failure;

> 注:调用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;

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

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

TK_uninitIOTC

/**
 IOTC反初始化
 */
+ (void)TK_uninitIOTC;

TK_initWithName

/**
 初始化Camera

 @param name camera名称
 @return Camera初始化后的实例对象
 */
- (id)TK_initWithName:(NSString *)name;

TK_getIOTCameraVersion

/**
 获取IOTCamera版本号

 @return IOTCamera版本号
 */
+ (NSString *)TK_getIOTCameraVersion;

RN封装实例
/// 获取IOTCamera版本号
/// @param callback 回调IOTCamera版本号
RCT_EXPORT_METHOD(RN_getIOTCameraVersion:(RCTResponseSenderBlock)callback) {
  callback(@[[Camera TK_getIOTCameraVersion]]);
}

TK_getIOTCAPIsVersion

/**
 获取IOTCAPIs版本号

 @return IOTCAPIs版本号
 */
+ (NSString *)TK_getIOTCAPIsVersion;

RN封装实例
/// 获取IOTCAPI版本号
/// @param callback 回调IOTCAPI版本号
RCT_EXPORT_METHOD(RN_getIOTCAPIsVerion:(RCTResponseSenderBlock)callback) {
  callback(@[[Camera TK_getIOTCAPIsVerion]]);
}

TK_getAVAPIsVersion

/**
 获取AVAPIs版本号

 @return AVAPIs版本号
 */
+ (NSString *)TK_getAVAPIsVersion;

RN封装实例
/// 获取AVAPI版本号
/// @param callback 回调AVAPI版本号
RCT_EXPORT_METHOD(RN_getAVAPIsVersion:(RCTResponseSenderBlock)callback) {
  callback(@[[Camera TK_getAVAPIsVersion]]);
}

TK_setMasterRegion

/**
 设置分区分流方案的地区
 @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
};

TK_LanSearch

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

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

1.2 回调接口

1.2.1 P2PDelegate

didChangeSessionStatus

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

RN封装实例
- (void)camera:(Camera *)camera didChangeSessionStatus:(NSInteger)status {
  TKLog(@"sessionStatus = %ld",status); // NSLog为系统打印
  if (!self.onDidSessionStatus) { return; }
  self.sessionStatus = status;
  self.onDidSessionStatus(@{@"status": @(status)});
}

didChangeChannelStatus

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

 @param camera camera对象
 @param channel av通道
 @param status 连线状态
 */
- (void)camera:(Camera *)camera didChangeChannelStatus:(NSInteger)channel ChannelStatus:(NSInteger)status;

RN封装实例
- (void)camera:(Camera *)camera didChangeChannelStatus:(NSInteger)channel ChannelStatus:(NSInteger)status {
  TKLog(@"channelStatus = %ld",status);
  if (!self.onDidChannelStatus) { return; }
  self.onDidChannelStatus(@{@"channel" : @(channel), @"status": @(status)});
}

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

 @param camera camera对象
 @param channel av通道
 @param status 连线状态
 */
- (void)camera:(Camera *)camera didChangeChannelStatus:(NSInteger)channel debugChannelStatus:(NSInteger)status;

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;

RN封装实例
- (void)camera:(Camera *)camera didReceiveIOCtrlWithType:(NSInteger)type Data:(const char*)data DataSize:(NSInteger)size Channel:(NSInteger)channel {
  [self.deviceBody removeAllObjects];

  switch (type) {
    case IOTYPE_USER_IPCAM_LISTEVENT_RESP: // 事件指令回调
    {
      SMsgAVIoctrlListEventResp *s = (SMsgAVIoctrlListEventResp *)data;
      [self.deviceBody setObject:@(s->total) forKey:@"total"];
      [self.deviceBody setObject:@(s->count) forKey:@"count"];
      [self.deviceBody setObject:@(s->channel) forKey:@"channel"];
      [self.deviceBody setObject:@(s->index) forKey:@"index"];
      NSMutableArray *eventList = [NSMutableArray array];
      if (s->count > 0) {
        for (int i = 0; i < s->count; i++) {
            SAvEvent saEvt = s->stEvent[i];
            NSDictionary *eventInfo = @{
              @"event" : @(saEvt.event),
              @"stTime" : @([RNIOTCameraUtility getTimeInMillis:saEvt.stTime]),
              @"status" : @(saEvt.status),
              @"channel": @(s->channel),
            };
          [eventList addObject:eventInfo];
          [self.deviceBody setObject:eventList forKey:@"eventList"];
        }
        if (s->endflag) {
          [self.deviceBody setObject:eventList forKey:@"eventList"];
        }
      }
    }
      break;
    case IOTYPE_USER_IPCAM_SETPASSWORD_RESP: // 修改设备密码
    {
      SMsgAVIoctrlSetPasswdResp *s = (SMsgAVIoctrlSetPasswdResp *)data;
      [self.deviceBody setObject:@(s->result) forKey:@"result"];
    }
      break;
    case IOTYPE_USER_IPCAM_GET_VIDEOMODE_RESP: // 获取视频翻转模式
    {
      SMsgAVIoctrlGetVideoModeResp *s = (SMsgAVIoctrlGetVideoModeResp *)data;
      [self.deviceBody setObject:@(s->mode) forKey:@"mode"];
    }
      break;
    case IOTYPE_USER_IPCAM_SET_VIDEOMODE_RESP: // 设置视频翻转模式
    {
      SMsgAVIoctrlSetVideoModeResp *s = (SMsgAVIoctrlSetVideoModeResp *)data;
      [self.deviceBody setObject:@(s->result) forKey:@"result"];
    }
      break;
    case IOTYPE_USER_IPCAM_SETSTREAMCTRL_RESP: // 设置视频质量等级
    {
      SMsgAVIoctrlSetStreamCtrlResp *s = (SMsgAVIoctrlSetStreamCtrlResp*)data;
      [self.deviceBody setObject:@(s->result) forKey:@"result"];
      if (s->result == 0) {
        [self.RN_Camera reStartShow:channel withCompleteBlock:^(void){}];
      }
    }
      break;
    case IOTYPE_USER_IPCAM_LISTWIFIAP_RESP: // 获取WiFi列表
    {
      SMsgAVIoctrlListWifiApResp *s = (SMsgAVIoctrlListWifiApResp *)data;
      [self.deviceBody setObject:@(s->number) forKey:@"number"];
      NSMutableArray *wifiListArray = [NSMutableArray array];
      if (s->number > 0) {
        SWifiAp wifiSSIDList[28];
        memset(wifiSSIDList, 0, sizeof(wifiSSIDList));
        memcpy(wifiSSIDList, s->stWifiAp, size - sizeof(s->number));

        for (int i = 0; i < s->number; i++) {
            SWifiAp wifiAp = wifiSSIDList[i];
            //返回的信号强度小于0时,默认使用最强信号值
            if (wifiAp.signal < 0) {
                wifiAp.signal = 100;
            }
          NSString *ssid = [NSString stringWithUTF8String:wifiAp.ssid];
          if (ssid.length > 0) {
            NSDictionary *wifiInfo = @{
              @"ssid" : ssid,
              @"enctype" : @(wifiAp.enctype),
              @"signal" : @(wifiAp.signal),
              @"mode" : @(wifiAp.mode),
              @"status" : @(wifiAp.status),
            };
            [wifiListArray addObject:wifiInfo];
          }
        }
        [self.deviceBody setObject:wifiListArray forKey:@"wifiList"];
      }
    }
      break;
    case IOTYPE_USER_IPCAM_SETWIFI_RESP: // 设置WiFi
    {
      SMsgAVIoctrlSetWifiResp *s = (SMsgAVIoctrlSetWifiResp *)data;
      [self.deviceBody setObject:@(s->result) forKey:@"result"];
    }
      break;
    case IOTYPE_USER_IPCAM_SETRECORD_RESP: // 设置设备的录像模式
    {
      SMsgAVIoctrlSetRecordResp *s = (SMsgAVIoctrlSetRecordResp *)data;
      [self.deviceBody setObject:@(s->result) forKey:@"result"];
    }
      break;
    case IOTYPE_USER_IPCAM_GETRECORD_RESP: // 获取设备的录像模式
    {
      SMsgAVIoctrlGetRecordResp *s = (SMsgAVIoctrlGetRecordResp*)data;
      memcpy(s, data, size);
      [self.deviceBody setObject:@(s->recordType) forKey:@"recordType"];
    }
      break;
    case IOTYPE_USER_IPCAM_DEVINFO_RESP: // 获取SD卡内存信息(大小,版本)
    {
      SMsgAVIoctrlDeviceInfoResp *s = (SMsgAVIoctrlDeviceInfoResp*)data;

      [self.deviceBody setObject:@(s->total) forKey:@"total"];
      [self.deviceBody setObject:@(s->free) forKey:@"free"];

      [self.deviceBody setObject:[NSString stringWithUTF8String:(char *)s->model] forKey:@"model"];
      [self.deviceBody setObject:[NSString stringWithUTF8String:(char *)s->vendor] forKey:@"vendor"];

      unsigned char v[4] = {0};
      v[3] = (char)s->version;
      v[2] = (char)(s->version >> 8);
      v[1] = (char)(s->version >> 16);
      v[0] = (char)(s->version >> 24);

      [self.deviceBody setObject:[NSString stringWithFormat:@"%d.%d.%d.%d", v[0], v[1], v[2], v[3]] forKey:@"version"];

    }
      break;
    case IOTYPE_USER_IPCAM_FORMATEXTSTORAGE_RESP: // 格式化SD卡
    {
      SMsgAVIoctrlFormatExtStorageResp *s = (SMsgAVIoctrlFormatExtStorageResp *)data;
      [self.deviceBody setObject:@(s->result) forKey:@"result"];
    }
      break;
    case IOTYPE_USER_IPCAM_DEVICE_INFO_RESP: // 获取SD卡扩展信息
    {

      SMsgAVIoctrlDeviceInfoRespEx *s = (SMsgAVIoctrlDeviceInfoRespEx*)data;
      [self.deviceBody setObject:[NSString stringWithUTF8String:(char *)s->model] forKey:@"model"];
      [self.deviceBody setObject:[NSString stringWithUTF8String:(char *)s->product] forKey:@"product"];
      [self.deviceBody setObject:[NSString stringWithUTF8String:(char *)s->vender] forKey:@"vender"];

      unsigned char v[4] = {0};
      v[3] = (char)s->version;
      v[2] = (char)(s->version >> 8);
      v[1] = (char)(s->version >> 16);
      v[0] = (char)(s->version >> 24);

      [self.deviceBody setObject:[NSString stringWithFormat:@"%d.%d.%d.%d", v[0], v[1], v[2], v[3]] forKey:@"version"];
    }
      break;
    case IOTYPE_USER_IPCAM_SETMOTIONDETECT_RESP:
    {
      SMsgAVIoctrlSetMotionDetectResp *s = (SMsgAVIoctrlSetMotionDetectResp*)data;
      [self.deviceBody setObject:@(s->result) forKey:@"result"];
    }
      break;
    case IOTYPE_USER_IPCAM_SET_TIME_SYNC_RESP: // 同步时间
    {
      SMsgAVIoctrlTimeSyncResp *s = (SMsgAVIoctrlTimeSyncResp *)data;
      [self.deviceBody setObject:@(s->result) forKey:@"result"];
    }
      break;
    case IOTYPE_USER_IPCAM_DEVICE_SUPPORT_OTA_RESP: // OTA信息
    {
      SMsgAVIoctrlDeviceSupportOTAResp *s = (SMsgAVIoctrlDeviceSupportOTAResp *)data;
      [self.deviceBody setObject:@(s->isSupport) forKey:@"isSupport"];
    }
      break;
    case IOTYPE_USER_IPCAM_RECORD_PLAYCONTROL_RESP:
    {
      SMsgAVIoctrlPlayRecordResp *s = (SMsgAVIoctrlPlayRecordResp *)data;
      [self.deviceBody setObject:@(s->command) forKey:@"command"];
    }
      break;
    case IOTYPE_USER_IPCAM_GET_PLAYBACK_RESP:
    {
      SMsgAVIoctrlGetPlaybackResp *s = (SMsgAVIoctrlGetPlaybackResp *)data;
      [self.deviceBody setObject:@(s->videoTime) forKey:@"videoTime"];
    }
      break;
    case IOTYPE_USER_IPCAM_SET_RECORD_PROGRESS_RESP:
    {
      SMsgAVIoctrlSeRecordProgressResp *s = (SMsgAVIoctrlSeRecordProgressResp *)data;
      [self.deviceBody setObject:@(s->result) forKey:@"result"];
      if (s->result == 0) {
        [self.RN_Camera reStartShow:channel withCompleteBlock:^{}];
      }
    }
      break;
    case IOTYPE_USER_IPCAM_SETGUARD_RESP:
    {
      SMsgAVIoctrlSetGuardResp *s = (SMsgAVIoctrlSetGuardResp *)data;
      [self.deviceBody setObject:@(s->result) forKey:@"result"];
    }
      break;
    default:
      break;
  }

  if (!self.onDevicesDatacall) { return; }
  self.onDevicesDatacall(@{@"type": @(type), @"data": self.deviceBody, @"channel" : @(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;

RN封装实例
- (void)camera:(Camera *)camera didStartTalkSuccess:(BOOL)isSuccess ErrorCode:(NSInteger)errorCode {
  if (!self.onTalkStatus) { return; }
  self.onTalkStatus(@{@"talkSuccess" : @(isSuccess), @"talkErrorCode" : @(errorCode)});
}

didStartListenSuccess

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

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

RN封装实例
- (void)camera:(Camera *)camera didStartListenSuccess:(BOOL)isSuccess Channel:(NSInteger)channel {
  if (!self.onListenStatus) { return; }
  self.onListenStatus(@{@"listenSuccess" : @(isSuccess)});
}

didconnFailErrCode

/**
 连线失败错误码的回调

 @param camera camera对象
 @param connFailErrCode 连线失败的错误码
 */
- (void)camera:(Camera *)camera didconnFailErrCode:(NSInteger)connFailErrCode;

RN封装实例
- (void)camera:(Camera *)camera didconnFailErrCode:(NSInteger)connFailErrCode {
  if (!self.onDidConnectFailed) { return; }
  self.onTalkStatus(@{@"failErrorCode": @(connFailErrCode)});
}

连线状态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;

RN封装实例
- (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 long)frameCount IncompleteFrameCount:(unsigned long)incompleteFrameCount isHwDecode:(BOOL)isHwDecode {
  if (!self.onReceiveFrameInfo) { return; }
  self.onReceiveFrameInfo(@{
    @"channel": @(channel), // 如果获取不到,则使用[NSString stringWithFormat:@"%ld",channel]
    @"videoWidth": @(videoWidth),
    @"videoHeight": @(videoHeight),
    @"FPS": @(fps),
    @"VBPS": @(videoBps),
    @"ABPS": @(audioBps),
    @"online": @(onlineNm),
    @"frameCount": @(frameCount),
    @"incompleteCount": @(incompleteFrameCount),
    @"isHwDecode": isHwDecode ? @"YES" : @"NO",
  });
}

didUpdateDecodedSampleBuffer

/**
 指定通道硬解码后的数据回调

 @param camera camera对象
 @param sampleBuffer 解码后的数据
 @param timestamp 时间戳
 @param channel av通道
 */
- (void)camera:(Camera *)camera didUpdateDecodedSampleBuffer: (CMSampleBufferRef)sampleBuffer timestamp:(uint64_t)timestamp Channel:(NSInteger)channel;

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;

didVideoDecodeSuccess

/**
 指定通道视频解码状态的回调

 @param camera camera对象
 @param isSuccess 是否解码成功
 @param isIFrame 是否I帧
 @param isHwDecode 是否硬解码
 @param channel av通道
 */
- (void)camera:(Camera *)camera didVideoDecodeSuccess:(BOOL)isSuccess isIFrame:(BOOL)isIFrame isHwDecode:(BOOL)isHwDecode 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;

didReceiveTimestamp

/**
 指定通道接收的视频帧时间戳

 @param camera camera对象
 @param frmTimestamp 视频帧时间戳
 @param channel av通道
 */
- (void)camera:(Camera *)camera didReceiveTimestamp:(unsigned int)frmTimestamp Channel:(NSInteger)channel;

didReceiveFrameDataInfo

/**
 获取FrameInfo帧信息

 @param camera camera对象
 @param frameData 帧信息(FRAMEINFO_t_video结构体转换的NSData *数据)
 @param channel av通道
 */
- (void)camera:(Camera *)camera didReceiveFrameDataInfo:(NSData *)frameData 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;

TK_changeAuthkey

/// 更新设备Authkey
/// @param channel 设备通道
- (NSString *)TK_changeAuthkey:(NSInteger)channel;

1.3.2 共有接口

TK_disconnect

/**
 断开设备连线
 */
- (void)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;

TK_stop

/**
 关闭AV通道

 @param channel av通道号
 */
- (void)TK_stop:(NSInteger)channel;

TK_setDtls

/**
 重置DTLS连接方式为Auto

 @param uid  设备UID
 @param channel av通道号
 */
- (void)TK_setDtls:(NSString*)uid channel:(NSInteger)channel;

TK_getConnectionStateOfChannel

/**
 获取指定通道的连线状态

 @param channel av通道
 @return 连线状态值
 */
- (NSInteger)TK_getConnectionStateOfChannel:(NSInteger)channel;

TK_getViewAccountOfChannel

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

 @param channel 指定通道
 @return 获取的用户名
 */
- (NSString *)TK_getViewAccountOfChannel:(NSInteger)channel;

TK_getViewPasswordOfChannel

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

 @param channel 指定通道
 @return 获取的密码
 */
- (NSString *)TK_getViewPasswordOfChannel:(NSInteger)channel;

TK_setIsDecode

/**
 指定通道是否需要进行解码

 @param isDecode 是否进行解码 默认YES(进行解码)
 @param channel av通道
 */
- (void)TK_setIsDecode:(BOOL)isDecode withChannel:(int)channel;//for DVR MultiView

TK_setOutputFrameData

/**
 指定通道是否同时上抛视频裸流

 @param isOutput 是否上抛
 @param channel av通道
 */
- (void)TK_setOutputFrameData:(BOOL)isOutput withChannel:(int)channel;

TK_setOutputAudioData

/**
 指定通道是否同时上抛音频裸流

 @param isOutput 是否上抛
 @param channel av通道
 */
- (void)TK_setOutputAudioData:(BOOL)isOutput withChannel:(int)channel;

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

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

TK_startShow

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

 @param channel av通道
 @param obScreen 屏幕显示对象
 @param isSWDecode 是否软解
 */
- (void)TK_startShow:(NSInteger)channel ScreenObject:(NSObject*)obScreen isSWDecode:(BOOL)isSWDecode;

TK_startShowWithYUV

/**
 开始接收、解码并上抛YUV数据

 @param channel av通道
 @param isSWDecode 是否软解
 */
- (void)TK_startShowWithYUV:(NSInteger)channel isSWDecode:(BOOL)isSWDecode;

TK_startRecvFrame

/**
 开始接收视频裸流数据

 @param channel av通道
 @param obScreen 屏幕显示对象
 */
- (void)TK_startRecvFrame:(NSInteger)channel ScreenObject:(NSObject*)obScreen;

TK_stopRecvFrame

/**
 停止接收视频裸流数据

 @param channel av通道
 */
- (void)TK_stopRecvFrame:(NSInteger)channel;

TK_stopShow

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

 @param channel av通道
 */
- (void)TK_stopShow:(NSInteger)channel;

TK_getVideoCodecId

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

1.5 音频处理接口

TK_startRecvAudio

/**
 开始接收音频数据

 @param channel av通道
 */
- (void)TK_startRecvAudio:(NSInteger)channel;

TK_stopRecvAudio

/**
 停止接受音频数据

 @param channel av通道
 */
- (void)TK_stopRecvAudio:(NSInteger)channel;

TK_setAudioSessionPlayMode

/**
 设置音频播放模式,默认为Speaker
 @param mode 播放模式 // TKAudioSessionPlayModeSpeaker | TKAudioSessionPlayModeReceiver
 */
- (void)TK_setAudioSessionPlayMode:(TKAudioSessionPlayMode)mode;

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;

TK_isAudioOutputavChannel

/// 处理发送音频数据上抛
/// @param avChannel av通道号
/// @param isRecvAudio 解码上抛
/// @param isSendAudio 发送上抛
- (void)TK_isAudioOutputavChannel:(NSInteger)avChannel isRecvAudio:(BOOL)isRecvAudio isSendAudio:(BOOL)isSendAudio;

TK_startSoundToPhone

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

 @param channel av通道
 */
- (void)TK_startSoundToPhone:(NSInteger)channel;

/**
开始接收、解码并监听设备声音
@param channel av通道
@param isDecodeAndPlay 是否解码并播放
*/
- (void)TK_startSoundToPhone:(NSInteger)channel isDecodeAndPlay:(BOOL)isDecodeAndPlay;

TK_stopSoundToPhone

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

 @param channel av通道
 */
- (void)TK_stopSoundToPhone:(NSInteger)channel;

TK_startSoundToDevice

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

 @param channel av通道
 @param isResend 是否开启重送
 */
- (void)TK_startSoundToDevice:(NSInteger)channel isResend:(BOOL)isResend;

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

@param channel      av通道
@param isResend     是否开取重传
@param captureSize  手机端采集音频的大小
*/
- (void)TK_startSoundToDevice:(NSInteger)channel isResend:(BOOL)isResend captureSize:(NSInteger)captureSize;

TK_stopSoundToDevice

/**
 停止对讲

 @param channel av通道
 */
- (void)TK_stopSoundToDevice:(NSInteger)channel;

TK_playAECAudio

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

 @param aecData aec音频数据
 @param channel av通道
 */
- (void)TK_playAECAudio:(NSData *)aecData Channel:(NSInteger)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;

TK_startSendAudioChannel

/** 
开启对讲发送

  @param channel av通道
 */
- (void)TK_startSendAudioChannel:(NSInteger)channel;

TK_stopSendAudioChannel

/** 
关闭对讲发送

 @param channel av通道
 @param isResend 是否重送
 */
- (void)TK_startSendAudioChannel:(NSInteger)channel isResend:(BOOL)isResend;

TK_getAudioOutputCodecId

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

TK_getAudioInputCodecId

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

1.6 录像与截图

TK_initVideoGenerator

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

 @param url 沙盒路径
 */
-(void)TK_initVideoGenerator:(NSURL*)url;

TK_startRecordingForChannel

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

 @param channel av通道
 @param duration 最大录像时长
 */
-(void)TK_startRecordingForChannel:(NSInteger)channel withDuration:(NSTimeInterval)duration;

TK_stopRecording

/**
 停止录像
 */
-(void)TK_stopRecording;

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_setIsSaveToSystemAlbum

/**
 设置是否保存到系统相册

 @param isSaveToSystemAlbum 是否保存到系统相册 (isSaveToSystemAlbum defult is yes)
 */
-(void)TK_setIsSaveToSystemAlbum:(BOOL)isSaveToSystemAlbum;

TK_getSnapShotImageWithChannel

/**
 获取截图图片

 @param channel av通道
 @return 截图图片
 */
- (UIImage *)TK_getSnapShotImageWithChannel:(NSInteger)channel;

TK_setHWDecodingAbility

/**
 设置指定通道的解码方式

 @param channel av通道
 @param bEnable 是否硬解码
 */
- (BOOL)TK_setHWDecodingAbility:(NSInteger)channel requestHWDecode:(BOOL)bEnable;

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;

RN封装实例
/// 指定通道发送指令
/// @param channel av通道
/// @param type 指令类型
/// @param buff 指令内容
/// @param bufferSize 指令内容大小
RCT_EXPORT_METHOD(RN_sendIOCtrlToChannel:(NSInteger)channel Type:(NSInteger)type Data:(char *)buff DataSize:(NSInteger)bufferSize) {
  [self.cameraView.RN_Camera TK_sendIOCtrlToChannel:channel Type:type Data:buff DataSize:bufferSize];
}

TK_sendJsonIOCtrlToChannel

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

 @param channel av通道
 @param type 指令类型
 @param data 指令数据
*/
- (void)TK_sendJsonIOCtrlToChannel:(NSInteger)channel Type:(NSInteger)type Data:(NSData *)data;

页面列表

ITEM_HTML