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.
5 import("//build/config/chrome_build.gni")
6 import("//build/config/chromecast_build.gni")
7 import("//build/config/chromeos/args.gni")
8 import("//build/config/chromeos/ui_mode.gni")
9 import("//build/config/features.gni")
10 import("//build/config/ui.gni")
11 import("//media/gpu/args.gni")
12 import("//testing/libfuzzer/fuzzer_test.gni")
13 import("//third_party/libaom/options.gni")
14 import("//third_party/libgav1/options.gni")
16 import("//tizen_src/build/config/tizen_features.gni")
19 # This flag sets defaults for the current generation of cast devices.
20 is_cast_media_device = is_castos || is_cast_android
22 # Out-of-process video decoding is a feature specific to Linux and ChromeOS
23 # which makes the interaction with platform drivers (for the purposes of
24 # hardware accelerated video decoding) happen on utility processes for stability
25 # and security purposes. When |allow_oop_video_decoder| is true, code to
26 # use this feature is compiled. Note that even if |allow_oop_video_decoder| is
27 # true, the feature may be disabled by a runtime flag.
29 # When |allow_hosting_oop_video_decoder| is true, code to host the video decoder
30 # utility processes is compiled. Note that even if
31 # |allow_hosting_oop_video_decoder| is true, the hosting of these utility
32 # processes may be disabled by a runtime flag.
34 # TODO(b/195769334): finish replacing usages of (is_linux || is_chromeos) with
35 # allow_oop_video_decoder where appropriate. Also, finish replacing usages of
36 # (is_linux || is_chromeos_ash) with allow_hosting_oop_video_decoder where
38 allow_hosting_oop_video_decoder =
39 (is_chromeos_ash || is_linux) && (use_vaapi || use_v4l2_codec)
40 allow_oop_video_decoder = is_chromeos_lacros || allow_hosting_oop_video_decoder
43 # Allows distributions to link pulseaudio directly (DT_NEEDED) instead of
44 # using dlopen. This helps with automated detection of ABI mismatches and
45 # prevents silent errors.
46 link_pulseaudio = false
48 # Enable usage of FFmpeg within the media library. Used for most software
49 # based decoding, demuxing, and sometimes optimized FFTs. If disabled,
50 # implementors must provide their own demuxers and decoders.
51 media_use_ffmpeg = true && tizen_multimedia
53 # Enable usage of libvpx within the media library. Used for software based
54 # decoding of VP9 and VP8A type content.
55 media_use_libvpx = true
57 # non-blink builds doesn't use ffmpeg, libvpx.
59 media_use_ffmpeg = false
60 media_use_libvpx = false
63 # Enable usage of OpenH264 within the media library. Used for software based
64 # encoding of H264 content.
65 media_use_openh264 = true
66 if (is_ios || is_android || !proprietary_codecs) {
67 media_use_openh264 = false
70 # Override to dynamically link the cras (ChromeOS audio) library.
71 use_cras = is_chromeos_device
73 # Enables AC3/EAC3 audio handling in chromium. This includes demuxing,
74 # on-device decoding and bitstream passthrough as supported by device.
75 enable_platform_ac3_eac3_audio =
76 proprietary_codecs && (is_cast_media_device || tizen_product_tv)
78 # Enables AC4 audio handling in chromium. This includes demuxing,
79 # on-device decoding and bitstream passthrough as supported by device.
80 enable_platform_ac4_audio = false
82 enable_platform_mpeg_h_audio = proprietary_codecs && is_cast_media_device
84 # Enables DTS/DTSX audio handling in chromium. This includes demuxing,
85 # on-device decoding and bitstream passthrough as supported by device.
86 enable_platform_dts_audio = false
88 # Enable Dolby Vision demuxing. Enabled by default for Chromecast and Windows.
89 # Actual decoding must be provided by the platform. Since most Dolby Vision
90 # profiles use HEVC, `enable_platform_hevc` is required to enable this.
92 # TODO(crbug.com/1336055): Revisit the default value for this setting as it
93 # applies to video-capable devices.
94 enable_platform_dolby_vision =
95 proprietary_codecs && (is_cast_media_device || is_win)
97 # Enable platform support of encrypted Dolby Vision. The actual support
98 # depends on platform capability and is controlled by the run time feature
99 # kPlatformEncryptedDolbyVision. Clear Dolby Vision is not supported by
100 # default, unless overwritten by the run time feature
101 # kAllowClearDolbyVisionInMseWhenPlatformEncryptedDvEnabled.
102 enable_platform_encrypted_dolby_vision = proprietary_codecs && is_win
104 # Enable logging override, e.g. enable DVLOGs through level 2 at build time.
105 # On Cast devices, these are logged as INFO.
106 # When enabled on Fuchsia, these are logged as VLOGs.
107 enable_logging_override = is_cast_media_device || tizen_product_tv
109 enable_dav1d_decoder = use_blink
111 # Enable browser managed persistent metadata storage for EME persistent
112 # session and persistent usage record session.
113 enable_media_drm_storage = is_android || is_castos
115 # Enable HLS manifest parser and demuxer.
116 enable_hls_demuxer = proprietary_codecs && is_android
118 # Enable inclusion of the HEVC/H265 parser and also enable HEVC/H265 decoding
119 # with hardware acceleration assist. Enabled by default for fuzzer builds,
120 # Windows, Mac, and Android.
121 enable_hevc_parser_and_hw_decoder =
122 proprietary_codecs && (use_fuzzing_engine || is_win || is_apple ||
123 is_android || is_linux || tizen_product_tv)
125 # Enable inclusion of VVC/H.266 parser/demuxer, and also enable VVC/H.266 decoding
126 # with hardware acceleration provided by platform. Disabled by default for all builds.
127 enable_platform_vvc = false
130 # Use another declare_args() to allow dependence on args defined above.
132 # If overriding this to false, possibly via its component values,
133 # `enable_libaom` should likely also be overriddent to false.
134 enable_av1_decoder = enable_dav1d_decoder || tizen_product_tv
136 # Enable HEVC/H265 demuxing. Actual decoding must be provided by the
137 # platform. Always enable this for Lacros, it determines support at runtime.
138 # TODO(crbug.com/1336055): Revisit the default value for this setting as it
139 # applies to video-capable devices.
140 enable_platform_hevc =
141 proprietary_codecs && (enable_hevc_parser_and_hw_decoder ||
142 is_cast_media_device || is_chromeos_lacros)
144 enable_mse_mpeg2ts_stream_parser =
145 proprietary_codecs &&
146 (enable_hls_demuxer || enable_cast_receiver || use_fuzzing_engine)
150 platform_has_optional_hevc_support =
151 enable_platform_hevc &&
152 (is_win || is_chromeos || is_linux || is_apple || is_android)
155 assert(!enable_hls_demuxer || enable_mse_mpeg2ts_stream_parser,
156 "enable_mse_mpeg2ts_stream_parser required for enable_hls_demuxer")
157 assert(!enable_hls_demuxer || proprietary_codecs,
158 "proprietary_codecs required for enable_hls_demuxer")
159 assert(!enable_platform_ac3_eac3_audio || proprietary_codecs,
160 "proprietary_codecs required for enable_platform_ac3_eac3_audio")
161 assert(!enable_platform_ac4_audio || proprietary_codecs,
162 "proprietary_codecs required for enable_platform_ac4_audio")
163 assert(!enable_platform_mpeg_h_audio || proprietary_codecs,
164 "proprietary_codecs required for enable_platform_mpeg_h_audio")
165 assert(!enable_mse_mpeg2ts_stream_parser || proprietary_codecs,
166 "proprietary_codecs required for enable_mse_mpeg2ts_stream_parser")
167 assert(!enable_platform_dolby_vision || proprietary_codecs,
168 "proprietary_codecs required for enable_platform_dolby_vision")
170 !enable_platform_encrypted_dolby_vision || enable_platform_dolby_vision,
171 "enable_platform_dolby_vision required for enable_platform_encrypted_dolby_vision")
172 assert(!enable_platform_dts_audio || proprietary_codecs,
173 "proprietary_codecs required for enable_platform_dts_audio")
174 assert(!enable_platform_hevc || proprietary_codecs,
175 "proprietary_codecs required for enable_platform_hevc")
176 assert(!enable_hevc_parser_and_hw_decoder || enable_platform_hevc,
177 "enable_platform_hevc required for enable_hevc_parser_and_hw_decoder")
179 # Most DolbyVision profiles (4, 5, 7, 8, not 9) require HEVC support. It's very
180 # unlikely that we support DolbyVision on a new platform without requiring HEVC
181 # support. See for details:
182 # https://professionalsupport.dolby.com/s/article/What-is-Dolby-Vision-Profile
183 assert(!enable_platform_dolby_vision || enable_platform_hevc,
184 "enable_platform_hevc required for enable_platform_dolby_vision")
186 # Use another declare_args() to pick up possible overrides of |use_cras|.
188 # Enables runtime selection of PulseAudio library.
189 use_pulseaudio = false
191 # Enables runtime selection of ALSA library for audio.
194 # Alsa should be used on all non-Android, non-Mac POSIX systems - with the
195 # exception of CastOS desktop builds.
197 # TODO(crbug.com/1336055): Remove legacy target_cpu hack used for targeting
198 # desktop Chromecast builds.
199 if (is_posix && !is_android && !is_apple &&
200 (!is_castos || (target_cpu == "x86" || target_cpu == "x64") ||
201 is_cast_audio_only)) {
204 # Pulse is not supported on Chromecast platforms.
206 # ASAN and TSAN will occasionally hang during pa_context_connect(), so we
207 # disable PulseAudio when these configurations are enabled.
209 # TODO(crbug.com/986021): We shouldn't have to do this, but it's unclear why
210 # our test bots are hanging and all of the ones that don't hang just fall
211 # back to ALSA after a connection error anyways.
212 if (!use_cras && !is_castos && !is_asan && !is_tsan && !is_tizen) {
213 use_pulseaudio = true
218 # Use another declare_args() to include possible overrides of media_use_ffmpeg
219 # from --args command line flags in the evaluation. See "gn help declare_args".
221 # On Android, FFMpeg is built without video decoders by default.
222 # This flag gives the option to override that decision in case there are no
223 # hardware decoders. To do so, you will also need to update ffmpeg build files
224 # in order to define which decoders to build in.
225 enable_ffmpeg_video_decoders = media_use_ffmpeg && !is_android
229 # Enables the use of library CDMs that implements the interface defined at
230 # media/cdm/api/content_decryption_module.h. If true, the actually library CDM
231 # will be hosted in the mojo CDM service running in the CDM (utility) process.
232 # Used for all desktop platforms.
233 enable_library_cdms = toolkit_views && !is_castos
236 # Use another declare_args() to allow dependence on `enable_library_cdms`.
238 # Enables host verification for CDMs.
240 enable_cdm_host_verification =
241 enable_library_cdms && (is_mac || is_win) && is_chrome_branded &&
242 !is_chrome_for_testing_branded
244 # Enable Storage ID which is used by CDMs. This is only available with chrome
245 # branding, but may be overridden by other embedders.
246 enable_cdm_storage_id = enable_library_cdms && is_chrome_branded &&
247 (is_win || is_mac || is_chromeos)
249 # If |enable_cdm_storage_id| is set, then an implementation specific key
250 # must also be provided. It can be provided by defining CDM_STORAGE_ID_KEY
251 # (which takes precedence), or by setting |alternate_cdm_storage_id_key|.
252 # The key must be a string of at least 32 characters.
253 alternate_cdm_storage_id_key = ""
256 assert(!enable_cdm_host_verification || is_mac || is_win,
257 "CDM host verification is only supported on Mac and Windows.")
259 # https://crbug.com/1475137#c37
260 assert(!is_chrome_for_testing_branded || !enable_cdm_host_verification,
261 "Chrome for Testing is incompatible with CDM Host Verification.")
263 # Default |mojo_media_services| and |mojo_media_host| on various platforms. See
264 # comments below for valid values. Can be overridden by gn build arguments from
265 # the --args command line flag.
266 _default_mojo_media_services = []
267 _default_mojo_media_host = ""
269 if (is_cast_media_device) {
270 _default_mojo_media_services = cast_mojo_media_services
271 _default_mojo_media_host = cast_mojo_media_host
272 } else if (is_android) {
273 _default_mojo_media_services = [
279 _default_mojo_media_host = "gpu"
280 } else if (is_apple || is_win) {
281 _default_mojo_media_services = [
286 _default_mojo_media_host = "gpu"
288 _default_mojo_media_services = [
292 _default_mojo_media_host = "gpu"
293 } else if (is_chromeos_ash || ((is_linux || is_chromeos_lacros) &&
294 (use_vaapi || use_v4l2_codec))) {
295 _default_mojo_media_services = [ "video_decoder" ]
296 _default_mojo_media_host = "gpu"
299 # When |enable_library_cdms| is true, the "cdm" service will run in a separate
300 # CdmService in the CDM (utility) process. Therefore there's no need to specify
301 # |_default_mojo_media_host| which controls where the MediaService runs in.
302 if (enable_library_cdms) {
303 _default_mojo_media_services += [ "cdm" ]
307 # A list of mojo media services that should be used in the media pipeline.
308 # Valid entries in the list are:
309 # - "renderer": Use mojo-based media Renderer service.
310 # - "cdm": Use mojo-based Content Decryption Module.
311 # - "audio_decoder": Use mojo-based audio decoder in the default media
312 # Renderer. Cannot be used with the mojo Renderer above.
313 # - "video_decoder": Use mojo-based video decoder in the default media
314 # Renderer. Cannot be used with the mojo Renderer above.
315 mojo_media_services = _default_mojo_media_services
317 # The process that the mojo MediaService runs in. By default, all services
318 # registered in |mojo_media_services| are hosted in the MediaService, with the
319 # exception that when |enable_library_cdms| is true, the "cdm" service will
320 # run in a separate CdmService in the CDM (utility) process, while other
321 # |mojo_media_services| still run in the MediaService in the process specified
322 # by "mojo_media_host".
324 # - "browser": Use mojo media service hosted in the browser process.
325 # - "gpu": Use mojo media service hosted in the gpu process.
326 # - "": Do not use mojo media service.
327 mojo_media_host = _default_mojo_media_host
331 # This switch defines whether the Media Remoting implementation will be built.
332 # When enabled, media is allowed to be renderer and played back on remote
333 # devices when the tab is being casted and other conditions are met.
334 enable_media_remoting = !is_cast_media_device && !is_ios
338 # Media Remoting RPC is disabled on Android since it's unused but increases
339 # the native binary size by ~70Kb.
340 enable_media_remoting_rpc = enable_media_remoting && !is_android
344 # Currently it is available on Win, Mac and Linux, since it requires the audio
345 # service to run in a separate process.
346 chrome_wide_echo_cancellation_supported = is_win || is_mac || is_linux
349 # Do not expand this list without double-checking with OWNERS, this is a list of
350 # all targets which roll up into the //media component. It controls visibility
351 # of subcomponent targets and public_deps for //media.
352 media_subcomponent_deps = [
356 # TODO(crbug.com/583067): These files should not be in //media/base.
357 "//media/base/android",
358 "//media/capabilities",
360 "//media/device_monitors",
369 media_subcomponent_deps += [ "//media/fuchsia/common" ]
372 if (media_use_ffmpeg) {
373 media_subcomponent_deps += [ "//media/ffmpeg" ]
376 if (enable_library_cdms || is_win) {
377 media_subcomponent_deps += [ "//media/cdm:cdm_type_conversion" ]
381 media_subcomponent_deps += [ "//media/base/win:media_foundation_util" ]