1 # Copyright 2014 The Chromium Authors
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 import("//build/buildflag_header.gni")
6 import("//build/config/android/config.gni")
7 import("//build/config/arm.gni")
8 import("//build/config/chromecast_build.gni")
9 import("//build/config/features.gni")
10 import("//build/config/linux/pkg_config.gni")
11 import("//build/config/ui.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 import("//tizen_src/chromium_impl/media/media_efl.gni")
18 if (enable_library_cdms) {
19 import("//media/cdm/library_cdm/cdm_paths.gni")
23 import("//build/config/ios/bundle_data_from_filelist.gni")
26 buildflag_header("media_buildflags") {
27 header = "media_buildflags.h"
29 enable_passthrough_audio_codecs =
30 enable_platform_dts_audio && (is_win || is_linux)
33 "ALLOW_OOP_VIDEO_DECODER=$allow_oop_video_decoder",
34 "ALLOW_HOSTING_OOP_VIDEO_DECODER=$allow_hosting_oop_video_decoder",
35 "ALTERNATE_CDM_STORAGE_ID_KEY=\"$alternate_cdm_storage_id_key\"",
36 "CHROME_WIDE_ECHO_CANCELLATION=$chrome_wide_echo_cancellation_supported",
37 "ENABLE_PLATFORM_AC3_EAC3_AUDIO=$enable_platform_ac3_eac3_audio",
38 "ENABLE_PLATFORM_AC4_AUDIO=$enable_platform_ac4_audio",
39 "ENABLE_CAST_AUDIO_RENDERER=$enable_cast_audio_renderer",
40 "ENABLE_DAV1D_DECODER=$enable_dav1d_decoder",
41 "ENABLE_AV1_DECODER=$enable_av1_decoder",
42 "ENABLE_PLATFORM_DOLBY_VISION=$enable_platform_dolby_vision",
43 "ENABLE_PLATFORM_ENCRYPTED_DOLBY_VISION=$enable_platform_encrypted_dolby_vision",
44 "ENABLE_FFMPEG=$media_use_ffmpeg",
45 "ENABLE_FFMPEG_VIDEO_DECODERS=$enable_ffmpeg_video_decoders",
46 "ENABLE_PLATFORM_HEVC=$enable_platform_hevc",
47 "ENABLE_HEVC_PARSER_AND_HW_DECODER=$enable_hevc_parser_and_hw_decoder",
48 "ENABLE_PLATFORM_VVC=$enable_platform_vvc",
49 "ENABLE_HLS_DEMUXER=$enable_hls_demuxer",
50 "ENABLE_LIBAOM=$enable_libaom",
51 "ENABLE_LIBRARY_CDMS=$enable_library_cdms",
52 "ENABLE_LIBVPX=$media_use_libvpx",
53 "ENABLE_LOGGING_OVERRIDE=$enable_logging_override",
54 "ENABLE_MEDIA_DRM_STORAGE=$enable_media_drm_storage",
55 "ENABLE_MEDIA_REMOTING=$enable_media_remoting",
56 "ENABLE_MEDIA_REMOTING_RPC=$enable_media_remoting_rpc",
57 "ENABLE_OPENH264=$media_use_openh264",
58 "ENABLE_PASSTHROUGH_AUDIO_CODECS=$enable_passthrough_audio_codecs",
59 "ENABLE_PLATFORM_DTS_AUDIO=$enable_platform_dts_audio",
60 "ENABLE_PLATFORM_MPEG_H_AUDIO=$enable_platform_mpeg_h_audio",
61 "ENABLE_MSE_MPEG2TS_STREAM_PARSER=$enable_mse_mpeg2ts_stream_parser",
62 "PLATFORM_HAS_OPTIONAL_HEVC_SUPPORT=$platform_has_optional_hevc_support",
63 "USE_ARC_PROTECTED_MEDIA=$use_arc_protected_media",
64 "USE_CHROMEOS_MEDIA_ACCELERATION=$use_vaapi||$use_v4l2_codec",
65 "USE_CHROMEOS_PROTECTED_AV1=$use_chromeos_protected_av1",
66 "USE_CHROMEOS_PROTECTED_MEDIA=$use_chromeos_protected_media",
67 "USE_PROPRIETARY_CODECS=$proprietary_codecs",
70 if (enable_library_cdms) {
72 "CDM_PLATFORM_SPECIFIC_PATH=\"$cdm_platform_specific_path\"",
73 "ENABLE_CDM_HOST_VERIFICATION=$enable_cdm_host_verification",
74 "ENABLE_CDM_STORAGE_ID=$enable_cdm_storage_id",
79 if (proprietary_codecs && media_use_ffmpeg && !tizen_multimedia) {
81 ffmpeg_branding != "Chromium",
82 "proprietary codecs and ffmpeg_branding set to Chromium are incompatible")
85 # Common configuration for targets in the media directory; these must not be
86 # exported since things like USE_NEON and USE_CRAS have different meanings
87 # elsewhere in the code base.
88 config("media_config") {
90 if (current_cpu == "arm64" || (current_cpu == "arm" && arm_use_neon)) {
91 defines += [ "USE_NEON" ]
94 defines += [ "USE_PULSEAUDIO" ]
95 if (!link_pulseaudio) {
96 defines += [ "DLOPEN_PULSEAUDIO" ]
100 defines += [ "USE_CRAS" ]
104 # Internal grouping of the configs necessary to support sub-folders having their
105 # own BUILD.gn files; only targets which roll up into the "media" target should
106 # include this config. I.e., not "test_support" or "unit_tests" targets.
108 # Without these configs having individual sub-folders take a //media/base DEP
109 # (or others) can yield incorrectly imported and exported symbols on Windows:
111 # fatal error LNK1169: one or more multiply defined symbols found.
113 config("subcomponent_config") {
114 visibility = media_subcomponent_deps
116 visibility += [ "//media/base/mac" ]
118 defines = [ "IS_MEDIA_IMPL" ]
121 "//build/config/compiler:wexit_time_destructors",
131 "//base/third_party/dynamic_annotations",
133 "//gpu/command_buffer/client:gles2_interface",
134 "//gpu/command_buffer/common",
135 "//third_party/libyuv",
136 "//ui/events:events_base",
143 public_configs = [ "//third_party/libwebm:libwebm_config" ]
144 public_deps = media_subcomponent_deps
147 ":shared_memory_support",
148 "//ui/gfx:color_space",
151 # This must be included here since it actually depends on //media/base.
152 if (is_mac || (use_blink && is_ios)) {
153 public_deps += [ "//media/base/mac" ]
157 deps += [ "//ui/ozone" ]
161 # Note: This can't be a static_library since it does not have any sources.
162 source_set("test_support") {
166 "//media/audio:test_support",
167 "//media/base:test_support",
168 "//media/base/android:test_support",
169 "//media/filters:test_support",
170 "//media/formats:test_support",
171 "//media/renderers:test_support",
172 "//media/video:test_support",
177 bundle_data_from_filelist("unit_tests_bundle_data") {
179 filelist_name = "unit_tests_bundle_data.filelist"
183 # Contains tests for all targets in the "media" folder.
184 # TODO(xhwang): Move mojo/capture/remoting tests here where applicable.
185 test("media_unittests") {
186 use_xvfb = use_xvfb_in_this_config
189 "//media/audio:unit_tests",
190 "//media/base:unit_tests",
191 "//media/capabilities:unit_tests",
192 "//media/cdm:unit_tests",
193 "//media/device_monitors:unit_tests",
194 "//media/filters:unit_tests",
195 "//media/formats:unit_tests",
196 "//media/gpu:unit_tests",
197 "//media/learning:unit_tests",
198 "//media/mojo:unit_tests",
199 "//media/muxers:unit_tests",
200 "//media/parsers:unit_tests",
201 "//media/renderers:unit_tests",
202 "//media/test:pipeline_integration_tests",
203 "//media/test:run_all_unittests",
204 "//media/video:unit_tests",
205 "//media/webrtc:unit_tests",
210 "formats/mp4/h264_annex_b_fuzz_corpus/",
211 "formats/mp4/h265_annex_b_fuzz_corpus/",
214 data_deps = [ "//testing/buildbot/filters:media_unittests_filters" ]
216 if (is_android && enable_chrome_android_internal) {
217 data_deps += [ "//clank/build/bot/filters:media_unittests_filters" ]
220 if (media_use_ffmpeg) {
221 deps += [ "//media/ffmpeg:unit_tests" ]
226 # The test needs the java dependencies to add the java classes for their
227 # native counterparts to the test apk.
228 "//gpu/command_buffer/service:android_texture_owner_unittests",
229 "//media/base/android:media_java",
230 "//media/base/android:unit_tests",
231 "//media/gpu:android_video_decode_accelerator_unittests",
232 "//ui/android:ui_java",
237 deps += [ "//media/fuchsia/video:unittests" ]
239 # PaintCanvasVideoRendererWithGLTest.* uses SwiftShader, which generates
241 test_runner_shard = "//build/config/fuchsia/test/elf_test_ambient_exec_runner.shard.test-cml"
243 additional_manifest_fragments = [
244 "//build/config/fuchsia/test/audio_output.shard.test-cml",
245 "//build/config/fuchsia/test/mark_vmo_executable.shard.test-cml",
246 "//build/config/fuchsia/test/platform_video_codecs.shard.test-cml",
247 "//third_party/fuchsia-sdk/sdk/pkg/vulkan/client.shard.cml",
250 if (enable_library_cdms) {
251 excluded_files = [ "lib.unstripped/libclearkeycdm.so" ]
255 if (enable_media_remoting) {
256 deps += [ "//media/remoting:media_remoting_tests" ]
259 # The test needs OPUS_FIXED_POINT conditional define.
260 configs += [ "//third_party/opus:opus_config" ]
263 deps += [ ":unit_tests_bundle_data" ]
267 test("media_perftests") {
268 configs += [ ":media_config" ]
271 "//base/test:test_support",
272 "//media/base:perftests",
273 "//media/filters:perftests",
274 "//media/test:pipeline_integration_perftests",
278 "//third_party/widevine/cdm:headers",
279 "//ui/gfx:test_support",
281 if (media_use_ffmpeg) {
282 # Direct dependency required to inherit config.
283 deps += [ "//third_party/ffmpeg" ]
286 # This target should not require the Chrome executable to run.
287 assert_no_deps = [ "//chrome" ]
289 data = [ "test/data/" ]
292 # Needed for isolate script to execute.
293 "//testing:run_perf_test",
297 # The audio subset of media_unittests. This target exists for running only the
298 # audio tests on the GPU bots (which have audio hardware).
299 test("audio_unittests") {
302 "//base/test:test_support",
303 "//media/audio:unit_tests",
304 "//media/test:run_all_unittests",
308 # The test needs the java dependencies to add the java classes for their
309 # native counterparts to the test apk.
310 "//media/base/android:media_java",
311 "//ui/android:ui_java",
316 additional_manifest_fragments =
317 [ "//build/config/fuchsia/test/audio_output.shard.test-cml" ]
321 # Note: Most external components should just depend on //media unless they
322 # specifically need this pared own target (NaCl, PPAPI, etc). Internal targets
323 # should just depend on //media/base which will propagate this target to them.
324 component("shared_memory_support") {
328 "base/audio_codecs.h",
329 "base/audio_latency.cc",
330 "base/audio_latency.h",
331 "base/audio_parameters.cc",
332 "base/audio_parameters.h",
333 "base/audio_point.cc",
334 "base/audio_point.h",
335 "base/audio_sample_types.h",
336 "base/channel_layout.cc",
337 "base/channel_layout.h",
339 "base/media_export.h",
340 "base/media_shmem_export.h",
341 "base/sample_format.cc",
342 "base/sample_format.h",
343 "base/vector_math.cc",
344 "base/vector_math.h",
345 "base/vector_math_testing.h",
346 "base/video_types.cc",
347 "base/video_types.h",
350 # These need to be included here because audio_latency.cc depends on them.
352 "base/mac/audio_latency_mac.cc",
353 "base/mac/audio_latency_mac.h",
357 # Do not use "subcomponent_config" here since these files are in their own
358 # component target and thus can't share the standard export macros.
359 configs += [ ":media_config" ]
360 defines = [ "MEDIA_SHMEM_IMPLEMENTATION" ]
363 configs -= [ "//build/config/compiler:default_optimization" ]
364 configs += [ "//build/config/compiler:optimize_max" ]
368 "//build:chromeos_buildflags",
369 "//media:media_buildflags",
374 # TODO(watk): Refactor tests that could be made to run on Android. See
375 # http://crbug.com/570762
376 if (media_use_ffmpeg && !is_android) {
377 test("ffmpeg_regression_tests") {
378 configs += [ "//media:media_config" ]
382 "//base/test:test_support",
383 "//media/ffmpeg:ffmpeg_regression_tests",
384 "//media/test:pipeline_integration_tests",
385 "//media/test:run_all_unittests",
388 "//ui/gfx:test_support",
394 if (proprietary_codecs) {
395 fuzzer_test("media_cenc_utils_fuzzer") {
396 sources = [ "cdm/cenc_utils_fuzzertest.cc" ]
401 fuzzer_test("media_vp9_parser_fuzzer") {
402 sources = [ "filters/vp9_parser_fuzzertest.cc" ]
407 libfuzzer_options = [ "max_len = 400000" ]
410 fuzzer_test("media_vp9_parser_encrypted_fuzzer") {
411 sources = [ "filters/vp9_parser_encrypted_fuzzertest.cc" ]
415 "//base/test:test_support",
417 seed_corpus = "//media/test/data"
420 fuzzer_test("media_vpx_video_decoder_fuzzer") {
421 sources = [ "filters/vpx_video_decoder_fuzzertest.cc" ]
425 "//base/test:test_support",
427 libfuzzer_options = [ "max_len = 400000" ]
428 seed_corpus = "//media/test/data"
431 fuzzer_test("media_webm_muxer_fuzzer") {
432 sources = [ "muxers/webm_muxer_fuzzertest.cc" ]
436 "//third_party/libwebm",
440 fuzzer_test("cbcs_decryptor_fuzzer") {
441 sources = [ "cdm/cbcs_decryptor_fuzzer.cc" ]
449 fuzzer_test("cenc_decryptor_fuzzer") {
450 sources = [ "cdm/cenc_decryptor_fuzzer.cc" ]
458 fuzzer_test("json_web_key_fuzzer") {
459 sources = [ "cdm/json_web_key_fuzzer.cc" ]
466 if (proprietary_codecs) {
467 fuzzer_test("media_mp4_avcc_parser_fuzzer") {
468 sources = [ "formats/mp4/mp4_avcc_parser_fuzzer.cc" ]
475 fuzzer_test("media_mp4_box_reader_fuzzer") {
476 sources = [ "formats/mp4/mp4_box_reader_fuzzer.cc" ]
481 libfuzzer_options = [ "max_len=500" ]
482 dict = "test/mp4.dict"
486 if (enable_mse_mpeg2ts_stream_parser) {
487 fuzzer_test("media_es_parser_adts_fuzzer") {
488 sources = [ "formats/mp2t/es_parser_adts_fuzzer.cc" ]
495 fuzzer_test("media_es_parser_h264_fuzzer") {
496 sources = [ "formats/mp2t/es_parser_h264_fuzzer.cc" ]
503 fuzzer_test("media_es_parser_mpeg1audio_fuzzer") {
504 sources = [ "formats/mp2t/es_parser_mpeg1audio_fuzzer.cc" ]