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