1 /*
2  * Copyright (C) 2023-2023 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  * Description: register napi module for napi interfaces.
15  * Author: zhangjingnan
16  * Create: 2022-7-11
17  */
18 
19 #include "napi/native_api.h"
20 #include "napi/native_node_api.h"
21 #include "napi_cast_session_manager.h"
22 #include "napi_cast_session.h"
23 #include "napi_castengine_utils.h"
24 #include "napi_stream_player.h"
25 #include "napi_mirror_player.h"
26 #include "napi_castengine_enum.h"
27 
28 namespace OHOS {
29 namespace CastEngine {
30 namespace CastEngineClient {
31 EXTERN_C_START
32 
Init(napi_env env, napi_value exports)33 static napi_value Init(napi_env env, napi_value exports)
34 {
35     InitEnums(env, exports);
36     NapiCastSessionManager::Init(env, exports);
37     NapiCastSession::DefineCastSessionJSClass(env);
38     NapiStreamPlayer::DefineStreamPlayerJSClass(env);
39     NapiMirrorPlayer::DefineMirrorPlayerJSClass(env);
40     return exports;
41 }
42 EXTERN_C_END
43 
44 // module description
45 static napi_module napiModule = {
46     .nm_version = 1,
47     .nm_flags = 0,
48     .nm_filename = nullptr,
49     .nm_register_func = Init,
50     .nm_modname = "cast",
51     .nm_priv = ((void *)0),
52     .reserved = { 0 }
53 };
54 
55 // module registration
RegisterModule()56 extern "C" __attribute__((constructor)) void RegisterModule()
57 {
58     napi_module_register(&napiModule);
59 }
60 } // namespace CastEngineClient
61 } // namespace CastEngine
62 } // namespace OHOS