BUILD.gn 13 KB

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