// media/mojo/mojom/output_protection.mojom-shared.cc is auto generated by mojom_bindings_generator.py, do not edit

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

#include "media/mojo/mojom/output_protection.mojom-shared.h"
#include <utility>
#include "base/strings/stringprintf.h"
#include "mojo/public/cpp/bindings/lib/validate_params.h"
#include "mojo/public/cpp/bindings/lib/validation_errors.h"
#include "mojo/public/cpp/bindings/lib/validation_util.h"
#include "third_party/perfetto/include/perfetto/tracing/traced_value.h"

#include "media/mojo/mojom/output_protection.mojom-params-data.h"
namespace media {
namespace mojom {

NOINLINE static const char* OutputProtection_ProtectionTypeToStringHelper(OutputProtection_ProtectionType value) {
  // Defined in a helper function to ensure that Clang generates a lookup table.
  switch(value) {
    case OutputProtection_ProtectionType::NONE:
      return "NONE";
    case OutputProtection_ProtectionType::HDCP:
      return "HDCP";
    default:
      return nullptr;
  }
}

std::string OutputProtection_ProtectionTypeToString(OutputProtection_ProtectionType value) {
  const char *str = OutputProtection_ProtectionTypeToStringHelper(value);
  if (!str) {
    return base::StringPrintf("Unknown OutputProtection_ProtectionType value: %i", static_cast<int32_t>(value));
  }
  return str;
}

std::ostream& operator<<(std::ostream& os, OutputProtection_ProtectionType value) {
  return os << OutputProtection_ProtectionTypeToString(value);
}

NOINLINE static const char* OutputProtection_LinkTypeToStringHelper(OutputProtection_LinkType value) {
  // Defined in a helper function to ensure that Clang generates a lookup table.
  switch(value) {
    case OutputProtection_LinkType::NONE:
      return "NONE";
    case OutputProtection_LinkType::UNKNOWN:
      return "UNKNOWN";
    case OutputProtection_LinkType::INTERNAL:
      return "INTERNAL";
    case OutputProtection_LinkType::VGA:
      return "VGA";
    case OutputProtection_LinkType::HDMI:
      return "HDMI";
    case OutputProtection_LinkType::DVI:
      return "DVI";
    case OutputProtection_LinkType::DISPLAYPORT:
      return "DISPLAYPORT";
    case OutputProtection_LinkType::NETWORK:
      return "NETWORK";
    default:
      return nullptr;
  }
}

std::string OutputProtection_LinkTypeToString(OutputProtection_LinkType value) {
  const char *str = OutputProtection_LinkTypeToStringHelper(value);
  if (!str) {
    return base::StringPrintf("Unknown OutputProtection_LinkType value: %i", static_cast<int32_t>(value));
  }
  return str;
}

std::ostream& operator<<(std::ostream& os, OutputProtection_LinkType value) {
  return os << OutputProtection_LinkTypeToString(value);
}

namespace internal {


// static
bool OutputProtection_QueryStatus_Params_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 8, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const OutputProtection_QueryStatus_Params_Data* object =
      static_cast<const OutputProtection_QueryStatus_Params_Data*>(data);

  return true;
}

OutputProtection_QueryStatus_Params_Data::OutputProtection_QueryStatus_Params_Data()
    : header_({sizeof(*this), 0}) {}


// static
bool OutputProtection_QueryStatus_ResponseParams_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 24, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const OutputProtection_QueryStatus_ResponseParams_Data* object =
      static_cast<const OutputProtection_QueryStatus_ResponseParams_Data*>(data);

  return true;
}

OutputProtection_QueryStatus_ResponseParams_Data::OutputProtection_QueryStatus_ResponseParams_Data()
    : header_({sizeof(*this), 0}) {}


// static
bool OutputProtection_EnableProtection_Params_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 16, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const OutputProtection_EnableProtection_Params_Data* object =
      static_cast<const OutputProtection_EnableProtection_Params_Data*>(data);

  return true;
}

OutputProtection_EnableProtection_Params_Data::OutputProtection_EnableProtection_Params_Data()
    : header_({sizeof(*this), 0}) {}


// static
bool OutputProtection_EnableProtection_ResponseParams_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 16, validation_context)) {
    return false;
  }

  // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if
  // the message comes from an older version.
  [[maybe_unused]] const OutputProtection_EnableProtection_ResponseParams_Data* object =
      static_cast<const OutputProtection_EnableProtection_ResponseParams_Data*>(data);

  return true;
}

OutputProtection_EnableProtection_ResponseParams_Data::OutputProtection_EnableProtection_ResponseParams_Data()
    : header_({sizeof(*this), 0}) {}

}  // namespace internal
}  // namespace mojom
}  // namespace media

namespace perfetto {

// static
void TraceFormatTraits<::media::mojom::OutputProtection_ProtectionType>::WriteIntoTrace(
   perfetto::TracedValue context, ::media::mojom::OutputProtection_ProtectionType value) {
  return std::move(context).WriteString(::media::mojom::OutputProtection_ProtectionTypeToString(value));
}

} // namespace perfetto

namespace perfetto {

// static
void TraceFormatTraits<::media::mojom::OutputProtection_LinkType>::WriteIntoTrace(
   perfetto::TracedValue context, ::media::mojom::OutputProtection_LinkType value) {
  return std::move(context).WriteString(::media::mojom::OutputProtection_LinkTypeToString(value));
}

} // namespace perfetto