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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
media / BUILD.gn [blame]
# Copyright 2014 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/buildflag_header.gni")
import("//build/config/android/config.gni")
import("//build/config/arm.gni")
import("//build/config/cast.gni")
import("//build/config/features.gni")
import("//build/config/linux/pkg_config.gni")
import("//build/config/ui.gni")
import("//media/media_options.gni")
import("//testing/libfuzzer/fuzzer_test.gni")
import("//testing/test.gni")
import("//third_party/ffmpeg/ffmpeg_options.gni")
if (enable_library_cdms) {
import("//media/cdm/library_cdm/cdm_paths.gni")
}
if (is_ios) {
import("//build/config/ios/bundle_data_from_filelist.gni")
}
buildflag_header("media_buildflags") {
header = "media_buildflags.h"
enable_passthrough_audio_codecs =
enable_platform_dts_audio && (is_win || is_linux)
flags = [
"ALLOW_OOP_VIDEO_DECODER=$allow_oop_video_decoder",
"ALLOW_HOSTING_OOP_VIDEO_DECODER=$allow_hosting_oop_video_decoder",
"ALTERNATE_CDM_STORAGE_ID_KEY=\"$alternate_cdm_storage_id_key\"",
"CHROME_WIDE_ECHO_CANCELLATION=$chrome_wide_echo_cancellation_supported",
"ENABLE_PLATFORM_AC3_EAC3_AUDIO=$enable_platform_ac3_eac3_audio",
"ENABLE_PLATFORM_AC4_AUDIO=$enable_platform_ac4_audio",
"ENABLE_CAST_AUDIO_RENDERER=$enable_cast_audio_renderer",
"ENABLE_DAV1D_DECODER=$enable_dav1d_decoder",
"ENABLE_AV1_DECODER=$enable_av1_decoder",
"ENABLE_PLATFORM_DOLBY_VISION=$enable_platform_dolby_vision",
"ENABLE_PLATFORM_ENCRYPTED_DOLBY_VISION=$enable_platform_encrypted_dolby_vision",
"ENABLE_FFMPEG=$media_use_ffmpeg",
"ENABLE_FFMPEG_VIDEO_DECODERS=$enable_ffmpeg_video_decoders",
"ENABLE_PLATFORM_HEVC=$enable_platform_hevc",
"ENABLE_HEVC_PARSER_AND_HW_DECODER=$enable_hevc_parser_and_hw_decoder",
"ENABLE_PLATFORM_VVC=$enable_platform_vvc",
"ENABLE_HLS_DEMUXER=$enable_hls_demuxer",
"ENABLE_LIBAOM=$enable_libaom",
"ENABLE_LIBRARY_CDMS=$enable_library_cdms",
"ENABLE_LIBVPX=$media_use_libvpx",
"ENABLE_LOGGING_OVERRIDE=$enable_logging_override",
"ENABLE_MEDIA_DRM_STORAGE=$enable_media_drm_storage",
"ENABLE_MEDIA_REMOTING=$enable_media_remoting",
"ENABLE_MEDIA_REMOTING_RPC=$enable_media_remoting_rpc",
"ENABLE_OPENH264=$media_use_openh264",
"ENABLE_PASSTHROUGH_AUDIO_CODECS=$enable_passthrough_audio_codecs",
"ENABLE_PLATFORM_DTS_AUDIO=$enable_platform_dts_audio",
"ENABLE_PLATFORM_IAMF_AUDIO=$enable_platform_iamf_audio",
"ENABLE_PLATFORM_MPEG_H_AUDIO=$enable_platform_mpeg_h_audio",
"ENABLE_MSE_MPEG2TS_STREAM_PARSER=$enable_mse_mpeg2ts_stream_parser",
"PLATFORM_HAS_OPTIONAL_HEVC_DECODE_SUPPORT=$platform_has_optional_hevc_decode_support",
"PLATFORM_HAS_OPTIONAL_HEVC_ENCODE_SUPPORT=$platform_has_optional_hevc_encode_support",
"USE_ARC_PROTECTED_MEDIA=$use_arc_protected_media",
"USE_CHROMEOS_MEDIA_ACCELERATION=$use_vaapi||$use_v4l2_codec",
"USE_CHROMEOS_PROTECTED_AV1=$use_chromeos_protected_av1",
"USE_CHROMEOS_PROTECTED_MEDIA=$use_chromeos_protected_media",
"USE_CRAS=$use_cras",
"USE_PROPRIETARY_CODECS=$proprietary_codecs",
"ENABLE_GPU_CHANNEL_MEDIA_CAPTURE=$enable_gpu_channel_media_capture",
]
if (enable_library_cdms) {
flags += [
"CDM_PLATFORM_SPECIFIC_PATH=\"$cdm_platform_specific_path\"",
"ENABLE_CDM_HOST_VERIFICATION=$enable_cdm_host_verification",
"ENABLE_CDM_STORAGE_ID=$enable_cdm_storage_id",
]
}
}
if (proprietary_codecs && media_use_ffmpeg) {
assert(
ffmpeg_branding != "Chromium",
"proprietary codecs and ffmpeg_branding set to Chromium are incompatible")
}
# Common configuration for targets in the media directory; these must not be
# exported since things like USE_NEON have different meanings elsewhere in the
# code base.
config("media_config") {
defines = []
if (current_cpu == "arm64" || (current_cpu == "arm" && arm_use_neon)) {
defines += [ "USE_NEON" ]
}
if (use_pulseaudio) {
defines += [ "USE_PULSEAUDIO" ]
if (!link_pulseaudio) {
defines += [ "DLOPEN_PULSEAUDIO" ]
}
}
}
# Internal grouping of the configs necessary to support sub-folders having their
# own BUILD.gn files; only targets which roll up into the "media" target should
# include this config. I.e., not "test_support" or "unit_tests" targets.
#
# Without these configs having individual sub-folders take a //media/base DEP
# (or others) can yield incorrectly imported and exported symbols on Windows:
#
# fatal error LNK1169: one or more multiply defined symbols found.
#
config("subcomponent_config") {
visibility = media_subcomponent_deps
if (is_apple) {
visibility += [ "//media/base/mac" ]
}
defines = [ "IS_MEDIA_IMPL" ]
configs = [
":media_config",
"//build/config/compiler:wexit_time_destructors",
]
}
component("media") {
libs = []
deps = [
"//base",
"//base:i18n",
"//cc/paint",
"//gpu/command_buffer/client:gles2_interface",
"//gpu/command_buffer/common",
"//third_party/libyuv",
"//ui/events:events_base",
"//ui/gfx",
"//ui/gfx/geometry",
"//ui/gl:gl",
"//url",
]
public_configs = [ "//third_party/libwebm:libwebm_config" ]
public_deps = media_subcomponent_deps
public_deps += [
":media_buildflags",
":shared_memory_support",
"//ui/gfx:color_space",
]
# This must be included here since it actually depends on //media/base.
if (is_mac || (use_blink && is_ios)) {
public_deps += [ "//media/base/mac" ]
}
if (use_ozone) {
deps += [ "//ui/ozone" ]
}
}
# Note: This can't be a static_library since it does not have any sources.
source_set("test_support") {
testonly = true
public_deps = [
":media",
"//media/audio:test_support",
"//media/base:test_support",
"//media/base/android:test_support",
"//media/filters:test_support",
"//media/formats:test_support",
"//media/mojo/services:test_support",
"//media/parsers:test_support",
"//media/renderers:test_support",
"//media/video:test_support",
]
}
if (is_ios) {
bundle_data_from_filelist("unit_tests_bundle_data") {
testonly = true
filelist_name = "unit_tests_bundle_data.filelist"
}
}
# Contains tests for all targets in the "media" folder.
# TODO(xhwang): Move mojo/capture/remoting tests here where applicable.
test("media_unittests") {
use_xvfb = use_xvfb_in_this_config
deps = [
"//media/audio:unit_tests",
"//media/base:unit_tests",
"//media/capabilities:unit_tests",
"//media/cdm:unit_tests",
"//media/device_monitors:unit_tests",
"//media/filters:unit_tests",
"//media/formats:unit_tests",
"//media/gpu:unit_tests",
"//media/learning:unit_tests",
"//media/mojo:unit_tests",
"//media/muxers:unit_tests",
"//media/parsers:unit_tests",
"//media/renderers:unit_tests",
"//media/test:pipeline_integration_tests",
"//media/test:run_all_unittests",
"//media/video:unit_tests",
"//media/webrtc:unit_tests",
]
data = [
"test/data/",
"formats/mp4/h264_annex_b_fuzz_corpus/",
"formats/mp4/h265_annex_b_fuzz_corpus/",
]
data_deps = [ "//testing/buildbot/filters:media_unittests_filters" ]
if (is_android && enable_chrome_android_internal) {
data_deps += [ "//clank/build/bot/filters:media_unittests_filters" ]
}
if (media_use_ffmpeg) {
deps += [ "//media/ffmpeg:unit_tests" ]
}
if (is_android) {
deps += [
# The test needs the java dependencies to add the java classes for their
# native counterparts to the test apk.
"//gpu/command_buffer/service:android_texture_owner_unittests",
"//media/base/android:media_java",
"//media/base/android:unit_tests",
"//media/gpu:android_video_decode_accelerator_unittests",
"//ui/android:ui_java",
]
}
if (is_fuchsia) {
deps += [ "//media/fuchsia/video:unittests" ]
# PaintCanvasVideoRendererWithGLTest.* uses SwiftShader, which generates
# machine code.
test_runner_shard = "//build/config/fuchsia/test/elf_test_ambient_exec_runner.shard.test-cml"
additional_manifest_fragments = [
"//build/config/fuchsia/test/audio_output.shard.test-cml",
"//build/config/fuchsia/test/mark_vmo_executable.shard.test-cml",
"//build/config/fuchsia/test/platform_video_codecs.shard.test-cml",
"//third_party/fuchsia-sdk/sdk/pkg/vulkan/client.shard.cml",
]
if (enable_library_cdms) {
excluded_files = [ "lib.unstripped/libclearkeycdm.so" ]
}
}
if (enable_media_remoting) {
deps += [ "//media/remoting:media_remoting_tests" ]
}
# The test needs OPUS_FIXED_POINT conditional define.
configs += [ "//third_party/opus:opus_config" ]
if (is_ios) {
deps += [ ":unit_tests_bundle_data" ]
}
}
test("media_perftests") {
configs += [ ":media_config" ]
deps = [
":test_support",
"//base/test:test_support",
"//media/base:perftests",
"//media/filters:perftests",
"//media/test:pipeline_integration_perftests",
"//testing/gmock",
"//testing/gtest",
"//testing/perf",
"//third_party/widevine/cdm:headers",
"//ui/gfx:test_support",
]
if (media_use_ffmpeg) {
# Direct dependency required to inherit config.
deps += [ "//third_party/ffmpeg" ]
}
# This target should not require the Chrome executable to run.
assert_no_deps = [ "//chrome" ]
data = [ "test/data/" ]
data_deps = [
# Needed for isolate script to execute.
"//testing:run_perf_test",
]
if (enable_av1_decoder &&
((is_chromeos && (use_v4l2_codec || use_vaapi)) || is_win)) {
data_deps += [ "//media/gpu/test/:video_encode_accelerator_tests" ]
}
}
# Note: Most external components should just depend on //media unless they
# specifically need this pared own target (NaCl, PPAPI, etc). Internal targets
# should just depend on //media/base which will propagate this target to them.
component("shared_memory_support") {
sources = [
"base/audio_bus.cc",
"base/audio_bus.h",
"base/audio_codecs.h",
"base/audio_latency.cc",
"base/audio_latency.h",
"base/audio_parameters.cc",
"base/audio_parameters.h",
"base/audio_point.cc",
"base/audio_point.h",
"base/audio_sample_types.h",
"base/channel_layout.cc",
"base/channel_layout.h",
"base/limits.h",
"base/media_export.h",
"base/media_shmem_export.h",
"base/sample_format.cc",
"base/sample_format.h",
"base/vector_math.cc",
"base/vector_math.h",
"base/vector_math_testing.h",
"base/video_types.cc",
"base/video_types.h",
]
if (is_mac) {
# These need to be included here because audio_latency.cc depends on them.
sources += [
"base/mac/audio_latency_mac.cc",
"base/mac/audio_latency_mac.h",
]
}
# Do not use "subcomponent_config" here since these files are in their own
# component target and thus can't share the standard export macros.
configs += [ ":media_config" ]
defines = [ "MEDIA_SHMEM_IMPLEMENTATION" ]
if (!is_debug) {
configs -= [ "//build/config/compiler:default_optimization" ]
configs += [ "//build/config/compiler:optimize_max" ]
}
deps = [
"//base",
"//build:chromeos_buildflags",
"//media:media_buildflags",
"//ui/gfx/geometry",
]
}
# TODO(watk): Refactor tests that could be made to run on Android. See
# http://crbug.com/570762
if (media_use_ffmpeg && !is_android) {
test("ffmpeg_regression_tests") {
configs += [ "//media:media_config" ]
deps = [
":test_support",
"//base/test:test_support",
"//media/ffmpeg:ffmpeg_regression_tests",
"//media/test:pipeline_integration_tests",
"//media/test:run_all_unittests",
"//testing/gmock",
"//testing/gtest",
"//ui/gfx:test_support",
"//ui/gfx/geometry",
]
}
}
if (proprietary_codecs) {
fuzzer_test("media_cenc_utils_fuzzer") {
sources = [ "cdm/cenc_utils_fuzzertest.cc" ]
deps = [ ":media" ]
}
}
fuzzer_test("media_vpx_video_decoder_fuzzer") {
sources = [ "filters/vpx_video_decoder_fuzzertest.cc" ]
deps = [
":media",
"//base",
"//base/test:test_support",
]
libfuzzer_options = [ "max_len = 400000" ]
seed_corpus = "//media/test/data"
}
fuzzer_test("media_webm_muxer_fuzzer") {
sources = [ "muxers/webm_muxer_fuzzertest.cc" ]
deps = [
":media",
"//base",
"//third_party/libwebm",
]
}
fuzzer_test("cbcs_decryptor_fuzzer") {
sources = [ "cdm/cbcs_decryptor_fuzzer.cc" ]
deps = [
":media",
"//base",
"//crypto",
]
}
fuzzer_test("cenc_decryptor_fuzzer") {
sources = [ "cdm/cenc_decryptor_fuzzer.cc" ]
deps = [
":media",
"//base",
"//crypto",
]
}
fuzzer_test("json_web_key_fuzzer") {
sources = [ "cdm/json_web_key_fuzzer.cc" ]
deps = [
":media",
"//base",
]
}
if (proprietary_codecs) {
fuzzer_test("media_mp4_avcc_parser_fuzzer") {
sources = [ "formats/mp4/mp4_avcc_parser_fuzzer.cc" ]
deps = [
":media",
"//base",
]
}
fuzzer_test("media_mp4_box_reader_fuzzer") {
sources = [ "formats/mp4/mp4_box_reader_fuzzer.cc" ]
deps = [
":media",
"//base",
]
libfuzzer_options = [ "max_len=500" ]
dict = "test/mp4.dict"
}
}
if (enable_mse_mpeg2ts_stream_parser) {
fuzzer_test("media_es_parser_adts_fuzzer") {
sources = [ "formats/mp2t/es_parser_adts_fuzzer.cc" ]
deps = [
":media",
"//base",
]
}
fuzzer_test("media_es_parser_h264_fuzzer") {
sources = [ "formats/mp2t/es_parser_h264_fuzzer.cc" ]
deps = [
":media",
"//base",
]
}
fuzzer_test("media_es_parser_mpeg1audio_fuzzer") {
sources = [ "formats/mp2t/es_parser_mpeg1audio_fuzzer.cc" ]
deps = [
":media",
"//base",
]
}
}