1 /*
2  * Copyright (C) 2022 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 DEPTH_DATA_NAPI_H_
17 #define DEPTH_DATA_NAPI_H_
18 
19 #include "camera_napi_utils.h"
20 
21 namespace OHOS {
22 namespace CameraStandard {
23 static const char DEPTH_DATA_NAPI_CLASS_NAME[] = "DepthData";
24 
25 class DepthDataNapi {
26 public:
27     DepthDataNapi();
28     ~DepthDataNapi();
29 
30     static napi_value Init(napi_env env, napi_value exports);
31     static napi_value CreateDepthData(napi_env env, napi_value format, napi_value depthMap, napi_value qualityLevel,
32                                       napi_value accuracy);
33 
34     static napi_value GetFormat(napi_env env, napi_callback_info info);
35     static napi_value GetDepthMap(napi_env env, napi_callback_info info);
36     static napi_value GetQualityLevel(napi_env env, napi_callback_info info);
37     static napi_value GetAccuracy(napi_env env, napi_callback_info info);
38     static napi_value Release(napi_env env, napi_callback_info info);
39 
40 private:
41     static napi_value DepthDataNapiConstructor(napi_env env, napi_callback_info info);
42     static void DepthDataNapiDestructor(napi_env env, void* nativeObject, void* finalize_hint);
43 
44     static thread_local napi_ref sConstructor_;
45     static thread_local napi_value sFormat_;
46     static thread_local napi_value sDepthMap_;
47     static thread_local napi_value sQualityLevel_;
48     static thread_local napi_value sAccuracy_;
49     static thread_local uint32_t depthDataTaskId;
50 
51     napi_env env_;
52     napi_value format_;
53     napi_value depthMap_;
54     napi_value qualityLevel_;
55     napi_value accuracy_;
56 };
57 
58 struct DepthDataAsyncContext : public AsyncContext {
59     DepthDataNapi* objectInfo;
60 
~DepthDataAsyncContextDepthDataAsyncContext61     ~DepthDataAsyncContext()
62     {
63         objectInfo = nullptr;
64     }
65 };
66 } // namespace CameraStandard
67 } // namespace OHOS
68 #endif // DEPTH_DATA_NAPI_H_