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