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 #include "native_module_ohos_image.h"
17 #include "hilog/log.h"
18
19 using OHOS::HiviewDFX::HiLog;
20 namespace {
21 constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_DOMAIN, "NAPITEST"};
22 }
23 namespace OHOS {
24 namespace Media{
25 /*
26 * Function registering all props and functions of ohos.medialibrary module
27 */
Export(napi_env env,napi_value exports)28 static napi_value Export(napi_env env, napi_value exports)
29 {
30 HiLog::Error(LABEL, "ImagePackerNapi CALL");
31 ImagePackerNapi::Init(env, exports);
32 HiLog::Error(LABEL, "PixelMapNapi CALL");
33 PixelMapNapi::Init(env, exports);
34 HiLog::Error(LABEL, "ImageSourceNapi CALL");
35 ImageSourceNapi::Init(env, exports);
36 #if !defined(IOS_PLATFORM) && !defined(A_PLATFORM)
37 HiLog::Error(LABEL, "ImageReceiverNapi CALL");
38 ImageReceiverNapi::Init(env, exports);
39 HiLog::Error(LABEL, "ImageCreatorNapi CALL");
40 ImageCreatorNapi::Init(env, exports);
41 HiLog::Error(LABEL, "ImageNapi CALL");
42 ImageNapi::Init(env, exports);
43 #endif
44 return exports;
45 }
46
47 /*
48 * module define
49 */
50 static napi_module g_module = {
51 .nm_version = 1,
52 .nm_flags = 0,
53 .nm_filename = nullptr,
54 .nm_register_func = Export,
55 .nm_modname = "multimedia.image",
56 .nm_priv = (reinterpret_cast<void *>(0)),
57 .reserved = {0}
58 };
59
60 /*
61 * module register
62 */
ImageRegisterModule(void)63 extern "C" __attribute__((constructor)) void ImageRegisterModule(void)
64 {
65 napi_module_register(&g_module);
66 }
67 } // namespace Media
68 } // namespace OHOS
69