1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51

media / mojo / mojom / key_system_capability_mojom_traits.h [blame]

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

#ifndef MEDIA_MOJO_MOJOM_KEY_SYSTEM_CAPABILITY_MOJOM_TRAITS_H_
#define MEDIA_MOJO_MOJOM_KEY_SYSTEM_CAPABILITY_MOJOM_TRAITS_H_

#include "media/base/cdm_capability.h"
#include "media/base/key_system_capability.h"
#include "media/mojo/mojom/key_system_support.mojom.h"

namespace mojo {

template <>
struct StructTraits<media::mojom::KeySystemCapabilityDataView,
                    media::KeySystemCapability> {
  static const std::optional<media::CdmCapability> sw_secure_capability(
      const media::KeySystemCapability& input) {
    return input.sw_cdm_capability_or_status.has_value()
               ? std::optional(input.sw_cdm_capability_or_status.value())
               : std::nullopt;
  }

  static const std::optional<media::CdmCapability> hw_secure_capability(
      const media::KeySystemCapability& input) {
    return input.hw_cdm_capability_or_status.has_value()
               ? std::optional(input.hw_cdm_capability_or_status.value())
               : std::nullopt;
  }

  static const std::optional<media::CdmCapabilityQueryStatus>
  sw_secure_capability_query_status(const media::KeySystemCapability& input) {
    return input.sw_cdm_capability_or_status.has_value()
               ? std::nullopt
               : std::optional(input.sw_cdm_capability_or_status.error());
  }

  static const std::optional<media::CdmCapabilityQueryStatus>
  hw_secure_capability_query_status(const media::KeySystemCapability& input) {
    return input.hw_cdm_capability_or_status.has_value()
               ? std::nullopt
               : std::optional(input.hw_cdm_capability_or_status.error());
  }

  static bool Read(media::mojom::KeySystemCapabilityDataView input,
                   media::KeySystemCapability* output);
};

}  // namespace mojo

#endif  // MEDIA_MOJO_MOJOM_KEY_SYSTEM_CAPABILITY_MOJOM_TRAITS_H_