|
Tange Cloud for Device
Rev.362 |
结构体 | |
| struct | ICECONFIG |
类型定义 | |
| typedef void(* | TCIONLIVEFRAMECB) (int channel, int stream, TCMEDIA mt, const uint8_t *pFrame, uint32_t size, uint32_t ts, int uFrameFlags) |
函数 | |
| TG_PUBLIC int | TciReportError (const char *name, const char *detail) |
| 上报错误 | |
| TG_PUBLIC void | TciSelectEnvironment (int env) |
| 用于选择调试环境 | |
| void | TciRegisterLiveFrameCB (TCIONLIVEFRAMECB cb) |
| void | TciUnregisterLiveFrameCB (TCIONLIVEFRAMECB cb) |
| void | TciSetParamFileOps (struct paramf_ops *ops) |
| 设置参数文件操作指针. | |
| TG_PUBLIC int | TciSetMaxP2pClientsNum (int num) |
| 设置最大p2p连接数. | |
| char * | TciGetDeviceInfoString (void) |
核心API | |
| TG_PUBLIC int | TciGetRevision (void) |
| 获取SDK版本号 TciInit()之后调用 | |
| TG_PUBLIC int | TciInit (const char *path, const char *uuid) |
| 配置基本参数 在TciStart()之前调用 | |
| TG_PUBLIC int | TciStart (int isBound, unsigned int uCloudBuffSize) |
| 启动服务 | |
| TG_PUBLIC int | TciStart2 (int isBound, unsigned int uCloudBuffSize, const char *uuid) |
| 启动服务. | |
| TG_PUBLIC int | TciStop (void) |
| 停止服务 | |
| TG_PUBLIC int | TciCleanup (void) |
| 释放资源 | |
| TG_PUBLIC int | TciSetCallback (const struct TciCB *cb) |
| 注册回调 – sdk内部事件 | |
| TG_PUBLIC int | TciSetCmdHandler (const TGCMDHANDLER cb) |
| 注册通用命令回调 在回调里处理APP发来的命令请求 | |
| TG_PUBLIC void | TciSetSessionUserData (p2phandle_t handle, void *pUser) |
| 绑定应用私有数据指针到p2p handle | |
| TG_PUBLIC void * | TciGetSessionUserData (p2phandle_t handle) |
| 返回由TciSetSessionUserData()设置的应用私有数据指针 | |
| TG_PUBLIC void | TciSetLogOption (int b_output_to_console, const char *log_path, int max_log_size) |
| 控制日志输出. | |
| TG_PUBLIC void | TciSetLogLevel (int level) |
| 设置SDK日志输出等级. | |
| TG_PUBLIC void | TciSetCloudStream (int channel, int stream) |
| 设置云存储录像通道的码流 | |
| TG_PUBLIC int | TciSetSysOption (TCSYSOPTION opt, const void *pVal) |
| 通用sdk工作选项设置接口. | |
| TG_PUBLIC int | TciGetSysOption (TCSYSOPTION opt, void *pVal) |
| 通用sdk工作选项获取接口. | |
| TG_PUBLIC int | TciStartInTestMode (const char *key_path) |
| 开启p2p功能,进入厂测状态. | |
上报事件/状态/其它数据到平台 | |
| TG_PUBLIC int | TciSetEventEx (EVENTPARAM *evtp) |
| 上报事件。本版本允许附带事件特定参数. | |
| TG_PUBLIC int | TciStopEvent (ECEVENT evt) |
| 停止事件, 仅少数事件才有意义. | |
| TG_PUBLIC int | TciSetLockEvent (int cls, int msg, int usrtyp, int usrid) |
| 门锁事件上报。图片和录像都在内部处理了. | |
| TG_PUBLIC int | TciSetDoorbellEvent () |
| 包装了门铃事件 | |
| TG_PUBLIC int | TciReport4GInfo (const char *imei, const char *iccid, ECG4STATE state) |
| TG_PUBLIC int | TciReport4GInfoEx (const TG4GINFO *info, ECG4STATE state) |
| 上报4G设备信息,代替 TciReport4GInfo() | |
| TG_PUBLIC int | TciReportGpsInfo (const unsigned int time, const double longitude, const double latitude, double speed, int angle, int signal_strength) |
| 上报GPS信息 | |
| TG_PUBLIC int | TciReportBatteryStatus (int qoe, int qoe_low, int charging) |
| 上报电池状态 | |
| TG_PUBLIC void | TciSetRtState (ENUMRTSTATE state, void *pData) |
| 报告系统运行时状态 | |
| TG_PUBLIC int | TciSwitchDeviceStatus (int status) |
| 设置设备开关状态. | |
| TG_PUBLIC int | TciSendUserData (const unsigned char *data, int len) |
| 发送用户自定义数据到第三方平台. | |
发送音视频和消息 | |
这个数据通过p2p通道传给App。或者,如果有服务,音视频会上传云端 | |
| TG_PUBLIC int | TciSendCmd (p2phandle_t handle, unsigned int cmd, const void *data, int dataSize) |
| 发送p2p命令请求 | |
| TG_PUBLIC int | TciSendCmdResp (p2phandle_t handle, unsigned int cmd, const void *data, int dataSize) |
| 发送p2p命令应答 | |
| TG_PUBLIC int | TciSendCmdRespStatus (p2phandle_t handle, unsigned int cmd, unsigned int status) |
| 发送一个 Tcis_ErrorResp 结构作应答. | |
| TG_PUBLIC int | TciSendPbFrame (p2phandle_t handle, uint32_t id_mt, const uint8_t *frame, int len, uint32_t timestamp, int uFrameFlags) |
| 回放时发送数据帧. | |
| TG_PUBLIC int | TciSendPbMessage (p2phandle_t handle, RTMTYPE type, unsigned int data1, unsigned int data2, const void *data, int data_len) |
| 在回放流中插入消息. | |
| TG_PUBLIC int | TciSendFrameEx (int channel, int stream, TCMEDIA mt, const uint8_t *pFrame, int length, uint32_t ts, int uFrameFlags) |
| 发送实时音视频帧, SDK内部会将数据分发到云端和APP. | |
| TG_PUBLIC int | TciSendLiveMessage (int channel, int stream, RTMTYPE type, unsigned int data1, unsigned int data2, const void *data, int data_len) |
| 发送实时流消息. | |
| TG_PUBLIC int | TciSendRtMsg (p2phandle_t handle, RTMTYPE type, unsigned int data1, unsigned data2, const void *extra_data, int extra_len) |
| 在命令通道上发送通知. | |
| #define | TciSendPbSyncFrame(handle, utc_time, is_response_to_PLAY_START) |
| 发送回放时间同步帧. | |
| #define | TciSendPbTimelapseFlag(handle, flag) |
| 发送缩时录像回放标志。在进入和退出时发送. | |
| #define | TciSendPbEndOfEvent(handle) |
| 在事件回放结束时发送此标志通知App. | |
| #define | TciSendLiveMsg_ReachPsp(channel, psp_num) |
| 发送预置位到位通知. | |
| #define | TciSendLiveMsg_LensSwitch(channel, stream) |
| 多目摄像机镜头切换时发送的标志帧, 要求在新镜头的第一帧前发送. | |
| #define | TciSendLensSwitchFlag(channel, stream) |
配网和注册 | |
| TG_PUBLIC int | TciConfigWifi (int mode) |
| 开始配置WIFI. | |
| TG_PUBLIC int | TciConfigWifiWithoutReset (int mode) |
| 开始配置WIFI. | |
| TG_PUBLIC int | TciCheckRegString (const char *s) |
| 在sdk外部扫二维码. | |
| TG_PUBLIC int | TciStopConfigWifi (int mode) |
| 中止配网. | |
| TG_PUBLIC const void * | TciGetRegisterConfiguration (int *len) |
| 保存wifi注册信息. | |
| SA_BOOL | TciSetRegisterConfiguration (const void *data, int len) |
| 恢复wifi注册信息. | |
| TG_PUBLIC int | TciSetP2pInfo (const char *sss) |
| TG_PUBLIC int | TciProcessRegInfo (const void *data) |
| 处理从蓝牙收到的注册数据 | |
| TG_PUBLIC int | TciSetRegInfo (const char *s) |
| 手动处理注册信息 | |
低功耗相关 | |
| TG_PUBLIC int | TciAllocCloudBuffer (unsigned int uCloudBuffSize) |
| 预分配云存储帧缓存空间. | |
| TG_PUBLIC void | TciFlushCsCache () |
| 等待录像缓冲区中的所有数据被消耗掉. | |
| TG_PUBLIC int | TciSetKeyVideoTime (int channel, int stream, time_t t) |
| 告诉SDK下一个视频关键帧的实际发生时间(UTC). | |
| TG_PUBLIC int | TciPrepareHiberation (int *socks, int size) |
| 准备休眠 本api建立到唤醒服务器的tcp连接,并且返回连接数. | |
| TG_PUBLIC int | TciGetWakeupServers (Ipv4Addr servers[3]) |
| 获取唤醒服务器ip地址 | |
| TG_PUBLIC const uint8_t * | TciPrepareAuthString (const char *randKey, int *len_of_authstring) |
| 生成唤醒服务器登录命令. | |
| TG_PUBLIC void | TciSetPowerMode (PMODE mode) |
| 设置低功耗设备的工作模式. | |
| TG_PUBLIC void | TciSetP2pDown (SA_BOOL bDown) |
| 暂停或继续运行 P2P. | |
| TG_PUBLIC void | TciFastRecoverP2p (void) |
| 从NETDOWN模式下恢复网络后,调用本api使p2p快速上线 | |
| TG_PUBLIC void | TciSetWakeupReason (time_t t_wakeup, int r, const char *user_reason, int sig_lvl, int sdc_rec) |
| 设置低功耗设备唤醒原因, 设备进入休眠时会上报给服务器. | |
| TG_PUBLIC int | TciForceSleeping (SA_BOOL bDiscardFilesInQueue) |
| 设备端准备强制休眠. | |
云存储自动补录 | |
| TG_PUBLIC int | TciSetBackStore (const char *sd_path, ECBUFFERHINT buffer_hint) |
| 设置云存储后备存储目录和缓存策略. | |
| TG_PUBLIC void | TciBackStoreEnableUpload (int en) |
| 允许或禁止后备上传. | |
| TG_PUBLIC void | TciBackStoreEnable (int en) |
| 这个接口用于sd卡格式化前释放backstore, 和格式化后重新开启后备存储 | |
用户定义云上传 | |
| void * | TciUduBegin2 (const char *evt, time_t tRecordStart, const char *jpg_pic, int pic_len) |
| 开始一个用户定义上传. | |
| TG_PUBLIC int | TciUduPutFrame (void *hUdu, TCMEDIA mt, uint32_t ts, const uint8_t *pFrame, int size, int uFrameFlags) |
| 自定义上传过程,写入帧. | |
| TG_PUBLIC void | TciUduEnd (void *hUdu) |
| 结束自定义上传 | |
| #define | TciUduBegin(evt, tRecordStart) |
手动OTA&文件上传下载 | |
| TG_PUBLIC int | TciUpgradeOnTheAir (const char *subdev) |
| 下载升级包 | |
| TG_PUBLIC int | TciQueryForOTA (const char *uuid, DEVICEOTAINFO *ota) |
| 查询升级包. | |
| TG_PUBLIC int | TciQueryForOta2 (const char *fw_id, const char *fw_ver, DEVICEOTAINFO *ota) |
| 查询第三方升级包. | |
| TG_PUBLIC int | TciPerformOTA (DEVICEOTAINFO *ota) |
| 执行下载过程,会调用回调里的 ota 接口. | |
下载用户文件 | |
| TG_PUBLIC int | TciGetUserFile (const char *name, SA_BOOL bToFile, union TgfDest *dest, int timeout) |
| 查询并下载用户文件. | |
| TG_PUBLIC int | TciQueryUserFile (const char *name, EcFileLink *flnk) |
| 获取用户文件的下载地址. | |
| TG_PUBLIC int | TciDownloadUserFile (const EcFileLink *flink, SA_BOOL bToFile, union TgfDest *dest, int timeout) |
| 下载用户文件. | |
日志上传工具 | |
以查询的方式上传日志,主要用于低功耗设备. | |
| int | TgQueryUploadReq (const char *uuid, const char *model_id, char **ppUrl) |
| int | TgPostLogFile (const char *url, const char *uuid, const char *path, int timeout) |
| int | TgPostLogMem (const char *url, const char *uuid, const void *mem, int size, const char *name, int timeout) |
| TG_PUBLIC int | TciGetLogConf (struct TgLogConf *pLogConf) |
| 查询日志上传配置 | |
| TG_PUBLIC int | TciPutLogFile (const char *local_path, int timeout) |
| 上传日志文件. | |
| TG_PUBLIC int | TciPutLogMem (const void *mem, int size, const char *name, int timeout) |
| 上传内存中的日志 | |
MCU配网api | |
低功耗设备在MCU端进行配网. | |
| char * | TciGetActivationAttrs (void) |
| 获取设备属性字符串。调用者把该字符串传给MCU,用于在MCU端激活设备. | |
| unsigned char * | TciGetPlatConfig (int *pLen) |
| 返回要同步到MCU的数据. | |
| TG_PUBLIC int | TciSyncPlatConfig (const unsigned char *pData, int len) |
| 同步从MCU来的数据. | |
其它功能 | |
| TG_PUBLIC void | TcnIpChanged () |
| 设备上线后IP发生变化时通知SDK, 用于立即更新长连接 | |
| TG_PUBLIC int | TciLocalStart (const char *url, const ICECONFIG *cfg, int size) |
| 开启本地工作模式. | |
| TG_PUBLIC unsigned int | TciGetSdkState (void) |
| 获取SDK内部状态. | |
| TG_PUBLIC int | TciSetEventRecordLength (int erl) |
| 设置用户定义低功耗设备的事件云录像时长. | |
| TG_PUBLIC int | TciClearCache (SA_BOOL bResetRemote) |
| 清除SDK运行cache. | |
呼入处理 | |
| TG_PUBLIC int | TciAcceptInCall2 (ECALLFLAVOR flavor) |
| 接听. | |
| TG_PUBLIC int | TciRejectInCall2 () |
| 拒接. | |
| TG_PUBLIC int | TciHangup (void) |
| 挂断当前通话 | |
| struct ICECONFIG |
在文件 TgCloudApi.h 第 1249 行定义.
| 成员变量 | ||
|---|---|---|
| char * | ip | |
| int | port | |
| char * | username | |
| char * | password | |
| int | is_turn | |
| #define TciSendPbSyncFrame | ( | handle, | |
| utc_time, | |||
| is_response_to_PLAY_START ) |
发送回放时间同步帧.
| handle | p2p 连接句柄 |
| utc_time | 下一帧的生成时间(utc, 单位s) |
| is_response_to_PLAY_START | 1:响应 TCI_CMD_RECORD_PLAYCONTROL; 0:自动跳到下一个文件 |
在文件 TgCloudApi.h 第 761 行定义.
| #define TciSendPbTimelapseFlag | ( | handle, | |
| flag ) |
发送缩时录像回放标志。在进入和退出时发送.
| handle | p2p 连接句柄 |
| flag | 1:进入缩时回放; 0:退出缩时回放 |
在文件 TgCloudApi.h 第 768 行定义.
| #define TciSendPbEndOfEvent | ( | handle | ) |
在事件回放结束时发送此标志通知App.
在文件 TgCloudApi.h 第 773 行定义.
| #define TciSendLiveMsg_ReachPsp | ( | channel, | |
| psp_num ) |
发送预置位到位通知.
在文件 TgCloudApi.h 第 809 行定义.
| #define TciSendLiveMsg_LensSwitch | ( | channel, | |
| stream ) |
多目摄像机镜头切换时发送的标志帧, 要求在新镜头的第一帧前发送.
在文件 TgCloudApi.h 第 813 行定义.
| #define TciSendLensSwitchFlag | ( | channel, | |
| stream ) |
在文件 TgCloudApi.h 第 818 行定义.
| #define TciUduBegin | ( | evt, | |
| tRecordStart ) |
在文件 TgCloudApi.h 第 1059 行定义.
| typedef void(* TCIONLIVEFRAMECB) (int channel, int stream, TCMEDIA mt, const uint8_t *pFrame, uint32_t size, uint32_t ts, int uFrameFlags) |
在文件 TgCloudApi.h 第 1087 行定义.
| TG_PUBLIC int TciGetRevision | ( | void | ) |
获取SDK版本号 TciInit()之后调用
| TG_PUBLIC int TciInit | ( | const char * | path, |
| const char * | uuid ) |
配置基本参数 在TciStart()之前调用
| path | 用于保存sdk私有数据的目录, 需要有读写权限 |
| uuid | 设备id. 新的id参数为 "uuid,key" 的形式, 烧号时由服务器分配 |
| TG_PUBLIC int TciStart | ( | int | isBound, |
| unsigned int | uCloudBuffSize ) |
启动服务
| isBound | 设备本地记录的绑定状态. 复位或在TciCB::on_status()里 STATUS_DELETED 时清除。收到 STATUS_LOGON 时设置并保存 |
| uCloudBuffSize | 云存储缓冲区大小(单位:字节). 要求能缓存3~5秒音视频数据, 为0会禁用云存 |
| 0 | 启动成功 |
| others. | Refer to 错误码 TgCloudConst.h |
| TG_PUBLIC int TciStart2 | ( | int | isBound, |
| unsigned int | uCloudBuffSize, | ||
| const char * | uuid ) |
启动服务.
| isBound | 设备本地记录的绑定状态. 复位或在TciCB::on_status()里 STATUS_DELETED 时清除。收到 STATUS_LOGON 时设置并保存 |
| uCloudBuffSize | 云存储缓冲区大小(单位:字节). 要求能缓存3~5秒音视频数据, 为0会禁用云存 |
| uuid | 设备id. 新的id参数为 "<uuid></i>,<i><key>" 的形式, 烧号时由服务器分配 |
| TG_PUBLIC int TciStop | ( | void | ) |
| TG_PUBLIC int TciCleanup | ( | void | ) |
| TG_PUBLIC int TciSetCallback | ( | const struct TciCB * | cb | ) |
| TG_PUBLIC int TciSetCmdHandler | ( | const TGCMDHANDLER | cb | ) |
注册通用命令回调 在回调里处理APP发来的命令请求
| TG_PUBLIC void TciSetSessionUserData | ( | p2phandle_t | handle, |
| void * | pUser ) |
绑定应用私有数据指针到p2p handle
| [in] | handle | P2P句柄, 来自命令回调 |
| [in] | pUser | 应用私有数据指针 |
| TG_PUBLIC void * TciGetSessionUserData | ( | p2phandle_t | handle | ) |
返回由TciSetSessionUserData()设置的应用私有数据指针
| [in] | handle | P2P句柄 |
| 返回P2P句柄绑定的应用私有数据,没有则返回NULL |
| TG_PUBLIC void TciSetLogOption | ( | int | b_output_to_console, |
| const char * | log_path, | ||
| int | max_log_size ) |
控制日志输出.
应该在TciInit()前调用
| b_output_to_console | 是否输出到控制台 |
| log_path | log文件路径。应该是一个全局或静态的字符串指针. 为NULL时不创建日志文件 |
| max_log_size | 日志文件最大尺寸(单位:byte) |
| TG_PUBLIC void TciSetLogLevel | ( | int | level | ) |
设置SDK日志输出等级.
| level | 3:Information(default); 5:verbose; 6:debug |
| TG_PUBLIC void TciSetCloudStream | ( | int | channel, |
| int | stream ) |
设置云存储录像通道的码流
| channel | 视频通道 |
| stream | 码流: 0-主; 1-辅 |
| TG_PUBLIC int TciSetSysOption | ( | TCSYSOPTION | opt, |
| const void * | pVal ) |
| TG_PUBLIC int TciGetSysOption | ( | TCSYSOPTION | opt, |
| void * | pVal ) |
| TG_PUBLIC int TciStartInTestMode | ( | const char * | key_path | ) |
开启p2p功能,进入厂测状态.
| key_path | key 文件路径 |
| 0 | ok |
| -1 | failed |
| TG_PUBLIC int TciSetEventEx | ( | EVENTPARAM * | evtp | ) |
上报事件。本版本允许附带事件特定参数.
| evtp | 事件参数指针 |
| TG_PUBLIC int TciStopEvent | ( | ECEVENT | evt | ) |
停止事件, 仅少数事件才有意义.
| evt | ECEVENT_DOORBELL 为取消呼叫. |
| TG_PUBLIC int TciSetLockEvent | ( | int | cls, |
| int | msg, | ||
| int | usrtyp, | ||
| int | usrid ) |
门锁事件上报。图片和录像都在内部处理了.
参数见外部文档
| TG_PUBLIC int TciReport4GInfo | ( | const char * | imei, |
| const char * | iccid, | ||
| ECG4STATE | state ) |
| TG_PUBLIC int TciReportGpsInfo | ( | const unsigned int | time, |
| const double | longitude, | ||
| const double | latitude, | ||
| double | speed, | ||
| int | angle, | ||
| int | signal_strength ) |
上报GPS信息
| time | 当前时间 |
| longitude | 当前经度值(单位:度). >0 东经,<0 西经 |
| latitude | 当前纬度值(单位:度). >0 北纬,<0 南纬 |
| speed | 速度 km/h |
| angle | 对正北方向的夹角: 0~359 |
| signal_strength | 0:未知(忽略); 1:弱; 2:中; 3:强 |
| TG_PUBLIC int TciReportBatteryStatus | ( | int | qoe, |
| int | qoe_low, | ||
| int | charging ) |
上报电池状态
| qoe | 电池电量百分比(0~100); -1:未知 |
| qoe_low |
|
| charging | 1-正在充电; 0-放电状态 |
| TG_PUBLIC void TciSetRtState | ( | ENUMRTSTATE | state, |
| void * | pData ) |
报告系统运行时状态
| state | 状态名. ENUMRTSTATE |
| pData | state 相关参数。具体见 |
| TG_PUBLIC int TciSwitchDeviceStatus | ( | int | status | ) |
设置设备开关状态.
| status | 0:关; 1:开 |
| TG_PUBLIC int TciSendUserData | ( | const unsigned char * | data, |
| int | len ) |
发送用户自定义数据到第三方平台.
需要平台间对接
| TG_PUBLIC int TciSendCmd | ( | p2phandle_t | handle, |
| unsigned int | cmd, | ||
| const void * | data, | ||
| int | dataSize ) |
发送p2p命令请求
| handle | 连接句柄,由 TciSetCmdHandler()设置的回调被调用时会收到此句柄 |
| cmd | 命令标识 |
| data | 指向命令参数 |
| dataSize | 参数长度 |
| TG_PUBLIC int TciSendCmdResp | ( | p2phandle_t | handle, |
| unsigned int | cmd, | ||
| const void * | data, | ||
| int | dataSize ) |
发送p2p命令应答
| handle | 连接句柄,由 TciSetCmdHandler()设置的回调被调用时会收到此句柄 |
| cmd | 命令标识 |
| data | 指向命令参数 |
| dataSize | 参数长度 |
| TG_PUBLIC int TciSendCmdRespStatus | ( | p2phandle_t | handle, |
| unsigned int | cmd, | ||
| unsigned int | status ) |
| TG_PUBLIC int TciSendPbFrame | ( | p2phandle_t | handle, |
| uint32_t | id_mt, | ||
| const uint8_t * | frame, | ||
| int | len, | ||
| uint32_t | timestamp, | ||
| int | uFrameFlags ) |
回放时发送数据帧.
| handle | 连接句柄 |
| id_mt | 低16位:媒体数据类型 TCMEDIA ; 高16位:视频通道号(0~N-1) |
| frame | 帧数据指针 |
| len | 帧数据长度 |
| timestamp | 帧的时间戳 |
| uFrameFlags | 帧标志(低16位)
|
| >0 | ok |
| 0 | 当前为回放暂停状态。 |
| TCE_NETWORK_BUSY | TCE_NETWORK_BUSY :网络拥堵,应用层要延迟一会儿(例如300ms)后重新发送 |
| -1 | 其它错误,通常意味着连接无效 |
| TG_PUBLIC int TciSendPbMessage | ( | p2phandle_t | handle, |
| RTMTYPE | type, | ||
| unsigned int | data1, | ||
| unsigned int | data2, | ||
| const void * | data, | ||
| int | data_len ) |
在回放流中插入消息.
| handle | p2p连接句柄。 |
| type | 消息类型 |
| data1 | RTMSGHEAD_t::data1 |
| data2 | RTMSGHEAD_t::data2 |
| data_len | 额外数据长度 RTMSGHEAD_t::frame_size |
| data | 指向额外数据 |
| TG_PUBLIC int TciSendFrameEx | ( | int | channel, |
| int | stream, | ||
| TCMEDIA | mt, | ||
| const uint8_t * | pFrame, | ||
| int | length, | ||
| uint32_t | ts, | ||
| int | uFrameFlags ) |
发送实时音视频帧, SDK内部会将数据分发到云端和APP.
| channel | 视频通道号: 0|1|...; 对音频为0. |
| stream | 视频码流: 0-高清; 1-标清. 对音频为0。 |
| mt | 媒体类型 TCMEDIA |
| pFrame | 指向数据帧。视频要带4个前导字节 00 00 00 01 |
| length | 数据帧长度 |
| ts | timestamp. 单位为ms |
| uFrameFlags | 帧标志(低16位)
|
| TG_PUBLIC int TciSendLiveMessage | ( | int | channel, |
| int | stream, | ||
| RTMTYPE | type, | ||
| unsigned int | data1, | ||
| unsigned int | data2, | ||
| const void * | data, | ||
| int | data_len ) |
发送实时流消息.
| channel | 通道。为-1时在全部通道上发送 |
| stream | 码流。为-1时在全部码流上发送 |
| type | 消息类型. 参见 RTMTYPE |
| data1 | 消息相关数据 |
| data2 | 消息相关数据 |
| data_len | 额外数据长度 RTMSGHEAD_t::frame_size |
| data | 指向额外数据 |
| TG_PUBLIC int TciSendRtMsg | ( | p2phandle_t | handle, |
| RTMTYPE | type, | ||
| unsigned int | data1, | ||
| unsigned | data2, | ||
| const void * | extra_data, | ||
| int | extra_len ) |
在命令通道上发送通知.
| handle | 指定连接。如果为NULL,则发广播. |
| type | 消息类型 |
| type | 消息类型. 参见 RTMTYPE |
| data1 | 消息相关数据 |
| data2 | 消息相关数据 |
| extra_data | 指向额外数据, 可以为NULL |
| extra_len | 额外数据长度 |
| TG_PUBLIC int TciConfigWifi | ( | int | mode | ) |
开始配置WIFI.
支持AP热点或设备扫描手机上的二维码的方式配置WIFI. AP热点名称为 "AICAM_uuid" 的形式.
该调用会一直阻塞直到获得了正确的wifi配置.
| mode | 配网方式. GWM_QRCODE (需要调用qrInit()初始化qrcode模块), GWM_AP 的组合。 |
| TG_PUBLIC int TciConfigWifiWithoutReset | ( | int | mode | ) |
开始配置WIFI.
同 TciConfigWifi(), 但不会复位SDK. 用于在设备绑定后重新配置wifi.
配网成功后调用TcuIpChanged()加快设备重新上线速度.
| TG_PUBLIC int TciCheckRegString | ( | const char * | s | ) |
在sdk外部扫二维码.
调用此接口验证
| TG_PUBLIC int TciStopConfigWifi | ( | int | mode | ) |
中止配网.
| mode | 要中止的配网方式. GWM_QRCODE 只中止qrcode; GWM_AP 会中止全部配网方式。 |
| TG_PUBLIC const void * TciGetRegisterConfiguration | ( | int * | len | ) |
保存wifi注册信息.
用于wifi模块从AP模式切换到STA模式必须重启的情形。
| SA_BOOL TciSetRegisterConfiguration | ( | const void * | data, |
| int | len ) |
恢复wifi注册信息.
| TG_PUBLIC int TciSetP2pInfo | ( | const char * | sss | ) |
| TG_PUBLIC int TciProcessRegInfo | ( | const void * | data | ) |
处理从蓝牙收到的注册数据
| data | 命令0x8006的数据 |
| TG_PUBLIC int TciSetRegInfo | ( | const char * | s | ) |
手动处理注册信息
| s | 另一台设备通过 STATUS_GOT_REGINFO 获取到的注册信息 |
| TG_PUBLIC int TciAllocCloudBuffer | ( | unsigned int | uCloudBuffSize | ) |
预分配云存储帧缓存空间.
本功能用于对上传时间敏感的事件唤醒类设备录像。 可以在网络初始化前就调用本接口,之后调用 TciSendFrameEx()就会向缓冲写入帧。 设备TciStart()成功后调用TciSetEventEx(),已经缓存的帧得以上传。
不调用本接口,TciStart()内部会在设备注册成功后执行同样功能.
| uCloudBuffSize | 云存储缓冲区大小(单位:字节),最小1M |
| TG_PUBLIC void TciFlushCsCache | ( | ) |
等待录像缓冲区中的所有数据被消耗掉.
| TG_PUBLIC int TciSetKeyVideoTime | ( | int | channel, |
| int | stream, | ||
| time_t | t ) |
告诉SDK下一个视频关键帧的实际发生时间(UTC).
| channel/stream | 云存的通道和码流 |
| t | 下一个关键帧的发生时间 |
| TG_PUBLIC int TciPrepareHiberation | ( | int * | socks, |
| int | size ) |
准备休眠 本api建立到唤醒服务器的tcp连接,并且返回连接数.
调用者对返回的socket调用getpeername()/getsockname()取得与唤醒服务器的连接信息, 并使用此信息配置wifi模组,然后对主芯片下电。在模组里每50"向唤醒 服务器发送64字节的心跳包,包内容任意。
注意: 设备如果要进入休眠,应用层不能关闭返回的socket.
| socks | 接收连接socket |
| size | socks数组大小 |
| >=0 | number of sockets connected to wakeup-servers |
| <0 | failed |
| TG_PUBLIC int TciGetWakeupServers | ( | Ipv4Addr | servers[3] | ) |
获取唤醒服务器ip地址
| servers | 接收服务器地址。最多返回3个地址 |
| TG_PUBLIC const uint8_t * TciPrepareAuthString | ( | const char * | randKey, |
| int * | len_of_authstring ) |
生成唤醒服务器登录命令.
本接口用于到唤醒服务器的tcp连接不由主机创建的情形.
| randKey | 服务器生成的随机串 |
| len_of_authstring | 登录命令长度 |
| TG_PUBLIC void TciSetP2pDown | ( | SA_BOOL | bDown | ) |
暂停或继续运行 P2P.
| bDown | 1:暂停p2p; 0:继续运行p2p |
| TG_PUBLIC void TciSetWakeupReason | ( | time_t | t_wakeup, |
| int | r, | ||
| const char * | user_reason, | ||
| int | sig_lvl, | ||
| int | sdc_rec ) |
设置低功耗设备唤醒原因, 设备进入休眠时会上报给服务器.
| t_wakeup | 唤醒时间 |
| r | <0:异常唤醒; 0:远程唤醒; >0:唤醒事件类型(ECEVENT) |
| user_reason | 当r=ECEVENT_USER_DEFINED, user_reason为用户定义的唤醒理由字符串,长度不超过15个字符. 其它情形下传NULL |
| sig_lvl | wifi或4G信号强度: 0~100. 传负数时由用户自己解释 |
| sdc_rec | SD卡录像长度 |
| TG_PUBLIC int TciForceSleeping | ( | SA_BOOL | bDiscardFilesInQueue | ) |
设备端准备强制休眠.
本操作会先通知实时用户(app端收到通知后要停止视频),然后停止云上传、退出p2p、断开长连接等.
返回后设备可以立即下电。
| bDiscardFilesInQueue | 是否放弃上传队列中未处理的文件. 如果为 SA_FALSE, 会尝试上传队列中的所有文件. 建议在开启了后备存储并且存储路径有效时 SA_TRUE,这样在网络不好,队列中文件多时可以加速返回. 其它情况下的设置由应用自行载定. |
| TG_PUBLIC int TciSetBackStore | ( | const char * | sd_path, |
| ECBUFFERHINT | buffer_hint ) |
设置云存储后备存储目录和缓存策略.
当设置后备存储目录后,SDK会利用此目录暂存上传失败的录像和图片, 并在合适的时机重传.
本功能要在 TciStart() 前调用
| sd_path | 用于后备存储的目录 |
| buffer_hint | 内存缓存策略. |
| 0 |
| TG_PUBLIC void TciBackStoreEnableUpload | ( | int | en | ) |
允许或禁止后备上传.
| en | 1:enable; 0:disable |
| TG_PUBLIC void TciBackStoreEnable | ( | int | en | ) |
这个接口用于sd卡格式化前释放backstore, 和格式化后重新开启后备存储
| en | 0-释放; 非0-重新打开 |
| void * TciUduBegin2 | ( | const char * | evt, |
| time_t | tRecordStart, | ||
| const char * | jpg_pic, | ||
| int | pic_len ) |
开始一个用户定义上传.
自定义上传主要用于sdk本身预录时间不足或不能录像,要从SD卡录像上传的情形.
必须在 TciStart() 成功后调用
| evt | 事件类型. ECEVENT (作为参数传入时要强传为 const char *型), 或长度小于16的字符串。 目前仅支持行车记录仪的事件(ECEVENT_DR_BEGIN ~ ECEVENT_DR_END) 或者 TciCB::on_status(STATUS_SDER, SDER *, ...) 回调的平台定义事件( SDER::event ) |
| tRecordStart | 录像起始时间 |
| jpg_pic | 图片数据(如果有的话)指针(SDK不会take图片缓冲区的所有权) |
| pic_len | 图片数据长度 |
| TG_PUBLIC int TciUduPutFrame | ( | void * | hUdu, |
| TCMEDIA | mt, | ||
| uint32_t | ts, | ||
| const uint8_t * | pFrame, | ||
| int | size, | ||
| int | uFrameFlags ) |
自定义上传过程,写入帧.
| hUdu | TciUduBegin() 返回的上传句柄 |
| mt | 媒体类型. 参见 TciSendPbFrame() 的 id_mt 参数 |
| ts | 时间戳 |
| pFrame | 帧数据指针 |
| size | 帧数据大小 |
| uFrameFlags | 视频:关键帧标志(1:关键帧;0:非关键帧); 音频: 音频采样格式 |
| TG_PUBLIC void TciUduEnd | ( | void * | hUdu | ) |
结束自定义上传
| hUdu | TciUduBegin() 返回的上传句柄 |
| TG_PUBLIC void TciSelectEnvironment | ( | int | env | ) |
| void TciSetParamFileOps | ( | struct paramf_ops * | ops | ) |
设置参数文件操作指针.
SDK会保存工作参数到flash. 小系统设备在flash上没有标准文件I/O支持时,需要提供载入和写参数的操作。本操作要在 TciInit() 之前调用
linux和有文件系统的liteos不需要设置
| ops | 参数文件操作结构指针 |
| TG_PUBLIC int TciSetMaxP2pClientsNum | ( | int | num | ) |
| TG_PUBLIC int TciUpgradeOnTheAir | ( | const char * | subdev | ) |
下载升级包
| subdev | NULL或子设备id. 用于选择相应的固件 |
| TG_PUBLIC int TciQueryForOTA | ( | const char * | uuid, |
| DEVICEOTAINFO * | ota ) |
| TG_PUBLIC int TciQueryForOta2 | ( | const char * | fw_id, |
| const char * | fw_ver, | ||
| DEVICEOTAINFO * | ota ) |
查询第三方升级包.
| fw_id | 第三方设备的 firmware id |
| fw_ver | 第三方设备的当前版本号。版本号在平台上是以8位数字("01010101")的方式记录. 如果第三方固件的版本有不同表示方式,需要在上传固件时自行维护一个映射关系. |
| ota | 返回升级包信息 |
| TG_PUBLIC int TciPerformOTA | ( | DEVICEOTAINFO * | ota | ) |
执行下载过程,会调用回调里的 ota 接口.
| TG_PUBLIC int TciGetUserFile | ( | const char * | name, |
| SA_BOOL | bToFile, | ||
| union TgfDest * | dest, | ||
| int | timeout ) |
查询并下载用户文件.
| name | 文件上传到服务器端时确定的文件标识 |
| bToFile | 1:下载到文件; 0:下载到内存 |
| dest | 下载到文件时,设置 dest->file.path 为本地文件路径; 下载到内存时,内容在dest->mem中返回 |
| timeout | 超时设置。单位: 秒 |
| TG_PUBLIC int TciQueryUserFile | ( | const char * | name, |
| EcFileLink * | flnk ) |
获取用户文件的下载地址.
| name | 文件上传到服务器端时确定的文件标识 |
| flnk | 成功时返回文件信息 |
| TG_PUBLIC int TciDownloadUserFile | ( | const EcFileLink * | flink, |
| SA_BOOL | bToFile, | ||
| union TgfDest * | dest, | ||
| int | timeout ) |
下载用户文件.
| flink | 用户文件信息 |
| bToFile | 1:下载到文件; 0:下载到内存 |
| dest | 下载到文件时,设置 dest->file.path 为本地文件路径; 下载到内存时,内容在dest->mem中返回 |
| timeout | 超时值。单位:秒 |
| int TgQueryUploadReq | ( | const char * | uuid, |
| const char * | model_id, | ||
| char ** | ppUrl ) |
| uuid | |
| model_id | may be NULL |
| ppUrl | 如果有请求,返回上传地址 |
| int TgPostLogFile | ( | const char * | url, |
| const char * | uuid, | ||
| const char * | path, | ||
| int | timeout ) |
| int TgPostLogMem | ( | const char * | url, |
| const char * | uuid, | ||
| const void * | mem, | ||
| int | size, | ||
| const char * | name, | ||
| int | timeout ) |
| url | TgQueryUploadReq() 返回的上传地址 |
| uuid | |
| mem | 内存地址 |
| size | 数据长度 |
| name | 保存为文件名name |
| timeout | 超时值(ms) |
| TG_PUBLIC int TciPutLogFile | ( | const char * | local_path, |
| int | timeout ) |
上传日志文件.
| local_path | 本地文件路径。 |
| timeout | 超时值(ms) |
| TG_PUBLIC int TciPutLogMem | ( | const void * | mem, |
| int | size, | ||
| const char * | name, | ||
| int | timeout ) |
上传内存中的日志
| mem | 内存地址 |
| size | 数据长度 |
| name | 保存为文件名name |
| timeout | 超时值(ms) |
| char * TciGetActivationAttrs | ( | void | ) |
获取设备属性字符串。调用者把该字符串传给MCU,用于在MCU端激活设备.
调用者要 free() 返回的字符串.
| unsigned char * TciGetPlatConfig | ( | int * | pLen | ) |
返回要同步到MCU的数据.
| pLen | 用于返回数据长度. |
| TG_PUBLIC int TciSyncPlatConfig | ( | const unsigned char * | pData, |
| int | len ) |
同步从MCU来的数据.
| pData | 从MCU收到的同步数据 |
| len | 数据长度 |
| TG_PUBLIC int TciLocalStart | ( | const char * | url, |
| const ICECONFIG * | cfg, | ||
| int | size ) |
开启本地工作模式.
该模式用于仅在局域网工作的设备. 有需要先要同我们联系.
| url | |
| cfg | webrtc 服务配置数组 |
| size | 数组大小 |
| TG_PUBLIC unsigned int TciGetSdkState | ( | void | ) |
| TG_PUBLIC int TciSetEventRecordLength | ( | int | erl | ) |
设置用户定义低功耗设备的事件云录像时长.
| erl | 录像时长,可取值 -1/10/20/30. <=0时录像时长由sdk决定. |
| TG_PUBLIC int TciClearCache | ( | SA_BOOL | bResetRemote | ) |
清除SDK运行cache.
| bResetRemote | 同时恢复平台端的配置 |
| TG_PUBLIC int TciAcceptInCall2 | ( | ECALLFLAVOR | flavor | ) |
接听.
| flavor | 通话类型 VIDEO_CALL 或 VOICE_CALL |
| TG_PUBLIC int TciRejectInCall2 | ( | ) |
拒接.