// media/mojo/mojom/video_decoder.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/video_decoder.mojom-shared.h"
#include <utility>
#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/video_decoder.mojom-params-data.h"
namespace media {
namespace mojom {

namespace internal {
// static
bool Cdm_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context,
    bool inlined) {
  if (!data) {
    DCHECK(!inlined);
    return true;
  }

  // If it is inlined, the alignment is already enforced by its enclosing
  // object. We don't have to validate that.
  DCHECK(!inlined || mojo::internal::IsAligned(data));

  if (!inlined &&
      !mojo::internal::ValidateNonInlinedUnionHeaderAndClaimMemory(
          data, validation_context)) {
    return false;
  }

  const Cdm_Data* object = static_cast<const Cdm_Data*>(data);

  if (inlined && object->is_null())
    return true;

  switch (object->tag) {

    case Cdm_Tag::kCdmId: {

      if (!mojo::internal::ValidatePointerNonNullable(
              object->data.f_cdm_id, 1, validation_context)) {
        return false;
      }
      if (!mojo::internal::ValidateStruct(object->data.f_cdm_id, validation_context))
        return false;
      return true;
    }
    case Cdm_Tag::kCdmContext: {

      if (!mojo::internal::ValidateHandleOrInterfaceNonNullable(
              object->data.f_cdm_context, 2, validation_context)) {
        return false;
      }
      if (!mojo::internal::ValidateHandleOrInterface(object->data.f_cdm_context,
                                                     validation_context)) {
        return false;
      }
      return true;
    }
    default: {

      ReportValidationError(
          validation_context,
          mojo::internal::VALIDATION_ERROR_UNKNOWN_UNION_TAG,
          "unknown tag in Cdm");
      return false;
    }
  }
}


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


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


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

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

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

  return true;
}

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


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

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

  return true;
}

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


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

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

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

  return true;
}

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


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

  return true;
}

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


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

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


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

  return true;
}

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


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

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

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

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

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

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

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

  return true;
}

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


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

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

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

  return true;
}

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


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

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


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

  return true;
}

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


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

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

  return true;
}

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


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

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

  return true;
}

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


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

  return true;
}

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


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

  return true;
}

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


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

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

  return true;
}

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


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

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

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

  return true;
}

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


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


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

  return true;
}

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


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

  return true;
}

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

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