summaryrefslogtreecommitdiff
path: root/chromium/media/media_options.gni
blob: b5e9170a2876cee16677c0dab8d33b8ce560d103 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/config/chrome_build.gni")
import("//build/config/chromecast_build.gni")
import("//build/config/chromeos/args.gni")
import("//build/config/chromeos/ui_mode.gni")
import("//build/config/features.gni")
import("//media/gpu/args.gni")
import("//testing/libfuzzer/fuzzer_test.gni")
import("//third_party/libgav1/options.gni")

declare_args() {
  # Allows distributions to link pulseaudio directly (DT_NEEDED) instead of
  # using dlopen. This helps with automated detection of ABI mismatches and
  # prevents silent errors.
  link_pulseaudio = false

  # Enable usage of FFmpeg within the media library. Used for most software
  # based decoding, demuxing, and sometimes optimized FFTs. If disabled,
  # implementors must provide their own demuxers and decoders.
  media_use_ffmpeg = true

  # Enable usage of libvpx within the media library. Used for software based
  # decoding of VP9 and VP8A type content.
  media_use_libvpx = true

  # iOS doesn't use ffmpeg, libvpx.
  if (is_ios) {
    media_use_ffmpeg = false
    media_use_libvpx = false
  }

  # Enable usage of OpenH264 within the media library. Used for software based
  # encoding of H264 content.
  media_use_openh264 = true
  if (is_ios || is_android || !proprietary_codecs) {
    media_use_openh264 = false
  }

  # Override to dynamically link the cras (ChromeOS audio) library.
  use_cras = is_chromeos_device

  # Enables AC3/EAC3 audio demuxing. This is enabled only on Chromecast, since
  # it only provides demuxing, and is only useful for AC3/EAC3 audio
  # pass-through to HDMI sink on Chromecast.
  enable_platform_ac3_eac3_audio = proprietary_codecs && is_chromecast

  enable_platform_mpeg_h_audio = proprietary_codecs && is_chromecast

  enable_mse_mpeg2ts_stream_parser =
      proprietary_codecs && (is_chromecast || is_fuchsia || use_fuzzing_engine)

  # Enable HEVC/H265 demuxing. Actual decoding must be provided by the
  # platform. Enabled by default for Chromecast, Chrome OS protected media and
  # fuzzer builds.
  enable_platform_hevc =
      proprietary_codecs &&
      (is_chromecast || use_chromeos_protected_media || use_fuzzing_engine)

  # Enable Dolby Vision demuxing. Enable by default for Chromecast. Actual
  # decoding must be provided by the platform. Note some Dolby Vision profiles
  # which are encoded using HEVC require |enable_platform_hevc| to be enabled.
  enable_platform_dolby_vision = proprietary_codecs && is_chromecast

  enable_web_speech = true

  enable_webrtc = true

  # Enable HLS with SAMPLE-AES decryption.
  enable_hls_sample_aes = proprietary_codecs && (is_chromecast || is_fuchsia)

  # Enable logging override, e.g. enable DVLOGs through level 2 at build time.
  # On Chromecast, these are logged as INFO.
  # On Fuchsia, these are logged as VLOGs.
  enable_logging_override = is_chromecast || is_fuchsia

  enable_dav1d_decoder = !is_ios

  # Enable browser managed persistent metadata storage for EME persistent
  # session and persistent usage record session.
  enable_media_drm_storage = is_android || is_chromecast
}

declare_args() {
  enable_av1_decoder = enable_dav1d_decoder || enable_libgav1_decoder
}

# enable_hls_sample_aes can only be true if enable_mse_mpeg2ts_stream_parser is.
assert(enable_mse_mpeg2ts_stream_parser || !enable_hls_sample_aes)

# Use a second declare_args() to pick up possible overrides of |use_cras|.
declare_args() {
  # Enables runtime selection of PulseAudio library.
  use_pulseaudio = false

  # Enables runtime selection of ALSA library for audio.
  use_alsa = false

  # Alsa should be used on non-Android, non-Mac POSIX systems.
  # Alsa should be used on desktop Chromecast and audio-only Chromecast builds.
  if (is_posix && !is_android && !is_mac &&
      (!is_chromecast || is_cast_desktop_build || is_cast_audio_only)) {
    use_alsa = true

    # Pulse is not supported on Chromecast platforms.
    #
    # ASAN and TSAN will occasionally hang during pa_context_connect(), so we
    # disable PulseAudio when these configurations are enabled.
    #
    # TODO(crbug.com/986021): We shouldn't have to do this, but it's unclear why
    # our test bots are hanging and all of the ones that don't hang just fall
    # back to ALSA after a connection error anyways.
    if (!use_cras && !is_chromecast && !is_asan && !is_tsan) {
      use_pulseaudio = true
    }
  }
}

# Use another declare_args() to include possible overrides of media_use_ffmpeg
# from --args command line flags in the evaluation. See "gn help declare_args".
declare_args() {
  # On Android, FFMpeg is built without video decoders by default.
  # This flag gives the option to override that decision in case there are no
  # hardware decoders. To do so, you will also need to update ffmpeg build files
  # in order to define which decoders to build in.
  enable_ffmpeg_video_decoders = media_use_ffmpeg && !is_android
}

