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_SIZE_NAPI_H_ 17 #define CAMERA_SIZE_NAPI_H_ 18 19 #include "camera_log.h" 20 #include "napi/native_api.h" 21 #include "napi/native_node_api.h" 22 23 #include "hilog/log.h" 24 #include "camera_napi_utils.h" 25 #include "input/camera_input.h" 26 27 #include <fstream> 28 #include <iostream> 29 #include <sstream> 30 #include <vector> 31 32 #include <fcntl.h> 33 #include <sys/stat.h> 34 #include <sys/time.h> 35 #include <sys/types.h> 36 37 namespace OHOS { 38 namespace CameraStandard { 39 static const char CAMERA_SIZE_NAPI_CLASS_NAME[] = "Size"; 40 41 class CameraSizeNapi { 42 public: 43 static napi_value Init(napi_env env, napi_value exports); 44 static napi_value CreateCameraSize(napi_env env, Size &cameraPicSize); 45 46 static napi_value GetCameraSizeWidth(napi_env env, napi_callback_info info); 47 static napi_value GetCameraSizeHeight(napi_env env, napi_callback_info info); 48 49 CameraSizeNapi(); 50 ~CameraSizeNapi(); 51 Size* cameraPicSize_; 52 53 private: 54 static void CameraSizeNapiDestructor(napi_env env, void* nativeObject, void* finalize_hint); 55 static napi_value CameraSizeNapiConstructor(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 Size* sCameraPicSize_; 62 }; 63 } // namespace CameraStandard 64 } // namespace OHOS 65 #endif /* CAMERA_SIZE_NAPI_H_ */ 66