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