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