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