// media/mojo/mojom/decryptor.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/decryptor.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/decryptor.mojom-params-data.h"
namespace media {
namespace mojom {

namespace internal {


// static
bool Decryptor_Initialize_Params_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 Decryptor_Initialize_Params_Data* object =
      static_cast<const Decryptor_Initialize_Params_Data*>(data);

  if (!mojo::internal::ValidateHandleOrInterfaceNonNullable(
          object->audio_pipe, 1, validation_context)) {
    return false;
  }
  if (!mojo::internal::ValidateHandleOrInterface(object->audio_pipe,
                                                 validation_context)) {
    return false;
  }

  if (!mojo::internal::ValidateHandleOrInterfaceNonNullable(
          object->video_pipe, 2, validation_context)) {
    return false;
  }
  if (!mojo::internal::ValidateHandleOrInterface(object->video_pipe,
                                                 validation_context)) {
    return false;
  }

  if (!mojo::internal::ValidateHandleOrInterfaceNonNullable(
          object->decrypt_pipe, 3, validation_context)) {
    return false;
  }
  if (!mojo::internal::ValidateHandleOrInterface(object->decrypt_pipe,
                                                 validation_context)) {
    return false;
  }

  if (!mojo::internal::ValidateHandleOrInterfaceNonNullable(
          object->decrypted_pipe, 4, validation_context)) {
    return false;
  }
  if (!mojo::internal::ValidateHandleOrInterface(object->decrypted_pipe,
                                                 validation_context)) {
    return false;
  }

  return true;
}

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


// static
bool Decryptor_Decrypt_Params_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 32, 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 Decryptor_Decrypt_Params_Data* object =
      static_cast<const Decryptor_Decrypt_Params_Data*>(data);


  if (!::media::mojom::internal::Decryptor_StreamType_Data
        ::Validate(object->stream_type, validation_context))
    return false;

  if (!mojo::internal::ValidateInlinedUnionNonNullable(
          object->encrypted, 2, validation_context)) {
    return false;
  }
  if (!mojo::internal::ValidateInlinedUnion(object->encrypted, validation_context))
    return false;

  return true;
}

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


// static
bool Decryptor_Decrypt_ResponseParams_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 32, 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 Decryptor_Decrypt_ResponseParams_Data* object =
      static_cast<const Decryptor_Decrypt_ResponseParams_Data*>(data);


  if (!::media::mojom::internal::Decryptor_Status_Data
        ::Validate(object->status, validation_context))
    return false;

  if (!mojo::internal::ValidateInlinedUnion(object->buffer, validation_context))
    return false;

  return true;
}

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


// static
bool Decryptor_CancelDecrypt_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 Decryptor_CancelDecrypt_Params_Data* object =
      static_cast<const Decryptor_CancelDecrypt_Params_Data*>(data);


  if (!::media::mojom::internal::Decryptor_StreamType_Data
        ::Validate(object->stream_type, validation_context))
    return false;

  return true;
}

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


// static
bool Decryptor_InitializeAudioDecoder_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 Decryptor_InitializeAudioDecoder_Params_Data* object =
      static_cast<const Decryptor_InitializeAudioDecoder_Params_Data*>(data);

  if (!mojo::internal::ValidatePointerNonNullable(
          object->config, 1, validation_context)) {
    return false;
  }
  if (!mojo::internal::ValidateStruct(object->config, validation_context))
    return false;

  return true;
}

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


// static
bool Decryptor_InitializeAudioDecoder_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 Decryptor_InitializeAudioDecoder_ResponseParams_Data* object =
      static_cast<const Decryptor_InitializeAudioDecoder_ResponseParams_Data*>(data);

  return true;
}

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


// static
bool Decryptor_InitializeVideoDecoder_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 Decryptor_InitializeVideoDecoder_Params_Data* object =
      static_cast<const Decryptor_InitializeVideoDecoder_Params_Data*>(data);

  if (!mojo::internal::ValidatePointerNonNullable(
          object->config, 1, validation_context)) {
    return false;
  }
  if (!mojo::internal::ValidateStruct(object->config, validation_context))
    return false;

  return true;
}

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


// static
bool Decryptor_InitializeVideoDecoder_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 Decryptor_InitializeVideoDecoder_ResponseParams_Data* object =
      static_cast<const Decryptor_InitializeVideoDecoder_ResponseParams_Data*>(data);

  return true;
}

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


// static
bool Decryptor_DecryptAndDecodeAudio_Params_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 Decryptor_DecryptAndDecodeAudio_Params_Data* object =
      static_cast<const Decryptor_DecryptAndDecodeAudio_Params_Data*>(data);

  if (!mojo::internal::ValidateInlinedUnionNonNullable(
          object->encrypted, 1, validation_context)) {
    return false;
  }
  if (!mojo::internal::ValidateInlinedUnion(object->encrypted, validation_context))
    return false;

  return true;
}

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


// static
bool Decryptor_DecryptAndDecodeAudio_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 Decryptor_DecryptAndDecodeAudio_ResponseParams_Data* object =
      static_cast<const Decryptor_DecryptAndDecodeAudio_ResponseParams_Data*>(data);


  if (!::media::mojom::internal::Decryptor_Status_Data
        ::Validate(object->status, validation_context))
    return false;

  if (!mojo::internal::ValidatePointerNonNullable(
          object->audio_buffers, 2, validation_context)) {
    return false;
  }
  constexpr const mojo::internal::ContainerValidateParams& audio_buffers_validate_params =
      mojo::internal::GetArrayValidator<0, false, nullptr>();
  if (!mojo::internal::ValidateContainer(object->audio_buffers, validation_context,
                                         &audio_buffers_validate_params)) {
    return false;
  }

  return true;
}

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


// static
bool Decryptor_DecryptAndDecodeVideo_Params_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 Decryptor_DecryptAndDecodeVideo_Params_Data* object =
      static_cast<const Decryptor_DecryptAndDecodeVideo_Params_Data*>(data);

  if (!mojo::internal::ValidateInlinedUnionNonNullable(
          object->encrypted, 1, validation_context)) {
    return false;
  }
  if (!mojo::internal::ValidateInlinedUnion(object->encrypted, validation_context))
    return false;

  return true;
}

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


// static
bool Decryptor_DecryptAndDecodeVideo_ResponseParams_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 32, 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 Decryptor_DecryptAndDecodeVideo_ResponseParams_Data* object =
      static_cast<const Decryptor_DecryptAndDecodeVideo_ResponseParams_Data*>(data);


  if (!::media::mojom::internal::Decryptor_Status_Data
        ::Validate(object->status, validation_context))
    return false;

  if (!mojo::internal::ValidateStruct(object->video_frame, validation_context))
    return false;

  if (!mojo::internal::ValidateHandleOrInterface(object->releaser,
                                                 validation_context)) {
    return false;
  }

  return true;
}

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


// static
bool Decryptor_ResetDecoder_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 Decryptor_ResetDecoder_Params_Data* object =
      static_cast<const Decryptor_ResetDecoder_Params_Data*>(data);


  if (!::media::mojom::internal::Decryptor_StreamType_Data
        ::Validate(object->stream_type, validation_context))
    return false;

  return true;
}

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


// static
bool Decryptor_DeinitializeDecoder_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 Decryptor_DeinitializeDecoder_Params_Data* object =
      static_cast<const Decryptor_DeinitializeDecoder_Params_Data*>(data);


  if (!::media::mojom::internal::Decryptor_StreamType_Data
        ::Validate(object->stream_type, validation_context))
    return false;

  return true;
}

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

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