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