1 /* 2 * Copyright (c) 2021-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 CAMERA_INFO_NAPI_H_ 17 #define CAMERA_INFO_NAPI_H_ 18 19 #include <fstream> 20 #include <iostream> 21 #include <sstream> 22 #include <vector> 23 #include <fcntl.h> 24 #include <sys/stat.h> 25 #include <sys/time.h> 26 #include <sys/types.h> 27 #include "display_type.h" 28 #include "camera_log.h" 29 #include "camera_napi_utils.h" 30 #include "input/camera_manager.h" 31 #include "input/camera_device.h" 32 #include "napi/native_api.h" 33 #include "napi/native_node_api.h" 34 #include "output/capture_output.h" 35 #include "hilog/log.h" 36 namespace OHOS { 37 namespace CameraStandard { 38 static const char CAMERA_OBJECT_NAPI_CLASS_NAME[] = "Camera"; 39 40 class CameraDeviceNapi { 41 public: 42 static napi_value Init(napi_env env, napi_value exports); 43 static napi_value CreateCameraObj(napi_env env, sptr<CameraDevice> cameraInfo); 44 CameraDeviceNapi(); 45 ~CameraDeviceNapi(); 46 sptr<CameraDevice> cameraDevice_; 47 48 private: 49 static void CameraDeviceNapiDestructor(napi_env env, void* nativeObject, void* finalize_hint); 50 static napi_value CameraDeviceNapiConstructor(napi_env env, napi_callback_info info); 51 52 static napi_value GetCameraId(napi_env env, napi_callback_info info); 53 static napi_value GetCameraPosition(napi_env env, napi_callback_info info); 54 static napi_value GetCameraType(napi_env env, napi_callback_info info); 55 static napi_value GetConnectionType(napi_env env, napi_callback_info info); 56 57 napi_env env_; 58 napi_ref wrapper_; 59 60 static thread_local napi_ref sConstructor_; 61 static thread_local sptr<CameraDevice> sCameraDevice_; 62 }; 63 } // namespace CameraStandard 64 } // namespace OHOS 65 #endif /* CAMERA_INFO_NAPI_H_ */ 66