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