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

import("//media/media_options.gni")

source_set("cdm_api") {
  sources = [ "api/content_decryption_module.h" ]
}

source_set("cdm_type_conversion") {
  if (enable_library_cdms || is_win) {
    # This target is a subcomponent.
    visibility = [
      ":*",
      "//media",
    ]
    configs += [ "//media:subcomponent_config" ]
  } else {
    visibility = [ "//media/cdm/library_cdm/clear_key_cdm:clear_key_cdm" ]
  }

  sources = [
    "cdm_type_conversion.cc",
    "cdm_type_conversion.h",
  ]

  deps = [
    ":cdm_api",
    "//media/base",
  ]
}

source_set("cdm") {
  # 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",

    # TODO(crbug.com/583067): These files should not be in //media/base.
    "//media/base/android",
    "//media/filters",
  ]

  sources = [
    "aes_cbc_crypto.cc",
    "aes_cbc_crypto.h",
    "aes_decryptor.cc",
    "aes_decryptor.h",
    "cbcs_decryptor.cc",
    "cbcs_decryptor.h",
    "cdm_capability.cc",
    "cdm_capability.h",
    "cdm_context_ref_impl.cc",
    "cdm_context_ref_impl.h",
    "cenc_decryptor.cc",
    "cenc_decryptor.h",
    "cenc_utils.cc",
    "cenc_utils.h",
    "default_cdm_factory.cc",
    "default_cdm_factory.h",
    "json_web_key.cc",
    "json_web_key.h",
    "supported_audio_codecs.cc",
    "supported_audio_codecs.h",
  ]

  public_deps = [
    ":cdm_type",
    ":clear_key_cdm_common",
  ]

  deps = [
    "//crypto",
    "//media/base",
    "//media/formats",
    "//third_party/boringssl",
    "//ui/gfx/geometry",
    "//url",
  ]

  configs += [ "//media:subcomponent_config" ]

  if (enable_library_cdms) {
    deps += [
      ":cdm_api",
      ":cdm_paths",
    ]
    sources += [
      "cdm_adapter.cc",
      "cdm_adapter.h",
      "cdm_adapter_factory.cc",
      "cdm_adapter_factory.h",
      "cdm_module.cc",
      "cdm_module.h",
      "cdm_wrapper.h",
      "output_protection.h",
      "supported_cdm_versions.cc",
      "supported_cdm_versions.h",
    ]

    if (enable_cdm_host_verification) {
      sources += [
        "cdm_host_file.cc",
        "cdm_host_file.h",
        "cdm_host_files.cc",
        "cdm_host_files.h",
      ]
    }
  }

  if (is_win || enable_library_cdms) {
    sources += [
      "cdm_allocator.cc",
      "cdm_allocator.h",
      "cdm_auxiliary_helper.cc",
      "cdm_auxiliary_helper.h",
      "cdm_document_service.h",
      "cdm_helpers.cc",
      "cdm_helpers.h",
      "load_cdm_uma_helper.cc",
      "load_cdm_uma_helper.h",
    ]
    deps += [
      ":cdm_api",
      ":cdm_type_conversion",
    ]
    public_deps += [ "//components/crash/core/common:crash_key" ]
  }

  if (is_win) {
    sources += [
      "media_foundation_cdm_data.cc",
      "media_foundation_cdm_data.h",
      "win/media_foundation_cdm.cc",
      "win/media_foundation_cdm.h",
      "win/media_foundation_cdm_factory.cc",
      "win/media_foundation_cdm_factory.h",
      "win/media_foundation_cdm_module.cc",
      "win/media_foundation_cdm_module.h",
      "win/media_foundation_cdm_session.cc",
      "win/media_foundation_cdm_session.h",
      "win/media_foundation_cdm_util.cc",
      "win/media_foundation_cdm_util.h",
    ]

    libs = [ "Propsys.lib" ]

    deps += [
      ":cdm_paths",
      "//media/base/win:media_foundation_util",
    ]
  }

  if (is_fuchsia) {
    sources += [
      "fuchsia/fuchsia_cdm.cc",
      "fuchsia/fuchsia_cdm.h",
      "fuchsia/fuchsia_cdm_context.h",
      "fuchsia/fuchsia_cdm_factory.cc",
      "fuchsia/fuchsia_cdm_factory.h",
      "fuchsia/fuchsia_cdm_provider.h",
      "fuchsia/fuchsia_decryptor.cc",
      "fuchsia/fuchsia_decryptor.h",
      "fuchsia/fuchsia_stream_decryptor.cc",
      "fuchsia/fuchsia_stream_decryptor.h",
    ]

    public_deps += [ "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.media.drm:fuchsia.media.drm_hlcpp" ]
    deps += [ "//media/fuchsia/common" ]
  }
}

if (enable_library_cdms) {
  static_library("cdm_paths") {
    public = [ "cdm_paths.h" ]

    sources = [ "cdm_paths.cc" ]

    deps = [
      "//base",
      "//media:media_buildflags",
    ]
  }
}

source_set("cdm_type") {
  sources = [ "cdm_type.h" ]
  deps = [ "//base" ]
}

source_set("clear_key_cdm_common") {
  sources = [ "clear_key_cdm_common.h" ]
  public_deps = [ ":cdm_type" ]
  deps = [ "//media:media_buildflags" ]
}

source_set("unit_tests") {
  testonly = true
  sources = [
    "aes_cbc_crypto_unittest.cc",
    "aes_decryptor_unittest.cc",
    "cbcs_decryptor_unittest.cc",
    "cenc_decryptor_unittest.cc",
    "json_web_key_unittest.cc",
  ]

  deps = [
    "//base/test:test_support",
    "//build:chromeos_buildflags",
    "//crypto",
    "//media:test_support",
    "//testing/gmock",
    "//testing/gtest",
    "//third_party/boringssl",
    "//ui/gfx:test_support",
    "//url",
  ]

  configs += [ "//media:media_config" ]

  data_deps = []

  if (enable_library_cdms) {
    sources += [
      "cdm_adapter_unittest.cc",
      "cdm_paths_unittest.cc",
      "external_clear_key_test_helper.cc",
      "external_clear_key_test_helper.h",
      "mock_helpers.cc",
      "mock_helpers.h",
      "simple_cdm_allocator.cc",
      "simple_cdm_allocator.h",
      "simple_cdm_allocator_unittest.cc",
      "simple_cdm_buffer.cc",
      "simple_cdm_buffer.h",
    ]

    data_deps += [ "//media/cdm/library_cdm/clear_key_cdm" ]

    deps += [
      ":cdm_api",
      ":cdm_paths",
      "//media/cdm/library_cdm:cdm_host_proxy",
      "//media/cdm/library_cdm:test_support",
    ]
  }

  if (proprietary_codecs) {
    sources += [ "cenc_utils_unittest.cc" ]
  }

  if (is_win) {
    sources += [
      "win/media_foundation_cdm_factory_unittest.cc",
      "win/media_foundation_cdm_session_unittest.cc",
      "win/media_foundation_cdm_unittest.cc",
    ]
  }
}
