BUILD.gn 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  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/cdm/library_cdm/cdm_paths.gni")
  12. import("//media/media_options.gni")
  13. import("//testing/libfuzzer/fuzzer_test.gni")
  14. import("//testing/test.gni")
  15. buildflag_header("media_buildflags") {
  16. header = "media_buildflags.h"
  17. flags = [
  18. "ALTERNATE_CDM_STORAGE_ID_KEY=\"$alternate_cdm_storage_id_key\"",
  19. "CDM_PLATFORM_SPECIFIC_PATH=\"$cdm_platform_specific_path\"",
  20. "CHROME_WIDE_ECHO_CANCELLATION=$chrome_wide_echo_cancellation_supported",
  21. "ENABLE_PLATFORM_AC3_EAC3_AUDIO=$enable_platform_ac3_eac3_audio",
  22. "ENABLE_CAST_AUDIO_RENDERER=$enable_cast_audio_renderer",
  23. "ENABLE_CDM_HOST_VERIFICATION=$enable_cdm_host_verification",
  24. "ENABLE_CDM_STORAGE_ID=$enable_cdm_storage_id",
  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_FFMPEG=$media_use_ffmpeg",
  29. "ENABLE_FFMPEG_VIDEO_DECODERS=$enable_ffmpeg_video_decoders",
  30. "ENABLE_PLATFORM_HEVC=$enable_platform_hevc",
  31. "ENABLE_PLATFORM_HEVC_DECODING=$enable_platform_hevc_decoding",
  32. "ENABLE_PLATFORM_ENCRYPTED_HEVC=$enable_platform_encrypted_hevc",
  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_LIBRARY_CDMS=$enable_library_cdms",
  37. "ENABLE_LIBAOM=$enable_libaom",
  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. }
  54. config("media_config") {
  55. defines = []
  56. if (current_cpu == "arm64" || (current_cpu == "arm" && arm_use_neon)) {
  57. defines += [ "USE_NEON" ]
  58. }
  59. if (use_pulseaudio) {
  60. defines += [ "USE_PULSEAUDIO" ]
  61. if (!link_pulseaudio) {
  62. defines += [ "DLOPEN_PULSEAUDIO" ]
  63. }
  64. }
  65. if (use_cras) {
  66. defines += [ "USE_CRAS" ]
  67. }
  68. }
  69. # Internal grouping of the configs necessary to support sub-folders having their
  70. # own BUILD.gn files; only targets which roll up into the "media" target should
  71. # include this config. I.e., not "test_support" or "unit_tests" targets.
  72. #
  73. # Without these configs having individual sub-folders take a //media/base DEP
  74. # (or others) can yield incorrectly imported and exported symbols on Windows:
  75. #
  76. # fatal error LNK1169: one or more multiply defined symbols found.
  77. #
  78. config("subcomponent_config") {
  79. visibility = media_subcomponent_deps
  80. if (is_mac) {
  81. visibility += [ "//media/base/mac" ]
  82. }
  83. defines = [ "IS_MEDIA_IMPL" ]
  84. configs = [
  85. ":media_config",
  86. "//build/config/compiler:wexit_time_destructors",
  87. ]
  88. }
  89. component("media") {
  90. libs = []
  91. deps = [
  92. "//base",
  93. "//base:i18n",
  94. "//base/third_party/dynamic_annotations",
  95. "//cc/paint",
  96. "//crypto:platform",
  97. "//gpu/command_buffer/client:gles2_interface",
  98. "//gpu/command_buffer/common",
  99. "//third_party/libyuv",
  100. "//ui/events:events_base",
  101. "//ui/gfx",
  102. "//ui/gfx/geometry",
  103. "//ui/gl:gl",
  104. "//url",
  105. ]
  106. public_configs = [ "//third_party/libwebm:libwebm_config" ]
  107. public_deps = media_subcomponent_deps
  108. public_deps += [
  109. ":media_buildflags",
  110. ":shared_memory_support",
  111. "//ui/gfx:color_space",
  112. ]
  113. # This must be included here since it actually depends on //media/base.
  114. if (is_apple) {
  115. public_deps += [ "//media/base/mac" ]
  116. }
  117. if (use_ozone) {
  118. deps += [ "//ui/ozone" ]
  119. }
  120. }
  121. # Note: This can't be a static_library since it does not have any sources.
  122. source_set("test_support") {
  123. testonly = true
  124. public_deps = [
  125. ":media",
  126. "//media/audio:test_support",
  127. "//media/base:test_support",
  128. "//media/base/android:test_support",
  129. "//media/filters:test_support",
  130. "//media/formats:test_support",
  131. "//media/renderers:test_support",
  132. "//media/video:test_support",
  133. ]
  134. }
  135. # Contains tests for all targets in the "media" folder.
  136. # TODO(xhwang): Move mojo/capture/remoting tests here where applicable.
  137. test("media_unittests") {
  138. use_xvfb = use_xvfb_in_this_config
  139. deps = [
  140. "//media/audio:unit_tests",
  141. "//media/base:unit_tests",
  142. "//media/capabilities:unit_tests",
  143. "//media/cdm:unit_tests",
  144. "//media/device_monitors:unit_tests",
  145. "//media/filters:unit_tests",
  146. "//media/formats:unit_tests",
  147. "//media/gpu:unit_tests",
  148. "//media/learning:unit_tests",
  149. "//media/mojo:unit_tests",
  150. "//media/muxers:unit_tests",
  151. "//media/parsers:unit_tests",
  152. "//media/renderers:unit_tests",
  153. "//media/test:pipeline_integration_tests",
  154. "//media/test:run_all_unittests",
  155. "//media/video:unit_tests",
  156. "//media/webrtc:unit_tests",
  157. ]
  158. data = [
  159. "test/data/",
  160. "formats/mp4/h264_annex_b_fuzz_corpus/",
  161. ]
  162. data_deps = [ "//testing/buildbot/filters:media_unittests_filters" ]
  163. if (is_android && enable_chrome_android_internal) {
  164. data_deps += [ "//clank/build/bot/filters:media_unittests_filters" ]
  165. }
  166. if (media_use_ffmpeg) {
  167. deps += [ "//media/ffmpeg:unit_tests" ]
  168. }
  169. if (is_android) {
  170. deps += [
  171. # The test needs the java dependencies to add the java classes for their
  172. # native counterparts to the test apk.
  173. "//gpu/command_buffer/service:android_texture_owner_unittests",
  174. "//media/base/android:media_java",
  175. "//media/base/android:unit_tests",
  176. "//media/gpu:android_video_decode_accelerator_unittests",
  177. "//ui/android:ui_java",
  178. ]
  179. }
  180. if (is_fuchsia) {
  181. deps += [
  182. "//media/fuchsia/audio:unittests",
  183. "//media/fuchsia/cdm/service:unittests",
  184. ]
  185. use_cfv2 = false
  186. additional_manifest_fragments = [
  187. "//build/config/fuchsia/test/audio_capabilities.test-cmx",
  188. # TODO(crbug.com/1185811): Figure out why
  189. # PaintCanvasVideoRendererWithGLTest.CopyVideoFrameYUVDataToGLTexture
  190. # crashes without "deprecated-ambient-replace-as-executable".
  191. "//build/config/fuchsia/test/jit_capabilities.test-cmx",
  192. "//build/config/fuchsia/test/vulkan_capabilities.test-cmx",
  193. ]
  194. }
  195. if (enable_media_remoting) {
  196. deps += [ "//media/remoting:media_remoting_tests" ]
  197. }
  198. # The test needs OPUS_FIXED_POINT conditional define.
  199. configs += [ "//third_party/opus:opus_config" ]
  200. }
  201. test("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. # This target should not require the Chrome executable to run.
  220. assert_no_deps = [ "//chrome" ]
  221. data = [ "test/data/" ]
  222. data_deps = [
  223. # Needed for isolate script to execute.
  224. "//testing:run_perf_test",
  225. ]
  226. }
  227. # The audio subset of media_unittests. This target exists for running only the
  228. # audio tests on the GPU bots (which have audio hardware).
  229. test("audio_unittests") {
  230. deps = [
  231. ":test_support",
  232. "//base/test:test_support",
  233. "//media/audio:unit_tests",
  234. "//media/test:run_all_unittests",
  235. ]
  236. if (is_android) {
  237. deps += [
  238. # The test needs the java dependencies to add the java classes for their
  239. # native counterparts to the test apk.
  240. "//media/base/android:media_java",
  241. "//ui/android:ui_java",
  242. ]
  243. }
  244. if (is_fuchsia) {
  245. use_cfv2 = false
  246. additional_manifest_fragments =
  247. [ "//build/config/fuchsia/test/audio_capabilities.test-cmx" ]
  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.
  253. component("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. "base/video_types.cc",
  274. "base/video_types.h",
  275. ]
  276. if (is_mac) {
  277. # These need to be included here because audio_latency.cc depends on them.
  278. sources += [
  279. "base/mac/audio_latency_mac.cc",
  280. "base/mac/audio_latency_mac.h",
  281. ]
  282. }
  283. # Do not use "subcomponent_config" here since these files are in their own
  284. # component target and thus can't share the standard export macros.
  285. configs += [ ":media_config" ]
  286. defines = [ "MEDIA_SHMEM_IMPLEMENTATION" ]
  287. if (!is_debug) {
  288. configs -= [ "//build/config/compiler:default_optimization" ]
  289. configs += [ "//build/config/compiler:optimize_max" ]
  290. }
  291. deps = [
  292. "//base",
  293. "//build:chromeos_buildflags",
  294. "//ui/gfx/geometry",
  295. ]
  296. }
  297. # TODO(watk): Refactor tests that could be made to run on Android. See
  298. # http://crbug.com/570762
  299. if (media_use_ffmpeg && !is_android) {
  300. test("ffmpeg_regression_tests") {
  301. configs += [ "//media:media_config" ]
  302. deps = [
  303. ":test_support",
  304. "//base/test:test_support",
  305. "//media/ffmpeg:ffmpeg_regression_tests",
  306. "//media/test:pipeline_integration_tests",
  307. "//media/test:run_all_unittests",
  308. "//testing/gmock",
  309. "//testing/gtest",
  310. "//ui/gfx:test_support",
  311. "//ui/gfx/geometry",
  312. ]
  313. }
  314. }
  315. if (proprietary_codecs) {
  316. fuzzer_test("media_cenc_utils_fuzzer") {
  317. sources = [ "cdm/cenc_utils_fuzzertest.cc" ]
  318. deps = [ ":media" ]
  319. }
  320. }
  321. fuzzer_test("media_vp9_parser_fuzzer") {
  322. sources = [ "filters/vp9_parser_fuzzertest.cc" ]
  323. deps = [
  324. ":test_support",
  325. "//base",
  326. ]
  327. libfuzzer_options = [ "max_len = 400000" ]
  328. }
  329. fuzzer_test("media_vp9_parser_encrypted_fuzzer") {
  330. sources = [ "filters/vp9_parser_encrypted_fuzzertest.cc" ]
  331. deps = [
  332. ":test_support",
  333. "//base",
  334. "//base/test:test_support",
  335. ]
  336. seed_corpus = "//media/test/data"
  337. }
  338. fuzzer_test("media_vpx_video_decoder_fuzzer") {
  339. sources = [ "filters/vpx_video_decoder_fuzzertest.cc" ]
  340. deps = [
  341. ":media",
  342. "//base",
  343. "//base/test:test_support",
  344. ]
  345. libfuzzer_options = [ "max_len = 400000" ]
  346. seed_corpus = "//media/test/data"
  347. }
  348. fuzzer_test("media_webm_muxer_fuzzer") {
  349. sources = [ "muxers/webm_muxer_fuzzertest.cc" ]
  350. deps = [
  351. ":media",
  352. "//base",
  353. "//third_party/libwebm",
  354. ]
  355. }
  356. fuzzer_test("cbcs_decryptor_fuzzer") {
  357. sources = [ "cdm/cbcs_decryptor_fuzzer.cc" ]
  358. deps = [
  359. ":media",
  360. "//base",
  361. "//crypto",
  362. ]
  363. }
  364. fuzzer_test("cenc_decryptor_fuzzer") {
  365. sources = [ "cdm/cenc_decryptor_fuzzer.cc" ]
  366. deps = [
  367. ":media",
  368. "//base",
  369. "//crypto",
  370. ]
  371. }
  372. fuzzer_test("json_web_key_fuzzer") {
  373. sources = [ "cdm/json_web_key_fuzzer.cc" ]
  374. deps = [
  375. ":media",
  376. "//base",
  377. ]
  378. }
  379. if (proprietary_codecs) {
  380. fuzzer_test("media_mp4_avcc_parser_fuzzer") {
  381. sources = [ "formats/mp4/mp4_avcc_parser_fuzzer.cc" ]
  382. deps = [
  383. ":media",
  384. "//base",
  385. ]
  386. }
  387. fuzzer_test("media_mp4_box_reader_fuzzer") {
  388. sources = [ "formats/mp4/mp4_box_reader_fuzzer.cc" ]
  389. deps = [
  390. ":media",
  391. "//base",
  392. ]
  393. libfuzzer_options = [ "max_len=500" ]
  394. dict = "test/mp4.dict"
  395. }
  396. }
  397. if (enable_mse_mpeg2ts_stream_parser) {
  398. fuzzer_test("media_es_parser_adts_fuzzer") {
  399. sources = [ "formats/mp2t/es_parser_adts_fuzzer.cc" ]
  400. deps = [
  401. ":media",
  402. "//base",
  403. ]
  404. }
  405. fuzzer_test("media_es_parser_h264_fuzzer") {
  406. sources = [ "formats/mp2t/es_parser_h264_fuzzer.cc" ]
  407. deps = [
  408. ":media",
  409. "//base",
  410. ]
  411. }
  412. fuzzer_test("media_es_parser_mpeg1audio_fuzzer") {
  413. sources = [ "formats/mp2t/es_parser_mpeg1audio_fuzzer.cc" ]
  414. deps = [
  415. ":media",
  416. "//base",
  417. ]
  418. }
  419. }