media_options.gni 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  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/config/chrome_build.gni")
  5. import("//build/config/chromecast_build.gni")
  6. import("//build/config/chromeos/args.gni")
  7. import("//build/config/chromeos/ui_mode.gni")
  8. import("//build/config/features.gni")
  9. import("//build/config/ui.gni")
  10. import("//media/gpu/args.gni")
  11. import("//testing/libfuzzer/fuzzer_test.gni")
  12. import("//third_party/libaom/options.gni")
  13. import("//third_party/libgav1/options.gni")
  14. # This flag sets defaults for the current generation of cast devices.
  15. is_cast_media_device = is_castos || is_cast_android
  16. declare_args() {
  17. # Allows distributions to link pulseaudio directly (DT_NEEDED) instead of
  18. # using dlopen. This helps with automated detection of ABI mismatches and
  19. # prevents silent errors.
  20. link_pulseaudio = false
  21. # Enable usage of FFmpeg within the media library. Used for most software
  22. # based decoding, demuxing, and sometimes optimized FFTs. If disabled,
  23. # implementors must provide their own demuxers and decoders.
  24. media_use_ffmpeg = true
  25. # Enable usage of libvpx within the media library. Used for software based
  26. # decoding of VP9 and VP8A type content.
  27. media_use_libvpx = true
  28. # iOS doesn't use ffmpeg, libvpx.
  29. if (is_ios) {
  30. media_use_ffmpeg = false
  31. media_use_libvpx = false
  32. }
  33. # Enable usage of OpenH264 within the media library. Used for software based
  34. # encoding of H264 content.
  35. media_use_openh264 = true
  36. if (is_ios || is_android || !proprietary_codecs) {
  37. media_use_openh264 = false
  38. }
  39. # Override to dynamically link the cras (ChromeOS audio) library.
  40. use_cras = is_chromeos_device
  41. # Enables AC3/EAC3 audio demuxing. This is enabled only on Chromecast, since
  42. # it only provides demuxing, and is only useful for AC3/EAC3 audio
  43. # pass-through to HDMI sink on Chromecast.
  44. enable_platform_ac3_eac3_audio = proprietary_codecs && is_cast_media_device
  45. enable_platform_mpeg_h_audio = proprietary_codecs && is_cast_media_device
  46. # Enables DTS/DTSX audio handling in chromium. This includes demuxing,
  47. # on-device decoding and bitstream passthrough as supported by device.
  48. enable_platform_dts_audio = false
  49. # TODO(crbug.com/1329657): Remove the `is_fuchsia` condition once fuchsia
  50. # builds set enable_cast_receiver.
  51. enable_mse_mpeg2ts_stream_parser =
  52. proprietary_codecs &&
  53. (enable_cast_receiver || is_fuchsia || use_fuzzing_engine)
  54. # Enable Dolby Vision demuxing. Enable by default for Chromecast. Actual
  55. # decoding must be provided by the platform. Note some Dolby Vision profiles
  56. # which are encoded using HEVC require `enable_platform_hevc` to be enabled.
  57. #
  58. # TODO(crbug.com/1336055): Revisit the default value for this setting as it
  59. # applies to video-capable devices.
  60. enable_platform_dolby_vision = proprietary_codecs && is_cast_media_device
  61. # Enable platform support of encrypted Dolby Vision. Clear Dolby Vision is
  62. # still not supported. The actual support depends on platform capability.
  63. enable_platform_encrypted_dolby_vision = false
  64. # Enable HLS with SAMPLE-AES decryption.
  65. #
  66. # TODO(crbug.com/1329657): Remove the `is_fuchsia` condition once fuchsia
  67. # builds set enable_cast_receiver.
  68. enable_hls_sample_aes =
  69. proprietary_codecs && (enable_cast_receiver || is_fuchsia)
  70. # Enable logging override, e.g. enable DVLOGs through level 2 at build time.
  71. # On Chromecast, these are logged as INFO.
  72. # On Fuchsia, these are logged as VLOGs.
  73. enable_logging_override = is_cast_media_device || is_fuchsia
  74. enable_dav1d_decoder = !is_ios
  75. # Enable browser managed persistent metadata storage for EME persistent
  76. # session and persistent usage record session.
  77. enable_media_drm_storage = is_android || is_castos
  78. # Enable HLS manifest parser and demuxer.
  79. enable_hls_demuxer = false
  80. # Enable inclusion of the HEVC/H265 parser and also enable HEVC/H265 decoding
  81. # with hardware acceleration assist. Enabled by default for fuzzer builds,
  82. # ChromeOS builds with protected content support, Windows, Mac, and Android.
  83. enable_hevc_parser_and_hw_decoder =
  84. proprietary_codecs &&
  85. (use_fuzzing_engine || use_chromeos_protected_media || is_win || is_mac ||
  86. is_android)
  87. }
  88. # Use another declare_args() to allow dependence on
  89. # |enable_hevc_parser_and_hw_decoder|.
  90. declare_args() {
  91. enable_av1_decoder = enable_dav1d_decoder || enable_libgav1_decoder
  92. # Enable HEVC/H265 demuxing. Actual decoding must be provided by the
  93. # platform.
  94. # TODO(b/194429120): Enable this for Lacros builds.
  95. # TODO(crbug.com/1336055): Revisit the default value for this setting as it
  96. # applies to video-capable devices.
  97. enable_platform_hevc =
  98. proprietary_codecs &&
  99. (enable_hevc_parser_and_hw_decoder || is_cast_media_device)
  100. }
  101. assert(
  102. !enable_platform_ac3_eac3_audio || proprietary_codecs,
  103. "proprietary_codecs=true is required for enable_platform_ac3_eac3_audio=true.")
  104. assert(
  105. !enable_platform_mpeg_h_audio || proprietary_codecs,
  106. "proprietary_codecs=true is required for enable_platform_mpeg_h_audio=true.")
  107. assert(
  108. !enable_mse_mpeg2ts_stream_parser || proprietary_codecs,
  109. "proprietary_codecs=true is required for enable_mse_mpeg2ts_stream_parser=true.")
  110. assert(
  111. !enable_platform_dolby_vision || proprietary_codecs,
  112. "proprietary_codecs=true is required for enable_platform_dolby_vision=true.")
  113. assert(
  114. !enable_platform_encrypted_dolby_vision || enable_platform_dolby_vision,
  115. "enable_platform_dolby_vision=true is required for enable_platform_encrypted_dolby_vision=true.")
  116. assert(!enable_hls_sample_aes || proprietary_codecs,
  117. "proprietary_codecs=true is required for enable_hls_sample_aes=true.")
  118. assert(
  119. !enable_platform_dts_audio || proprietary_codecs,
  120. "proprietary_codecs=true is required for enable_platform_dts_audio=true.")
  121. assert(
  122. !enable_hls_sample_aes || enable_mse_mpeg2ts_stream_parser,
  123. "enable_mse_mpeg2ts_stream_parser=true is required for enable_hls_sample_aes=true.")
  124. assert(
  125. !enable_hls_demuxer || enable_mse_mpeg2ts_stream_parser,
  126. "enable_mse_mpeg2ts_stream_parser=true is required for enable_hls_demuxer=true.")
  127. assert(!enable_platform_hevc || proprietary_codecs,
  128. "proprietary_codecs=true is required for enable_platform_hevc=true.")
  129. assert(
  130. !enable_hevc_parser_and_hw_decoder || enable_platform_hevc,
  131. "enable_platform_hevc=true is required for enable_hevc_parser_and_hw_decoder=true.")
  132. # Use another declare_args() to pick up possible overrides of |use_cras|.
  133. declare_args() {
  134. # Enables runtime selection of PulseAudio library.
  135. use_pulseaudio = false
  136. # Enables runtime selection of ALSA library for audio.
  137. use_alsa = false
  138. # Alsa should be used on all non-Android, non-Mac POSIX systems - with the
  139. # exception of CastOS desktop builds.
  140. #
  141. # TODO(crbug.com/1336055): Remove legacy target_cpu hack used for targeting
  142. # desktop Chromecast builds.
  143. if (is_posix && !is_android && !is_mac &&
  144. (!is_castos || (target_cpu == "x86" || target_cpu == "x64") ||
  145. is_cast_audio_only)) {
  146. use_alsa = true
  147. # Pulse is not supported on Chromecast platforms.
  148. #
  149. # ASAN and TSAN will occasionally hang during pa_context_connect(), so we
  150. # disable PulseAudio when these configurations are enabled.
  151. #
  152. # TODO(crbug.com/986021): We shouldn't have to do this, but it's unclear why
  153. # our test bots are hanging and all of the ones that don't hang just fall
  154. # back to ALSA after a connection error anyways.
  155. if (!use_cras && !is_castos && !is_asan && !is_tsan) {
  156. use_pulseaudio = true
  157. }
  158. }
  159. }
  160. # Use another declare_args() to include possible overrides of media_use_ffmpeg
  161. # from --args command line flags in the evaluation. See "gn help declare_args".
  162. declare_args() {
  163. # On Android, FFMpeg is built without video decoders by default.
  164. # This flag gives the option to override that decision in case there are no
  165. # hardware decoders. To do so, you will also need to update ffmpeg build files
  166. # in order to define which decoders to build in.
  167. enable_ffmpeg_video_decoders = media_use_ffmpeg && !is_android
  168. }
  169. declare_args() {
  170. # Enables the use of library CDMs that implements the interface defined at
  171. # media/cdm/api/content_decryption_module.h. If true, the actually library CDM
  172. # will be hosted in the mojo CDM service running in the CDM (utility) process.
  173. # Used for all desktop platforms except Fuchsia (crbug.com/1265618).
  174. enable_library_cdms = toolkit_views && !is_fuchsia && !is_castos
  175. }
  176. declare_args() {
  177. # Enables host verification for CDMs.
  178. # Windows and Mac.
  179. enable_cdm_host_verification =
  180. enable_library_cdms && (is_mac || is_win) && is_chrome_branded
  181. # Enable Storage ID which is used by CDMs. This is only available with chrome
  182. # branding, but may be overridden by other embedders.
  183. enable_cdm_storage_id = enable_library_cdms && is_chrome_branded &&
  184. (is_win || is_mac || is_chromeos)
  185. # If |enable_cdm_storage_id| is set, then an implementation specific key
  186. # must also be provided. It can be provided by defining CDM_STORAGE_ID_KEY
  187. # (which takes precedence), or by setting |alternate_cdm_storage_id_key|.
  188. # The key must be a string of at least 32 characters.
  189. alternate_cdm_storage_id_key = ""
  190. }
  191. assert(!enable_cdm_host_verification || is_mac || is_win,
  192. "CDM host verification is only supported on Mac and Windows.")
  193. # Default |mojo_media_services| and |mojo_media_host| on various platforms. See
  194. # comments below for valid values. Can be overridden by gn build arguments from
  195. # the --args command line flag.
  196. _default_mojo_media_services = []
  197. _default_mojo_media_host = ""
  198. if (is_cast_media_device) {
  199. _default_mojo_media_services = cast_mojo_media_services
  200. _default_mojo_media_host = cast_mojo_media_host
  201. } else if (is_android) {
  202. _default_mojo_media_services = [
  203. "cdm",
  204. "audio_decoder",
  205. "video_decoder",
  206. ]
  207. _default_mojo_media_host = "gpu"
  208. } else if (is_mac || (is_win && enable_platform_dts_audio)) {
  209. _default_mojo_media_services = [
  210. "audio_decoder",
  211. "audio_encoder",
  212. "video_decoder",
  213. ]
  214. _default_mojo_media_host = "gpu"
  215. } else if (is_win) {
  216. _default_mojo_media_services = [
  217. "audio_encoder",
  218. "video_decoder",
  219. ]
  220. _default_mojo_media_host = "gpu"
  221. } else if (is_chromeos_ash || ((is_linux || is_chromeos_lacros) &&
  222. (use_vaapi || use_v4l2_codec))) {
  223. _default_mojo_media_services = [ "video_decoder" ]
  224. _default_mojo_media_host = "gpu"
  225. }
  226. # When |enable_library_cdms| is true, the "cdm" service will run in a separate
  227. # CdmService in the CDM (utility) process. Therefore there's no need to specify
  228. # |_default_mojo_media_host| which controls where the MediaService runs in.
  229. if (enable_library_cdms) {
  230. _default_mojo_media_services += [ "cdm" ]
  231. }
  232. declare_args() {
  233. # A list of mojo media services that should be used in the media pipeline.
  234. # Valid entries in the list are:
  235. # - "renderer": Use mojo-based media Renderer service.
  236. # - "cdm": Use mojo-based Content Decryption Module.
  237. # - "audio_decoder": Use mojo-based audio decoder in the default media
  238. # Renderer. Cannot be used with the mojo Renderer above.
  239. # - "video_decoder": Use mojo-based video decoder in the default media
  240. # Renderer. Cannot be used with the mojo Renderer above.
  241. mojo_media_services = _default_mojo_media_services
  242. # The process that the mojo MediaService runs in. By default, all services
  243. # registered in |mojo_media_services| are hosted in the MediaService, with the
  244. # exception that when |enable_library_cdms| is true, the "cdm" service will
  245. # run in a separate CdmService in the CDM (utility) process, while other
  246. # |mojo_media_services| still run in the MediaService in the process specified
  247. # by "mojo_media_host".
  248. # Valid options are:
  249. # - "browser": Use mojo media service hosted in the browser process.
  250. # - "gpu": Use mojo media service hosted in the gpu process.
  251. # - "": Do not use mojo media service.
  252. mojo_media_host = _default_mojo_media_host
  253. }
  254. declare_args() {
  255. # This switch defines whether the Media Remoting implementation will be built.
  256. # When enabled, media is allowed to be renderer and played back on remote
  257. # devices when the tab is being casted and other conditions are met.
  258. enable_media_remoting = !is_cast_media_device && !is_ios
  259. }
  260. declare_args() {
  261. # Media Remoting RPC is disabled on Android since it's unused but increases
  262. # the native binary size by ~70Kb.
  263. enable_media_remoting_rpc = enable_media_remoting && !is_android
  264. }
  265. declare_args() {
  266. # Currently it is available on Win, Mac and Linux, since it requires the audio
  267. # service to run in a separate process.
  268. chrome_wide_echo_cancellation_supported = is_win || is_mac || is_linux
  269. }
  270. # Do not expand this list without double-checking with OWNERS, this is a list of
  271. # all targets which roll up into the //media component. It controls visibility
  272. # of subcomponent targets and public_deps for //media.
  273. media_subcomponent_deps = [
  274. "//media/audio",
  275. "//media/base",
  276. # TODO(crbug.com/583067): These files should not be in //media/base.
  277. "//media/base/android",
  278. "//media/capabilities",
  279. "//media/cdm",
  280. "//media/device_monitors",
  281. "//media/filters",
  282. "//media/formats",
  283. "//media/muxers",
  284. "//media/renderers",
  285. "//media/video",
  286. ]
  287. if (is_fuchsia) {
  288. media_subcomponent_deps += [
  289. "//media/fuchsia/cdm",
  290. "//media/fuchsia/common",
  291. ]
  292. }
  293. if (media_use_ffmpeg) {
  294. media_subcomponent_deps += [ "//media/ffmpeg" ]
  295. }
  296. if (enable_library_cdms || is_win) {
  297. media_subcomponent_deps += [ "//media/cdm:cdm_type_conversion" ]
  298. }