chromium/media/base/BUILD.gn

# Copyright 2014 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/config/android/config.gni")
import("//build/config/arm.gni")
import("//build/config/features.gni")
import("//build/config/linux/pkg_config.gni")
import("//build/config/ozone.gni")
import("//build/config/ui.gni")
import("//media/media_options.gni")
import("//testing/libfuzzer/fuzzer_test.gni")

if (is_android) {
  import("//build/config/android/rules.gni")
}

source_set("base") {
  # Do not expand the visibility here without double-checking with OWNERS, this
  # is a roll-up target which is part of the //media component. Most other DEPs
  # should be using //media and not directly DEP this roll-up target.
  visibility = media_subcomponent_deps
  visibility += [ "//media" ]

  if (!enable_library_cdms) {
    # cdm_type_conversion is not part of media_subcomponent_deps.
    visibility += [ "//media/cdm:cdm_type_conversion" ]
  }

  # TODO(dalecurtis): Replace this with empty targets on non-mac so
  # we can just include //media/base/mac in media_subcomponent_deps.
  if (is_apple) {
    visibility += [ "//media/base/mac" ]
  }

  if (is_win) {
    visibility += [ "//media/base/win:color_space_util_win" ]
    visibility += [ "//media/base/win:media_foundation_util" ]
  }

  if (is_android) {
    visibility +=
        [ "//gpu/command_buffer/service:android_texture_owner_unittests" ]
  }

  sources = [
    "amplitude_peak_detector.cc",
    "amplitude_peak_detector.h",
    "android_overlay_config.cc",
    "android_overlay_config.h",
    "android_overlay_mojo_factory.h",
    "async_destroy_video_decoder.h",
    "async_destroy_video_encoder.h",
    "audio_block_fifo.cc",
    "audio_block_fifo.h",
    "audio_buffer.cc",
    "audio_buffer.h",
    "audio_buffer_converter.cc",
    "audio_buffer_converter.h",
    "audio_buffer_queue.cc",
    "audio_buffer_queue.h",
    "audio_bus_pool.cc",
    "audio_bus_pool.h",
    "audio_capturer_source.h",
    "audio_codecs.cc",
    "audio_codecs.h",
    "audio_converter.cc",
    "audio_converter.h",
    "audio_decoder.cc",
    "audio_decoder.h",
    "audio_decoder_config.cc",
    "audio_decoder_config.h",
    "audio_discard_helper.cc",
    "audio_discard_helper.h",
    "audio_encoder.cc",
    "audio_encoder.h",
    "audio_fifo.cc",
    "audio_fifo.h",
    "audio_glitch_info.cc",
    "audio_glitch_info.h",
    "audio_hash.cc",
    "audio_hash.h",
    "audio_power_monitor.cc",
    "audio_power_monitor.h",
    "audio_processing.cc",
    "audio_processing.h",
    "audio_processor_controls.h",
    "audio_pull_fifo.cc",
    "audio_pull_fifo.h",
    "audio_push_fifo.cc",
    "audio_push_fifo.h",
    "audio_renderer.cc",
    "audio_renderer.h",
    "audio_renderer_sink.h",
    "audio_shifter.cc",
    "audio_shifter.h",
    "audio_timestamp_helper.cc",
    "audio_timestamp_helper.h",
    "bit_reader.cc",
    "bit_reader.h",
    "bit_reader_core.cc",
    "bit_reader_core.h",
    "bitrate.cc",
    "bitrate.h",
    "bitstream_buffer.cc",
    "bitstream_buffer.h",
    "buffering_state.cc",
    "buffering_state.h",
    "byte_queue.cc",
    "byte_queue.h",
    "callback_holder.h",
    "callback_registry.h",
    "callback_timeout_helpers.h",
    "cdm_callback_promise.cc",
    "cdm_callback_promise.h",
    "cdm_capability.cc",
    "cdm_capability.h",
    "cdm_config.cc",
    "cdm_config.h",
    "cdm_context.cc",
    "cdm_context.h",
    "cdm_factory.cc",
    "cdm_factory.h",
    "cdm_initialized_promise.cc",
    "cdm_initialized_promise.h",
    "cdm_key_information.cc",
    "cdm_key_information.h",
    "cdm_promise.cc",
    "cdm_promise.h",
    "cdm_promise_adapter.cc",
    "cdm_promise_adapter.h",
    "cdm_session_tracker.cc",
    "cdm_session_tracker.h",
    "channel_mixer.cc",
    "channel_mixer.h",
    "channel_mixing_matrix.cc",
    "channel_mixing_matrix.h",
    "codec_worker_impl.h",
    "color_plane_layout.cc",
    "color_plane_layout.h",
    "container_names.cc",
    "container_names.h",
    "content_decryption_module.cc",
    "content_decryption_module.h",
    "converting_audio_fifo.cc",
    "converting_audio_fifo.h",
    "crc_16.h",
    "cross_origin_data_source.h",
    "data_buffer.cc",
    "data_buffer.h",
    "data_source.cc",
    "data_source.h",
    "decoder.cc",
    "decoder.h",
    "decoder_buffer.cc",
    "decoder_buffer.h",
    "decoder_buffer_queue.cc",
    "decoder_buffer_queue.h",
    "decoder_buffer_side_data.cc",
    "decoder_buffer_side_data.h",
    "decoder_factory.cc",
    "decoder_factory.h",
    "decoder_status.cc",
    "decoder_status.h",
    "decrypt_config.cc",
    "decrypt_config.h",
    "decryptor.cc",
    "decryptor.h",
    "demuxer.cc",
    "demuxer.h",
    "demuxer_memory_limit.h",
    "demuxer_stream.cc",
    "demuxer_stream.h",
    "djb2.cc",
    "djb2.h",
    "eme_constants.h",
    "encoder_status.cc",
    "encoder_status.h",
    "encryption_pattern.cc",
    "encryption_pattern.h",
    "encryption_scheme.cc",
    "encryption_scheme.h",
    "fake_audio_worker.cc",
    "fake_audio_worker.h",
    "feedback_signal_accumulator.h",
    "flinging_controller.h",
    "format_utils.cc",
    "format_utils.h",
    "frame_buffer_pool.cc",
    "frame_buffer_pool.h",
    "frame_rate_estimator.cc",
    "frame_rate_estimator.h",
    "key_system_capability.cc",
    "key_system_capability.h",
    "key_system_info.cc",
    "key_system_info.h",
    "key_system_names.cc",
    "key_system_names.h",
    "key_systems.cc",
    "key_systems.h",
    "key_systems_impl.cc",
    "key_systems_impl.h",
    "key_systems_support_registration.cc",
    "key_systems_support_registration.h",
    "localized_strings.cc",
    "localized_strings.h",
    "logging_override_if_enabled.h",
    "loopback_audio_converter.cc",
    "loopback_audio_converter.h",
    "media.cc",
    "media.h",
    "media_client.cc",
    "media_client.h",
    "media_content_type.cc",
    "media_content_type.h",
    "media_controller.h",
    "media_export.h",
    "media_log.cc",
    "media_log.h",
    "media_log_events.cc",
    "media_log_events.h",
    "media_log_message_levels.cc",
    "media_log_message_levels.h",
    "media_log_properties.cc",
    "media_log_properties.h",
    "media_log_record.h",
    "media_log_type_enforcement.h",
    "media_observer.cc",
    "media_observer.h",
    "media_permission.cc",
    "media_permission.h",
    "media_player_logging_id.cc",
    "media_player_logging_id.h",
    "media_resource.cc",
    "media_resource.h",
    "media_serializers.h",
    "media_serializers_base.h",
    "media_status.cc",
    "media_status.h",
    "media_status_observer.h",
    "media_switches.cc",
    "media_switches.h",
    "media_track.cc",
    "media_track.h",
    "media_tracks.cc",
    "media_tracks.h",
    "media_types.cc",
    "media_types.h",
    "media_url_demuxer.cc",
    "media_url_demuxer.h",
    "media_url_params.cc",
    "media_url_params.h",
    "media_util.cc",
    "media_util.h",
    "memory_dump_provider_proxy.cc",
    "memory_dump_provider_proxy.h",
    "mime_util.cc",
    "mime_util.h",
    "mime_util_internal.cc",
    "mime_util_internal.h",
    "multi_channel_resampler.cc",
    "multi_channel_resampler.h",
    "null_video_sink.cc",
    "null_video_sink.h",
    "offloading_audio_encoder.cc",
    "offloading_audio_encoder.h",
    "output_device_info.cc",
    "output_device_info.h",
    "overlay_info.cc",
    "overlay_info.h",
    "pipeline.h",
    "pipeline_impl.cc",
    "pipeline_impl.h",
    "pipeline_metadata.cc",
    "pipeline_metadata.h",
    "pipeline_status.cc",
    "pipeline_status.h",
    "platform_features.cc",
    "platform_features.h",
    "provision_fetcher.h",
    "ranges.cc",
    "ranges.h",
    "reentrancy_checker.cc",
    "reentrancy_checker.h",
    "remoting_constants.h",
    "renderer.cc",
    "renderer.h",
    "renderer_client.cc",
    "renderer_client.h",
    "renderer_factory.cc",
    "renderer_factory.h",
    "renderer_factory_selector.cc",
    "renderer_factory_selector.h",
    "routing_token_callback.h",
    "sample_rates.cc",
    "sample_rates.h",
    "scoped_async_trace.cc",
    "scoped_async_trace.h",
    "seekable_buffer.cc",
    "seekable_buffer.h",
    "serial_runner.cc",
    "serial_runner.h",
    "silent_sink_suspender.cc",
    "silent_sink_suspender.h",
    "simple_sync_token_client.cc",
    "simple_sync_token_client.h",
    "simple_watch_timer.cc",
    "simple_watch_timer.h",
    "sinc_resampler.cc",
    "sinc_resampler.h",
    "status.cc",
    "status.h",
    "stream_parser.cc",
    "stream_parser.h",
    "stream_parser_buffer.cc",
    "stream_parser_buffer.h",
    "subsample_entry.cc",
    "subsample_entry.h",
    "supported_audio_decoder_config.cc",
    "supported_audio_decoder_config.h",
    "supported_types.cc",
    "supported_types.h",
    "supported_video_decoder_config.cc",
    "supported_video_decoder_config.h",
    "svc_scalability_mode.cc",
    "svc_scalability_mode.h",
    "time_delta_interpolator.cc",
    "time_delta_interpolator.h",
    "time_source.h",
    "timestamp_constants.h",
    "tuneable.cc",
    "tuneable.h",
    "use_after_free_checker.h",
    "user_input_monitor.cc",
    "user_input_monitor.h",
    "video_aspect_ratio.cc",
    "video_aspect_ratio.h",
    "video_bitrate_allocation.cc",
    "video_bitrate_allocation.h",
    "video_codec_string_parsers.cc",
    "video_codec_string_parsers.h",
    "video_codecs.cc",
    "video_codecs.h",
    "video_color_space.cc",
    "video_color_space.h",
    "video_decoder.cc",
    "video_decoder.h",
    "video_decoder_config.cc",
    "video_decoder_config.h",
    "video_encoder.cc",
    "video_encoder.h",
    "video_encoder_metrics_provider.h",
    "video_frame.cc",
    "video_frame.h",
    "video_frame_converter.cc",
    "video_frame_converter.h",
    "video_frame_converter_internals.cc",
    "video_frame_converter_internals.h",
    "video_frame_layout.cc",
    "video_frame_layout.h",
    "video_frame_metadata.cc",
    "video_frame_metadata.h",
    "video_frame_pool.cc",
    "video_frame_pool.h",
    "video_renderer.cc",
    "video_renderer.h",
    "video_renderer_sink.h",
    "video_thumbnail_decoder.cc",
    "video_thumbnail_decoder.h",
    "video_transformation.cc",
    "video_transformation.h",
    "video_util.cc",
    "video_util.h",
    "wait_and_replace_sync_token_client.cc",
    "wait_and_replace_sync_token_client.h",
    "waiting.h",
    "wall_clock_time_source.cc",
    "wall_clock_time_source.h",
    "watch_time_keys.cc",
    "watch_time_keys.h",
    "webvtt_util.h",
  ]

  defines = []
  public_deps = [
    ":video_facing",
    "//media:media_buildflags",
    "//media:shared_memory_support",
    "//media/gpu:buildflags",
    "//media/mojo:buildflags",
    "//ui/gfx:color_space",
    "//ui/gl",
  ]
  deps = [
    "//base",
    "//base/allocator:buildflags",
    "//build:chromeos_buildflags",
    "//components/system_media_controls/linux/buildflags",
    "//gpu/command_buffer/client:client",
    "//gpu/command_buffer/client:interface_base",
    "//gpu/command_buffer/client:raster_interface",
    "//gpu/command_buffer/common",
    "//gpu/ipc/common:common",
    "//media/cdm:clear_key_cdm_common",
    "//net",
    "//skia",
    "//third_party/libyuv",
    "//third_party/widevine/cdm:headers",
    "//ui/display:display",
    "//ui/events:events",
    "//ui/events:events_base",
    "//ui/events:keyboard_hook",
    "//url:url",
  ]

  libs = []
  configs += [
    "//build/config:precompiled_headers",

    "//media:subcomponent_config",
  ]

  if (media_use_ffmpeg) {
    deps += [
      "//third_party/ffmpeg",
      "//third_party/ffmpeg:ffmpeg_features",
    ]
  }

  if (is_chromeos_ash) {
    deps += [ "//ash/constants" ]
  }

  if (media_use_libvpx) {
    sources += [
      "libvpx_thread_wrapper.cc",
      "libvpx_thread_wrapper.h",
    ]
    deps += [ "//third_party/libvpx" ]
  }

  if (enable_libaom) {
    sources += [
      "libaom_thread_wrapper.cc",
      "libaom_thread_wrapper.h",
    ]
    deps += [ "//third_party/libaom" ]
  }

  if (is_linux && !is_castos) {
    sources += [ "user_input_monitor_linux.cc" ]
  } else if (is_mac) {
    sources += [ "user_input_monitor_mac.cc" ]
    frameworks = [
      "CoreVideo.framework",
      "CoreFoundation.framework",
      "CoreGraphics.framework",
      "IOSurface.framework",
    ]
  } else if (is_win) {
    sources += [ "user_input_monitor_win.cc" ]
  } else {
    defines += [ "DISABLE_USER_INPUT_MONITOR" ]
  }
  if (use_ozone) {
    deps += [ "//ui/ozone" ]
  }

  if (is_win) {
    public_deps += [
      "//media/base/win:dcomp_texture_wrapper",
      "//media/base/win:mf_cdm_proxy",
      "//media/base/win:overlay_state_observer_subscription",
    ]
    sources += [
      "win/media_foundation_package_locator_helper.cc",
      "win/media_foundation_package_locator_helper.h",
      "win/media_foundation_package_runtime_locator.cc",
      "win/media_foundation_package_runtime_locator.h",
      "win/mf_feature_checks.cc",
      "win/mf_feature_checks.h",
    ]
  }

  if (is_android) {
    sources += [ "demuxer_memory_limit_android.cc" ]
  } else if (is_castos) {
    sources += [ "demuxer_memory_limit_cast.cc" ]
  } else {
    sources += [ "demuxer_memory_limit_default.cc" ]
  }

  if (!is_android) {
    sources += [ "speech_recognition_client.h" ]
  }

  if (enable_media_drm_storage) {
    sources += [
      "media_drm_key_type.h",
      "media_drm_storage.cc",
      "media_drm_storage.h",
    ]
  }
}

