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

import("//chromecast/chromecast.gni")

source_set("key_systems") {
  sources = [
    "key_systems_common.cc",
    "key_systems_common.h",
  ]

  if (use_playready) {
    public_configs = [ "//chromecast:playready_config" ]
  }

  deps = [
    "//base",
    "//chromecast/public/media",
    "//media",
    "//third_party/widevine/cdm:headers",
  ]
}

source_set("base") {
  sources = [
    "decrypt_context_impl.cc",
    "decrypt_context_impl.h",
    "decrypt_context_impl_clearkey.cc",
    "decrypt_context_impl_clearkey.h",
    "media_caps.cc",
    "media_caps.h",
    "media_codec_support.cc",
    "media_codec_support.h",
    "media_resource_tracker.cc",
    "media_resource_tracker.h",
    "video_plane_controller.cc",
    "video_plane_controller.h",
  ]

  if (!is_android) {
    sources += [
      "video_resolution_policy.cc",
      "video_resolution_policy.h",
    ]
  }

  public_deps = [
    ":key_systems",
    "//chromecast/public/media",
  ]

  deps = [
    ":libcast_media_1.0",
    "//base",
    "//chromecast/base",
    "//crypto",
    "//crypto:platform",
    "//media",
    "//ui/gfx/geometry",
  ]
}

# 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.
shared_library("libcast_media_1.0") {
  sources = [
    "cast_media_dummy.cc",
  ]

  public_deps = [
    "//chromecast/public",
  ]
}

# This target can be statically linked into unittests, but production
# binaries should not depend on this target.
source_set("libcast_media_1.0_default_core") {
  sources = [
    "cast_media_default.cc",
  ]

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

  deps = [
    "//base",
    "//build/config/sanitizers:deps",
    "//chromecast/base",
    "//chromecast/media/cma/backend",
  ]
}

# Default implementation of libcast_media_1.0.so.
# TODO(slan): Make this target a loadable_module (crbug/380327)
shared_library("libcast_media_1.0_default") {
  # Note that it cannot depend on libcast_media_1.0_default_core since a
  # loadable_module include only symbols necessary for source files.
  # So, it should include top-level .cc, here cast_media_default.cc explicitly.
  sources = [
    "cast_media_default.cc",
  ]

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

  deps = [
    "//base",
    "//build/config/sanitizers:deps",
    "//chromecast/base",
    "//chromecast/media/cma/backend",
  ]
}
