BUILD.gn 13 KB

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