• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2025 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 #include "native_module_ohos_camera.h"
17 
18 #include "input/camera_input_napi.h"
19 #include "input/camera_manager_napi.h"
20 #include "input/camera_napi.h"
21 #include "mode/photo_session_napi.h"
22 #include "mode/secure_camera_session_napi.h"
23 #include "mode/video_session_napi.h"
24 #include "output/photo_napi.h"
25 #include "output/photo_output_napi.h"
26 #include "output/preview_output_napi.h"
27 #include "output/video_output_napi.h"
28 
29 namespace OHOS {
30 namespace CameraStandard {
31 /*
32  * Function registering all props and functions of ohos.camera module
33  */
Export(napi_env env,napi_value exports)34 static napi_value Export(napi_env env, napi_value exports)
35 {
36     MEDIA_DEBUG_LOG("Export called()");
37     CameraInputNapi::Init(env, exports);
38     PreviewOutputNapi::Init(env, exports);
39     PhotoOutputNapi::Init(env, exports);
40     VideoOutputNapi::Init(env, exports);
41     CameraManagerNapi::Init(env, exports);
42     CameraNapi::Init(env, exports);
43     MetadataOutputNapi::Init(env, exports);
44     PhotoSessionNapi::Init(env, exports);
45     VideoSessionNapi::Init(env, exports);
46     PhotoNapi::Init(env, exports);
47     SecureCameraSessionNapi::Init(env, exports);
48     MEDIA_DEBUG_LOG("Export is end");
49     return exports;
50 }
51 
52 /*
53  * module define0......................................................................................................
54  */
55 static napi_module g_module = { .nm_version = 1,
56     .nm_flags = 0,
57     .nm_filename = nullptr,
58     .nm_register_func = Export,
59     .nm_modname = "multimedia.camera",
60     .nm_priv = (reinterpret_cast<void*>(0)),
61     .reserved = { 0 } };
62 
63 /*
64  * module register
65  */
RegisterCameraModule(void)66 extern "C" __attribute__((constructor)) void RegisterCameraModule(void)
67 {
68     MEDIA_DEBUG_LOG("RegisterCameraModule is called");
69     napi_module_register(&g_module);
70 }
71 } // namespace CameraStandard
72 } // namespace OHOS
73