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