1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef IC_SDK_IMPL_H
17 #define IC_SDK_IMPL_H
18 
19 #include <vector>
20 
21 #include "aie_algorithm_type.h"
22 #include "aie_info_define.h"
23 #include "constants.h"
24 #include "ic_constants.h"
25 #include "ic_sdk.h"
26 #include "single_instance.h"
27 
28 namespace OHOS {
29 namespace AI {
30 class IcSdkImpl {
31 DECLARE_SINGLE_INSTANCE(IcSdkImpl);
32 public:
33     int32_t Create();
34     int32_t SetCallback(std::shared_ptr<IcCallback> callback);
35     int32_t SyncExecute(const IcInput &picInput);
36     int32_t Destroy();
37 private:
38     std::shared_ptr<IcCallback> callback_ = nullptr;
39     intptr_t icHandle_ = INVALID_IC_HANDLE;
40     int32_t OnSyncExecute(const IcInput &picInput, DataInfo &outputInfo);
41     ConfigInfo configInfo_ {
42         .description = "Ic config description"
43     };
44     ClientInfo clientInfo_ {
45         .clientVersion = CLIENT_VERSION_IC,
46         .clientId = INVALID_CLIENT_ID,
47         .sessionId = INVALID_SESSION_ID,
48         .extendLen = EXT_MSG_LEN_DEFAULT,
49         .extendMsg = nullptr
50     };
51     AlgorithmInfo algorithmInfo_ {
52         .clientVersion = CLIENT_VERSION_IC,
53         .isAsync = false,
54         .algorithmType = ALGORITHM_TYPE_IC,
55         .algorithmVersion = ALGOTYPE_VERSION_IC,
56         .isCloud = false,
57         .operateId = STARTING_OPERATE_ID,
58         .requestId = STARTING_REQ_ID,
59         .extendLen = EXT_MSG_LEN_DEFAULT,
60         .extendMsg = nullptr
61     };
62 };
63 } // namespace AI
64 } // namespace OHOS
65 #endif // IC_SDK_IMPL_H