media_options.gni 12 KB

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