chromium/chromecast/media/cma/backend/BUILD.gn

# Copyright 2015 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/buildflag_header.gni")
import("//build/config/cast.gni")
import("//chromecast/chromecast.gni")
import("//media/media_options.gni")

declare_args() {
  system_owns_volume =
      use_alsa && !enable_assistant && chromecast_branding != "google"
}

cast_source_set("backend") {
  sources = [
    "cma_backend_factory_impl.cc",
    "cma_backend_factory_impl.h",
  ]

  public_deps = [
    "//chromecast/media/api",
    "//chromecast/public",
    "//chromecast/public/media",
  ]

  deps = [
    "//base",
    "//chromecast:chromecast_buildflags",
    "//chromecast/base/metrics:metrics",
    "//chromecast/media:libcast_media",
    "//chromecast/media/cma/base",
    "//chromecast/media/cma/decoder",
    "//chromecast/media/common:media_pipeline_backend_manager",
    "//chromecast/media/common:media_resource_tracker",
  ]

  if (enable_chromium_runtime_cast_renderer) {
    deps += [ "//chromecast/media/cma/backend/proxy" ]
  }

  if (have_full_mixer) {
    sources += [ "media_pipeline_backend_manager_mixer.cc" ]
    deps += [ "//chromecast/media/audio/mixer_service:control_connection" ]
  } else {
    sources += [ "media_pipeline_backend_manager_no_mixer.cc" ]
  }
}

# Target for OEM partners to override media shared library, i.e.
# libcast_media_1.0.so. This target is only used to build executables
# with correct linkage information.
cast_shared_library("libcast_media_1.0") {
  sources = [ "cast_media_dummy.cc" ]

  deps = [
    ":audio_buildflags",
    "//chromecast/public",
  ]
}

volume_control_in_media_shlib = !cast_volume_control_in_avsettings

buildflag_header("audio_buildflags") {
  header = "audio_buildflags.h"

  flags = [
    "MEDIA_CLOCK_MONOTONIC_RAW=$media_clock_monotonic_raw",
    "SYSTEM_OWNS_VOLUME=$system_owns_volume",
    "VOLUME_CONTROL_IN_MEDIA_SHLIB=$volume_control_in_media_shlib",
    "MIXER_IN_CAST_SHELL=$mixer_in_cast_shell",
  ]
}

# Implementation of video decoder that discards decoder buffers.
# Used on audio platforms for media streams containing video.
cast_source_set("null_video") {
  sources = [
    "video_decoder_null.cc",
    "video_decoder_null.h",
  ]

  deps = [
    "//base",
    "//chromecast/public/media",
  ]
}

cast_source_set("public") {
  sources = [ "system_volume_control.h" ]

  deps = [
    "//base",
    "//chromecast/public/media",
  ]
}

cast_source_set("av_sync_dummy") {
  sources = [ "av_sync_dummy.cc" ]

  deps = [
    "//base",
    "//chromecast/public",
  ]
}

cast_source_set("audio_codec_support") {
  sources = [ "media_codec_support_cast_audio.cc" ]
  deps = [
    "//base",
    "//chromecast/public",
    "//chromecast/public/media:media",
  ]
}

cast_source_set("cast_audio_json") {
  sources = [
    "cast_audio_json.cc",
    "cast_audio_json.h",
  ]

  deps = [ "//base" ]
}

cast_source_set("volume_map") {
  sources = [
    "volume_map.cc",
    "volume_map.h",
  ]
  deps = [
    ":cast_audio_json",
    "//base",
    "//chromecast/public",
  ]
}

cast_source_set("saved_volumes") {
  sources = [
    "saved_volumes.cc",
    "saved_volumes.h",
  ]
  deps = [
    ":cast_audio_json",
    "//base",
    "//chromecast/public",
  ]
}

cast_source_set("for_mixer_audio") {
  sources = [
    "audio_decoder_for_mixer.cc",
    "audio_decoder_for_mixer.h",
    "media_pipeline_backend_for_mixer.cc",
    "media_pipeline_backend_for_mixer.h",
    "volume_control.cc",
  ]

  deps = [
    ":audio_buildflags",
    ":cast_audio_json",
    ":public",
    ":saved_volumes",
    ":volume_map",
    "//base",
    "//chromecast/base",
    "//chromecast/media/api",
    "//chromecast/media/audio:processing",
    "//chromecast/media/audio/mixer_service:common",
    "//chromecast/media/audio/mixer_service:control_connection",
    "//chromecast/media/audio/mixer_service:output_stream_connection",
    "//chromecast/media/audio/mixer_service:proto",
    "//chromecast/media/audio/net:common",
    "//chromecast/media/audio/net:proto",
    "//chromecast/media/base:monotonic_clock",
    "//chromecast/media/cma/base",
    "//chromecast/media/cma/decoder",
    "//chromecast/net:io_buffer_pool",
    "//chromecast/public",
    "//chromecast/public/media",
    "//media",
    "//media:shared_memory_support",
  ]

  if (mixer_in_cast_shell) {
    deps += [ "//chromecast/media/cma/backend/mixer" ]
  }
}

test("cast_audio_backend_unittests") {
  testonly = true
  sources = [ "volume_map_unittest.cc" ]

  deps = [
    ":cast_audio_json",
    ":volume_map",
    "//base",
    "//base/test:run_all_unittests",
    "//base/test:test_support",
    "//chromecast/media/cma/backend/mixer:unittests",
    "//media",
    "//testing/gmock",
    "//testing/gtest",
  ]

  if (use_alsa) {
    deps += [ "//chromecast/media/cma/backend/alsa:unittests" ]
  }
}