Tange Cloud for Device
 Rev.368
载入中...
搜索中...
未找到
TgCloudApi.h
浏览该文件的文档.
1/**
2 * @file TgCloudApi.h
3 * @brief 探鸽云SDK接口申明
4 */
5#ifndef __TgCloudApi_h__
6#define __TgCloudApi_h__
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12#include <stdint.h>
13#include <time.h>
14#include "TgCloudConst.h"
15#include "TgCloudCmd.h"
16#include "TgCloudCmdEx.h"
17#include "ec_const.h"
18#include "TgCloudUtil.h"
19
20
21/** \addtogroup api_const
22 * @{*/
23/** sim 卡类型 */
24typedef enum {
25 SIMT_PHY, ///< 物理卡
26 SIMT_ESIM, ///< ESIM
27 SIMT_VSIM ///< vsim卡
29
30/** 低功耗设备的工作模式 */
31typedef enum {
32 PM_ALLON, ///< 常电模式。非低功耗设备的默认模式
33 PM_SLEEPABLE, ///< 系统可休眠(会收到STATUS_IDLE状态回调。这是低功耗设备的默认模式)
34 PM_NETDOWN ///< 主控正常工作,网络模块进入休眠模式
35} PMODE;
36
37/** 传输内容 */
38typedef enum {
39 TRANS_SERVICE_LIVE_AV = 0,
40 TRANS_SERVICE_AUDIO_PIC = 1,
41 TRANS_SERVICE_PIC_ONLY = 2,
42 TRANS_SERVICE_MAX
44
45/** SDK选项常数 */
46typedef enum {
47 /** 有人观看时禁止上传.
48 * 类型: int*
49 * - 1 disable
50 * - 0 Allow parallel operation
51 */
53
54 /** 云存储缓冲文件数.
55 * 类型: int*: 1~6
56 */
58
59 /** 传输内容.
60 * 类型: int*:
61 * - 0 live video/audio
62 * - 1 picture+audio
63 * - 2 picture only.
64 * @ref ETRANSSERVICE.
65 */
67
68#if 0
69 /** tcp连接方式.
70 * 类型 int*:
71 * - 0 default
72 * - 1 并发
73 */
74 TCOPT_TCP_CONNECTOR = 4,
75#endif
76
77 /** backstore 存储天数.
78 * 类型 int*:
79 * - 0 同云服务保存天数
80 * - >0 自定义的存储天数.不超过服务规定的天数
81 */
83
84 /** 最大云存data文件。超出的帧会丢弃.
85 * 类型: int*
86 */
88
89 /** 仅上报AI事件.
90 * 类型: int*
91 * @sa TCOPT_ONLY_REPORT_AI_EVENT2
92 */
94
95 /** 用户没有应答不能拉流. 用于楼宇对讲.
96 * 类型: int *
97 */
99
100 /** 事件云存预录时间长度, 单位: 秒.
101 * 类型: int *
102 * @note 默认为5\". 实际长度受云存缓存大小限制。记住录像总时长是不变的.
103 */
105
106 /* Set by VDP. Don't genera event&record for wxvoip/doorbell. */
107 TCOPT_NO_CALL_EVENT = 10,
108 /* Set by VDP. 如果设置, doorbell的响应由vdp模块集中处理. */
109 TCOPT_UNIFORMED_CALL_PROCESS = 11,
110
111 /** 开关云存码流调整功能.
112 * 类型: int *
113 */
115
116 /** 在有AI服务时仅上报AI事件, 无服务时可以上报普通事件.
117 * 类型: int *
118 * @sa TCOPT_ONLY_REPORT_AI_EVENT
119 */
121
122 /** 探测长连接心跳.
123 * 类型: int *
124 * - 0 不探测, 采用默认的短心跳
125 * - 1 开启探测
126 */
128
129 /** 云端缩时录像回放倍速.
130 * 类型: int *
131 */
133
134 /** 支持缩时录像补录.
135 * 类型: int *
136 */
139
140/** @anchor sdk_state_flags */
141/** @name SDK状态标志
142 * @{*/
143#define TGSS_F_CS_INSERVICE 0x00000001 ///< 云文件正在打包
144#define TGSS_F_P2P_CONNECTED 0x00000002 ///< 有用户连接
145#define TGSS_F_P2P_STREAMING 0x00000004 ///< 用户正在拉流
146#define TGSS_F_P2P_INSETTING 0x00000008 ///< 用户处在设置界面
147#define TGSS_F_BS_UPLOADING 0x00000010 ///< 后备存储正在上传
148#define TGSS_F_CALL_PENDING 0x00000020 ///< 呼叫正在等待处理
149#define TGSS_F_IN_CONVERSATION 0x00000040 ///< 呼叫通话中
150#define TGSS_F_CS_UPLOADING 0x00000080 ///< 云文件正在上传
151/**@}*/
152
153/**@}*/ //group api_const
154
155/** \defgroup api_structure API数据结构
156 * API接口用到的数据结构
157 * @{*/
158/** 设备基本信息 */
159typedef struct TCIDEVICEINFO {
160 char device_type[16]; ///< Not used
161 char vendor[16]; ///<设备生产厂商 OEM
162 char firmware_id[32]; ///<ota 升级用的固件标识, 平台唯一. 两款设备,如果升级包一样,就有相同的 firmware_id。
163 ///< 可以按 "公司_方案_设备类型_其它信息" 的规则自己定义一个字符串, 例如: "TANGE_HISI_IPC_001".
164 ///< 标识里不能有"."。
165 ///< 平台按字符串比较,不关心具体内容.
166 char firmware_ver[10]; ///< 固件主版本,8个数字组成的字符串。like: "03020201", means 3.2.2.1.
167 char model[32]; ///< 产品型号
169
170/** 云服务信息 */
171typedef struct TCISERVICEINFO {
172 ECSERVICETYPE serviceType; ///< 云服务类型
173 time_t expiration; ///< 过期时间(utc)
174 union {
176 /**< 当 serviceType = @ref ECGS_TYPE_STORAGE, sub_type 为云存服务子类型:
177 * - EC_SVC_EVENT: 事件录像
178 * - EC_SVC_CONTINUOUS: 全天录像
179 * - EC_SVC_FOR_AI: 仅为ai服务提供短录像,其它事件不录像
180 * - EC_SVC_IMAGE_N: 保存N张图片
181 */
182
183 char *objects;
184 /**< 当 serviceType = @ref ECGS_TYPE_AI, objects 为
185 * '\0'结尾并以一个额外 '\0'结束的允许检测的ai对象列表。例如: "body\0car\0cry\0"
186 */
187 };
189
190/** p2p连接句柄. A opaque pointer */
191typedef void *p2phandle_t;
192/** 命令回调类型 */
193typedef int (*TGCMDHANDLER)(p2phandle_t handle, int cmd, const void *data, int len);
194
195/*
196typedef uint64_t feature_map_t;
197void FEATURE_ZERO(feature_map_t *fm);
198int FEATURE_SET(feature_map_t *fm, feature_t f);
199int HAS_FEATURE(const feature_map_t *fm, feature_t f);
200*/
201
202/** P2P发送统计数据结构 */
204 short id; ///< 用户(连接)标识
205 short vchannel; ///< 视频通道
206 short vstream; ///< 码流
207 short is_igop; ///< 1:统计间隔为一个I帧间隔; 0:周期约为~1s
208 int nBytesInBuff; ///< 位于发送缓冲区的字节数
209 int nBytesSent; ///< 已经发送的字节数
210 int nBytesTotal; ///< 总共收到的字节数
211 int nBytesThrow; ///< 丢掉的字节数。丢包会持续到到一个I帧,这期间即使网络恢复也会丢,所以其值只能作为参考, 不能用于计算网速
212 int msStatInterval; ///< 统计周期(单位: ms)
213};
214
215/** sdk 回调函数结构 */
216struct TciCB {
217 /** 获取设备基本信息 */
218 int (*get_info)(TCIDEVICEINFO *info);
219
220 //int (*on_get_features)(feature_map_t *features);
221
222/** 设备能力. 参见 @ref DeviceFeatures
223 \param key 能力名
224 \param buf 返回能力描述的缓冲区
225 \param size 缓冲区大小
226 \retval 0 ok
227 \retval <0 failed(not recognize)
228*/
229 int (*get_feature)(const char *key, char *buf, int size);
230
231 /** 取设备当前状态或初始默认设置.
232 *
233 * \param key 状态名
234 * \li \c CVideoQuality 云录像清晰度. 格式: <tt>stream:channel</tt>
235 * \li \c streamQuality 实时视频默认码流. 格式: <tt>stream:channel</tt>
236 * - \c stream 码流: 0-高清; 1-标清
237 * - \c channel 视频通道号: 0, 1, ...
238 *
239 * \li \c mac 设备mac地址, null结尾的12个十六进制字符
240 * \li \c versions 版本号的json数组。格式: ["main_ver", "sub_ver1", ...]. 版本号为8个数字级成的字符串如"01000208"(=1.0.2.8)
241 *
242 * \param buf 返回值缓冲区
243 * \param size 缓冲区大小
244 *
245 */
246 int (*get_state)(const char *key, char *buf, int size);
247
248 /** 直连模式下用户登录帐号检查
249 * \param user 用户名, 目前未使用
250 * \param key 用户密码加密
251 * \retval 1 验证成功
252 * \retval 0 失败
253 */
254 int (*on_apmode_login)(const char *user, const char *key);
255
256/**
257 * @name OTA接口
258 * @{
259 */
260 /** OTA升级开始
261 * \param new_version 升级包版本
262 * \param size 升级包大小
263 * \return 0 升级继续; -1 升级中止
264 */
265 int (*on_ota_download_start)(const char *new_version, unsigned int size);
266
267 /** 升级包数据
268 * 升级包下载过程中,sdk调用此回调将数据传给应用层
269 * \param buff 数据
270 * \param size 数据长度
271 * \return 0 继续; -1 传输中止
272 */
273 int (*on_ota_download_data)(const uint8_t *buff, int size);
274
275 /** 升级包下载结束
276 * \param status 完成状态: 0-ok, 可以执行升级; 1-下载中断; 2-数据校验错
277 * \retval -1 应用中止升级过程
278 * \retval 0 如果应用可以立即执行升级,可以返回0表示升级成功
279 * \retval 1 如果应用要退出进程再升级,返回1通知APP等待.
280 * @note 因为返回0/1后应用会退出,不保证APP端一定能收到应答
281 */
282 int (*on_ota_download_finished)(int status);
283/**@}*/
284
285
286/**
287 * @name 二维码扫描
288 * @{
289 */
290 /** 二维码扫描开始
291 * 应用层在此开启取Y数据的通道
292 * \return 0 ok; -1 failed
293 */
294 int (*qrcode_start)(void);
295
296 /** 获取Y图片
297 * \param[in,out] ppYBuff
298 * \param[out] width 返回图片宽度
299 * \param[out] height 返回图片高度
300 * \return 0 ok; -1 停止扫描
301 * @note 第一次调用时 *ppYBuff为NULL. 应用层在此分配一个缓冲区, 填入Y数据,并把缓冲区指针保存到*ppYBuff.
302 * 之后的调用 *ppYBuff为之前设置的值
303 */
304 int (*qrcode_get_y_data)(uint8_t **ppYBuff, int *width, int *height);
305
306 /** 结束二维码扫描
307 * \param ppYBuff *ppYBuff中为最后一次在on_get_y_data中返回的值
308 * @note 应用层在此释放前面分配的内存(free(*ppYBuff)), 关闭Y通道
309 */
310 void (*qrcode_end)(uint8_t *pYBuff);
311/**@}*/
312
313 /** 抓取图片. 目前只支持jpeg格式
314 * \param type @ref pic_type "图片类型" in TciCloudConst.h
315 * \param ppJgp *ppJpg为图片地址或用于返回图片的址.见note
316 * \param size 返回时*size为图片字节数
317 * \return 0 ok; @ref TCE_BUFFER_TOO_SMALL; -1 其它错误
318 * @note 如果*ppJpg为NULL,应用层分配图片空间, 空间指针和图片大小分别保存在*ppJpg和*size. sdk内部负责释放空间。
319 * 如果*ppJpg为非空,*ppJpg为SDK内分配的空间地址,*size为空间大小。返回时*size为实际图片大小
320 */
321 int (*snapshot)(int type, uint8_t **ppJpg, int *size); //??
322
323 /** 设置wifi参数
324 * \param is_switching 0:配网; 1:添加成功后修改wifi
325 * \return 0 配置ok; -1 配置不对
326 * \note 返回时, wifi处在station模式
327 */
328 int (*set_wifi)(int is_switching, const char *ssid, const char *key);
329
330 /** 设置时区
331 * \param tzs 时区字符串. Refer to man page of tzset().
332 */
333 int (*set_timezone)(const char *tzs);
334
335 /** 设置时间
336 * \param time utc 时间
337 */
338 int (*set_time)(time_t time);
339
340 /** sdk内部状态
341 * \param status 状态. Refer to @ref ESTATUSCODE in TgCloudConst.h
342 * \param pData 状态相关数据
343 * \param len 同status相关。一般情况下是pData所指数据的长度
344 * \return 返回值同status的值有关. 请查看 @ref ESTATUSCODE. 未作说明和未处理的需要返回0
345 */
346 int (*on_status)(int status, const void *pData, int len);
347
348
349/**
350 * @name 对讲
351 * @{
352 */
353 /** 开始对讲
354 * \return 0 ok; -1 中断
355 */
356 int (*on_talkback_start)(void);
357
358 /** 对讲数据回调
359 * 格式在前面已经协商过
360 * \return 0 if played
361 */
362 int (*talkback)(TCMEDIA at, const uint8_t *audio, int len);
363
364 /** 结束对讲 */
365 void (*on_talkback_stop)(void);
366/**@}*/
367
368 /** @deprecated
369 * 请求I帧. 请使用 request_iframe_ex
370 * \param vstream 视频流. 0-主码流; 1-辅码流
371 * \return 0
372 */
373 int (*request_iframe)(int vstream);
374
375 /** 当AI识别成功,通过本回调通知应用. (本回调未使用,设为NULL)
376 * \param type \ref pic_type "图片类别指示"
377 * \param pJpg 正识别图片
378 * \param len 图片长度
379 */
380 void (*ai_result)(int type, const uint8_t* pJpg, int len);
381
382 /** 在平台端采集设备日志
383 * \param action
384 * - 0-开始长日志采集;
385 * - 1-停止长日志采集;
386 * - 2-获取日志文件用于上传云端. 文件路径不能有空格
387 * - 102-获取日志文件用于传给app。文件只支持文本格式, 路径不能有空格
388 *
389 * \param logfile 同action有关。
390 * - action为0或1时, logfile为NULL
391 * - 当action为2时, logfile用于应用层返回日志文件路径. 多个路径用';'分隔,总长不超过256
392 *
393 * \return 0:ok; -1:failed
394 *
395 * \note 上传会对文件内容作校验,所以上传期间不能修改日志文件内容,应用需要把要上传的文件 \n
396 * 分离出来, 或者在收到上传回调后的一段时间不要更新日志文件内容.
397 */
398 int (*log)(int action, char *logfile);
399
400 /** 请求指定图像通道的I帧
401 * \param channel 图像通道
402 * \param vstream 视频流. 0-主码流; 1-辅码流
403 * \return 0
404 */
405 int (*request_iframe_ex)(int channel, int vstream);
406
407 /** 网络传输统计回调 */
408 void (*trans_stat)(const struct TransStatUser *_stat);
409
410 /** 切换图像质量
411 * @param channel 图像通道。目前为0
412 * @param stream 码流 0,1,..., 在"Resolutions"能力中返回
413 * @param qstr 质量描述串, 例如 HD/SD/FHD/..., 在"Resolutions"能力中返回.
414 */
415 void (*switch_quality)(int channel, int stream, const char *qstr);
416
417 /** 对讲数据回调.
418 * @param mt 数据类型 @ref TCMEDIA
419 * @param ts 时间戳
420 * @param data 媒体帧
421 * @param len 帧长度
422 * @param uFrameFlags 参见 TciSendFrameEx()
423 */
424 void (*talkback_ex)(int mt, unsigned int ts, const void *data, int len, unsigned int uFrameFlags);
425};
426
427/** IPv4 地址表示(网络字节顺序) */
428typedef struct Ipv4Addr {
429 unsigned int ip; ///< ip, network byte-order
430 unsigned short port; ///< port, network byte-order
431} Ipv4Addr;
432
433/** Simple Buffer */
434typedef struct SIMPLEBUFFER {
435 uint8_t *data; ///< 数据缓冲区指针
436 int size; ///< 缓冲区大小
437 int len; ///< 数据长度
439
440/** 参数文件读写函数据指针结构 */
442 /** 分配缓冲区,并读出参数文件.
443 * @param buff 缓冲区结构指针. 由实现填充结构成员。缓冲区大小为参数文件大小加上 cbExtra
444 * @param cbExtra 额外分配的字节数
445 * @retval 1 ok
446 * @retval 0 failed
447 */
448 int (*alloc_and_readall)(SIMPLEBUFFER *buff, int cbExtra);
449
450 /** 写参数文件
451 * @param buff 参数缓冲区指针
452 * @retval 1 ok
453 * @retval 0 failed
454 */
455 int (*save_buff)(const SIMPLEBUFFER *buff);
456
457 /** 释放参数缓冲区 */
458 void (*free_buff)(SIMPLEBUFFER *buff);
459
460 /** 删除参数文件(或者清空参数文件)。下一次读出时 len为0 */
461 void (*remove)(void);
462};
463
464/** 用户文件下载目的地.
465 * @ref TciGetUserFile() */
466union TgfDest {
467 /** 数据下载到文件 */
468 struct to_file {
469 char *path; ///< IN: file path
470 } file;
471 /** 数据下载到内存 */
472 struct to_mem {
473 void *mem; ///< OUT: 指向sdk分配的内存
474 int size; ///< OUT: 数据长度
475 } mem;
476};
477
478/** 设备升级包信息 */
479typedef struct DEVICEOTAINFO {
480 int size; ///< 升级包大小
481 char ver[16]; ///< 升级包版本
482 char md5[36]; ///< md5 检验字符串
483 char url[256]; ///< 下载地址
485
486/** 4G 设备信息 */
487typedef struct TG4GINFO {
488 char imei[24]; ///< 4g模块标识
489 char iccid[24]; ///< sim卡号
490 SIMCARDTYPE sim_type; ///< sim卡类型
491} TG4GINFO;
492
493/** 日志上传配置 */
494struct TgLogConf {
495 time_t tValidUntil; ///< 0:diabled; >0:在此时间后无效
496 int level; ///< 日志等级
497 /** 请求特定模块的日志. 因为上传操作是固件主动发行,因此可以忽略或自行解释这个标志.
498 * - bit 0: SDK日志
499 * - bit 1: 应用层日志
500 */
502};
503
504/**@}*///{group api_structure}
505
506/** \defgroup api_reference API参考
507 * @{*/
508
509/** \name 核心API
510 * @{*/
511
512/** 获取SDK版本号
513 * TciInit()之后调用
514 * \return SDK版本号字符串。如:"rev. nn"
515 */
516TG_PUBLIC int TciGetRevision(void);
517
518/** 配置基本参数
519 * 在TciStart()之前调用
520 * \param path 用于保存sdk私有数据的目录, 需要有读写权限
521 * \param uuid 设备id. 新的id参数为 \"<i>uuid</i>,<i>key</i>\" 的形式, 烧号时由服务器分配
522 * \return 0
523 */
524TG_PUBLIC int TciInit(const char *path, const char *uuid);
525
526/** 启动服务
527 * @pre 调用本接口前需要保证网络已经配置好
528 * 本调用阻塞直到内部完成初始化或操作失败
529 * \param isBound 设备本地记录的绑定状态. 复位或在TciCB::on_status()里 @ref STATUS_DELETED 时清除。收到 @ref STATUS_LOGON 时设置并保存
530 * \param uCloudBuffSize 云存储缓冲区大小(单位:字节). 要求能缓存3~5秒音视频数据, 为0会禁用云存
531 * \retval 0 启动成功
532 * \retval others. Refer to @ref error_code "错误码"
533 * @ref TgCloudConst.h
534 */
535TG_PUBLIC int TciStart(int isBound, unsigned int uCloudBuffSize);
536
537/** 启动服务.
538 * \param isBound 设备本地记录的绑定状态. 复位或在TciCB::on_status()里 @ref STATUS_DELETED 时清除。收到 @ref STATUS_LOGON 时设置并保存
539 * \param uCloudBuffSize 云存储缓冲区大小(单位:字节). 要求能缓存3~5秒音视频数据, 为0会禁用云存
540 * @param uuid 设备id. 新的id参数为 \"<i><uuid></i>,<i><key></i>\" 的形式, 烧号时由服务器分配
541 * @note
542 * 这个接口用于 TciInit() 没有传 uuid 参数的情形. 例如工厂生产测试烧号后立即 \n
543 * 启动服务。烧号前调用TciInit()时uuid为NULL, 烧号后可以在这里传入uuid。
544 * 其它参数和返回值同 TciStart()
545 */
546TG_PUBLIC int TciStart2(int isBound, unsigned int uCloudBuffSize, const char *uuid);
547
548
549/** 停止服务
550 * @pre TciStart() 返回0
551 * @return 0(成功), 或 @ref TCE_SERVER_IS_DOWN, @ref TCE_INVALID_UUID
552 * @ref TgCloudConst.h
553 */
554TG_PUBLIC int TciStop(void);
555
556/** 释放资源
557 * @pre TciStop()
558 * @return Always return 0
559 */
560TG_PUBLIC int TciCleanup(void);
561
562/** 注册回调 -- sdk内部事件
563 * \param cb 非局部TciCB结构指针
564 * \return 0
565 * @note 在 TciInit() 前调用
566 */
567TG_PUBLIC int TciSetCallback(const struct TciCB *cb);
568
569/** 注册通用命令回调
570 * 在回调里处理APP发来的命令请求
571 * @note 在 TciInit() 前调用
572 */
573TG_PUBLIC int TciSetCmdHandler(const TGCMDHANDLER cb);
574
575/** 绑定应用私有数据指针到p2p handle
576 * @param[in] handle P2P句柄, 来自命令回调
577 * @param[in] pUser 应用私有数据指针
578 */
579TG_PUBLIC void TciSetSessionUserData(p2phandle_t handle, void *pUser);
580
581/** 返回由TciSetSessionUserData()设置的应用私有数据指针
582 * @param[in] handle P2P句柄
583 * @retval 返回P2P句柄绑定的应用私有数据,没有则返回NULL
584 */
585TG_PUBLIC void *TciGetSessionUserData(p2phandle_t handle);
586
587/** 控制日志输出. 应该在TciInit()前调用
588 * @param b_output_to_console 是否输出到控制台
589 * @param log_path log文件路径。应该是一个全局或静态的字符串指针. 为NULL时不创建日志文件
590 * @param max_log_size 日志文件最大尺寸(单位:byte)
591 */
592TG_PUBLIC void TciSetLogOption(int b_output_to_console, const char *log_path, int max_log_size);
593
594/** 设置SDK日志输出等级.
595 * @param level 3:Information(default); 5:verbose; 6:debug
596 */
597TG_PUBLIC void TciSetLogLevel(int level);
598
599/** 设置云存储录像通道的码流
600 * @param channel 视频通道
601 * @param stream 码流: 0-主; 1-辅
602 * @note 本接口拟用于画中画设备. \n
603 * 当收到 @ref TCI_CMD_SET_PRIMARY_VIEW 命令时,设备可能希望云录像通道与实时画面一致,就可以调用此接口. \n
604 * 非此情形,用户可以通过App发送 @ref TCI_CMD_SET_CLOUD_VIDEO_QUALITY_REQ 来显式设置云录像通道和码流。这一命令在sdk内部处理, 不会回调给应用层.
605 */
606TG_PUBLIC void TciSetCloudStream(int channel, int stream);
607
608/** 通用sdk工作选项设置接口.
609 * @param opt 选项名. @ref TCSYSOPTION
610 * @param pVal 传入选项值
611 * @return >=0:ok; <0:错误
612 */
613TG_PUBLIC int TciSetSysOption(TCSYSOPTION opt, const void *pVal);
614
615/** 通用sdk工作选项获取接口.
616 * @param opt 选项名. @ref TCSYSOPTION
617 * @param pVal 返回选项的值
618 * @return >=0:ok; <0:错误
619 */
620TG_PUBLIC int TciGetSysOption(TCSYSOPTION opt, void *pVal);
621
622/** 开启p2p功能,进入厂测状态.
623 * @param key_path key 文件路径
624 * @retval 0 ok
625 * @retval -1 failed
626 */
627TG_PUBLIC int TciStartInTestMode(const char *key_path);
628
629/**@}*/ //name 核心API
630
631/** \name 上报事件/状态/其它数据到平台
632 * @{*/
633/** 上报事件。本版本允许附带事件特定参数.
634 * @param evtp 事件参数指针
635 * @return 0:事件已经排队等待发送; non-zeor:错误码
636 * @note 本操作是异步的,返回0后要求evtp->jpg_pic仍然有效。 \n
637 * 如果evtp->evtp_flags 最低位非0, 上传结束后sdk会释放空间. \n
638 * evtp->evtp_flags最低位为0,用于jpg_pic为全局空间的情形. \n
639 * 返回非0时,调用者要自己释放图片空间.
640 */
641TG_PUBLIC int TciSetEventEx(EVENTPARAM *evtp);
642
643/** 停止事件, 仅少数事件才有意义.
644 * @param evt ECEVENT_DOORBELL 为取消呼叫.
645 * @note 取消呼叫时, sdk内部自动取呼叫的时间
646 */
647TG_PUBLIC int TciStopEvent(ECEVENT evt);
648
649/** 门锁事件上报。图片和录像都在内部处理了.
650 * 参数见外部文档
651 */
652TG_PUBLIC int TciSetLockEvent(int cls, int msg, int usrtyp, int usrid);
653
654/** 包装了门铃事件 */
655TG_PUBLIC int TciSetDoorbellEvent();
656
657/** 包装了门铃事件, 无图片.
658 * @param hint: 1-呼叫; 0-取消呼叫
659 */
660TG_PUBLIC int TciSetCallEvent(int hint);
661
662/** @deprecated
663 * 上报4G设备信息. 请使用 TciReport4GInfoEx()
664 * @param imei
665 * @param iccid
666 * @param state G4STATE_xxx
667 * @return 0:成功; <0:错误码
668 */
669TG_PUBLIC int TciReport4GInfo(const char *imei, const char *iccid, ECG4STATE state);
670
671/** 上报4G设备信息,代替 TciReport4GInfo()
672 * @param info 指向4G信息结构
673 * @param state 4G联网状态
674 * @return 0:成功; <0:错误码
675 */
676TG_PUBLIC int TciReport4GInfoEx(const TG4GINFO *info, ECG4STATE state);
677
678/** 上报GPS信息
679 * @param time 当前时间
680 * @param longitude 当前经度值(单位:度). >0 东经,<0 西经
681 * @param latitude 当前纬度值(单位:度). >0 北纬,<0 南纬
682 * @param speed 速度 km/h
683 * @param angle 对正北方向的夹角: 0~359
684 * @param signal_strength 0:未知(忽略); 1:弱; 2:中; 3:强
685 * @return 0:ok; non-zero: error code
686*/
687TG_PUBLIC int TciReportGpsInfo(const unsigned int time, const double longitude, const double latitude,
688 double speed, int angle , int signal_strength);
689
690/** 上报电池状态
691 * @param qoe 电池电量百分比(0~100); -1:未知
692 * @param qoe_low
693 * - 1: 电量低;
694 * - 0: 电量正常;
695 * - -1:未知
696 * @param charging 1-正在充电; 0-放电状态
697 * @return 0-成功; 非0-错误码
698 */
699TG_PUBLIC int TciReportBatteryStatus(int qoe, int qoe_low, int charging);
700
701/** 报告系统运行时状态
702 @param state 状态名. @ref ENUMRTSTATE
703 * @param pData state 相关参数。具体见
704 */
705TG_PUBLIC void TciSetRtState(ENUMRTSTATE state, void *pData);
706
707/** 设置设备开关状态.
708 * @param status 0:关; 1:开
709 * @return 0:ok; <0:error code
710 */
711TG_PUBLIC int TciSwitchDeviceStatus(int status);
712
713/** 发送用户自定义数据到第三方平台.
714 * 需要平台间对接
715 */
716TG_PUBLIC int TciSendUserData(const unsigned char *data, int len);
717
718/**@}*/ //name 上报事件
719
720/** \name 发送音视频和消息
721 * 这个数据通过p2p通道传给App。或者,如果有服务,音视频会上传云端
722 * @{*/
723
724/** 发送p2p命令请求
725 * @param handle 连接句柄,由 TciSetCmdHandler()设置的回调被调用时会收到此句柄
726 * @param cmd 命令标识
727 * @param data 指向命令参数
728 * @param dataSize 参数长度
729 * @return 0 或 \ref error_code "错误码"
730 */
731TG_PUBLIC int TciSendCmd(p2phandle_t handle, unsigned int cmd, const void *data, int dataSize);
732
733/** 发送p2p命令应答
734 * @param handle 连接句柄,由 TciSetCmdHandler()设置的回调被调用时会收到此句柄
735 * @param cmd 命令标识
736 * @param data 指向命令参数
737 * @param dataSize 参数长度
738 * @return 0 或 \ref error_code "错误码"
739 */
740TG_PUBLIC int TciSendCmdResp(p2phandle_t handle, unsigned int cmd, const void *data, int dataSize);
741
742/** 发送一个 Tcis_ErrorResp 结构作应答.
743 * 这个应答用于只需要简单地通知客户端命令执行成功或失败的情形.
744 * @param handle P2P句柄
745 * @param cmd 命令标识
746 * @param status @ref TCI_OK 或 TCI_E_xxx, 参见 @ref generic_err_code "通用错误码"
747 * @return 0 或 \ref error_code "错误码"
748 */
749TG_PUBLIC int TciSendCmdRespStatus(p2phandle_t handle, unsigned int cmd, unsigned int status);
750
751/** 回放时发送数据帧.
752 * @param handle 连接句柄
753 * @param id_mt 低16位:媒体数据类型 @ref TCMEDIA ; 高16位:视频通道号(0~N-1)
754 * @param frame 帧数据指针
755 * @param len 帧数据长度
756 * @param timestamp 帧的时间戳
757 * @param uFrameFlags 帧标志(低16位)
758 * - 视频: 0或 @ref video_frame_flags "FF_KEYFRAME/FF_TIMELAPSE/..." 的组合
759 * - 音频: @ref audio_sample_fmt "音频采样格式" (0(默认)或2: 8k16bmono; 10:16k16bmono)
760 * @retval >0 ok
761 * @retval 0 当前为回放暂停状态。
762 * @retval TCE_NETWORK_BUSY @ref TCE_NETWORK_BUSY :网络拥堵,应用层要延迟一会儿(例如300ms)后重新发送
763 * @retval -1 其它错误,通常意味着连接无效
764 * @note 每次设备在文件内或文件间重新定位, 或者自动跳到下一个文件,要通过 TciSendPbSyncFrame 先发一个绝对时间同步帧.
765 *
766 * @see TciSendPbSyncFrame
767 */
768TG_PUBLIC int TciSendPbFrame(p2phandle_t handle, uint32_t id_mt, const uint8_t *frame, int len, uint32_t timestamp, int uFrameFlags);
769
770/** 在回放流中插入消息.
771 * @param handle p2p连接句柄。
772 * @param type 消息类型
773 * @param data1 @ref RTMSGHEAD_t::data1
774 * @param data2 @ref RTMSGHEAD_t::data2
775 * @param data_len 额外数据长度 @ref RTMSGHEAD_t::frame_size
776 * @param data 指向额外数据
777 */
778TG_PUBLIC int TciSendPbMessage(p2phandle_t handle, RTMTYPE type, unsigned int data1, unsigned int data2, const void *data, int data_len);
779
780/** \def TciSendPbSyncFrame
781 * 发送回放时间同步帧.
782 * @param handle p2p 连接句柄
783 * @param utc_time 下一帧的生成时间(utc, 单位s)
784 * @param is_response_to_PLAY_START 1:响应 @ref TCI_CMD_RECORD_PLAYCONTROL; 0:自动跳到下一个文件
785 */
786#define TciSendPbSyncFrame(handle, utc_time, is_response_to_PLAY_START) TciSendPbMessage(handle, is_response_to_PLAY_START?RTM_SYNCTIME_RESPONSE_TO_USER:RTM_SYNCTIME, 0, utc_time, NULL, 0)
787
788/** \def TciSendPbTimelapseFlag
789 * 发送缩时录像回放标志。在进入和退出时发送.
790 * @param handle p2p 连接句柄
791 * @param flag 1:进入缩时回放; 0:退出缩时回放
792 */
793#define TciSendPbTimelapseFlag(handle, flag) TciSendPbMessage(handle, RTM_TIME_LAPSED, flag, 0, NULL, 0)
794
795/** \def TciSendPbEndOfEvent
796 * 在事件回放结束时发送此标志通知App.
797 */
798#define TciSendPbEndOfEvent(handle) TciSendPbMessage(handle, RTM_END_OF_EVENT, 0, 0, NULL, 0)
799
800
801/** 发送实时音视频帧, SDK内部会将数据分发到云端和APP.
802 * @param channel 视频通道号: 0|1|...; 对音频为0.
803 * @param stream 视频码流: 0-高清; 1-标清. 对音频为0。
804 * @param mt 媒体类型 @ref TCMEDIA
805 * @param pFrame 指向数据帧。视频要带4个前导字节 00 00 00 01
806 * @param length 数据帧长度
807 * @param ts timestamp. 单位为ms
808 * @param uFrameFlags 帧标志(低16位)
809 * - 视频: 0或 @ref video_frame_flags "FF_KEYFRAME/FF_TIMELAPSE/..." 的组合
810 * - 音频: @ref audio_sample_fmt "音频采样格式" (0(默认)或2: 8k16bmono; 10:16k16bmono)
811 * @return >=0:成功; <0:错误码
812 *
813 * @note 该操作不会阻塞调用。如果没有消费者(没有云服务,没有人访问),实际不会做任何事情
814 */
815TG_PUBLIC int TciSendFrameEx(int channel, int stream, TCMEDIA mt, const uint8_t *pFrame, int length, uint32_t ts, int uFrameFlags);
816
817/* @deprecated */
818//#define TciSendFrame(stream_, mt, pFrame, length, ts, uFrameFlags) TciSendFrameEx(0, stream_, mt, pFrame, length, ts, uFrameFlags)
819
820/** 发送实时流消息.
821 * @param channel 通道。为-1时在全部通道上发送
822 * @param stream 码流。为-1时在全部码流上发送
823 * @param type 消息类型. 参见 @ref RTMTYPE
824 * @param data1 消息相关数据
825 * @param data2 消息相关数据
826 * @param data_len 额外数据长度 @ref RTMSGHEAD_t::frame_size
827 * @param data 指向额外数据
828 * @return >=0:成功; <0:错误码
829 */
830TG_PUBLIC int TciSendLiveMessage(int channel, int stream, RTMTYPE type, unsigned int data1, unsigned int data2, const void *data, int data_len);
831
832/** \def TciSendLiveMsg_ReachPsp
833 * 发送预置位到位通知. */
834#define TciSendLiveMsg_ReachPsp(channel, psp_num) TciSendLiveMessage(channel, -1, RTM_REACH_PSP, channel, psp_num, NULL, 0)
835
836/** \def TciSendLiveMsg_LensSwitch
837 * 多目摄像机镜头切换时发送的标志帧, 要求在新镜头的第一帧前发送. */
838#define TciSendLiveMsg_LensSwitch(channel, stream) TciSendLiveMessage(channel, stream, RTM_LENS_SWITCH, channel, stream, NULL, 0)
839
840/** @deprecated
841 * \def TciSendLensSwitchFlag
842 * 发送镜头切换通知, 旧的名字. */
843#define TciSendLensSwitchFlag(channel, stream) TciSendLiveMsg_LensSwitch(channel, stream)
844
845/** 在命令通道上发送通知.
846 * @param handle 指定连接。如果为NULL,则发广播.
847 * @param type 消息类型
848 * @param type 消息类型. 参见 @ref RTMTYPE
849 * @param data1 消息相关数据
850 * @param data2 消息相关数据
851 * @param extra_data 指向额外数据, 可以为NULL
852 * @param extra_len 额外数据长度
853 * @return >0: ok; <0:error code
854 */
855TG_PUBLIC int TciSendRtMsg(p2phandle_t handle, RTMTYPE type, unsigned int data1, unsigned data2, const void *extra_data, int extra_len);
856
857/**@}*/ //name 发送数据
858
859
860/** @name 配网和注册
861 * @{*/
862
863/** 开始配置WIFI.
864 * 支持AP热点或设备扫描手机上的二维码的方式配置WIFI. AP热点名称为 \"<b>AICAM_</b><I>uuid</I>\" 的形式. \n
865 * 该调用会一直阻塞直到获得了正确的wifi配置.
866 * \param mode 配网方式. @ref GWM_QRCODE (需要调用qrInit()初始化qrcode模块), @ref GWM_AP 的组合。
867 * @note 如果SDK不参与配网过程(例如有线、4G,或开发者通过自己的方式完成配网)则不不需要调用本接口. \n
868 * * 如果使用 GWM_AP 但没有真的开启热点, 需要为设备设置一个临时IP.
869 */
870TG_PUBLIC int TciConfigWifi(int mode);
871
872/** 开始配置WIFI.
873 * 同 TciConfigWifi(), 但不会复位SDK. 用于在设备绑定后重新配置wifi. \n
874 * 配网成功后调用TcuIpChanged()加快设备重新上线速度.
875 */
876TG_PUBLIC int TciConfigWifiWithoutReset(int mode);
877
878/** 在sdk外部扫二维码. 调用此接口验证
879 * @return 有效时返回SA_TRUE, 否则返回 SA_FALSE
880 * @note 需要先调用TciConfigWifi()
881 */
882TG_PUBLIC int TciCheckRegString(const char *s);
883
884/** 中止配网.
885 * \param mode 要中止的配网方式. @ref GWM_QRCODE 只中止qrcode; @ref GWM_AP 会中止全部配网方式。
886 */
887TG_PUBLIC int TciStopConfigWifi(int mode);
888
889/** 保存wifi注册信息.
890 * 用于wifi模块从AP模式切换到STA模式必须重启的情形。 \n
891 * @return 要保存的数据的地址。 *len 为要保存的数据的长度
892 *
893 * @note 在 TciConfigWifi()返回后调用 TciGetRegisterConfiguration() 操作并且保存返回的数据。\n
894 * 重启后不调用 TciConfigWifi(), 而是用保存的内容调用 TciSetRegisterConfiguration()。
895 * 然后执行 TciStart() 完成注册过程。
896 */
897TG_PUBLIC const void *TciGetRegisterConfiguration(int *len);
898
899/** 恢复wifi注册信息.
900 * \return 非0表示成功
901 */
902SA_BOOL TciSetRegisterConfiguration(const void *data, int len);
903
904/** @deprecated 设置p2p信息.
905 * @param sss 从平台获取的p2p信息字符串
906 * @return 0:ok; -1:内容错误
907 * @note 在 TciStart()前调用
908 */
909TG_PUBLIC int TciSetP2pInfo(const char *sss);
910
911/** 处理从蓝牙收到的注册数据
912 * @param data 命令0x8006的数据
913 * @note 参看《蓝牙的应用层协议.md》文档。
914 * @note 需要先运行TciConfigWifi()
915 * */
916TG_PUBLIC int TciProcessRegInfo(const void *data);
917
918/** 手动处理注册信息
919 * @param s 另一台设备通过 STATUS_GOT_REGINFO 获取到的注册信息
920 * @note 需要先运行TciConfigWifi()
921 */
922TG_PUBLIC int TciSetRegInfo(const char *s);
923
924/**@}*/ //name 配网和注册
925
926
927/** @name 低功耗相关
928 * @{*/
929/** 预分配云存储帧缓存空间.
930 * 本功能用于对上传时间敏感的事件唤醒类设备录像。
931 * 可以在网络初始化前就调用本接口,之后调用 TciSendFrameEx()就会向缓冲写入帧。
932 * 设备TciStart()成功后调用TciSetEventEx(),已经缓存的帧得以上传。
933 *
934 * 不调用本接口,TciStart()内部会在设备注册成功后执行同样功能.
935 *
936 * \param uCloudBuffSize 云存储缓冲区大小(单位:字节),最小1M
937 *
938 * @return 内存不足时返回-1, 否则返回0
939 *
940 * @note TciStart()会通过回调修改系统时间,设备要保证 TciStart()前后帧的时间戳时连续的。 \n
941 * * 要在 TciInit() 之后调用
942 * * 要在调用前从RTC恢复系统时间和设置时区
943 */
944TG_PUBLIC int TciAllocCloudBuffer(unsigned int uCloudBuffSize);
945
946/** 等待录像缓冲区中的所有数据被消耗掉.
947 * @note 本功能用在缩时录像时缓存周期结束时通知sdk结束打包并立即上传. \n
948 * 操作会阻塞直到打包上传完成. 操作期间不要向sdk送入新的帧.
949 */
950TG_PUBLIC void TciFlushCsCache();
951
952/** 告诉SDK下一个视频关键帧的实际发生时间(UTC).
953 * @param channel/stream 云存的通道和码流
954 * @param t 下一个关键帧的发生时间
955 * @note 默认情况下SDK以调用 TciSendFrameEx()时的时间作为帧的产生时间, 这个时间用于确定云 \n
956 * 存储的开始时间和回放定位.
957 * 当应用层存在缓存行为(帧在时间 T0 时产生, 但在n秒后的 T0+n 时发送), 需要调用本接口 \n
958 * 告诉SDK传入的时间(T0)才是帧的实际发生时间。\n
959 * 调用本接口后,下一次事件时间如果等于或早于T0, 录像从缓冲区中的第一帧开始; 否则执行 \n
960 * 普通的5秒预录。\n
961 * 这种情形一般发生在低功耗设备.
962 */
963TG_PUBLIC int TciSetKeyVideoTime(int channel, int stream, time_t t);
964
965/** 准备休眠
966 * 本api建立到唤醒服务器的tcp连接,并且返回连接数.
967 * 调用者对返回的socket调用getpeername()/getsockname()取得与唤醒服务器的连接信息,
968 * 并使用此信息配置wifi模组,然后对主芯片下电。在模组里每50\"向唤醒
969 * 服务器发送64字节的心跳包,包内容任意。
970 *
971 * 注意: 设备如果要进入休眠,应用层不能关闭返回的socket.
972 *
973 * @param socks 接收连接socket
974 * @param size socks数组大小
975 * @retval >=0 number of sockets connected to wakeup-servers
976 * @retval <0 failed
977 */
978TG_PUBLIC int TciPrepareHiberation(int *socks, int size);
979
980/** 获取唤醒服务器ip地址
981 * @param servers 接收服务器地址。最多返回3个地址
982 * @return 服务器个数
983 */
984TG_PUBLIC int TciGetWakeupServers(Ipv4Addr servers[3]);
985
986/** 生成唤醒服务器登录命令.
987 * 本接口用于到唤醒服务器的tcp连接不由主机创建的情形.
988 *
989 * @param randKey 服务器生成的随机串
990 * @param len_of_authstring 登录命令长度
991 * @return 登录字节串指针。如果失败返回 NULL
992 *
993 * @note 应用要按以下步骤建立到唤醒服务器的有效连接:
994 * 1. 应用调用 TciGetWakeupServers() 获取唤醒服务器的地址
995 * 2. 通信模块建立到唤醒服务器的连接, 接收由服务器返回的randkey
996 * 3. 应用使用此randkey调用本接口
997 * 4. 通信模块向服务器发送本接口生成的认证字符串
998 * 6. 主控下电. 通信模块每50\"向服务器发送64字节的心跳包,包内容任意。
999 */
1000TG_PUBLIC const uint8_t *TciPrepareAuthString(const char *randKey, int *len_of_authstring);
1001
1002/** 设置低功耗设备的工作模式.
1003 *
1004 * @note 需要在TciStart()之后调用. 调用逻辑一定参看文档 @ref a21_ManuallyPowerManagement
1005 */
1006TG_PUBLIC void TciSetPowerMode(PMODE mode);
1007
1008/** 暂停或继续运行 P2P.
1009 * @param bDown 1:暂停p2p; 0:继续运行p2p
1010 * @note 为了能够快速恢复,并不会初始化和反初始化.
1011 */
1012TG_PUBLIC void TciSetP2pDown(SA_BOOL bDown);
1013
1014/** 从NETDOWN模式下恢复网络后,调用本api使p2p快速上线 */
1015TG_PUBLIC void TciFastRecoverP2p(void);
1016
1017/** 设置低功耗设备唤醒原因, 设备进入休眠时会上报给服务器.
1018 * @param t_wakeup 唤醒时间
1019 * @param r <0:异常唤醒; 0:远程唤醒; >0:唤醒事件类型(ECEVENT)
1020 * @param user_reason 当r=ECEVENT_USER_DEFINED, user_reason为用户定义的唤醒理由字符串,长度不超过15个字符. \n
1021 * 其它情形下传NULL
1022 * @param sig_lvl wifi或4G信号强度: 0~100. 传负数时由用户自己解释
1023 * @param sdc_rec SD卡录像长度
1024 * @note 要在 STATUS_IDLE 返回0的时候调用,因为随此上报的还有别的信息。
1025 */
1026TG_PUBLIC void TciSetWakeupReason(time_t t_wakeup, int r, const char *user_reason, int sig_lvl, int sdc_rec);
1027
1028
1029/** 设备端准备强制休眠.
1030 * 本操作会先通知实时用户(app端收到通知后要停止视频),然后停止云上传、退出p2p、断开长连接等. \n
1031 * 返回后设备可以立即下电。
1032 * @param bDiscardFilesInQueue 是否放弃上传队列中未处理的文件. \n
1033 * 如果为 SA_FALSE, 会尝试上传队列中的所有文件. \n
1034 * 建议在开启了后备存储并且存储路径有效时 SA_TRUE,这样在网络不好,队列中文件多时可以加速返回. \n
1035 * 其它情况下的设置由应用自行载定.
1036 */
1037TG_PUBLIC int TciForceSleeping(SA_BOOL bDiscardFilesInQueue);
1038/**@}*/
1039
1040/** @name 云存储自动补录
1041 * @{*/
1042/** 设置云存储后备存储目录和缓存策略.
1043 * 当设置后备存储目录后,SDK会利用此目录暂存上传失败的录像和图片,
1044 * 并在合适的时机重传. \n
1045 * 本功能要在 TciStart() 前调用
1046 * @param sd_path 用于后备存储的目录
1047 * @param buffer_hint 内存缓存策略.
1048 * @retval 0
1049 * @note 缓存策略影响用于云存储的内存大小。参看 @ref ECBUFFERHINT 的说明
1050 */
1051TG_PUBLIC int TciSetBackStore(const char *sd_path, ECBUFFERHINT buffer_hint);
1052
1053/** 允许或禁止后备上传.
1054 * @param en 1:enable; 0:disable
1055 * @note 默认由sdk根据网络情况决定上传时间。如果应用层要临时禁止上传,可调用此接口
1056 */
1057TG_PUBLIC void TciBackStoreEnableUpload(int en);
1058
1059/** 这个接口用于sd卡格式化前释放backstore, 和格式化后重新开启后备存储
1060 * @param en 0-释放; 非0-重新打开
1061 */
1062TG_PUBLIC void TciBackStoreEnable(int en);
1063/**@}*/
1064
1065
1066/** @name 用户定义云上传
1067 * @{*/
1068/** 开始一个用户定义上传.
1069 * 自定义上传主要用于sdk本身预录时间不足或不能录像,要从SD卡录像上传的情形. \n
1070 * 必须在 TciStart() 成功后调用
1071 *
1072 * @param evt 事件类型. @ref ECEVENT (作为参数传入时要强传为 const char *型), 或长度小于16的字符串。 \n
1073 * 目前仅支持行车记录仪的事件(@ref ECEVENT_DR_BEGIN ~ @ref ECEVENT_DR_END) \n
1074 * 或者 TciCB::on_status(@ref STATUS_SDER, SDER *, ...) 回调的平台定义事件( SDER::event )
1075 * @param tRecordStart 录像起始时间
1076 * @param jpg_pic 图片数据(如果有的话)指针(SDK不会take图片缓冲区的所有权)
1077 * @param pic_len 图片数据长度
1078 * @return 如果允许上传,返回一个用户上传句柄。否则返回NULL
1079 * @note 用户自定义上传只能是事件上传,长度限制在30秒内. \n
1080 * 自定义上传的是事后发觉的事件,这个时候录像已经保存到sd卡了。\n
1081 * 自定义上传的时间范围不能与TciSetEvent 的时间重叠,也不能与另一个自定义事件的时间范围重叠
1082 */
1083void *TciUduBegin2(const char *evt, time_t tRecordStart, const char *jpg_pic, int pic_len);
1084#define TciUduBegin(evt, tRecordStart) TciUduBegin2(evt, tRecordStart, NULL, 0)
1085
1086/** 自定义上传过程,写入帧.
1087 * @param hUdu TciUduBegin() 返回的上传句柄
1088 * @param mt 媒体类型. 参见 TciSendPbFrame() 的 id_mt 参数
1089 * @param ts 时间戳
1090 * @param pFrame 帧数据指针
1091 * @param size 帧数据大小
1092 * @param uFrameFlags 视频:关键帧标志(1:关键帧;0:非关键帧); 音频: @ref audio_sample_fmt "音频采样格式"
1093 * @return 0:ok; 非0:录像长度超限,用户要调用 TciUduEnd()
1094 */
1095TG_PUBLIC int TciUduPutFrame(void *hUdu, TCMEDIA mt, uint32_t ts, const uint8_t *pFrame, int size, int uFrameFlags);
1096
1097/** 结束自定义上传
1098 * @param hUdu TciUduBegin() 返回的上传句柄
1099 */
1100TG_PUBLIC void TciUduEnd(void *hUdu);
1101/**@}*///name 用户定义云上传
1102
1103/** 上报错误 */
1104TG_PUBLIC int TciReportError(const char *name, const char *detail);
1105
1106/** 用于选择调试环境
1107 * @param env 1:测试环境; 0:正式环境
1108 * @note 在 TciStart() 之前调用
1109 */
1110TG_PUBLIC void TciSelectEnvironment(int env);
1111
1112typedef void (*TCIONLIVEFRAMECB)(int channel, int stream, TCMEDIA mt, const uint8_t *pFrame, uint32_t size, uint32_t ts, int uFrameFlags);
1113void TciRegisterLiveFrameCB(TCIONLIVEFRAMECB cb);
1114void TciUnregisterLiveFrameCB(TCIONLIVEFRAMECB cb);
1115
1116/** 设置参数文件操作指针.
1117 * SDK会保存工作参数到flash. 小系统设备在flash上没有标准文件I/O支持时,需要提供载入和写参数的操作。本操作要在 TciInit() 之前调用 \n
1118 * linux和有文件系统的liteos不需要设置
1119 * @param ops 参数文件操作结构指针
1120 */
1122
1123/** 设置最大p2p连接数.
1124 * @param num 要设置的最大连接数
1125 * @return 最大连接数有效值
1126 * @note 只能在 TciStart()和TciConfigWifi()前调用
1127 */
1128TG_PUBLIC int TciSetMaxP2pClientsNum(int num);
1129
1130char *TciGetDeviceInfoString(void);
1131
1132/** \name 手动OTA&文件上传下载
1133 * @{*/
1134/** 下载升级包
1135 * @param subdev NULL或子设备id. 用于选择相应的固件
1136 * @return 0:ok; <0:error code
1137 */
1138TG_PUBLIC int TciUpgradeOnTheAir(const char *subdev);
1139
1140
1141/** 查询升级包.
1142 * @param uuid
1143 * @param ota 返回升级包信息
1144 * @note 先要调用 TciStart()
1145 */
1146TG_PUBLIC int TciQueryForOTA(const char *uuid, DEVICEOTAINFO *ota);
1147
1148/** 查询第三方升级包.
1149 * @param fw_id 第三方设备的 firmware id
1150 * @param fw_ver 第三方设备的当前版本号。版本号在平台上是以8位数字("01010101")的方式记录. \n
1151 * 如果第三方固件的版本有不同表示方式,需要在上传固件时自行维护一个映射关系.
1152 * @param ota 返回升级包信息
1153 * @return 0:查询成功, 是否有可用升级包看 *ota 内容; <0:错误码
1154 * @note 先要调用 TciStart()
1155 */
1156TG_PUBLIC int TciQueryForOta2(const char *fw_id, const char *fw_ver, DEVICEOTAINFO *ota);
1157
1158/** 执行下载过程,会调用回调里的 ota 接口.
1159 * @return 0:下载完成; -1:没有设置回调; 其它<0:通信错误
1160 */
1161TG_PUBLIC int TciPerformOTA(DEVICEOTAINFO *ota);
1162/**@}*/ //手动OTA
1163
1164
1165/** \name 下载用户文件
1166 * @{*/
1167/** 查询并下载用户文件.
1168 * @param name 文件上传到服务器端时确定的文件标识
1169 * @param bToFile 1:下载到文件; 0:下载到内存
1170 * @param dest 下载到文件时,设置 dest->file.path 为本地文件路径; 下载到内存时,内容在dest->mem中返回
1171 * @param timeout 超时设置。单位: 秒
1172 */
1173TG_PUBLIC int TciGetUserFile(const char *name, SA_BOOL bToFile, union TgfDest *dest, int timeout/*s*/);
1174
1175/** 获取用户文件的下载地址.
1176 * @param name 文件上传到服务器端时确定的文件标识
1177 * @param flnk 成功时返回文件信息
1178 * @return 0:成功; 非0:错误码
1179 */
1180TG_PUBLIC int TciQueryUserFileInfo(const char *name, EcFileLink *flnk);
1181
1182/** 下载用户文件.
1183 * @param flink 用户文件信息
1184 * @param bToFile 1:下载到文件; 0:下载到内存
1185 * @param dest 下载到文件时,设置 dest->file.path 为本地文件路径; 下载到内存时,内容在dest->mem中返回
1186 * @param timeout 超时值。单位:秒
1187 * @return 0:成功; 非0:错误码
1188 */
1189TG_PUBLIC int TciDownloadUserFile(const EcFileLink *flink, SA_BOOL bToFile, union TgfDest *dest, int timeout);
1190/**@}*/
1191
1192/** \name 日志上传工具
1193 * 以查询的方式上传日志,主要用于低功耗设备.
1194 * @{*/
1195/** \deprecated
1196 * 查询日志上传请求
1197 * @param uuid
1198 * @param model_id may be NULL
1199 * @param ppUrl 如果有请求,返回上传地址
1200 * @return 0:ok; none-zero: error code
1201 * @note 如果有请求,用返回的地址调用 TgPostMultiparts()
1202 */
1203int TgQueryUploadReq(const char* uuid, const char *model_id, char **ppUrl);
1204
1205/** \deprecated
1206 * 上传日志文件
1207 * @param url TgQueryUploadReq() 返回的上传地址
1208 * @param uuid
1209 * @param path 本地文件名
1210 * @param timeout 超时值(ms)
1211 * @return 0:ok; otherwise error
1212 */
1213int TgPostLogFile(const char *url, const char *uuid, const char *path, int timeout);
1214
1215/** \deprecated
1216 * 上传内存中的日志
1217 * @param url TgQueryUploadReq() 返回的上传地址
1218 * @param uuid
1219 * @param mem 内存地址
1220 * @param size 数据长度
1221 * @param name 保存为文件名name
1222 * @param timeout 超时值(ms)
1223 * @return 0:ok; otherwise error
1224 */
1225int TgPostLogMem(const char *url, const char *uuid, const void *mem, int size, const char *name, int timeout);
1226
1227/** 查询日志上传配置.
1228 * @param pLogConf 返回日志配置
1229 */
1230TG_PUBLIC int TciGetLogConf(struct TgLogConf *pLogConf);
1231
1232/** 上传日志文件.
1233 * @param local_path 本地文件路径。
1234 * @param timeout 超时值(ms)
1235 */
1236TG_PUBLIC int TciPutLogFile(const char *local_path, int timeout);
1237
1238/** 上传内存中的日志
1239 * @param mem 内存地址
1240 * @param size 数据长度
1241 * @param name 保存为文件名name
1242 * @param timeout 超时值(ms)
1243 */
1244TG_PUBLIC int TciPutLogMem(const void *mem, int size, const char *name, int timeout);
1245
1246/**@}*/ //name 上传下载
1247
1248/** \name MCU配网api
1249 * 低功耗设备在MCU端进行配网.
1250 * @{*/
1251/** 获取设备属性字符串。调用者把该字符串传给MCU,用于在MCU端激活设备.
1252 * 调用者要 free() 返回的字符串.
1253 */
1255
1256/** 返回要同步到MCU的数据.
1257 \param pLen 用于返回数据长度.
1258 \return 要同步到MCU的数据缓冲区地址。调用者要负责释放(free())
1259 */
1260unsigned char *TciGetPlatConfig(int *pLen);
1261
1262/** 同步从MCU来的数据.
1263 \param pData 从MCU收到的同步数据
1264 \param len 数据长度
1265 \return 0:成功; <0:失败
1266 */
1267TG_PUBLIC int TciSyncPlatConfig(const unsigned char *pData, int len);
1268/**@}*/// name register_in_mcu
1269
1270
1271/** \name 其它功能
1272 * @{*/
1273/** 设备上线后IP发生变化时通知SDK, 用于立即更新长连接 */
1274TG_PUBLIC void TcnIpChanged();
1275
1276typedef struct _IceConfig {
1277 char *ip;
1278 int port;
1279 char *username;
1280 char *password;
1281 int is_turn;
1282} ICECONFIG;
1283
1284/** 开启本地工作模式.
1285 * 该模式用于仅在局域网工作的设备. 有需要先要同我们联系.
1286 * @param url
1287 * @param cfg webrtc 服务配置数组
1288 * @param size 数组大小
1289 * @return 0:成功; <0:错误码
1290 * @note 函数内部会复制cfg信息, 返回后用户可以释放cfg引用或间接引用的空间
1291 */
1292TG_PUBLIC int TciLocalStart(const char *url, const ICECONFIG *cfg, int size);
1293
1294/** 获取SDK内部状态.
1295 * @return 0 或 @ref sdk_state_flags "SDK状态标志" 的组合
1296 * @note 本函数只是用来告诉用户当前用什么事件在处理. \n
1297 * 不能用来代替 STATUS_IDLE 状态回调.
1298 */
1299TG_PUBLIC unsigned int TciGetSdkState(void);
1300
1301
1302/** 设置用户定义低功耗设备的事件云录像时长.
1303 * @param erl 录像时长,可取值 -1/10/20. <=0时录像时长由sdk决定.
1304 * @note 非低功耗设备该设置无效. 在TciInit()后调用.
1305 * @return 0(ok) 或 TCI_E_NOT_ALLOWED
1306 */
1307TG_PUBLIC int TciSetEventRecordLength(int erl);
1308
1309/** 清除SDK运行cache.
1310 * @param bResetRemote 同时恢复平台端的配置
1311 * @return 0:成功; <0:错误码
1312 * @note 当SDK导致程序在启动期间反复崩溃, 应用可以调用本接口将SDK的配置参数据恢复到刚添加时的状态. \n
1313 * 调用时机安排在SDK初始化前。如果要恢复平台端的配置,需要确保联网能够连接。应用可以先尝试 \n
1314 * 先清除本地cache, 不能恢复再复位平台配置。
1315 * 这一操作可以由用户判断并触发(例如按键),或者应用可以对程序非正常启动作一个计数,超上限后 \n
1316 * 自动执行。
1317 */
1318TG_PUBLIC int TciClearCache(SA_BOOL bResetRemote);
1319/**@}*/ //misc
1320
1321/** \name 呼入处理
1322 * @{*/
1323/** 接听.
1324 * @param flavor 通话类型 @ref VIDEO_CALL 或 @ref VOICE_CALL
1325 * @return 0:成功; 非0为错误码。如果呼叫来自微信小程序, 错误码定义在 wx_err.h
1326 * @note flavor是对从@ref STATUS_INCALL2 收到的@ref INCALLINFO::flavor 的响应, \n
1327 * 不得高于请求的值. \n
1328 * 不要在回调中调用本接口。
1329 */
1330TG_PUBLIC int TciAcceptInCall2(ECALLFLAVOR flavor);
1331
1332/** 拒接.
1333 * @return 0:成功; 非0为错误码。如果呼叫来自微信小程序, 错误码定义在 wx_err.h
1334 */
1335TG_PUBLIC int TciRejectInCall2();
1336
1337/** 挂断当前通话 */
1338TG_PUBLIC int TciHangup(void);
1339/**@}*/ //name 呼入
1340
1341/**@}*/ //api_reference
1342
1343#ifdef __cplusplus
1344}
1345#endif
1346
1347#endif
P2p Commands and Structures
P2p Commands and Structures
ENUMRTSTATE
运行时状态
探鸽云SDK常数定义
常数和错误码定义
ECBUFFERHINT
云上传文件队列长度.
PMODE
低功耗设备的工作模式
ECEVENT
上报事件类型.
ECSERVICESUBTYPE
云服务子类型
ECALLFLAVOR
通话类型
SIMCARDTYPE
sim 卡类型
RTMTYPE
插入到媒体流(实时或回放)或命令通道中的消息类型.
ECG4STATE
4G状态
ECSERVICETYPE
云服务类型
TCMEDIA
媒体类型枚举常数
ETRANSSERVICE
传输内容
TCSYSOPTION
SDK选项常数
@ PM_ALLON
常电模式。非低功耗设备的默认模式
@ PM_NETDOWN
主控正常工作,网络模块进入休眠模式
@ PM_SLEEPABLE
系统可休眠(会收到STATUS_IDLE状态回调。这是低功耗设备的默认模式)
@ SIMT_ESIM
ESIM
@ SIMT_VSIM
vsim卡
@ SIMT_PHY
物理卡
@ TCOPT_PROBE_HEARTBEAT_INTERVAL
探测长连接心跳.
@ TCOPT_PRERECORD_LENGTH
事件云存预录时间长度, 单位: 秒.
@ TCOPT_MAX_DATAFILE_SIZE
最大云存data文件。超出的帧会丢弃.
@ TCOPT_ONLY_REPORT_AI_EVENT
仅上报AI事件.
@ TCOPT_NO_STREAMING_WITHOUT_ACCEPTING_CALL
用户没有应答不能拉流.
@ TCOPT_ENABLE_ADJUSTMENT_FOR_CS
开关云存码流调整功能.
@ TCOPT_TRANS_MEDIA_TYPE
传输内容.
@ TCOPT_DISABLE_UPLOAD_WHEN_VIEWING
有人观看时禁止上传.
@ TCOPT_CS_PLAYBACK_SPEED
云端缩时录像回放倍速.
@ TCOPT_ONLY_REPORT_AI_EVENT2
在有AI服务时仅上报AI事件, 无服务时可以上报普通事件.
@ TCOPT_BUFFER_QUEUE_SIZE
云存储缓冲文件数.
@ TCOPT_BACKUP_TIMELAPSE_FILE
支持缩时录像补录.
@ TCOPT_BACKSTORE_SAVEDAYS
backstore 存储天数.
TG_PUBLIC int TciQueryForOta2(const char *fw_id, const char *fw_ver, DEVICEOTAINFO *ota)
查询第三方升级包.
TG_PUBLIC int TciPrepareHiberation(int *socks, int size)
准备休眠 本api建立到唤醒服务器的tcp连接,并且返回连接数.
TG_PUBLIC int TciReport4GInfoEx(const TG4GINFO *info, ECG4STATE state)
上报4G设备信息,代替 TciReport4GInfo()
TG_PUBLIC int TciSendUserData(const unsigned char *data, int 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 TciSetMaxP2pClientsNum(int num)
设置最大p2p连接数.
TG_PUBLIC void TciFastRecoverP2p(void)
从NETDOWN模式下恢复网络后,调用本api使p2p快速上线
TG_PUBLIC int TciSetEventRecordLength(int erl)
设置用户定义低功耗设备的事件云录像时长.
TG_PUBLIC int TciSyncPlatConfig(const unsigned char *pData, int len)
同步从MCU来的数据.
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 TciGetUserFile(const char *name, SA_BOOL bToFile, union TgfDest *dest, int timeout)
查询并下载用户文件.
TG_PUBLIC int TciProcessRegInfo(const void *data)
处理从蓝牙收到的注册数据
TG_PUBLIC void TciSetRtState(ENUMRTSTATE state, void *pData)
报告系统运行时状态
TG_PUBLIC int TciReportBatteryStatus(int qoe, int qoe_low, int charging)
上报电池状态
TG_PUBLIC const void * TciGetRegisterConfiguration(int *len)
保存wifi注册信息.
TG_PUBLIC int TciStartInTestMode(const char *key_path)
开启p2p功能,进入厂测状态.
TG_PUBLIC int TciInit(const char *path, const char *uuid)
配置基本参数 在TciStart()之前调用
TG_PUBLIC int TciSendCmdRespStatus(p2phandle_t handle, unsigned int cmd, unsigned int status)
发送一个 Tcis_ErrorResp 结构作应答.
char * TciGetActivationAttrs(void)
获取设备属性字符串。调用者把该字符串传给MCU,用于在MCU端激活设备.
TG_PUBLIC int TciSendRtMsg(p2phandle_t handle, RTMTYPE type, unsigned int data1, unsigned data2, const void *extra_data, int extra_len)
在命令通道上发送通知.
TG_PUBLIC int TciForceSleeping(SA_BOOL bDiscardFilesInQueue)
设备端准备强制休眠.
TG_PUBLIC int TciPerformOTA(DEVICEOTAINFO *ota)
执行下载过程,会调用回调里的 ota 接口.
TG_PUBLIC int TciGetLogConf(struct TgLogConf *pLogConf)
查询日志上传配置.
TG_PUBLIC void * TciGetSessionUserData(p2phandle_t handle)
返回由TciSetSessionUserData()设置的应用私有数据指针
TG_PUBLIC void TcnIpChanged()
设备上线后IP发生变化时通知SDK, 用于立即更新长连接
TG_PUBLIC int TciStopEvent(ECEVENT evt)
停止事件, 仅少数事件才有意义.
TG_PUBLIC int TciConfigWifi(int mode)
开始配置WIFI.
TG_PUBLIC void TciSetLogLevel(int level)
设置SDK日志输出等级.
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 TciDownloadUserFile(const EcFileLink *flink, SA_BOOL bToFile, union TgfDest *dest, int timeout)
下载用户文件.
TG_PUBLIC int TciStopConfigWifi(int mode)
中止配网.
TG_PUBLIC void TciSelectEnvironment(int env)
用于选择调试环境
TG_PUBLIC int TciSetCallEvent(int hint)
包装了门铃事件, 无图片.
TG_PUBLIC int TciLocalStart(const char *url, const ICECONFIG *cfg, int size)
开启本地工作模式.
TG_PUBLIC int TciSetKeyVideoTime(int channel, int stream, time_t t)
告诉SDK下一个视频关键帧的实际发生时间(UTC).
TG_PUBLIC int TciStop(void)
停止服务
TG_PUBLIC void TciSetLogOption(int b_output_to_console, const char *log_path, int max_log_size)
控制日志输出.
TG_PUBLIC int TciCheckRegString(const char *s)
在sdk外部扫二维码.
TG_PUBLIC int TciSetCmdHandler(const TGCMDHANDLER cb)
注册通用命令回调 在回调里处理APP发来的命令请求
TG_PUBLIC void TciSetSessionUserData(p2phandle_t handle, void *pUser)
绑定应用私有数据指针到p2p handle
TG_PUBLIC int TciRejectInCall2()
拒接.
TG_PUBLIC int TciSendPbMessage(p2phandle_t handle, RTMTYPE type, unsigned int data1, unsigned int data2, const void *data, int data_len)
在回放流中插入消息.
TG_PUBLIC const uint8_t * TciPrepareAuthString(const char *randKey, int *len_of_authstring)
生成唤醒服务器登录命令.
TG_PUBLIC int TciSetCallback(const struct TciCB *cb)
注册回调 – sdk内部事件
TG_PUBLIC int TciUduPutFrame(void *hUdu, TCMEDIA mt, uint32_t ts, const uint8_t *pFrame, int size, int uFrameFlags)
自定义上传过程,写入帧.
TG_PUBLIC unsigned int TciGetSdkState(void)
获取SDK内部状态.
TG_PUBLIC void TciBackStoreEnableUpload(int en)
允许或禁止后备上传.
TG_PUBLIC int TciGetWakeupServers(Ipv4Addr servers[3])
获取唤醒服务器ip地址
TG_PUBLIC int TciReportError(const char *name, const char *detail)
上报错误
void * TciUduBegin2(const char *evt, time_t tRecordStart, const char *jpg_pic, int pic_len)
开始一个用户定义上传.
TG_PUBLIC int TciSetRegInfo(const char *s)
手动处理注册信息
TG_PUBLIC int TciGetSysOption(TCSYSOPTION opt, void *pVal)
通用sdk工作选项获取接口.
TG_PUBLIC void TciSetWakeupReason(time_t t_wakeup, int r, const char *user_reason, int sig_lvl, int sdc_rec)
设置低功耗设备唤醒原因, 设备进入休眠时会上报给服务器.
TG_PUBLIC int TciSwitchDeviceStatus(int status)
设置设备开关状态.
TG_PUBLIC void TciSetP2pDown(SA_BOOL bDown)
暂停或继续运行 P2P.
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 TciAllocCloudBuffer(unsigned int uCloudBuffSize)
预分配云存储帧缓存空间.
void TciSetParamFileOps(struct paramf_ops *ops)
设置参数文件操作指针.
unsigned char * TciGetPlatConfig(int *pLen)
返回要同步到MCU的数据.
TG_PUBLIC int TciSendCmd(p2phandle_t handle, unsigned int cmd, const void *data, int dataSize)
发送p2p命令请求
TG_PUBLIC int TciPutLogFile(const char *local_path, int timeout)
上传日志文件.
int TgQueryUploadReq(const char *uuid, const char *model_id, char **ppUrl)
TG_PUBLIC void TciFlushCsCache()
等待录像缓冲区中的所有数据被消耗掉.
int TgPostLogFile(const char *url, const char *uuid, const char *path, int timeout)
TG_PUBLIC int TciStart2(int isBound, unsigned int uCloudBuffSize, const char *uuid)
启动服务.
TG_PUBLIC void TciSetPowerMode(PMODE mode)
设置低功耗设备的工作模式.
TG_PUBLIC int TciSetSysOption(TCSYSOPTION opt, const void *pVal)
通用sdk工作选项设置接口.
TG_PUBLIC int TciSetP2pInfo(const char *sss)
TG_PUBLIC void TciBackStoreEnable(int en)
这个接口用于sd卡格式化前释放backstore, 和格式化后重新开启后备存储
TG_PUBLIC int TciReport4GInfo(const char *imei, const char *iccid, ECG4STATE state)
int TgPostLogMem(const char *url, const char *uuid, const void *mem, int size, const char *name, int timeout)
TG_PUBLIC int TciSetDoorbellEvent()
包装了门铃事件
TG_PUBLIC void TciUduEnd(void *hUdu)
结束自定义上传
TG_PUBLIC int TciQueryForOTA(const char *uuid, DEVICEOTAINFO *ota)
查询升级包.
TG_PUBLIC int TciSetLockEvent(int cls, int msg, int usrtyp, int usrid)
门锁事件上报。图片和录像都在内部处理了.
TG_PUBLIC int TciConfigWifiWithoutReset(int mode)
开始配置WIFI.
TG_PUBLIC int TciSendCmdResp(p2phandle_t handle, unsigned int cmd, const void *data, int dataSize)
发送p2p命令应答
TG_PUBLIC int TciClearCache(SA_BOOL bResetRemote)
清除SDK运行cache.
TG_PUBLIC void TciSetCloudStream(int channel, int stream)
设置云存储录像通道的码流
TG_PUBLIC int TciAcceptInCall2(ECALLFLAVOR flavor)
接听.
TG_PUBLIC int TciStart(int isBound, unsigned int uCloudBuffSize)
启动服务
TG_PUBLIC int TciSetBackStore(const char *sd_path, ECBUFFERHINT buffer_hint)
设置云存储后备存储目录和缓存策略.
TG_PUBLIC int TciQueryUserFileInfo(const char *name, EcFileLink *flnk)
获取用户文件的下载地址.
TG_PUBLIC int TciSetEventEx(EVENTPARAM *evtp)
上报事件。本版本允许附带事件特定参数.
TG_PUBLIC int TciHangup(void)
挂断当前通话
TG_PUBLIC int TciCleanup(void)
释放资源
SA_BOOL TciSetRegisterConfiguration(const void *data, int len)
恢复wifi注册信息.
TG_PUBLIC int TciGetRevision(void)
获取SDK版本号 TciInit()之后调用
TG_PUBLIC int TciPutLogMem(const void *mem, int size, const char *name, int timeout)
上传内存中的日志
TG_PUBLIC int TciUpgradeOnTheAir(const char *subdev)
下载升级包
int(* on_ota_download_finished)(int status)
升级包下载结束
int(* on_status)(int status, const void *pData, int len)
sdk内部状态
int level
日志等级
short id
用户(连接)标识
int(* snapshot)(int type, uint8_t **ppJpg, int *size)
抓取图片.
unsigned short port
port, network byte-order
char ver[16]
升级包版本
int size
升级包大小
void(* trans_stat)(const struct TransStatUser *_stat)
网络传输统计回调
int msStatInterval
统计周期(单位: ms)
int(* get_feature)(const char *key, char *buf, int size)
设备能力.
void(* on_talkback_stop)(void)
结束对讲
short vstream
码流
unsigned int ip
ip, network byte-order
int(* set_time)(time_t time)
设置时间
int(* qrcode_get_y_data)(uint8_t **ppYBuff, int *width, int *height)
获取Y图片
ECSERVICESUBTYPE sub_type
当 serviceType = ECGS_TYPE_STORAGE, sub_type 为云存服务子类型:
int(* request_iframe_ex)(int channel, int vstream)
请求指定图像通道的I帧
char * objects
当 serviceType = ECGS_TYPE_AI, objects 为 '\0'结尾并以一个额外 '\0'结束的允许检测的ai对象列表。例如: "body\0car\0cry\0"
int nBytesInBuff
位于发送缓冲区的字节数
int(* on_talkback_start)(void)
开始对讲
int(* log)(int action, char *logfile)
在平台端采集设备日志
int(* qrcode_start)(void)
二维码扫描开始 应用层在此开启取Y数据的通道
int(* talkback)(TCMEDIA at, const uint8_t *audio, int len)
对讲数据回调 格式在前面已经协商过
int(* on_ota_download_start)(const char *new_version, unsigned int size)
OTA升级开始
int(* set_wifi)(int is_switching, const char *ssid, const char *key)
设置wifi参数
char firmware_ver[10]
固件主版本,8个数字组成的字符串。like: "03020201", means 3.2.2.1.
char * path
IN: file path
char md5[36]
md5 检验字符串
void(* talkback_ex)(int mt, unsigned int ts, const void *data, int len, unsigned int uFrameFlags)
对讲数据回调.
void * mem
OUT: 指向sdk分配的内存
uint8_t * data
数据缓冲区指针
char url[256]
下载地址
void(* free_buff)(SIMPLEBUFFER *buff)
释放参数缓冲区
time_t expiration
过期时间(utc)
int size
OUT: 数据长度
int(* on_ota_download_data)(const uint8_t *buff, int size)
升级包数据 升级包下载过程中,sdk调用此回调将数据传给应用层
int len
数据长度
int nBytesSent
已经发送的字节数
char iccid[24]
sim卡号
short is_igop
1:统计间隔为一个I帧间隔; 0:周期约为~1s
SIMCARDTYPE sim_type
sim卡类型
int nBytesTotal
总共收到的字节数
char imei[24]
4g模块标识
int size
缓冲区大小
int(* get_state)(const char *key, char *buf, int size)
取设备当前状态或初始默认设置.
int(* request_iframe)(int vstream)
char vendor[16]
设备生产厂商 OEM
char device_type[16]
Not used
short vchannel
视频通道
int(* save_buff)(const SIMPLEBUFFER *buff)
写参数文件
ECSERVICETYPE serviceType
云服务类型
int(* set_timezone)(const char *tzs)
设置时区
void(* switch_quality)(int channel, int stream, const char *qstr)
切换图像质量
void(* remove)(void)
删除参数文件(或者清空参数文件)。下一次读出时 len为0
int(* alloc_and_readall)(SIMPLEBUFFER *buff, int cbExtra)
分配缓冲区,并读出参数文件.
void(* qrcode_end)(uint8_t *pYBuff)
结束二维码扫描
char firmware_id[32]
ota 升级用的固件标识, 平台唯一.
time_t tValidUntil
0:diabled; >0:在此时间后无效
char model[32]
产品型号
void(* ai_result)(int type, const uint8_t *pJpg, int len)
当AI识别成功,通过本回调通知应用.
int(* on_apmode_login)(const char *user, const char *key)
直连模式下用户登录帐号检查
int(* get_info)(TCIDEVICEINFO *info)
获取设备基本信息
int fModules
请求特定模块的日志.
int nBytesThrow
丢掉的字节数。丢包会持续到到一个I帧,这期间即使网络恢复也会丢,所以其值只能作为参考, 不能用于计算网速
void * p2phandle_t
p2p连接句柄.
int(* TGCMDHANDLER)(p2phandle_t handle, int cmd, const void *data, int len)
命令回调类型
设备升级包信息
事件上报参数.
IPv4 地址表示(网络字节顺序)
Simple Buffer
设备基本信息
云服务信息
4G 设备信息
sdk 回调函数结构
日志上传配置
数据下载到文件
数据下载到内存
P2P发送统计数据结构
参数文件读写函数据指针结构
用户文件下载目的地.