source_set("video_facing") {
  sources = [ "video_facing.h" ]
}

if (is_android) {
  java_cpp_enum("java_enums") {
    sources = [
      "audio_parameters.h",
      "container_names.h",
      "encryption_scheme.h",
      "video_codecs.h",
    ]
  }
}

# Note: Only specific internal targets that roll up into the //media component
# should depend on this, external targets should use //media:test_support.
static_library("test_support") {
  visibility = [
    "//media:test_support",
    "//media/audio:test_support",
    "//media/base/android:test_support",
    "//media/filters:test_support",
    "//media/formats:test_support",
    "//media/renderers:test_support",
    "//media/video:test_support",
  ]
  testonly = true
  sources = [
    "fake_audio_render_callback.cc",
    "fake_audio_render_callback.h",
    "fake_audio_renderer_sink.cc",
    "fake_audio_renderer_sink.h",
    "fake_demuxer_stream.cc",
    "fake_demuxer_stream.h",
    "fake_localized_strings.cc",
    "fake_localized_strings.h",
    "fake_single_thread_task_runner.cc",
    "fake_single_thread_task_runner.h",
    "mock_audio_renderer_sink.cc",
    "mock_audio_renderer_sink.h",
    "mock_demuxer_host.cc",
    "mock_demuxer_host.h",
    "mock_filters.cc",
    "mock_filters.h",
    "mock_media_log.cc",
    "mock_media_log.h",
    "mock_video_renderer_sink.cc",
    "mock_video_renderer_sink.h",
    "test_data_util.cc",
    "test_data_util.h",
    "test_helpers.cc",
    "test_helpers.h",
    "test_random.h",
  ]
  configs += [ "//media:media_config" ]

  # Do not add any other //media deps except this; this ensures other
  # test_support targets all use the same //media component to avoid duplicate
  # and undefined symbol issues on Windows.
  public_deps = [ "//media" ]

  deps = [
    "//base",
    "//base/test:test_support",
    "//build:chromeos_buildflags",
    "//testing/gmock",
    "//third_party/libyuv",
    "//ui/gfx:test_support",
    "//url",
  ]

  if (is_win) {
    public_deps += [ "//media/base/win:test_support" ]
  }
}

