1 Star 0 Fork 5.1K

youguilin / docs

forked from OpenHarmony / docs 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
SDK开发过程.md 22.83 KB
一键复制 编辑 原始数据 按行查看 历史
mamingshuai 提交于 2021-06-02 01:00 . update OpenHarmony 2.0 Canary

SDK开发过程

SDK头文件的功能实现是基于对SDK的调用映射到对client的调用。Client端提供的接口如下表1所示。

表 1 Client端提供的接口

接口名

接口说明

参数要求

int AieClientInit(const ConfigInfo &configInfo, ClientInfo &clientInfo, const AlgorithmInfo &algorithmInfo, IServiceDeadCb *cb)

作用:链接并初始化引擎服务,激活跨进程调用。

返回值:0为成功,其他返回值失败。

configInfo(NOT NULL):引擎相关初始化配置数据;

clientInfo(NOT NULL):引擎客户端信息;

algorithmInfo(NOT NULL):调用算法信息;

cb(可为NULL):死亡回调 对象;

int AieClientPrepare(const ClientInfo &clientInfo, const AlgorithmInfo &algorithmInfo, const DataInfo &inputInfo, DataInfo &outputInfo, IClientCb *cb)

作用:加载算法插件。

返回值: 0为成功,其他返回值失败。

clientInfo(NOT NULL):引擎客户端信息;

algorithmInfo(NOT NULL):调用算法信息;

inputInfo(可为NULL):加载算法插件时输入所需信息;

outputInfo(可为NULL):加载算法插件之后如需返回信息则通过此出参返回;

cb:异步算法通过此回调返回运算结果,因此异步算法此结构体不能为空;若为同步算法,传入空值即可;

int AieClientAsyncProcess(const ClientInfo &clientInfo, const AlgorithmInfo &algorithmInfo, const DataInfo &inputInfo)

作用:执行异步算法。

返回值:0为成功,其他返回值失败。

clientInfo(NOT NULL):引擎客户端信息;

algorithmInfo(NOT NULL):调用算法信息;

inputInfo(可为NULL):算法运算入参;

int AieClientSyncProcess(const ClientInfo &clientInfo, const AlgorithmInfo &algorithmInfo, const DataInfo &inputInfo, DataInfo &outputInfo)

作用:执行同步算法。

返回值:0为成功,其他返回值失败。

clientInfo(NOT NULL):引擎客户端信息;

algorithmInfo(NOT NULL):调用算法信息;

inputInfo(可为NULL):算法运算入参;

outputInfo(可为NULL):同步算法运算结果出参;

int AieClientRelease(const ClientInfo &clientInfo, const AlgorithmInfo &algorithmInfo, const DataInfo &inputInfo)

作用:卸载算法插件。

返回值:0为成功,其他返回值失败。

clientInfo(NOT NULL):引擎客户端信息;

algorithmInfo(NOT NULL):卸载算法插件的相关信息;

inputInfo(可为NULL):调用卸载接口时的输入信息;

int AieClientDestroy(ClientInfo &clientInfo)

作用:断开与服务端的链接,释放相关缓存。

返回值:0为成功,其他返回值失败。

clientInfo(NOT NULL):所要销毁的引擎客户端信息;

int AieClientSetOption(const ClientInfo &clientInfo, int optionType, const DataInfo &inputInfo)

作用:设置配置项,可将一些算法的拓展信息通过此接口传入插件。

返回值:0为成功,其他返回值失败。

clientInfo(NOT NULL):引擎客户端信息;

optionType (NOT NULL):算法配置项,算法插件可根据需要利用此状态位;

inputInfo(可为NULL):插件可根据需要通过此入参设置算法参数信息;

int AieClientGetOption(const ClientInfo &clientInfo, int optionType, const DataInfo &inputInfo, DataInfo &outputInfo)

作用:给定特定的optionType和inputInfo,获取其对应的配置项信息。

返回值:0为成功,其他返回值失败。

clientInfo(NOT NULL):引擎客户端信息;

optionType(NOT NULL):所获取配置项信息的对应算法状态位;

inputInfo(可为NULL):所获取配置项信息的对应算法参数信息;

outputInfo(可为NULL):所要获取的配置项信息返回结果;

其中,ConfigInfo,ClientInfo,AlgorithmInfo,DataInfo的数据结构如下表2所示。

表 2 ConfigInfo,ClientInfo,AlgorithmInfo,DataInfo的数据结构

结构体名称

说明

属性

ConfigInfo

算法配置项信息。

const char *description:配置项信息主体;

ClientInfo

客户端信息。

long long clientVersion:客户端设备版本号(当前还未启用);

int clientId:客户端ID;

int sessionId:会话ID;

int extendLen:拓展信息(extendMsg)长度;

unsigned char *extendMsg:拓展信息主体;

AlgorithmInfo

算法信息。

long long clientVersion:客户端设备版本号(当前还未启用);

bool isAsync:是否为异步执行;

int algorithmType:引擎框架根据插件加载顺序分配的算法类型ID;

long long algorithmVersion:算法版本号;

bool isCloud:是否上云(当前还未启用);

int operateId:执行ID(当前还未启用);

int requestId:请求ID,标识每次request,以对应执行结果;

int extendLen:拓展信息(extendMsg)长度;

unsigned char *extendMsg:拓展信息主体;

DataInfo

算法数据入参(inputInfo)、接口调用结果出参(outputInfo)。

unsigned char *data:数据主体;

int length:数据(data)长度;

具体开发过程可参考唤醒词识别SDK开发示例。

1
https://gitee.com/yougl/docs.git
git@gitee.com:yougl/docs.git
yougl
docs
docs
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891