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