declare_args() {
  # Enables the use of library CDMs that implements the interface defined at
  # media/cdm/api/content_decryption_module.h. If true, the actually library CDM
  # will be hosted in the mojo CDM service running in the CDM (utility) process.
  enable_library_cdms = (is_linux && !is_chromecast) || is_chromeos_lacros ||
                        is_chromeos_ash || is_mac || is_win
}

declare_args() {
  # When enabled, this feature allows developers to use a runtime flag to
  # choose the implementation of the renderer that is used. On a build which
  # enables the mojo renderer, if --disable-mojo-renderer is passed at start-up,
  # the "default" renderer will be used instead. Both renderer implementations
  # will be linked if this feature is enabled, increasing the binary size. This
  # feature does not make sense if the mojo renderer is not enabled.
  enable_runtime_media_renderer_selection = is_cast_desktop_build

  # Enables host verification for CDMs.
  # Windows and Mac.
  enable_cdm_host_verification =
      enable_library_cdms && (is_mac || is_win) && is_chrome_branded

  # Enable Storage ID which is used by CDMs. This is only available with chrome
  # branding, but may be overridden by other embedders.
  enable_cdm_storage_id = enable_library_cdms && is_chrome_branded &&
                          (is_win || is_mac || is_chromeos_ash)

  # If |enable_cdm_storage_id| is set, then an implementation specific key
  # must also be provided. It can be provided by defining CDM_STORAGE_ID_KEY
  # (which takes precedence), or by setting |alternate_cdm_storage_id_key|.
  # The key must be a string of at least 32 characters.
  alternate_cdm_storage_id_key = ""
}

assert(!enable_cdm_host_verification || is_mac || is_win,
       "CDM host verification is only supported on Mac and Windows.")

# Default |mojo_media_services| and |mojo_media_host| on various platforms. See
# comments below for valid values. Can be overridden by gn build arguments from
# the --args command line flag.
_default_mojo_media_services = []
_default_mojo_media_host = ""

if (is_chromecast) {
  _default_mojo_media_services = cast_mojo_media_services
  _default_mojo_media_host = cast_mojo_media_host
} else if (is_android) {
  _default_mojo_media_services = [
    "cdm",
    "audio_decoder",
    "video_decoder",
  ]
  _default_mojo_media_host = "gpu"
} else if (is_chromeos_ash || is_mac || is_win ||
           ((is_linux || is_chromeos_lacros) && use_vaapi)) {
  _default_mojo_media_services = [ "video_decoder" ]
  _default_mojo_media_host = "gpu"
}

# When |enable_library_cdms| is true, the "cdm" service will run in a separate
# CdmService in the CDM (utility) process. Therefore there's no need to specify
# |_default_mojo_media_host| which controls where the MediaService runs in.
if (enable_library_cdms) {
  _default_mojo_media_services += [ "cdm" ]
}

declare_args() {
  # A list of mojo media services that should be used in the media pipeline.
  # Valid entries in the list are:
  # - "renderer": Use mojo-based media Renderer service.
  # - "cdm": Use mojo-based Content Decryption Module.
  # - "audio_decoder": Use mojo-based audio decoder in the default media
  #                    Renderer. Cannot be used with the mojo Renderer above.
  # - "video_decoder": Use mojo-based video decoder in the default media
  #                    Renderer. Cannot be used with the mojo Renderer above.
  mojo_media_services = _default_mojo_media_services

  # The process that the mojo MediaService runs in. By default, all services
  # registered in |mojo_media_services| are hosted in the MediaService, with the
  # exception that when |enable_library_cdms| is true, the "cdm" service will
  # run in a separate CdmService in the CDM (utility) process, while other
  # |mojo_media_services| still run in the MediaService in the process specified
  # by "mojo_media_host".
  # Valid options are:
  # - "browser": Use mojo media service hosted in the browser process.
  # - "gpu": Use mojo media service hosted in the gpu process.
  # - "utility": Use mojo media service hosted in the utility process.
  # - "": Do not use mojo media service.
  mojo_media_host = _default_mojo_media_host
}

declare_args() {
  # This switch defines whether the Media Remoting implementation will be built.
  # When enabled, media is allowed to be renderer and played back on remote
  # devices when the tab is being casted and other conditions are met.
  enable_media_remoting = !is_chromecast && !is_ios
}

declare_args() {
  # Media Remoting RPC is disabled on Android since it's unused but increases
  # the native binary size by ~70Kb.
  enable_media_remoting_rpc = enable_media_remoting && !is_android
}

# Do not expand this list without double-checking with OWNERS, this is a list of
# all targets which roll up into the //media component. It controls visibility
# of subcomponent targets and public_deps for //media.
media_subcomponent_deps = [
  "//media/audio",
  "//media/base",

  # TODO(crbug.com/583067): These files should not be in //media/base.
  "//media/base/android",
  "//media/capabilities",
  "//media/cdm",
  "//media/device_monitors",
  "//media/filters",
  "//media/formats",
  "//media/muxers",
  "//media/renderers",
  "//media/video",
]

if (is_fuchsia) {
  media_subcomponent_deps += [
    "//media/fuchsia/audio",
    "//media/fuchsia/cdm",
    "//media/fuchsia/common",
  ]
}

if (media_use_ffmpeg) {
  media_subcomponent_deps += [ "//media/ffmpeg" ]
}

if (enable_library_cdms || is_win) {
  media_subcomponent_deps += [ "//media/cdm:cdm_type_conversion" ]
}