chromium/media/mojo/mojom/stable/BUILD.gn

# Copyright 2021 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/gpu/args.gni")
import("//mojo/public/tools/bindings/mojom.gni")

mojom("stable_video_decoder") {
  generate_java = true

  sources = [
    "stable_video_decoder.mojom",
    "stable_video_decoder_types.mojom",
  ]

  enabled_features = []
  if (is_linux || is_chromeos_ash) {
    enabled_features += [ "is_linux_or_chromeos_ash" ]
  }

  public_deps = [
    ":native_pixmap_handle",
    "//gpu/ipc/common:interfaces",
    "//media/mojo/mojom:encryption_pattern",
    "//mojo/public/mojom/base",
    "//sandbox/policy/mojom",
    "//ui/gfx/geometry/mojom",
    "//ui/gfx/mojom",
  ]

  cpp_typemaps = [
    {
      types = [
        {
          mojom = "media.stable.mojom.CdmContextEvent"
          cpp = "::media::CdmContext::Event"
        },
        {
          mojom = "media.stable.mojom.ColorSpacePrimaryID"
          cpp = "::gfx::ColorSpace::PrimaryID"
        },
        {
          mojom = "media.stable.mojom.ColorSpaceTransferID"
          cpp = "::gfx::ColorSpace::TransferID"
        },
        {
          mojom = "media.stable.mojom.ColorSpaceMatrixID"
          cpp = "::gfx::ColorSpace::MatrixID"
        },
        {
          mojom = "media.stable.mojom.ColorSpaceRangeID"
          cpp = "::gfx::ColorSpace::RangeID"
        },
        {
          mojom = "media.stable.mojom.ColorSpace"
          cpp = "::gfx::ColorSpace"
        },
        {
          mojom = "media.stable.mojom.ColorVolumeMetadata"
          cpp = "::gfx::HdrMetadataSmpteSt2086"
        },
        {
          mojom = "media.stable.mojom.DecoderBuffer"
          cpp = "::scoped_refptr<::media::DecoderBuffer>"
          nullable_is_same_type = true
        },
        {
          mojom = "media.stable.mojom.DecryptConfig"
          cpp = "::std::unique_ptr<::media::DecryptConfig>"
          move_only = true
          nullable_is_same_type = true
        },
        {
          mojom = "media.stable.mojom.DecryptStatus"
          cpp = "::media::Decryptor::Status"
        },
        {
          mojom = "media.stable.mojom.EncryptionScheme"
          cpp = "::media::EncryptionScheme"
        },
        {
          mojom = "media.stable.mojom.HDRMetadata"
          cpp = "::gfx::HDRMetadata"
        },
        {
          mojom = "media.stable.mojom.MediaLogRecord.Type"
          cpp = "::media::MediaLogRecord::Type"
        },
        {
          mojom = "media.stable.mojom.MediaLogRecord"
          cpp = "::media::MediaLogRecord"
        },
        {
          mojom = "media.stable.mojom.NativeGpuMemoryBufferHandle"
          cpp = "::gfx::GpuMemoryBufferHandle"
          move_only = true
        },
        {
          mojom = "media.stable.mojom.StatusData"
          cpp = "::media::internal::StatusData"
        },
        {
          mojom = "media.stable.mojom.Status"
          cpp = "::media::DecoderStatus"
        },
        {
          mojom = "media.stable.mojom.SubsampleEntry"
          cpp = "::media::SubsampleEntry"
        },
        {
          mojom = "media.stable.mojom.SupportedVideoDecoderConfig"
          cpp = "::media::SupportedVideoDecoderConfig"
        },
        {
          mojom = "media.stable.mojom.VideoCodec"
          cpp = "::media::VideoCodec"
        },
        {
          mojom = "media.stable.mojom.VideoCodecProfile"
          cpp = "::media::VideoCodecProfile"
        },
        {
          mojom = "media.stable.mojom.VideoDecoderConfig"
          cpp = "::media::VideoDecoderConfig"
        },
        {
          mojom = "media.stable.mojom.VideoDecoderType"
          cpp = "::media::VideoDecoderType"
        },
        {
          mojom = "media.stable.mojom.VideoFrameMetadata"
          cpp = "::media::VideoFrameMetadata"
        },
        {
          mojom = "media.stable.mojom.VideoPixelFormat"
          cpp = "::media::VideoPixelFormat"
        },
        {
          mojom = "media.stable.mojom.WaitingReason"
          cpp = "::media::WaitingReason"
        },
      ]
      traits_headers = [ "stable_video_decoder_types_mojom_traits.h" ]
      traits_sources = [ "stable_video_decoder_types_mojom_traits.cc" ]
      traits_public_deps = [ "//media" ]

      if (use_vaapi) {
        traits_deps = [ "//media/gpu/vaapi:vaapi_status" ]
      } else if (use_v4l2_codec) {
        traits_deps = [ "//media/gpu/v4l2:v4l2_status" ]
      }
    },
  ]
}

mojom("native_pixmap_handle") {
  generate_java = true

  sources = [ "native_pixmap_handle.mojom" ]

  if (is_linux || is_chromeos) {
    cpp_typemaps = [
      {
        types = [
          {
            mojom = "media.stable.mojom.NativePixmapHandle"
            cpp = "::gfx::NativePixmapHandle"
            move_only = true
          },
          {
            mojom = "media.stable.mojom.NativePixmapPlane"
            cpp = "::gfx::NativePixmapPlane"
            move_only = true
          },
        ]
        traits_headers = [
          "native_pixmap_handle_mojom_traits.h",
          "//ui/gfx/native_pixmap_handle.h",
        ]
        traits_sources = [ "native_pixmap_handle_mojom_traits.cc" ]
        traits_public_deps = [ "//ui/gfx:memory_buffer" ]
      },
    ]
  }
}

source_set("unit_tests") {
  testonly = true
  sources = [ "stable_video_decoder_types_mojom_traits_unittest.cc" ]
  deps = [
    ":stable_video_decoder",
    "//testing/gtest",
  ]
  if (use_vaapi) {
    deps += [ "//media/gpu/vaapi:vaapi_status" ]
  } else if (use_v4l2_codec) {
    deps += [ "//media/gpu/v4l2:v4l2_status" ]
  }
  if (is_linux || is_chromeos) {
    sources += [
      "mojom_traits_test_util.cc",
      "mojom_traits_test_util.h",
      "native_pixmap_handle_mojom_traits_unittest.cc",
    ]
    deps += [ "//base/test:test_support" ]
  }
}