Upload upstream chromium 76.0.3809.146
[platform/framework/web/chromium-efl.git] / media / BUILD.gn
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
5 import("//build/buildflag_header.gni")
6 import("//build/config/android/config.gni")
7 import("//build/config/arm.gni")
8 import("//build/config/features.gni")
9 import("//build/config/linux/pkg_config.gni")
10 import("//build/config/ui.gni")
11 import("//media/media_options.gni")
12 import("//testing/libfuzzer/fuzzer_test.gni")
13 import("//testing/test.gni")
14 import("//third_party/ffmpeg/ffmpeg_options.gni")
15 if (use_efl) {
16   import("//tizen_src/chromium_impl/media/media_efl.gni")
17 }
18
19 buildflag_header("media_buildflags") {
20   header = "media_buildflags.h"
21
22   flags = [
23     "ALTERNATE_CDM_STORAGE_ID_KEY=$alternate_cdm_storage_id_key",
24     "ENABLE_AC3_EAC3_AUDIO_DEMUXING=$enable_ac3_eac3_audio_demuxing",
25     "ENABLE_CBCS_ENCRYPTION_SCHEME=$enable_cbcs_encryption_scheme",
26     "ENABLE_CDM_HOST_VERIFICATION=$enable_cdm_host_verification",
27     "ENABLE_CDM_STORAGE_ID=$enable_cdm_storage_id",
28     "ENABLE_DAV1D_DECODER=$enable_dav1d_decoder",
29     "ENABLE_AV1_DECODER=$enable_av1_decoder",
30     "ENABLE_DOLBY_VISION_DEMUXING=$enable_dolby_vision_demuxing",
31     "ENABLE_FFMPEG=$media_use_ffmpeg",
32     "ENABLE_FFMPEG_VIDEO_DECODERS=$enable_ffmpeg_video_decoders",
33     "ENABLE_HEVC_DEMUXING=$enable_hevc_demuxing",
34     "ENABLE_HLS_SAMPLE_AES=$enable_hls_sample_aes",
35     "ENABLE_LIBRARY_CDMS=$enable_library_cdms",
36     "ENABLE_LIBVPX=$media_use_libvpx",
37     "ENABLE_LOGGING_OVERRIDE=$enable_logging_override",
38     "ENABLE_MEDIA_REMOTING=$enable_media_remoting",
39     "ENABLE_MEDIA_REMOTING_RPC=$enable_media_remoting_rpc",
40     "ENABLE_MPEG_H_AUDIO_DEMUXING=$enable_mpeg_h_audio_demuxing",
41     "ENABLE_MSE_MPEG2TS_STREAM_PARSER=$enable_mse_mpeg2ts_stream_parser",
42     "USE_PROPRIETARY_CODECS=$proprietary_codecs",
43   ]
44 }
45
46 if (proprietary_codecs && media_use_ffmpeg) {
47   assert(
48       ffmpeg_branding != "Chromium",
49       "proprietary codecs and ffmpeg_branding set to Chromium are incompatible")
50 }
51
52 # Common configuration for targets in the media directory; these must not be
53 # exported since things like USE_NEON and USE_CRAS have different meanings
54 # elsewhere in the code base.
55 config("media_config") {
56   defines = []
57   if (current_cpu == "arm64" || (current_cpu == "arm" && arm_use_neon)) {
58     defines += [ "USE_NEON" ]
59   }
60   if (use_pulseaudio) {
61     defines += [ "USE_PULSEAUDIO" ]
62     if (!link_pulseaudio) {
63       defines += [ "DLOPEN_PULSEAUDIO" ]
64     }
65   }
66   if (use_cras) {
67     defines += [ "USE_CRAS" ]
68   }
69 }
70
71 # Internal grouping of the configs necessary to support sub-folders having their
72 # own BUILD.gn files; only targets which roll up into the "media" target should
73 # include this config. I.e., not "test_support" or "unit_tests" targets.
74 #
75 # Without these configs having individual sub-folders take a //media/base DEP
76 # (or others) can yield incorrectly imported and exported symbols on Windows:
77 #
78 #    fatal error LNK1169: one or more multiply defined symbols found.
79 #
80 config("subcomponent_config") {
81   visibility = media_subcomponent_deps
82   if (is_mac) {
83     visibility += [ "//media/base/mac" ]
84   }
85   defines = [ "IS_MEDIA_IMPL" ]
86   configs = [
87     ":media_config",
88     "//build/config/compiler:wexit_time_destructors",
89   ]
90 }
91
92 component("media") {
93   libs = []
94
95   deps = [
96     "//base",
97     "//base:i18n",
98     "//base/third_party/dynamic_annotations",
99     "//cc/paint",
100     "//crypto:platform",
101     "//gpu/command_buffer/client:gles2_interface",
102     "//gpu/command_buffer/common",
103     "//third_party/libyuv",
104     "//ui/events:events_base",
105     "//ui/gfx",
106     "//ui/gfx/geometry",
107     "//ui/gl:gl",
108     "//url",
109   ]
110
111   public_configs = [ "//third_party/libwebm:libwebm_config" ]
112   public_deps = media_subcomponent_deps
113   public_deps += [
114     ":media_buildflags",
115     ":shared_memory_support",
116     "//ui/gfx:color_space",
117   ]
118
119   # This must be included here since it actually depends on //media/base.
120   if (is_mac || is_ios) {
121     public_deps += [ "//media/base/mac" ]
122   }
123 }
124
125 # Note: This can't be a static_library since it does not have any sources.
126 source_set("test_support") {
127   testonly = true
128   public_deps = [
129     ":media",
130     "//media/audio:test_support",
131     "//media/base:test_support",
132     "//media/base/android:test_support",
133     "//media/filters:test_support",
134     "//media/formats:test_support",
135     "//media/gpu:test_support",
136     "//media/video:test_support",
137   ]
138 }
139
140 # Contains tests for all targets in the "media" folder.
141 # TODO(xhwang): Move mojo/capture/remoting tests here where applicable.
142 test("media_unittests") {
143   deps = [
144     "//media/audio:unit_tests",
145     "//media/base:unit_tests",
146     "//media/capabilities:unit_tests",
147     "//media/cdm:unit_tests",
148     "//media/device_monitors:unit_tests",
149     "//media/filters:unit_tests",
150     "//media/formats:unit_tests",
151     "//media/gpu:unit_tests",
152     "//media/learning:unit_tests",
153     "//media/mojo:unit_tests",
154     "//media/muxers:unit_tests",
155     "//media/parsers:unit_tests",
156     "//media/renderers:unit_tests",
157     "//media/test:pipeline_integration_tests",
158     "//media/test:run_all_unittests",
159     "//media/video:unit_tests",
160     "//media/webrtc:unit_tests",
161   ]
162
163   data = [
164     "test/data/",
165   ]
166
167   data_deps = []
168
169   if (media_use_ffmpeg) {
170     deps += [ "//media/ffmpeg:unit_tests" ]
171   }
172
173   if (is_android) {
174     deps += [
175       # The test needs the java dependencies to add the java classes for their
176       # native counterparts to the test apk.
177       "//media/base/android:media_java",
178       "//media/base/android:unit_tests",
179       "//media/gpu:android_video_decode_accelerator_unittests",
180       "//ui/android:ui_java",
181     ]
182   }
183
184   if (enable_media_remoting) {
185     deps += [ "//media/remoting:media_remoting_tests" ]
186   }
187
188   # The test needs OPUS_FIXED_POINT conditional define.
189   configs += [ "//third_party/opus:opus_config" ]
190 }
191
192 test("media_perftests") {
193   configs += [ ":media_config" ]
194   deps = [
195     ":test_support",
196     "//base/test:test_support",
197     "//media/base:perftests",
198     "//media/filters:perftests",
199     "//media/test:pipeline_integration_perftests",
200     "//testing/gmock",
201     "//testing/gtest",
202     "//testing/perf",
203     "//third_party/widevine/cdm:headers",
204     "//ui/gfx:test_support",
205   ]
206   if (media_use_ffmpeg) {
207     # Direct dependency required to inherit config.
208     deps += [ "//third_party/ffmpeg" ]
209   }
210
211   # This target should not require the Chrome executable to run.
212   assert_no_deps = [ "//chrome" ]
213
214   data = [
215     "test/data/",
216   ]
217
218   data_deps = [
219     # Needed for isolate script to execute.
220     "//testing:run_perf_test",
221   ]
222 }
223
224 # The audio subset of media_unittests. This target exists for running only the
225 # audio tests on the GPU bots (which have audio hardware).
226 test("audio_unittests") {
227   deps = [
228     ":test_support",
229     "//base/test:test_support",
230     "//media/audio:unit_tests",
231     "//media/test:run_all_unittests",
232   ]
233   if (is_android) {
234     deps += [
235       # The test needs the java dependencies to add the java classes for their
236       # native counterparts to the test apk.
237       "//media/base/android:media_java",
238       "//ui/android:ui_java",
239     ]
240   }
241 }
242
243 # Note: Most external components should just depend on //media unless they
244 # specifically need this pared own target (NaCl, PPAPI, etc). Internal targets
245 # should just depend on //media/base which will propagate this target to them.
246 component("shared_memory_support") {
247   sources = [
248     "base/audio_bus.cc",
249     "base/audio_bus.h",
250     "base/audio_latency.cc",
251     "base/audio_latency.h",
252     "base/audio_parameters.cc",
253     "base/audio_parameters.h",
254     "base/audio_point.cc",
255     "base/audio_point.h",
256     "base/audio_sample_types.h",
257     "base/channel_layout.cc",
258     "base/channel_layout.h",
259     "base/limits.h",
260     "base/media_shmem_export.h",
261     "base/sample_format.cc",
262     "base/sample_format.h",
263     "base/vector_math.cc",
264     "base/vector_math.h",
265     "base/vector_math_testing.h",
266   ]
267   if (is_mac) {
268     # These need to be included here because audio_latency.cc depends on them.
269     sources += [
270       "base/mac/audio_latency_mac.cc",
271       "base/mac/audio_latency_mac.h",
272     ]
273   }
274
275   # Do not use "subcomponent_config" here since these files are in their own
276   # component target and thus can't share the standard export macros.
277   configs += [ ":media_config" ]
278   defines = [ "MEDIA_SHMEM_IMPLEMENTATION" ]
279
280   if (!is_debug) {
281     configs -= [ "//build/config/compiler:default_optimization" ]
282     configs += [ "//build/config/compiler:optimize_max" ]
283   }
284   deps = [
285     "//base",
286     "//ui/gfx/geometry",
287   ]
288 }
289
290 # TODO(watk): Refactor tests that could be made to run on Android. See
291 # http://crbug.com/570762
292 if (media_use_ffmpeg && !is_android) {
293   test("ffmpeg_regression_tests") {
294     configs += [ "//media:media_config" ]
295
296     deps = [
297       ":test_support",
298       "//base/test:test_support",
299       "//media/ffmpeg:ffmpeg_regression_tests",
300       "//media/test:pipeline_integration_tests",
301       "//media/test:run_all_unittests",
302       "//testing/gmock",
303       "//testing/gtest",
304       "//ui/gfx:test_support",
305       "//ui/gfx/geometry",
306     ]
307   }
308 }
309
310 if (proprietary_codecs) {
311   fuzzer_test("media_cenc_utils_fuzzer") {
312     sources = [
313       "cdm/cenc_utils_fuzzertest.cc",
314     ]
315     deps = [
316       ":media",
317     ]
318   }
319 }
320
321 fuzzer_test("media_vp9_parser_fuzzer") {
322   sources = [
323     "filters/vp9_parser_fuzzertest.cc",
324   ]
325   deps = [
326     ":test_support",
327     "//base",
328   ]
329   libfuzzer_options = [ "max_len = 400000" ]
330 }
331
332 fuzzer_test("media_vp9_parser_encrypted_fuzzer") {
333   sources = [
334     "filters/vp9_parser_encrypted_fuzzertest.cc",
335   ]
336   deps = [
337     ":test_support",
338     "//base",
339     "//base/test:test_support",
340   ]
341   seed_corpus = "//media/test/data"
342 }
343
344 fuzzer_test("media_vpx_video_decoder_fuzzer") {
345   sources = [
346     "filters/vpx_video_decoder_fuzzertest.cc",
347   ]
348   deps = [
349     ":media",
350     "//base",
351   ]
352   libfuzzer_options = [ "max_len = 400000" ]
353   seed_corpus = "//media/test/data"
354 }
355
356 fuzzer_test("media_webm_muxer_fuzzer") {
357   sources = [
358     "muxers/webm_muxer_fuzzertest.cc",
359   ]
360   deps = [
361     ":media",
362     "//base",
363     "//third_party/libwebm",
364   ]
365
366   if (use_efl && tizen_multimedia_support) {
367     deps += external_media_efl_deps
368     sources += external_media_efl_sources
369     sources -= external_exclude_media_efl_sources
370     configs += external_media_efl_config
371   }
372 }
373
374 fuzzer_test("cbcs_decryptor_fuzzer") {
375   sources = [
376     "cdm/cbcs_decryptor_fuzzer.cc",
377   ]
378   deps = [
379     ":media",
380     "//base",
381     "//crypto",
382   ]
383 }
384
385 fuzzer_test("cenc_decryptor_fuzzer") {
386   sources = [
387     "cdm/cenc_decryptor_fuzzer.cc",
388   ]
389   deps = [
390     ":media",
391     "//base",
392     "//crypto",
393   ]
394 }
395
396 if (proprietary_codecs) {
397   fuzzer_test("media_mp4_avcc_parser_fuzzer") {
398     sources = [
399       "formats/mp4/mp4_avcc_parser_fuzzer.cc",
400     ]
401     deps = [
402       ":media",
403       "//base",
404     ]
405   }
406
407   fuzzer_test("media_mp4_box_reader_fuzzer") {
408     sources = [
409       "formats/mp4/mp4_box_reader_fuzzer.cc",
410     ]
411     deps = [
412       ":media",
413       "//base",
414     ]
415     libfuzzer_options = [ "max_len=500" ]
416     dict = "test/mp4.dict"
417   }
418 }
419
420 if (enable_mse_mpeg2ts_stream_parser) {
421   fuzzer_test("media_es_parser_adts_fuzzer") {
422     sources = [
423       "formats/mp2t/es_parser_adts_fuzzer.cc",
424     ]
425     deps = [
426       ":media",
427       "//base",
428     ]
429   }
430
431   fuzzer_test("media_es_parser_h264_fuzzer") {
432     sources = [
433       "formats/mp2t/es_parser_h264_fuzzer.cc",
434     ]
435     deps = [
436       ":media",
437       "//base",
438     ]
439   }
440
441   fuzzer_test("media_es_parser_mpeg1audio_fuzzer") {
442     sources = [
443       "formats/mp2t/es_parser_mpeg1audio_fuzzer.cc",
444     ]
445     deps = [
446       ":media",
447       "//base",
448     ]
449   }
450 }