Roll src/third_party/WebKit d10c917:a1123a1 (svn 198729:198730)
[chromium-blink-merge.git] / media / base / BUILD.gn
blob098b6e5563de33e9306a3a324ea44823e7bf1437
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.
5 import("//build/config/android/config.gni")
6 import("//build/config/arm.gni")
7 import("//build/config/features.gni")
8 import("//build/config/ui.gni")
9 import("//build/config/linux/pkg_config.gni")
10 import("//media/media_options.gni")
12 source_set("base") {
13   # This is part of the media component.
14   visibility = [ "//media" ]
15   sources = [
16     "audio_block_fifo.cc",
17     "audio_block_fifo.h",
18     "audio_buffer.cc",
19     "audio_buffer.h",
20     "audio_buffer_converter.cc",
21     "audio_buffer_converter.h",
22     "audio_buffer_queue.cc",
23     "audio_buffer_queue.h",
24     "audio_capturer_source.h",
25     "audio_converter.cc",
26     "audio_converter.h",
27     "audio_decoder.cc",
28     "audio_decoder.h",
29     "audio_decoder_config.cc",
30     "audio_decoder_config.h",
31     "audio_discard_helper.cc",
32     "audio_discard_helper.h",
33     "audio_fifo.cc",
34     "audio_fifo.h",
35     "audio_hardware_config.cc",
36     "audio_hardware_config.h",
37     "audio_hash.cc",
38     "audio_hash.h",
39     "audio_pull_fifo.cc",
40     "audio_pull_fifo.h",
41     "audio_renderer.cc",
42     "audio_renderer.h",
43     "audio_renderer_mixer.cc",
44     "audio_renderer_mixer.h",
45     "audio_renderer_mixer_input.cc",
46     "audio_renderer_mixer_input.h",
47     "audio_renderer_sink.h",
48     "audio_shifter.cc",
49     "audio_shifter.h",
50     "audio_splicer.cc",
51     "audio_splicer.h",
52     "audio_timestamp_helper.cc",
53     "audio_timestamp_helper.h",
54     "bind_to_current_loop.h",
55     "bit_reader.cc",
56     "bit_reader.h",
57     "bit_reader_core.cc",
58     "bit_reader_core.h",
59     "bitstream_buffer.h",
60     "buffering_state.h",
61     "buffers.h",
62     "byte_queue.cc",
63     "byte_queue.h",
64     "cdm_callback_promise.cc",
65     "cdm_callback_promise.h",
66     "cdm_config.h",
67     "cdm_context.cc",
68     "cdm_context.h",
69     "cdm_factory.cc",
70     "cdm_factory.h",
71     "cdm_initialized_promise.cc",
72     "cdm_initialized_promise.h",
73     "cdm_key_information.cc",
74     "cdm_key_information.h",
75     "cdm_promise.cc",
76     "cdm_promise.h",
77     "cdm_promise_adapter.cc",
78     "cdm_promise_adapter.h",
79     "channel_mixer.cc",
80     "channel_mixer.h",
81     "channel_mixing_matrix.cc",
82     "channel_mixing_matrix.h",
83     "clock.h",
84     "data_buffer.cc",
85     "data_buffer.h",
86     "data_source.cc",
87     "data_source.h",
88     "decoder_buffer.cc",
89     "decoder_buffer.h",
90     "decoder_buffer_queue.cc",
91     "decoder_buffer_queue.h",
92     "decrypt_config.cc",
93     "decrypt_config.h",
94     "decryptor.cc",
95     "decryptor.h",
96     "demuxer.cc",
97     "demuxer.h",
98     "demuxer_stream.cc",
99     "demuxer_stream.h",
100     "demuxer_stream_provider.cc",
101     "demuxer_stream_provider.h",
102     "djb2.cc",
103     "djb2.h",
104     "eme_constants.h",
105     "key_system_info.cc",
106     "key_system_info.h",
107     "key_systems.cc",
108     "key_systems.h",
109     "key_systems.h",
110     "key_systems_support_uma.cc",
111     "key_systems_support_uma.h",
112     "media.cc",
113     "media.h",
114     "media_client.cc",
115     "media_client.h",
116     "media_keys.cc",
117     "media_keys.h",
118     "media_log.cc",
119     "media_log.h",
120     "media_log_event.h",
121     "media_permission.cc",
122     "media_permission.h",
123     "media_switches.cc",
124     "media_switches.h",
125     "mime_util.cc",
126     "mime_util.h",
127     "moving_average.cc",
128     "moving_average.h",
129     "multi_channel_resampler.cc",
130     "multi_channel_resampler.h",
131     "null_video_sink.cc",
132     "null_video_sink.h",
133     "pipeline.cc",
134     "pipeline.h",
135     "pipeline_status.h",
136     "player_tracker.cc",
137     "player_tracker.h",
138     "ranges.cc",
139     "ranges.h",
140     "renderer.cc",
141     "renderer.h",
142     "renderer_factory.cc",
143     "renderer_factory.h",
144     "sample_format.cc",
145     "sample_format.h",
146     "seekable_buffer.cc",
147     "seekable_buffer.h",
148     "serial_runner.cc",
149     "serial_runner.h",
150     "simd/convert_rgb_to_yuv.h",
151     "simd/convert_rgb_to_yuv_c.cc",
152     "simd/convert_yuv_to_rgb.h",
153     "simd/convert_yuv_to_rgb_c.cc",
154     "simd/filter_yuv.h",
155     "simd/filter_yuv_c.cc",
156     "sinc_resampler.cc",
157     "sinc_resampler.h",
158     "stream_parser.cc",
159     "stream_parser.h",
160     "stream_parser_buffer.cc",
161     "stream_parser_buffer.h",
162     "text_cue.cc",
163     "text_cue.h",
164     "text_ranges.cc",
165     "text_ranges.h",
166     "text_renderer.cc",
167     "text_renderer.h",
168     "text_track.h",
169     "text_track_config.cc",
170     "text_track_config.h",
171     "time_delta_interpolator.cc",
172     "time_delta_interpolator.h",
173     "time_source.h",
174     "user_input_monitor.cc",
175     "user_input_monitor.h",
176     "video_capture_types.cc",
177     "video_capture_types.h",
178     "video_capturer_source.cc",
179     "video_capturer_source.h",
180     "video_decoder.cc",
181     "video_decoder.h",
182     "video_decoder_config.cc",
183     "video_decoder_config.h",
184     "video_frame.cc",
185     "video_frame.h",
186     "video_frame_metadata.cc",
187     "video_frame_metadata.h",
188     "video_frame_pool.cc",
189     "video_frame_pool.h",
190     "video_renderer.cc",
191     "video_renderer.h",
192     "video_rotation.h",
193     "video_util.cc",
194     "video_util.h",
195     "wall_clock_time_source.cc",
196     "wall_clock_time_source.h",
197     "yuv_convert.cc",
198     "yuv_convert.h",
199   ]
201   allow_circular_includes_from = []
202   defines = []
203   public_deps = []
204   deps = [
205     "//ui/events:events_base",
206     "//skia",
207   ]
208   libs = []
209   configs += [
210     "//media:media_config",
211     "//media:media_implementation",
212   ]
214   if (media_use_ffmpeg) {
215     sources += [
216       "audio_video_metadata_extractor.cc",
217       "audio_video_metadata_extractor.h",
218       "container_names.cc",
219       "container_names.h",
220       "media_file_checker.cc",
221       "media_file_checker.h",
222     ]
224     deps += [ "//third_party/ffmpeg" ]
225   }
227   if (enable_browser_cdms) {
228     sources += [
229       "browser_cdm.cc",
230       "browser_cdm.h",
231       "browser_cdm_factory.cc",
232       "browser_cdm_factory.h",
233     ]
234   }
236   if (is_android) {
237     public_deps = [
238       "//media/base/android",
239       "//media/base/android:media_java",
240       "//media/base/android:media_jni_headers",
241       "//media/base/android:video_capture_jni_headers",
242     ]
243     allow_circular_includes_from += [ "//media/base/android" ]
244   }
246   if (is_linux && use_x11) {
247     configs += [
248       "//build/config/linux:x11",
249       "//build/config/linux:xext",
251       # TODO(ajwong): Why does xent get a separate thing in //build/config/linux:BUILD.gn
252       #         "//build/config/linux:xdamage",
253       #         "//build/config/linux:xfixes",
254       #         "//build/config/linux:xtst",
255     ]
256     sources += [ "user_input_monitor_linux.cc" ]
257     deps += [
258       "//ui/events:events_base",
259       "//ui/gfx/x",
260     ]
261   } else if (is_mac) {
262     sources += [ "user_input_monitor_mac.cc" ]
264     # Required by video_frame.cc.
265     libs = [ "CoreVideo.framework" ]
266   } else if (is_win) {
267     sources += [ "user_input_monitor_win.cc" ]
268   } else {
269     defines += [ "DISABLE_USER_INPUT_MONITOR" ]
270   }
272   if (current_cpu == "x86" || current_cpu == "x64") {
273     sources += [
274       "simd/convert_rgb_to_yuv_sse2.cc",
275       "simd/convert_rgb_to_yuv_ssse3.cc",
276       "simd/convert_yuv_to_rgb_x86.cc",
277       "simd/filter_yuv_sse2.cc",
278     ]
279     deps += [ ":media_yasm" ]
280   }
282   configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]
284   if (is_linux || is_win) {
285     sources += [
286       "keyboard_event_counter.cc",
287       "keyboard_event_counter.h",
288     ]
289   }
292 # Minimal media component for media/cast on iOS.
293 config("base_for_cast_ios_dependent_config") {
294   defines = [ "MEDIA_FOR_CAST_IOS" ]
297 if (is_ios) {
298   source_set("base_for_cast_ios") {
299     sources = [
300       "simd/convert_rgb_to_yuv.h",
301       "simd/convert_rgb_to_yuv_c.cc",
302       "simd/convert_yuv_to_rgb.h",
303       "simd/convert_yuv_to_rgb_c.cc",
304       "simd/filter_yuv.h",
305       "simd/filter_yuv_c.cc",
306       "video_frame.cc",
307       "video_frame.h",
308       "video_frame_metadata.cc",
309       "video_frame_metadata.h",
310       "video_util.cc",
311       "video_util.h",
312       "yuv_convert.cc",
313       "yuv_convert.h",
314     ]
315     configs += [
316       "//build/config/compiler:no_size_t_to_int_warning",
317       "//media:media_config",
318     ]
319     all_dependent_configs = [ ":base_for_cast_ios_dependent_config" ]
320   }
323 source_set("test_support") {
324   testonly = true
325   sources = [
326     "fake_audio_render_callback.cc",
327     "fake_audio_render_callback.h",
328     "fake_audio_renderer_sink.cc",
329     "fake_audio_renderer_sink.h",
330     "fake_demuxer_stream.cc",
331     "fake_demuxer_stream.h",
332     "fake_text_track_stream.cc",
333     "fake_text_track_stream.h",
334     "gmock_callback_support.h",
335     "mock_audio_renderer_sink.cc",
336     "mock_audio_renderer_sink.h",
337     "mock_demuxer_host.cc",
338     "mock_demuxer_host.h",
339     "mock_filters.cc",
340     "mock_filters.h",
341     "test_data_util.cc",
342     "test_data_util.h",
343     "test_helpers.cc",
344     "test_helpers.h",
345   ]
346   configs += [ "//media:media_config" ]
347   deps = [
348     "//testing/gmock",
349   ]
352 source_set("unittests") {
353   testonly = true
354   sources = [
355     "audio_block_fifo_unittest.cc",
356     "audio_buffer_converter_unittest.cc",
357     "audio_buffer_queue_unittest.cc",
358     "audio_buffer_unittest.cc",
359     "audio_bus_unittest.cc",
360     "audio_converter_unittest.cc",
361     "audio_discard_helper_unittest.cc",
362     "audio_fifo_unittest.cc",
363     "audio_hardware_config_unittest.cc",
364     "audio_hash_unittest.cc",
365     "audio_pull_fifo_unittest.cc",
366     "audio_renderer_mixer_input_unittest.cc",
367     "audio_renderer_mixer_unittest.cc",
368     "audio_shifter_unittest.cc",
369     "audio_splicer_unittest.cc",
370     "audio_timestamp_helper_unittest.cc",
371     "bind_to_current_loop_unittest.cc",
372     "bit_reader_unittest.cc",
373     "callback_holder.h",
374     "callback_holder_unittest.cc",
375     "channel_mixer_unittest.cc",
376     "channel_mixing_matrix_unittest.cc",
377     "data_buffer_unittest.cc",
378     "decoder_buffer_queue_unittest.cc",
379     "decoder_buffer_unittest.cc",
380     "djb2_unittest.cc",
381     "fake_demuxer_stream_unittest.cc",
382     "gmock_callback_support_unittest.cc",
383     "key_systems_unittest.cc",
384     "mime_util_unittest.cc",
385     "moving_average_unittest.cc",
386     "multi_channel_resampler_unittest.cc",
387     "null_video_sink_unittest.cc",
388     "pipeline_unittest.cc",
389     "ranges_unittest.cc",
390     "run_all_unittests.cc",
391     "seekable_buffer_unittest.cc",
392     "serial_runner_unittest.cc",
393     "sinc_resampler_unittest.cc",
394     "stream_parser_unittest.cc",
395     "text_ranges_unittest.cc",
396     "text_renderer_unittest.cc",
397     "user_input_monitor_unittest.cc",
398     "vector_math_testing.h",
399     "vector_math_unittest.cc",
400     "video_frame_pool_unittest.cc",
401     "video_frame_unittest.cc",
402     "video_util_unittest.cc",
403     "wall_clock_time_source_unittest.cc",
404     "yuv_convert_unittest.cc",
405   ]
406   configs += [
407     "//build/config/compiler:no_size_t_to_int_warning",
408     "//media:media_config",
409   ]
410   deps = [
411     ":test_support",
412     "//gpu/command_buffer/common",
413     "//media",
414     "//skia",
415     "//testing/gmock",
416     "//testing/gtest",
417   ]
419   if (media_use_ffmpeg) {
420     sources += [
421       "audio_video_metadata_extractor_unittest.cc",
422       "media_file_checker_unittest.cc",
423     ]
424   }
426   if (!is_android) {
427     sources += [ "container_names_unittest.cc" ]
428   } else {
429     deps += [ "//ui/gl" ]
430   }
432   if (current_cpu == "x86" || current_cpu == "x64") {
433     sources += [ "simd/convert_rgb_to_yuv_unittest.cc" ]
434   }
437 source_set("perftests") {
438   testonly = true
439   sources = [
440     "audio_bus_perftest.cc",
441     "audio_converter_perftest.cc",
442     "run_all_perftests.cc",
443     "sinc_resampler_perftest.cc",
444     "vector_math_perftest.cc",
445     "yuv_convert_perftest.cc",
446   ]
447   configs += [ "//media:media_config" ]
448   deps = [
449     ":test_support",
450     "//media",
451     "//testing/gmock",
452     "//testing/gtest",
453   ]
455   if (media_use_ffmpeg) {
456     sources += [ "demuxer_perftest.cc" ]
457   }
459   if (is_android) {
460     deps += [ "//ui/gl" ]
461   }
464 if (current_cpu == "x86" || current_cpu == "x64") {
465   import("//third_party/yasm/yasm_assemble.gni")
466   yasm_assemble("media_yasm") {
467     sources = [
468       "simd/convert_rgb_to_yuv_ssse3.asm",
469       "simd/convert_yuv_to_rgb_sse.asm",
470       "simd/convert_yuva_to_argb_mmx.asm",
471       "simd/empty_register_state_mmx.asm",
472       "simd/linear_scale_yuv_to_rgb_mmx.asm",
473       "simd/linear_scale_yuv_to_rgb_sse.asm",
474       "simd/scale_yuv_to_rgb_mmx.asm",
475       "simd/scale_yuv_to_rgb_sse.asm",
476     ]
478     # TODO(ajwong): Only export if shared_library build...
479     yasm_flags = [
480       "-DCHROMIUM",
481       "-DEXPORT_SYMBOLS",
483       # In addition to the same path as source asm, let yasm %include
484       # search path be relative to src/ per Chromium policy.
485       "-I",
486       rebase_path("..", root_build_dir),
487     ]
489     inputs = [
490       "//third_party/x86inc/x86inc.asm",
491       "simd/convert_rgb_to_yuv_ssse3.inc",
492       "simd/convert_yuv_to_rgb_mmx.inc",
493       "simd/convert_yuva_to_argb_mmx.inc",
494       "simd/linear_scale_yuv_to_rgb_mmx.inc",
495       "simd/media_export.asm",
496       "simd/scale_yuv_to_rgb_mmx.inc",
497     ]
499     if (current_cpu == "x86") {
500       yasm_flags += [ "-DARCH_X86_32" ]
501     } else if (current_cpu == "x64") {
502       yasm_flags += [ "-DARCH_X86_64" ]
503       sources += [
504         "simd/linear_scale_yuv_to_rgb_mmx_x64.asm",
505         "simd/scale_yuv_to_rgb_sse2_x64.asm",
506       ]
507     }
509     if (is_mac || is_ios) {
510       yasm_flags += [
511         "-DPREFIX",
512         "-DMACHO",
513       ]
514     } else {
515       if (is_posix) {
516         yasm_flags += [ "-DELF" ]
517         if (current_cpu == "x64") {
518           # TODO(ajwong): Why isn't this true in mac?
519           yasm_flags += [ "-DPIC" ]
520         }
521       }
522     }
523   }