1# Copyright (C) 2021 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6#     http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14import("//build/ohos.gni")
15import("//build/ohos/ace/ace.gni")
16import("//foundation/multimedia/player_framework/config.gni")
17import("./../../../multimedia_player_framework_aafwk.gni")
18
19group("napi_packages") {
20  deps = []
21  if (player_framework_support_jsapi) {
22    deps += [
23      "./../../../frameworks/js/audio_haptic:audiohaptic_napi",
24      "./../../../frameworks/js/system_sound_manager:systemsoundmanager",
25      "//foundation/multimedia/player_framework/interfaces/kits/js:media",
26      "//foundation/multimedia/player_framework/interfaces/kits/js:media_js",
27    ]
28  }
29}
30
31js_declaration("media_js") {
32  part_name = "player_framework"
33  sources = [ "./@ohos.multimedia.media.d.ts" ]
34}
35
36ohos_copy("media_declaration") {
37  sources = [ "./@ohos.multimedia.media.d.ts" ]
38  outputs = [ target_out_dir + "/$target_name/" ]
39  module_source_dir = target_out_dir + "/$target_name"
40  module_install_name = ""
41}
42
43ohos_shared_library("media") {
44  stack_protector_ret = true
45  sanitize = {
46    integer_overflow = true
47    ubsan = true
48    boundary_sanitize = true
49    cfi = true
50    cfi_cross_dso = true
51    debug = false
52  }
53
54  include_dirs = [
55    "//foundation/multimedia/player_framework/interfaces/kits/js",
56    "//foundation/multimedia/player_framework/frameworks/js/avplayer",
57    "//foundation/multimedia/player_framework/frameworks/js/avrecorder",
58    "${multimedia_player_framework_path}/frameworks/js/avtranscoder",
59    "//foundation/multimedia/player_framework/frameworks/js/player",
60    "//foundation/multimedia/player_framework/frameworks/js/recorder",
61    "//foundation/multimedia/player_framework/frameworks/js/media",
62    "${multimedia_player_framework_path}/frameworks/js/mediasource",
63    "//foundation/multimedia/player_framework/frameworks/js/common",
64    "${multimedia_player_framework_path}/frameworks/js/avscreen_capture",
65    "//foundation/multimedia/player_framework/services/utils/include",
66    "${multimedia_player_framework_path}/frameworks/js/soundpool/include",
67    "${multimedia_player_framework_path}/frameworks/js/metadatahelper",
68    "${multimedia_player_framework_path}/interfaces/inner_api/native/soundpool/include",
69    "//foundation/multimedia/player_framework/interfaces/inner_api/native/",
70  ]
71
72  sources = [
73    "${multimedia_player_framework_path}/frameworks/js/mediasource/media_source_napi.cpp",
74    "//foundation/multimedia/player_framework/frameworks/js/common/common_napi.cpp",
75    "//foundation/multimedia/player_framework/frameworks/js/media/media_enum_napi.cpp",
76    "//foundation/multimedia/player_framework/frameworks/js/media/native_module_ohos_media.cpp",
77  ]
78
79  if (player_framework_support_player) {
80    sources += [
81      "//foundation/multimedia/player_framework/frameworks/js/player/audio_player_napi.cpp",
82      "//foundation/multimedia/player_framework/frameworks/js/player/player_callback_napi.cpp",
83    ]
84    if (player_framework_support_video) {
85      sources += [
86        "//foundation/multimedia/player_framework/frameworks/js/player/video_callback_napi.cpp",
87        "//foundation/multimedia/player_framework/frameworks/js/player/video_player_napi.cpp",
88      ]
89    }
90  }
91
92  if (player_framework_support_recorder) {
93    sources += [
94      "//foundation/multimedia/player_framework/frameworks/js/recorder/audio_recorder_napi.cpp",
95      "//foundation/multimedia/player_framework/frameworks/js/recorder/recorder_callback_napi.cpp",
96      "//foundation/multimedia/player_framework/frameworks/js/recorder/recorder_napi_utils.cpp",
97      "//foundation/multimedia/player_framework/frameworks/js/recorder/video_recorder_napi.cpp",
98    ]
99  }
100
101  if (player_framework_support_recorder_js_api9) {
102    sources += [
103      "//foundation/multimedia/player_framework/frameworks/js/avrecorder/avrecorder_callback.cpp",
104      "//foundation/multimedia/player_framework/frameworks/js/avrecorder/avrecorder_napi.cpp",
105    ]
106  }
107
108  if (player_framework_support_metadata) {
109    sources += [
110      "${multimedia_player_framework_path}/frameworks/js/metadatahelper/avimagegenerator_napi.cpp",
111      "${multimedia_player_framework_path}/frameworks/js/metadatahelper/avmetadataextractor_napi.cpp",
112      "${multimedia_player_framework_path}/frameworks/js/metadatahelper/avmetadatahelper_callback.cpp",
113      "${multimedia_player_framework_path}/frameworks/js/metadatahelper/helper_data_source_callback.cpp",
114    ]
115  }
116
117  if (player_framework_support_screen_capture) {
118    sources += [
119      "${multimedia_player_framework_path}/frameworks/js/avscreen_capture/avscreen_capture_callback.cpp",
120      "${multimedia_player_framework_path}/frameworks/js/avscreen_capture/avscreen_capture_napi.cpp",
121    ]
122  }
123
124  if (player_framework_support_transcoder) {
125    sources += [
126      "${multimedia_player_framework_path}/frameworks/js/avtranscoder/avtranscoder_callback.cpp",
127      "${multimedia_player_framework_path}/frameworks/js/avtranscoder/avtranscoder_napi.cpp",
128    ]
129  }
130
131  cflags = [
132    "-std=c++17",
133    "-fno-rtti",
134    "-fno-exceptions",
135    "-Wall",
136    "-fno-common",
137    "-fstack-protector-strong",
138    "-Wshadow",
139    "-FPIC",
140    "-FS",
141    "-O2",
142    "-D_FORTIFY_SOURCE=2",
143    "-fvisibility=hidden",
144    "-Wformat=2",
145    "-Wfloat-equal",
146    "-Wdate-time",
147    "-Werror",
148    "-Wextra",
149    "-Wimplicit-fallthrough",
150    "-Wsign-compare",
151    "-Wunused-parameter",
152  ]
153
154  deps = [
155    "//foundation/multimedia/player_framework/interfaces/inner_api/native:media_client",
156    "//foundation/multimedia/player_framework/services/utils:media_service_utils",
157  ]
158
159  if (player_framework_support_jssoundpool) {
160    deps += [
161      "${multimedia_player_framework_path}/frameworks/js/soundpool:media_soundpool",
162      "${multimedia_player_framework_path}/frameworks/native/soundpool:soundpool_client",
163    ]
164  }
165
166  external_deps = [
167    "access_token:libaccesstoken_sdk",
168    "access_token:libtokenid_sdk",
169    "audio_framework:audio_client",
170    "audio_framework:audio_renderer",
171    "av_codec:av_codec_client",
172    "c_utils:utils",
173    "hilog:libhilog",
174    "image_framework:image",
175    "image_framework:image_native",
176    "ipc:ipc_core",
177    "ipc:ipc_single",
178    "libuv:uv",
179    "media_foundation:media_foundation",
180    "napi:ace_napi",
181    "qos_manager:qos",
182    "window_manager:libdm",
183  ]
184
185  if (player_framework_support_auto_create_file) {
186    external_deps += [ "media_library:medialibrary_nutils" ]
187  }
188
189  if (player_framework_support_player_js_api9) {
190    deps += [ "../../../../../../foundation/multimedia/player_framework/frameworks/js/avplayer:media_avplayer" ]
191    external_deps += [ "bounds_checking_function:libsec_shared" ]
192  }
193
194  if (player_framework_support_video) {
195    external_deps += [ "graphic_surface:surface" ]
196  }
197
198  if (player_framework_support_jsstack) {
199    external_deps += [ "hiview:libxpower_event_js" ]
200  }
201
202  defines = []
203  defines += player_framework_defines
204
205  if (is_arkui_x) {
206    defines += [ "CROSS_PLATFORM" ]
207  }
208
209  relative_install_dir = "module/multimedia"
210  part_name = "player_framework"
211  subsystem_name = "multimedia"
212}
213