Upload upstream chromium 85.0.4183.84
[platform/framework/web/chromium-efl.git] / media / BUILD.gn
1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import("//build/buildflag_header.gni")
6 import("//build/config/android/config.gni")
7 import("//build/config/arm.gni")
8 import("//build/config/features.gni")
9 import("//build/config/linux/pkg_config.gni")
10 import("//build/config/ui.gni")
11 import("//media/cdm/library_cdm/cdm_paths.gni")
12 import("//media/media_options.gni")
13 import("//testing/libfuzzer/fuzzer_test.gni")
14 import("//testing/test.gni")
15 import("//third_party/ffmpeg/ffmpeg_options.gni")
16 if (use_efl) {
17   import("//tizen_src/chromium_impl/media/media_efl.gni")
18 }
19
20 buildflag_header("media_buildflags") {
21   header = "media_buildflags.h"
22
23   flags = [
24     "ALTERNATE_CDM_STORAGE_ID_KEY=\"$alternate_cdm_storage_id_key\"",
25     "CDM_PLATFORM_SPECIFIC_PATH=\"$cdm_platform_specific_path\"",
26     "ENABLE_PLATFORM_AC3_EAC3_AUDIO=$enable_platform_ac3_eac3_audio",
27     "ENABLE_CDM_HOST_VERIFICATION=$enable_cdm_host_verification",
28     "ENABLE_CDM_STORAGE_ID=$enable_cdm_storage_id",
29     "ENABLE_DAV1D_DECODER=$enable_dav1d_decoder",
30     "ENABLE_AV1_DECODER=$enable_av1_decoder",
31     "ENABLE_PLATFORM_DOLBY_VISION=$enable_platform_dolby_vision",
32     "ENABLE_FFMPEG=$media_use_ffmpeg",
33     "ENABLE_FFMPEG_VIDEO_DECODERS=$enable_ffmpeg_video_decoders",
34     "ENABLE_PLATFORM_HEVC=$enable_platform_hevc",
35     "ENABLE_HLS_SAMPLE_AES=$enable_hls_sample_aes",
36     "ENABLE_LIBGAV1_DECODER=$enable_libgav1_decoder",
37     "ENABLE_LIBRARY_CDMS=$enable_library_cdms",
38     "ENABLE_LIBVPX=$media_use_libvpx",
39     "ENABLE_LOGGING_OVERRIDE=$enable_logging_override",
40     "ENABLE_MEDIA_DRM_STORAGE=$enable_media_drm_storage",
41     "ENABLE_MEDIA_REMOTING=$enable_media_remoting",
42     "ENABLE_MEDIA_REMOTING_RPC=$enable_media_remoting_rpc",
43     "ENABLE_PLATFORM_MPEG_H_AUDIO=$enable_platform_mpeg_h_audio",
44     "ENABLE_MSE_MPEG2TS_STREAM_PARSER=$enable_mse_mpeg2ts_stream_parser",
45     "USE_CHROMEOS_MEDIA_ACCELERATION=$use_vaapi||$use_v4l2_codec",
46     "USE_PROPRIETARY_CODECS=$proprietary_codecs",
47   ]
48 }
49
50 if (proprietary_codecs && media_use_ffmpeg) {
51   assert(
52       ffmpeg_branding != "Chromium",
53       "proprietary codecs and ffmpeg_branding set to Chromium are incompatible")
54 }
55
56 # Common configuration for targets in the media directory; these must not be
57 # exported since things like USE_NEON and USE_CRAS have different meanings
58 # elsewhere in the code base.
59 config("media_config") {
60   defines = []
61   if (current_cpu == "arm64" || (current_cpu == "arm" && arm_use_neon)) {
62     defines += [ "USE_NEON" ]
63   }
64   if (use_pulseaudio) {
65     defines += [ "USE_PULSEAUDIO" ]
66     if (!link_pulseaudio) {
67       defines += [ "DLOPEN_PULSEAUDIO" ]
68     }
69   }
70   if (use_cras) {
71     defines += [ "USE_CRAS" ]
72   }
73 }
74
75 # Internal grouping of the configs necessary to support sub-folders having their
76 # own BUILD.gn files; only targets which roll up into the "media" target should
77 # include this config. I.e., not "test_support" or "unit_tests" targets.
78 #
79 # Without these configs having individual sub-folders take a //media/base DEP
80 # (or others) can yield incorrectly imported and exported symbols on Windows:
81 #
82 #    fatal error LNK1169: one or more multiply defined symbols found.
83 #
84 config("subcomponent_config") {
85   visibility = media_subcomponent_deps
86   if (is_mac) {
87     visibility += [ "//media/base/mac" ]
88   }
89   defines = [ "IS_MEDIA_IMPL" ]
90   configs = [
91     ":media_config",
92     "//build/config/compiler:wexit_time_destructors",
93   ]
94 }
95
96 component("media") {
97   libs = []
98
99   deps = [
100     "//base",
101     "//base:i18n",
102     "//base/third_party/dynamic_annotations",
103     "//cc/paint",
104     "//crypto:platform",
105     "//gpu/command_buffer/client:gles2_interface",
106     "//gpu/command_buffer/common",
107     "//third_party/libyuv",
108     "//ui/events:events_base",
109     "//ui/gfx",
110     "//ui/gfx/geometry",
111     "//ui/gl:gl",
112     "//url",
113   ]
114
115   public_configs = [ "//third_party/libwebm:libwebm_config" ]
116   public_deps = media_subcomponent_deps
117   public_deps += [
118     ":media_buildflags",
119     ":shared_memory_support",
120     "//ui/gfx:color_space",
121   ]
122
123   # This must be included here since it actually depends on //media/base.
124   if (is_mac || is_ios) {
125     public_deps += [ "//media/base/mac" ]
126   }
127 }
128
129 # Note: This can't be a static_library since it does not have any sources.
130 source_set("test_support") {
131   testonly = true
132   public_deps = [
133     ":media",
134     "//media/audio:test_support",
135     "//media/base:test_support",
136     "//media/base/android:test_support",
137     "//media/filters:test_support",
138     "//media/formats:test_support",
139     "//media/video:test_support",
140   ]
141 }
142
143 # Contains tests for all targets in the "media" folder.
144 # TODO(xhwang): Move mojo/capture/remoting tests here where applicable.
145 test("media_unittests") {
146   deps = [
147     "//media/audio:unit_tests",
148     "//media/base:unit_tests",
149     "//media/capabilities:unit_tests",
150     "//media/cdm:unit_tests",
151     "//media/device_monitors:unit_tests",
152     "//media/filters:unit_tests",
153     "//media/formats:unit_tests",
154     "//media/gpu:unit_tests",
155     "//media/learning:unit_tests",
156     "//media/mojo:unit_tests",
157     "//media/muxers:unit_tests",
158     "//media/parsers:unit_tests",
159     "//media/renderers:unit_tests",
160     "//media/test:pipeline_integration_tests",
161     "//media/test:run_all_unittests",
162     "//media/video:unit_tests",
163     "//media/webrtc:unit_tests",
164   ]
165
166   data = [ "test/data/" ]
167
168   data_deps = [ "//testing/buildbot/filters:media_unittests_filters" ]
169
170   if (media_use_ffmpeg) {
171     deps += [ "//media/ffmpeg:unit_tests" ]
172   }
173
174   if (is_android) {
175     deps += [
176       # The test needs the java dependencies to add the java classes for their
177       # native counterparts to the test apk.
178       "//gpu/command_buffer/service:android_texture_owner_unittests",
179       "//media/base/android:media_java",
180       "//media/base/android:unit_tests",
181       "//media/gpu:android_video_decode_accelerator_unittests",
182       "//ui/android:ui_java",
183     ]
184   }
185
186   if (is_fuchsia) {
187     deps += [ "//media/fuchsia/audio:unittests" ]
188   }
189
190   if (enable_media_remoting) {
191     deps += [ "//media/remoting:media_remoting_tests" ]
192   }
193
194   # The test needs OPUS_FIXED_POINT conditional define.
195   configs += [ "//third_party/opus:opus_config" ]
196 }
197
198 test("media_perftests") {
199   configs += [ ":media_config" ]
200   deps = [
201     ":test_support",
202     "//base/test:test_support",
203     "//media/base:perftests",
204     "//media/filters:perftests",
205     "//media/test:pipeline_integration_perftests",
206     "//testing/gmock",
207     "//testing/gtest",
208     "//testing/perf",
209     "//third_party/widevine/cdm:headers",
210     "//ui/gfx:test_support",
211   ]
212   if (media_use_ffmpeg) {
213     # Direct dependency required to inherit config.
214     deps += [ "//third_party/ffmpeg" ]
215   }
216
217   # This target should not require the Chrome executable to run.
218   assert_no_deps = [ "//chrome" ]
219
220   data = [ "test/data/" ]
221
222   data_deps = [
223     # Needed for isolate script to execute.
224     "//testing:run_perf_test",
225   ]
226 }
227
228 # The audio subset of media_unittests. This target exists for running only the
229 # audio tests on the GPU bots (which have audio hardware).
230 test("audio_unittests") {
231   deps = [
232     ":test_support",
233     "//base/test:test_support",
234     "//media/audio:unit_tests",
235     "//media/test:run_all_unittests",
236   ]
237   if (is_android) {
238     deps += [
239       # The test needs the java dependencies to add the java classes for their
240       # native counterparts to the test apk.
241       "//media/base/android:media_java",
242       "//ui/android:ui_java",
243     ]
244   }
245 }
246
247 # Note: Most external components should just depend on //media unless they
248 # specifically need this pared own target (NaCl, PPAPI, etc). Internal targets
249 # should just depend on //media/base which will propagate this target to them.
250 component("shared_memory_support") {
251   sources = [
252     "base/audio_bus.cc",
253     "base/audio_bus.h",
254     "base/audio_latency.cc",
255     "base/audio_latency.h",
256     "base/audio_parameters.cc",
257     "base/audio_parameters.h",
258     "base/audio_point.cc",
259     "base/audio_point.h",
260     "base/audio_sample_types.h",
261     "base/channel_layout.cc",
262     "base/channel_layout.h",
263     "base/limits.h",
264     "base/media_shmem_export.h",
265     "base/sample_format.cc",
266     "base/sample_format.h",
267     "base/vector_math.cc",
268     "base/vector_math.h",
269     "base/vector_math_testing.h",
270   ]
271   if (is_mac) {
272     # These need to be included here because audio_latency.cc depends on them.
273     sources += [
274       "base/mac/audio_latency_mac.cc",
275       "base/mac/audio_latency_mac.h",
276     ]
277   }
278
279   # Do not use "subcomponent_config" here since these files are in their own
280   # component target and thus can't share the standard export macros.
281   configs += [ ":media_config" ]
282   defines = [ "MEDIA_SHMEM_IMPLEMENTATION" ]
283
284   if (!is_debug) {
285     configs -= [ "//build/config/compiler:default_optimization" ]
286     configs += [ "//build/config/compiler:optimize_max" ]
287   }
288   deps = [
289     "//base",
290     "//ui/gfx/geometry",
291   ]
292 }
293
294 # TODO(watk): Refactor tests that could be made to run on Android. See
295 # http://crbug.com/570762
296 if (media_use_ffmpeg && !is_android) {
297   test("ffmpeg_regression_tests") {
298     configs += [ "//media:media_config" ]
299
300     deps = [
301       ":test_support",
302       "//base/test:test_support",
303       "//media/ffmpeg:ffmpeg_regression_tests",
304       "//media/test:pipeline_integration_tests",
305       "//media/test:run_all_unittests",
306       "//testing/gmock",
307       "//testing/gtest",
308       "//ui/gfx:test_support",
309       "//ui/gfx/geometry",
310     ]
311   }
312 }
313
314 if (proprietary_codecs) {
315   fuzzer_test("media_cenc_utils_fuzzer") {
316     sources = [ "cdm/cenc_utils_fuzzertest.cc" ]
317     deps = [ ":media" ]
318   }
319 }
320
321 fuzzer_test("media_vp9_parser_fuzzer") {
322   sources = [ "filters/vp9_parser_fuzzertest.cc" ]
323   deps = [
324     ":test_support",
325     "//base",
326   ]
327   libfuzzer_options = [ "max_len = 400000" ]
328 }
329
330 fuzzer_test("media_vp9_parser_encrypted_fuzzer") {
331   sources = [ "filters/vp9_parser_encrypted_fuzzertest.cc" ]
332   deps = [
333     ":test_support",
334     "//base",
335     "//base/test:test_support",
336   ]
337   seed_corpus = "//media/test/data"
338 }
339
340 fuzzer_test("media_vpx_video_decoder_fuzzer") {
341   sources = [ "filters/vpx_video_decoder_fuzzertest.cc" ]
342   deps = [
343     ":media",
344     "//base",
345     "//base/test:test_support",
346   ]
347   libfuzzer_options = [ "max_len = 400000" ]
348   seed_corpus = "//media/test/data"
349 }
350
351 fuzzer_test("media_webm_muxer_fuzzer") {
352   sources = [ "muxers/webm_muxer_fuzzertest.cc" ]
353   deps = [
354     ":media",
355     "//base",
356     "//third_party/libwebm",
357   ]
358
359   if (use_efl && tizen_multimedia_support) {
360     deps += external_media_efl_deps
361     sources += external_media_efl_sources
362     sources -= external_exclude_media_efl_sources
363     configs += external_media_efl_config
364   }
365 }
366
367 fuzzer_test("cbcs_decryptor_fuzzer") {
368   sources = [ "cdm/cbcs_decryptor_fuzzer.cc" ]
369   deps = [
370     ":media",
371     "//base",
372     "//crypto",
373   ]
374 }
375
376 fuzzer_test("cenc_decryptor_fuzzer") {
377   sources = [ "cdm/cenc_decryptor_fuzzer.cc" ]
378   deps = [
379     ":media",
380     "//base",
381     "//crypto",
382   ]
383 }
384
385 fuzzer_test("json_web_key_fuzzer") {
386   sources = [ "cdm/json_web_key_fuzzer.cc" ]
387   deps = [
388     ":media",
389     "//base",
390   ]
391 }
392
393 if (proprietary_codecs) {
394   fuzzer_test("media_mp4_avcc_parser_fuzzer") {
395     sources = [ "formats/mp4/mp4_avcc_parser_fuzzer.cc" ]
396     deps = [
397       ":media",
398       "//base",
399     ]
400   }
401
402   fuzzer_test("media_mp4_box_reader_fuzzer") {
403     sources = [ "formats/mp4/mp4_box_reader_fuzzer.cc" ]
404     deps = [
405       ":media",
406       "//base",
407     ]
408     libfuzzer_options = [ "max_len=500" ]
409     dict = "test/mp4.dict"
410   }
411 }
412
413 if (enable_mse_mpeg2ts_stream_parser) {
414   fuzzer_test("media_es_parser_adts_fuzzer") {
415     sources = [ "formats/mp2t/es_parser_adts_fuzzer.cc" ]
416     deps = [
417       ":media",
418       "//base",
419     ]
420   }
421
422   fuzzer_test("media_es_parser_h264_fuzzer") {
423     sources = [ "formats/mp2t/es_parser_h264_fuzzer.cc" ]
424     deps = [
425       ":media",
426       "//base",
427     ]
428   }
429
430   fuzzer_test("media_es_parser_mpeg1audio_fuzzer") {
431     sources = [ "formats/mp2t/es_parser_mpeg1audio_fuzzer.cc" ]
432     deps = [
433       ":media",
434       "//base",
435     ]
436   }
437 }