Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
5366820b
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
5366820b
编写于
4月 28, 2021
作者:
O
openharmony_ci
提交者:
Gitee
4月 28, 2021
浏览文件
操作
浏览文件
下载
差异文件
!167 修改测试套以支持共享内存【master】
Merge pull request !167 from liushijiu/addshm
上级
c31fd5ff
6dec2661
变更
11
显示空白变更内容
内联
并排
Showing
11 changed file
with
151 addition
and
197 deletion
+151
-197
ai_lite/ai_engine_posix/base/src/aie_client/AieClientAsyncProcessFunctionTest.cpp
...base/src/aie_client/AieClientAsyncProcessFunctionTest.cpp
+3
-1
ai_lite/ai_engine_posix/base/src/aie_client/AieClientDestroyFunctionTest.cpp
...osix/base/src/aie_client/AieClientDestroyFunctionTest.cpp
+3
-1
ai_lite/ai_engine_posix/base/src/aie_client/AieClientInitFunctionTest.cpp
...e_posix/base/src/aie_client/AieClientInitFunctionTest.cpp
+3
-1
ai_lite/ai_engine_posix/base/src/aie_client/AieClientPrepareFunctionTest.cpp
...osix/base/src/aie_client/AieClientPrepareFunctionTest.cpp
+3
-1
ai_lite/ai_engine_posix/base/src/aie_client/AieClientReleaseFunctionTest.cpp
...osix/base/src/aie_client/AieClientReleaseFunctionTest.cpp
+3
-1
ai_lite/ai_engine_posix/base/src/aie_client/AieClientSetOptionFunctionTest.cpp
...ix/base/src/aie_client/AieClientSetOptionFunctionTest.cpp
+3
-1
ai_lite/ai_engine_posix/base/src/aie_client/AieClientSyncProcessFunctionTest.cpp
.../base/src/aie_client/AieClientSyncProcessFunctionTest.cpp
+3
-1
ai_lite/ai_engine_posix/base/src/sample/include/sample_plugin_1.h
...ai_engine_posix/base/src/sample/include/sample_plugin_1.h
+4
-10
ai_lite/ai_engine_posix/base/src/sample/include/sample_plugin_2.h
...ai_engine_posix/base/src/sample/include/sample_plugin_2.h
+4
-8
ai_lite/ai_engine_posix/base/src/sample/source/sample_plugin_1.cpp
...i_engine_posix/base/src/sample/source/sample_plugin_1.cpp
+61
-86
ai_lite/ai_engine_posix/base/src/sample/source/sample_plugin_2.cpp
...i_engine_posix/base/src/sample/source/sample_plugin_2.cpp
+61
-86
未找到文件。
ai_lite/ai_engine_posix/base/src/aie_client/AieClientAsyncProcessFunctionTest.cpp
浏览文件 @
5366820b
...
...
@@ -61,6 +61,8 @@ static void GetClientInfo(ClientInfo &clientInfo)
.
clientVersion
=
CLIENT_VERSION_VALID
,
.
clientId
=
INVALID_CLIENT_ID
,
.
sessionId
=
INVALID_SESSION_ID
,
.
serverUid
=
INVALID_UID
,
.
clientUid
=
INVALID_UID
,
.
extendLen
=
len
,
.
extendMsg
=
(
unsigned
char
*
)
extendMsg
,
};
...
...
ai_lite/ai_engine_posix/base/src/aie_client/AieClientDestroyFunctionTest.cpp
浏览文件 @
5366820b
...
...
@@ -52,6 +52,8 @@ static void GetClientInfo(ClientInfo &clientInfo)
.
clientVersion
=
CLIENT_VERSION_VALID
,
.
clientId
=
INVALID_CLIENT_ID
,
.
sessionId
=
INVALID_SESSION_ID
,
.
serverUid
=
INVALID_UID
,
.
clientUid
=
INVALID_UID
,
.
extendLen
=
len
,
.
extendMsg
=
(
unsigned
char
*
)
extendMsg
,
};
...
...
ai_lite/ai_engine_posix/base/src/aie_client/AieClientInitFunctionTest.cpp
浏览文件 @
5366820b
...
...
@@ -56,6 +56,8 @@ static void GetClientInfo(ClientInfo &clientInfo)
.
clientVersion
=
CLIENT_VERSION_VALID
,
.
clientId
=
INVALID_CLIENT_ID
,
.
sessionId
=
INVALID_SESSION_ID
,
.
serverUid
=
INVALID_UID
,
.
clientUid
=
INVALID_UID
,
.
extendLen
=
len
,
.
extendMsg
=
(
unsigned
char
*
)
extendMsg
,
};
...
...
ai_lite/ai_engine_posix/base/src/aie_client/AieClientPrepareFunctionTest.cpp
浏览文件 @
5366820b
...
...
@@ -55,6 +55,8 @@ static void GetClientInfo(ClientInfo &clientInfo)
.
clientVersion
=
CLIENT_VERSION_VALID
,
.
clientId
=
INVALID_CLIENT_ID
,
.
sessionId
=
INVALID_SESSION_ID
,
.
serverUid
=
INVALID_UID
,
.
clientUid
=
INVALID_UID
,
.
extendLen
=
len
,
.
extendMsg
=
(
unsigned
char
*
)
extendMsg
,
};
...
...
ai_lite/ai_engine_posix/base/src/aie_client/AieClientReleaseFunctionTest.cpp
浏览文件 @
5366820b
...
...
@@ -52,6 +52,8 @@ static void GetClientInfo(ClientInfo &clientInfo)
.
clientVersion
=
CLIENT_VERSION_VALID
,
.
clientId
=
INVALID_CLIENT_ID
,
.
sessionId
=
INVALID_SESSION_ID
,
.
serverUid
=
INVALID_UID
,
.
clientUid
=
INVALID_UID
,
.
extendLen
=
len
,
.
extendMsg
=
(
unsigned
char
*
)
extendMsg
,
};
...
...
ai_lite/ai_engine_posix/base/src/aie_client/AieClientSetOptionFunctionTest.cpp
浏览文件 @
5366820b
...
...
@@ -60,6 +60,8 @@ static void GetClientInfo(ClientInfo &clientInfo)
.
clientVersion
=
CLIENT_VERSION_VALID
,
.
clientId
=
INVALID_CLIENT_ID
,
.
sessionId
=
INVALID_SESSION_ID
,
.
serverUid
=
INVALID_UID
,
.
clientUid
=
INVALID_UID
,
.
extendLen
=
len
,
.
extendMsg
=
(
unsigned
char
*
)
extendMsg
,
};
...
...
ai_lite/ai_engine_posix/base/src/aie_client/AieClientSyncProcessFunctionTest.cpp
浏览文件 @
5366820b
...
...
@@ -56,6 +56,8 @@ static void GetClientInfo(ClientInfo &clientInfo)
.
clientVersion
=
CLIENT_VERSION_VALID
,
.
clientId
=
INVALID_CLIENT_ID
,
.
sessionId
=
INVALID_SESSION_ID
,
.
serverUid
=
INVALID_UID
,
.
clientUid
=
INVALID_UID
,
.
extendLen
=
len
,
.
extendMsg
=
(
unsigned
char
*
)
extendMsg
,
};
...
...
ai_lite/ai_engine_posix/base/src/sample/include/sample_plugin_1.h
浏览文件 @
5366820b
...
...
@@ -16,24 +16,15 @@
#ifndef SAMPLE_PLUGIN_1_H
#define SAMPLE_PLUGIN_1_H
#include <cstring>
#include "plugin/i_plugin.h"
namespace
OHOS
{
namespace
AI
{
class
SamplePlugin1
:
public
IPlugin
{
const
long
long
ALG_VERSION
=
1
;
const
char
*
ALG_NAME
=
"SAMPLE_PLUGIN_1"
;
const
char
*
const
PLUGIN_INFER_MODEL
=
"SYNC"
;
const
char
*
DEFAULT_OPTION_DATA
=
"default option data"
;
unsigned
char
*
optionData
=
nullptr
;
int
optionLength
=
0
;
public:
SamplePlugin1
();
~
SamplePlugin1
();
~
SamplePlugin1
()
override
;
const
long
long
GetVersion
()
const
override
;
...
...
@@ -52,6 +43,9 @@ public:
int
SetOption
(
int
optionType
,
const
DataInfo
&
inputInfo
)
override
;
int
GetOption
(
int
optionType
,
const
DataInfo
&
inputInfo
,
DataInfo
&
outputInfo
)
override
;
private:
DataInfo
optionData_
{};
};
}
}
...
...
ai_lite/ai_engine_posix/base/src/sample/include/sample_plugin_2.h
浏览文件 @
5366820b
...
...
@@ -23,17 +23,10 @@
namespace
OHOS
{
namespace
AI
{
class
SamplePlugin2
:
public
IPlugin
{
const
long
long
ALG_VERSION
=
1
;
const
char
*
ALG_NAME
=
"SAMPLE_PLUGIN_2"
;
const
char
*
const
PLUGIN_INFER_MODEL
=
"ASYNC"
;
const
char
*
DEFAULT_OPTION_DATA
=
"default option data"
;
unsigned
char
*
optionData
=
nullptr
;
int
optionLength
=
0
;
public:
SamplePlugin2
();
~
SamplePlugin2
();
~
SamplePlugin2
()
override
;
const
long
long
GetVersion
()
const
override
;
...
...
@@ -52,6 +45,9 @@ public:
int
SetOption
(
int
optionType
,
const
DataInfo
&
inputInfo
)
override
;
int
GetOption
(
int
optionType
,
const
DataInfo
&
inputInfo
,
DataInfo
&
outputInfo
)
override
;
private:
DataInfo
optionData_
{};
};
}
}
...
...
ai_lite/ai_engine_posix/base/src/sample/source/sample_plugin_1.cpp
浏览文件 @
5366820b
...
...
@@ -24,15 +24,53 @@
namespace
OHOS
{
namespace
AI
{
namespace
{
constexpr
long
long
ALG_VERSION
=
1
;
const
char
*
ALG_NAME
=
"SAMPLE_PLUGIN_1"
;
const
char
*
const
PLUGIN_INFER_MODEL
=
"SYNC"
;
const
char
*
const
DEFAULT_PROCESS_STRING
=
"sample_plugin_1 SyncProcess default data"
;
void
FreeDataInfo
(
DataInfo
*
dataInfo
)
{
if
(
dataInfo
!=
nullptr
&&
dataInfo
->
data
!=
nullptr
)
{
free
(
dataInfo
->
data
);
dataInfo
->
data
=
nullptr
;
dataInfo
->
length
=
0
;
}
}
int
ReturnDataCopyOrDefaultData
(
const
DataInfo
&
inputInfo
,
DataInfo
&
outputInfo
)
{
errno_t
retCode
;
DataInfo
sourceData
{};
if
(
inputInfo
.
length
<=
0
||
inputInfo
.
data
==
nullptr
)
{
sourceData
.
data
=
reinterpret_cast
<
unsigned
char
*>
(
const_cast
<
char
*>
(
DEFAULT_PROCESS_STRING
));
sourceData
.
length
=
strlen
(
DEFAULT_PROCESS_STRING
)
+
1
;
}
else
{
sourceData
=
inputInfo
;
}
outputInfo
.
length
=
sourceData
.
length
;
outputInfo
.
data
=
reinterpret_cast
<
unsigned
char
*>
(
malloc
(
sourceData
.
length
));
if
(
outputInfo
.
data
==
nullptr
)
{
HILOGE
(
"[SamplePlugin1]malloc failed."
);
return
RETCODE_FAILURE
;
}
retCode
=
memcpy_s
(
outputInfo
.
data
,
outputInfo
.
length
,
sourceData
.
data
,
sourceData
.
length
);
if
(
retCode
!=
EOK
)
{
HILOGE
(
"[SamplePlugin1]memcpy_s failed[%d]."
,
retCode
);
FreeDataInfo
(
&
outputInfo
);
return
RETCODE_FAILURE
;
}
return
RETCODE_SUCCESS
;
}
}
// anonymous namespace
SamplePlugin1
::
SamplePlugin1
()
=
default
;
SamplePlugin1
::~
SamplePlugin1
()
{
if
(
optionData
!=
nullptr
)
{
free
(
optionData
);
optionData
=
nullptr
;
optionLength
=
0
;
}
FreeDataInfo
(
&
optionData_
);
}
const
long
long
SamplePlugin1
::
GetVersion
()
const
...
...
@@ -53,116 +91,53 @@ const char *SamplePlugin1::GetInferMode() const
int
SamplePlugin1
::
SyncProcess
(
IRequest
*
request
,
IResponse
*&
response
)
{
DataInfo
inputInfo
=
request
->
GetMsg
();
if
(
inputInfo
.
data
!=
nullptr
)
{
HILOGE
(
"[SamplePlugin2]inputInfo data is %p."
,
inputInfo
.
data
);
if
(
inputInfo
.
data
!=
nullptr
&&
inputInfo
.
length
<=
0
)
{
HILOGE
(
"[SamplePlugin1]inputInfo data is invalid."
);
return
RETCODE_FAILURE
;
}
response
=
IResponse
::
Create
(
request
);
CHK_RET
(
response
==
nullptr
,
RETCODE_FAILURE
);
const
char
*
str
=
"sample_plugin_1 SyncProcess outputInfo"
;
char
*
outputData
=
const_cast
<
char
*>
(
str
);
int
len
=
strlen
(
str
)
+
1
;
DataInfo
outputInfo
=
{
.
data
=
(
unsigned
char
*
)
outputData
,
.
length
=
len
,
};
DataInfo
outputInfo
{};
int
retCode
=
ReturnDataCopyOrDefaultData
(
inputInfo
,
outputInfo
);
response
->
SetResult
(
outputInfo
);
response
->
SetRetCode
(
RETCODE_SUCCESS
);
return
RETCODE_SUCCESS
;
response
->
SetRetCode
(
retCode
);
return
retCode
;
}
int
SamplePlugin1
::
AsyncProcess
(
IRequest
*
request
,
IPluginCallback
*
callback
)
{
DataInfo
inputInfo
=
request
->
GetMsg
();
if
(
inputInfo
.
data
!=
nullptr
)
{
HILOGE
(
"[SamplePlugin2]inputInfo data is %p."
,
inputInfo
.
data
);
}
IResponse
*
response
=
IResponse
::
Create
(
request
);
CHK_RET
(
response
==
nullptr
,
RETCODE_FAILURE
);
const
char
*
str
=
"sample_plugin_1 AsyncProcess outputInfo"
;
char
*
outputData
=
const_cast
<
char
*>
(
str
);
int
len
=
strlen
(
str
)
+
1
;
DataInfo
outputInfo
=
{
.
data
=
(
unsigned
char
*
)
outputData
,
.
length
=
len
,
};
response
->
SetResult
(
outputInfo
);
response
->
SetRetCode
(
RETCODE_SUCCESS
);
int
retCode
=
callback
->
OnEvent
(
ON_PLUGIN_SUCCEED
,
response
);
return
retCode
;
HILOGE
(
"[SamplePlugin1]Sync plugin, can't run AsyncProcess."
);
return
RETCODE_FAILURE
;
}
int
SamplePlugin1
::
Prepare
(
long
long
transactionId
,
const
DataInfo
&
inputInfo
,
DataInfo
&
outputInfo
)
{
const
char
*
str
=
"sample_plugin_1 Prepare outputInfo"
;
char
*
outputData
=
const_cast
<
char
*>
(
str
);
int
len
=
strlen
(
str
)
+
1
;
outputInfo
=
{
.
data
=
(
unsigned
char
*
)
outputData
,
.
length
=
len
,
};
return
RETCODE_SUCCESS
;
return
ReturnDataCopyOrDefaultData
(
inputInfo
,
outputInfo
);
}
int
SamplePlugin1
::
Release
(
bool
isFullUnload
,
long
long
transactionId
,
const
DataInfo
&
inputInfo
)
{
if
(
optionData
!=
nullptr
)
{
free
(
optionData
);
optionData
=
nullptr
;
optionLength
=
0
;
}
FreeDataInfo
(
&
optionData_
);
return
RETCODE_SUCCESS
;
}
int
SamplePlugin1
::
SetOption
(
int
optionType
,
const
DataInfo
&
inputInfo
)
{
if
(
optionData
!=
nullptr
)
{
free
(
optionData
);
optionData
=
nullptr
;
optionLength
=
0
;
}
FreeDataInfo
(
&
optionData_
);
if
(
inputInfo
.
data
==
nullptr
)
{
return
RETCODE_SUCCESS
;
}
optionLength
=
inputInfo
.
length
;
optionData
=
(
unsigned
char
*
)
malloc
(
sizeof
(
unsigned
char
)
*
optionLength
);
if
(
optionData
==
nullptr
)
{
HILOGE
(
"[SamplePlugin1]Failed to request memory."
);
return
RETCODE_OUT_OF_MEMORY
;
}
errno_t
retCode
=
memcpy_s
(
optionData
,
optionLength
,
inputInfo
.
data
,
optionLength
);
if
(
retCode
!=
EOK
)
{
HILOGE
(
"[SamplePlugin1]Failed to memory copy, retCode[%d]."
,
retCode
);
free
(
optionData
);
optionData
=
nullptr
;
return
RETCODE_MEMORY_COPY_FAILURE
;
}
return
RETCODE_SUCCESS
;
return
ReturnDataCopyOrDefaultData
(
inputInfo
,
optionData_
);
}
int
SamplePlugin1
::
GetOption
(
int
optionType
,
const
DataInfo
&
inputInfo
,
DataInfo
&
outputInfo
)
{
if
(
optionData
==
nullptr
)
{
optionLength
=
strlen
(
DEFAULT_OPTION_DATA
)
+
1
;
optionData
=
(
unsigned
char
*
)
malloc
(
sizeof
(
unsigned
char
)
*
optionLength
);
if
(
optionData
==
nullptr
)
{
HILOGE
(
"[SamplePlugin1]Failed to request memory."
);
return
RETCODE_OUT_OF_MEMORY
;
}
errno_t
retCode
=
memcpy_s
(
optionData
,
optionLength
,
DEFAULT_OPTION_DATA
,
optionLength
);
if
(
retCode
!=
EOK
)
{
HILOGE
(
"[SamplePlugin1]Failed to memory copy, retCode[%d]."
,
retCode
);
free
(
optionData
);
optionData
=
nullptr
;
return
RETCODE_MEMORY_COPY_FAILURE
;
}
}
outputInfo
=
{
.
data
=
optionData
,
.
length
=
optionLength
};
return
RETCODE_SUCCESS
;
return
ReturnDataCopyOrDefaultData
(
optionData_
,
outputInfo
);
}
PLUGIN_INTERFACE_IMPL
(
SamplePlugin1
);
...
...
ai_lite/ai_engine_posix/base/src/sample/source/sample_plugin_2.cpp
浏览文件 @
5366820b
...
...
@@ -24,15 +24,53 @@
namespace
OHOS
{
namespace
AI
{
namespace
{
constexpr
long
long
ALG_VERSION
=
1
;
const
char
*
ALG_NAME
=
"SAMPLE_PLUGIN_2"
;
const
char
*
const
PLUGIN_INFER_MODEL
=
"ASYNC"
;
const
char
*
const
DEFAULT_PROCESS_STRING
=
"sample_plugin_2 AsyncProcess default data"
;
void
FreeDataInfo
(
DataInfo
*
dataInfo
)
{
if
(
dataInfo
!=
nullptr
&&
dataInfo
->
data
!=
nullptr
)
{
free
(
dataInfo
->
data
);
dataInfo
->
data
=
nullptr
;
dataInfo
->
length
=
0
;
}
}
int
ReturnDataCopyOrDefaultData
(
const
DataInfo
&
inputInfo
,
DataInfo
&
outputInfo
)
{
errno_t
retCode
;
DataInfo
sourceData
{};
if
(
inputInfo
.
length
<=
0
||
inputInfo
.
data
==
nullptr
)
{
sourceData
.
data
=
reinterpret_cast
<
unsigned
char
*>
(
const_cast
<
char
*>
(
DEFAULT_PROCESS_STRING
));
sourceData
.
length
=
strlen
(
DEFAULT_PROCESS_STRING
)
+
1
;
}
else
{
sourceData
=
inputInfo
;
}
outputInfo
.
length
=
sourceData
.
length
;
outputInfo
.
data
=
reinterpret_cast
<
unsigned
char
*>
(
malloc
(
sourceData
.
length
));
if
(
outputInfo
.
data
==
nullptr
)
{
HILOGE
(
"[SamplePlugin2]malloc failed."
);
return
RETCODE_FAILURE
;
}
retCode
=
memcpy_s
(
outputInfo
.
data
,
outputInfo
.
length
,
sourceData
.
data
,
sourceData
.
length
);
if
(
retCode
!=
EOK
)
{
HILOGE
(
"[SamplePlugin2]memcpy_s failed[%d]."
,
retCode
);
FreeDataInfo
(
&
outputInfo
);
return
RETCODE_FAILURE
;
}
return
RETCODE_SUCCESS
;
}
}
// anonymous namespace
SamplePlugin2
::
SamplePlugin2
()
=
default
;
SamplePlugin2
::~
SamplePlugin2
()
{
if
(
optionData
!=
nullptr
)
{
free
(
optionData
);
optionData
=
nullptr
;
optionLength
=
0
;
}
FreeDataInfo
(
&
optionData_
);
}
const
long
long
SamplePlugin2
::
GetVersion
()
const
...
...
@@ -52,117 +90,54 @@ const char *SamplePlugin2::GetInferMode() const
int
SamplePlugin2
::
SyncProcess
(
IRequest
*
request
,
IResponse
*&
response
)
{
DataInfo
inputInfo
=
request
->
GetMsg
();
if
(
inputInfo
.
data
!=
nullptr
)
{
HILOGE
(
"[SamplePlugin2]inputInfo data is %p."
,
inputInfo
.
data
);
}
response
=
IResponse
::
Create
(
request
);
CHK_RET
(
response
==
nullptr
,
RETCODE_FAILURE
);
const
char
*
str
=
"sample_plugin_2 Process outputInfo"
;
char
*
outputData
=
const_cast
<
char
*>
(
str
);
int
len
=
strlen
(
str
)
+
1
;
DataInfo
outputInfo
=
{
.
data
=
(
unsigned
char
*
)
outputData
,
.
length
=
len
,
};
response
->
SetResult
(
outputInfo
);
response
->
SetRetCode
(
RETCODE_SUCCESS
);
return
RETCODE_SUCCESS
;
HILOGE
(
"[SamplePlugin2]Async plugin, can't run SyncProcess."
);
return
RETCODE_FAILURE
;
}
int
SamplePlugin2
::
AsyncProcess
(
IRequest
*
request
,
IPluginCallback
*
callback
)
{
DataInfo
inputInfo
=
request
->
GetMsg
();
if
(
inputInfo
.
data
!=
nullptr
)
{
HILOGE
(
"[SamplePlugin2]inputInfo data is %p."
,
inputInfo
.
data
);
if
(
inputInfo
.
data
!=
nullptr
&&
inputInfo
.
length
<=
0
)
{
HILOGE
(
"[SamplePlugin2]inputInfo data is invalid."
);
return
RETCODE_FAILURE
;
}
IResponse
*
response
=
IResponse
::
Create
(
request
);
CHK_RET
(
response
==
nullptr
,
RETCODE_FAILURE
);
const
char
*
str
=
"sample_plugin_2 AsyncProcess outputInfo"
;
char
*
outputData
=
const_cast
<
char
*>
(
str
);
int
len
=
strlen
(
str
)
+
1
;
DataInfo
outputInfo
=
{
.
data
=
(
unsigned
char
*
)
outputData
,
.
length
=
len
,
};
DataInfo
outputInfo
{};
int
retCode
=
ReturnDataCopyOrDefaultData
(
inputInfo
,
outputInfo
);
response
->
SetResult
(
outputInfo
);
response
->
SetRetCode
(
RETCODE_SUCCESS
);
int
retCode
=
callback
->
OnEvent
(
ON_PLUGIN_SUCCEED
,
response
);
return
retCode
;
response
->
SetRetCode
(
retCode
);
return
callback
->
OnEvent
(
ON_PLUGIN_SUCCEED
,
response
);
}
int
SamplePlugin2
::
Prepare
(
long
long
transactionId
,
const
DataInfo
&
inputInfo
,
DataInfo
&
outputInfo
)
{
const
char
*
str
=
"sample_plugin_2 Prepare outputInfo"
;
char
*
outputData
=
const_cast
<
char
*>
(
str
);
int
len
=
strlen
(
str
)
+
1
;
outputInfo
=
{
.
data
=
(
unsigned
char
*
)
outputData
,
.
length
=
len
,
};
return
RETCODE_SUCCESS
;
return
ReturnDataCopyOrDefaultData
(
inputInfo
,
outputInfo
);
}
int
SamplePlugin2
::
Release
(
bool
isFullUnload
,
long
long
transactionId
,
const
DataInfo
&
inputInfo
)
{
if
(
optionData
!=
nullptr
)
{
free
(
optionData
);
optionData
=
nullptr
;
optionLength
=
0
;
}
FreeDataInfo
(
&
optionData_
);
return
RETCODE_SUCCESS
;
}
int
SamplePlugin2
::
SetOption
(
int
optionType
,
const
DataInfo
&
inputInfo
)
{
if
(
optionData
!=
nullptr
)
{
free
(
optionData
);
optionData
=
nullptr
;
optionLength
=
0
;
}
FreeDataInfo
(
&
optionData_
);
if
(
inputInfo
.
data
==
nullptr
)
{
return
RETCODE_SUCCESS
;
}
optionLength
=
inputInfo
.
length
;
optionData
=
(
unsigned
char
*
)
malloc
(
sizeof
(
unsigned
char
)
*
optionLength
);
if
(
optionData
==
nullptr
)
{
HILOGE
(
"[SamplePlugin2]Failed to request memory."
);
return
RETCODE_OUT_OF_MEMORY
;
}
errno_t
retCode
=
memcpy_s
(
optionData
,
optionLength
,
inputInfo
.
data
,
optionLength
);
if
(
retCode
!=
EOK
)
{
HILOGE
(
"[SamplePlugin2]Failed to memory copy, retCode[%d]."
,
retCode
);
free
(
optionData
);
optionData
=
nullptr
;
return
RETCODE_MEMORY_COPY_FAILURE
;
}
return
RETCODE_SUCCESS
;
return
ReturnDataCopyOrDefaultData
(
inputInfo
,
optionData_
);
}
int
SamplePlugin2
::
GetOption
(
int
optionType
,
const
DataInfo
&
inputInfo
,
DataInfo
&
outputInfo
)
{
if
(
optionData
==
nullptr
)
{
optionLength
=
strlen
(
DEFAULT_OPTION_DATA
)
+
1
;
optionData
=
(
unsigned
char
*
)
malloc
(
sizeof
(
unsigned
char
)
*
optionLength
);
if
(
optionData
==
nullptr
)
{
HILOGE
(
"[SamplePlugin1]Failed to request memory."
);
return
RETCODE_OUT_OF_MEMORY
;
}
errno_t
retCode
=
memcpy_s
(
optionData
,
optionLength
,
DEFAULT_OPTION_DATA
,
optionLength
);
if
(
retCode
!=
EOK
)
{
HILOGE
(
"[SamplePlugin1]Failed to memory copy, retCode[%d]."
,
retCode
);
free
(
optionData
);
optionData
=
nullptr
;
return
RETCODE_MEMORY_COPY_FAILURE
;
}
}
outputInfo
=
{
.
data
=
optionData
,
.
length
=
optionLength
};
return
RETCODE_SUCCESS
;
return
ReturnDataCopyOrDefaultData
(
optionData_
,
outputInfo
);
}
PLUGIN_INTERFACE_IMPL
(
SamplePlugin2
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录