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