chromium/media/cdm/BUILD.gn

# 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/41237623): 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_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",
    ]
  }
}