# Copyright 2014 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. import("//build/buildflag_header.gni") import("//build/config/android/config.gni") import("//build/config/arm.gni") import("//build/config/features.gni") import("//build/config/linux/pkg_config.gni") import("//build/config/ui.gni") import("//media/media_options.gni") import("//testing/libfuzzer/fuzzer_test.gni") import("//testing/test.gni") import("//third_party/ffmpeg/ffmpeg_options.gni") buildflag_header("media_features") { header = "media_features.h" flags = [ "ENABLE_AC3_EAC3_AUDIO_DEMUXING=$enable_ac3_eac3_audio_demuxing", "ENABLE_CBCS_ENCRYPTION_SCHEME=$enable_cbcs_encryption_scheme", "ENABLE_CDM_HOST_VERIFICATION=$enable_cdm_host_verification", "ENABLE_HEVC_DEMUXING=$enable_hevc_demuxing", "ENABLE_DOLBY_VISION_DEMUXING=$enable_dolby_vision_demuxing", "ENABLE_HLS_SAMPLE_AES=$enable_hls_sample_aes", "ENABLE_LIBRARY_CDMS=$enable_library_cdms", "ENABLE_MSE_MPEG2TS_STREAM_PARSER=$enable_mse_mpeg2ts_stream_parser", "ENABLE_RUNTIME_MEDIA_RENDERER_SELECTION=$enable_runtime_media_renderer_selection", "ENABLE_MEDIA_REMOTING=$enable_media_remoting", "ENABLE_MEDIA_REMOTING_RPC=$enable_media_remoting_rpc", "ENABLE_WEBRTC=$enable_webrtc", "USE_PROPRIETARY_CODECS=$proprietary_codecs", ] } if (proprietary_codecs && media_use_ffmpeg) { assert( ffmpeg_branding != "Chromium", "proprietary codecs and ffmpeg_branding set to Chromium are incompatible") } # Common configuration for targets in the media directory; these must not be # exported since things like USE_NEON and USE_CRAS have different meanings # elsewhere in the code base. config("media_config") { configs = [ ":media_dependent_config" ] defines = [] if (current_cpu == "arm64" || (current_cpu == "arm" && arm_use_neon)) { defines += [ "USE_NEON" ] } if (use_pulseaudio) { defines += [ "USE_PULSEAUDIO" ] if (!link_pulseaudio) { defines += [ "DLOPEN_PULSEAUDIO" ] } } if (use_cras) { defines += [ "USE_CRAS" ] } } # Common defines which must be set in targets which depend on //media. # TODO(dalecurtis): These should be converted to BUILDFLAGs. config("media_dependent_config") { defines = [] if (!media_use_libvpx) { defines += [ "MEDIA_DISABLE_LIBVPX" ] } if (!media_use_ffmpeg) { defines += [ "MEDIA_DISABLE_FFMPEG" ] } if (disable_ffmpeg_video_decoders) { defines += [ "DISABLE_FFMPEG_VIDEO_DECODERS" ] } } # Internal grouping of the configs necessary to support sub-folders having their # own BUILD.gn files; only targets which roll up into the "media" target should # include this config. I.e., not "test_support" or "unit_tests" targets. # # Without these configs having individual sub-folders take a //media/base DEP # (or others) can yield incorrectly imported and exported symbols on Windows: # # fatal error LNK1169: one or more multiply defined symbols found. # config("subcomponent_config") { visibility = media_subcomponent_deps if (is_mac) { visibility += [ "//media/base/mac" ] } defines = [ "MEDIA_IMPLEMENTATION" ] configs = [ ":media_config" ] } component("media") { libs = [] deps = [ "//base", "//base:i18n", "//base/third_party/dynamic_annotations", "//cc/paint", "//crypto:platform", "//gpu/command_buffer/client:gles2_interface", "//gpu/command_buffer/common", "//third_party/libyuv", "//ui/events:events_base", "//ui/gfx", "//ui/gfx/geometry", "//ui/gl:gl", "//url", ] all_dependent_configs = [ ":media_dependent_config" ] public_configs = [ "//third_party/libwebm:libwebm_config" ] public_deps = media_subcomponent_deps public_deps += [ ":media_features", ":shared_memory_support", # media_switches.h needs ppapi/features/features.h. "//ppapi/features", "//ui/gfx:color_space", ] # This must be included here since it actually depends on //media/base. if (is_mac || is_ios) { public_deps += [ "//media/base/mac" ] } } # Note: This can't be a static_library since it does not have any sources. source_set("test_support") { testonly = true public_deps = [ ":media", "//media/audio:test_support", "//media/base:test_support", "//media/base/android:test_support", "//media/formats:test_support", "//media/video:test_support", ] } # Contains tests for all targets in the "media" folder. # TODO(xhwang): Move mojo/capture/remoting tests here where applicable. test("media_unittests") { deps = [ "//media/audio:unit_tests", "//media/base:unit_tests", "//media/cdm:unit_tests", "//media/device_monitors:unit_tests", "//media/filters:unit_tests", "//media/formats:unit_tests", "//media/gpu:unit_tests", "//media/mojo:unit_tests", "//media/muxers:unit_tests", "//media/renderers:unit_tests", "//media/test:pipeline_integration_tests", "//media/test:run_all_unittests", "//media/video:unit_tests", ] data = [ "test/data/", ] data_deps = [] if (media_use_ffmpeg) { deps += [ "//media/ffmpeg:unit_tests" ] } if (is_android) { deps += [ # The test needs the java dependencies to add the java classes for their # native counterparts to the test apk. "//media/base/android:media_java", "//media/base/android:unit_tests", "//media/gpu:android_video_decode_accelerator_unittests", "//ui/android:ui_java", ] } if (enable_media_remoting) { deps += [ "//media/remoting:media_remoting_tests" ] } if (proprietary_codecs) { configs += [ "//third_party/opus:opus_config" ] } } test("media_perftests") { configs += [ ":media_config" ] deps = [ ":test_support", "//base/test:test_support", "//media/base:perftests", "//media/filters:perftests", "//media/test:pipeline_integration_perftests", "//testing/gmock", "//testing/gtest", "//testing/perf", "//third_party/widevine/cdm:headers", "//ui/gfx:test_support", ] if (media_use_ffmpeg) { # Direct dependency required to inherit config. deps += [ "//third_party/ffmpeg" ] } # This target should not require the Chrome executable to run. assert_no_deps = [ "//chrome" ] data = [ "test/data/", # Needed for isolate script to execute. "//testing/scripts/common.py", "//testing/xvfb.py", "//testing/scripts/run_gtest_perf_test.py", "//tools/perf/generate_legacy_perf_dashboard_json.py", ] } # The audio subset of media_unittests. This target exists for running only the # audio tests on the GPU bots (which have audio hardware). test("audio_unittests") { deps = [ ":test_support", "//base/test:test_support", "//media/audio:unit_tests", "//media/test:run_all_unittests", ] if (is_android) { deps += [ # The test needs the java dependencies to add the java classes for their # native counterparts to the test apk. "//media/base/android:media_java", "//ui/android:ui_java", ] } } # Note: Most external components should just depend on //media unless they # specifically need this pared own target (NaCl, PPAPI, etc). Internal targets # should just depend on //media/base which will propagate this target to them. component("shared_memory_support") { sources = [ "base/audio_bus.cc", "base/audio_bus.h", "base/audio_latency.cc", "base/audio_latency.h", "base/audio_parameters.cc", "base/audio_parameters.h", "base/audio_point.cc", "base/audio_point.h", "base/audio_sample_types.h", "base/channel_layout.cc", "base/channel_layout.h", "base/limits.h", "base/media_shmem_export.h", "base/vector_math.cc", "base/vector_math.h", "base/vector_math_testing.h", ] if (is_mac) { # These need to be included here because audio_latency.cc depends on them. sources += [ "base/mac/audio_latency_mac.cc", "base/mac/audio_latency_mac.h", ] } # Do not use "subcomponent_config" here since these files are in their own # component target and thus can't share the standard export macros. configs += [ ":media_config" ] defines = [ "MEDIA_SHMEM_IMPLEMENTATION" ] if (!is_debug) { configs -= [ "//build/config/compiler:default_optimization" ] configs += [ "//build/config/compiler:optimize_max" ] } deps = [ "//base", "//ui/gfx/geometry", ] } # TODO(watk): Refactor tests that could be made to run on Android. See # http://crbug.com/570762 if (media_use_ffmpeg && !is_android) { test("ffmpeg_regression_tests") { configs += [ "//media:media_config" ] deps = [ ":test_support", "//base/test:test_support", "//media/ffmpeg:ffmpeg_regression_tests", "//media/test:pipeline_integration_tests", "//media/test:run_all_unittests", "//testing/gmock", "//testing/gtest", "//ui/gfx:test_support", "//ui/gfx/geometry", ] } } if (proprietary_codecs) { fuzzer_test("media_cenc_utils_fuzzer") { sources = [ "cdm/cenc_utils_fuzzertest.cc", ] deps = [ ":media", ] } } fuzzer_test("media_vp8_parser_fuzzer") { sources = [ "filters/vp8_parser_fuzzertest.cc", ] deps = [ ":media", "//base", ] libfuzzer_options = [ "max_len = 400000" ] dict = "test/vp8.dict" } fuzzer_test("media_vp9_parser_fuzzer") { sources = [ "filters/vp9_parser_fuzzertest.cc", ] deps = [ ":media", "//base", ] libfuzzer_options = [ "max_len = 400000" ] } fuzzer_test("media_vpx_video_decoder_fuzzer") { sources = [ "filters/vpx_video_decoder_fuzzertest.cc", ] deps = [ ":media", "//base", ] libfuzzer_options = [ "max_len = 400000" ] seed_corpus = "//media/test/data" } fuzzer_test("media_webm_muxer_fuzzer") { sources = [ "muxers/webm_muxer_fuzzertest.cc", ] deps = [ ":media", "//base", "//third_party/libwebm", ] } if (proprietary_codecs) { fuzzer_test("media_mp4_avcc_parser_fuzzer") { sources = [ "formats/mp4/mp4_avcc_parser_fuzzer.cc", ] deps = [ ":media", "//base", ] } }