source_set("unit_tests") {
  testonly = true
  sources = [
    "amplitude_peak_detector_unittest.cc",
    "audio_block_fifo_unittest.cc",
    "audio_buffer_converter_unittest.cc",
    "audio_buffer_queue_unittest.cc",
    "audio_buffer_unittest.cc",
    "audio_bus_pool_unittest.cc",
    "audio_bus_unittest.cc",
    "audio_codecs_unittest.cc",
    "audio_converter_unittest.cc",
    "audio_discard_helper_unittest.cc",
    "audio_fifo_unittest.cc",
    "audio_glitch_info_unittest.cc",
    "audio_hash_unittest.cc",
    "audio_latency_unittest.cc",
    "audio_parameters_unittest.cc",
    "audio_point_unittest.cc",
    "audio_power_monitor_unittest.cc",
    "audio_pull_fifo_unittest.cc",
    "audio_push_fifo_unittest.cc",
    "audio_sample_types_unittest.cc",
    "audio_shifter_unittest.cc",
    "audio_timestamp_helper_unittest.cc",
    "bit_reader_unittest.cc",
    "bitrate_unittest.cc",
    "callback_holder_unittest.cc",
    "callback_registry_unittest.cc",
    "callback_timeout_helpers_unittest.cc",
    "channel_mixer_unittest.cc",
    "channel_mixing_matrix_unittest.cc",
    "container_names_unittest.cc",
    "converting_audio_fifo_unittest.cc",
    "crc_16_unittest.cc",
    "data_buffer_unittest.cc",
    "decoder_buffer_queue_unittest.cc",
    "decoder_buffer_unittest.cc",
    "decrypt_config_unittest.cc",
    "djb2_unittest.cc",
    "fake_audio_worker_unittest.cc",
    "fake_demuxer_stream_unittest.cc",
    "feedback_signal_accumulator_unittest.cc",
    "frame_buffer_pool_unittest.cc",
    "frame_rate_estimator_unittest.cc",
    "key_systems_unittest.cc",
    "media_log_unittest.cc",
    "media_serializers_unittest.cc",
    "media_url_demuxer_unittest.cc",
    "mime_util_unittest.cc",
    "multi_channel_resampler_unittest.cc",
    "null_video_sink_unittest.cc",
    "offloading_audio_encoder_unittest.cc",
    "pipeline_impl_unittest.cc",
    "ranges_unittest.cc",
    "reentrancy_checker_unittest.cc",
    "renderer_factory_selector_unittest.cc",
    "seekable_buffer_unittest.cc",
    "serial_runner_unittest.cc",
    "silent_sink_suspender_unittest.cc",
    "sinc_resampler_unittest.cc",
    "status_unittest.cc",
    "stream_parser_unittest.cc",
    "subsample_entry_unittest.cc",
    "supported_audio_decoder_config_unittest.cc",
    "supported_types_unittest.cc",
    "supported_video_decoder_config_unittest.cc",
    "time_delta_interpolator_unittest.cc",
    "tuneable_unittest.cc",
    "user_input_monitor_unittest.cc",
    "vector_math_unittest.cc",
    "video_aspect_ratio_unittest.cc",
    "video_bitrate_allocation_unittest.cc",
    "video_codec_string_parsers_unittest.cc",
    "video_color_space_unittest.cc",
    "video_decoder_config_unittest.cc",
    "video_frame_converter_unittest.cc",
    "video_frame_layout_unittest.cc",
    "video_frame_pool_unittest.cc",
    "video_frame_unittest.cc",
    "video_thumbnail_decoder_unittest.cc",
    "video_transformation_unittest.cc",
    "video_types_unittest.cc",
    "video_util_unittest.cc",
    "wall_clock_time_source_unittest.cc",
  ]
  configs += [ "//media:media_config" ]
  deps = [
    "//base/test:test_support",
    "//build:chromeos_buildflags",
    "//components/viz/common",
    "//gpu/command_buffer/common",
    "//media:test_support",
    "//net",
    "//testing/gmock",
    "//testing/gtest",
    "//third_party/libyuv",
    "//third_party/widevine/cdm:headers",
    "//ui/gfx",
  ]

  if (is_mac) {
    deps += [ "//media/base/mac:unit_tests" ]
  }

  if (is_win) {
    sources += [
      "win/dxgi_device_scope_handle_unittest.cc",
      "win/media_foundation_package_locator_unittest.cc",
    ]
    deps += [
      "//media",
      "//ui/events:test_support",
    ]
    libs = [
      "d3d11.lib",
      "mfplat.lib",
    ]
  }

  if (is_castos) {
    sources += [ "demuxer_memory_limit_cast_unittest.cc" ]
  }
}

source_set("perftests") {
  testonly = true
  sources = [
    "audio_bus_perftest.cc",
    "audio_converter_perftest.cc",
    "run_all_perftests.cc",
    "sinc_resampler_perftest.cc",
    "vector_math_perftest.cc",
  ]
  configs += [ "//media:media_config" ]
  deps = [
    "//base",
    "//base/test:test_support",
    "//media:test_support",
    "//testing/gmock",
    "//testing/gtest",
    "//testing/perf",
  ]
}

fuzzer_test("media_bit_reader_fuzzer") {
  sources = [ "bit_reader_fuzzertest.cc" ]
  deps = [
    "//base",
    "//media:test_support",
  ]
}

fuzzer_test("media_container_names_fuzzer") {
  sources = [ "container_names_fuzzertest.cc" ]
  deps = [
    "//base",
    "//media:test_support",
  ]
}