blob: 53cc74ae344ba7e9be10e6e1c67305bfeb1fdacf [file] [log] [blame]
// components/chromeos_camera/common/dmabuf.mojom.h is auto generated by mojom_bindings_generator.py, do not edit
// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_CHROMEOS_CAMERA_COMMON_DMABUF_MOJOM_H_
#define COMPONENTS_CHROMEOS_CAMERA_COMMON_DMABUF_MOJOM_H_
#include <stdint.h>
#include <limits>
#include <optional>
#include <type_traits>
#include <utility>
#include "base/types/cxx23_to_underlying.h"
#include "mojo/public/cpp/bindings/clone_traits.h"
#include "mojo/public/cpp/bindings/equals_traits.h"
#include "mojo/public/cpp/bindings/lib/serialization.h"
#include "mojo/public/cpp/bindings/struct_ptr.h"
#include "mojo/public/cpp/bindings/struct_traits.h"
#include "mojo/public/cpp/bindings/union_traits.h"
#include "third_party/perfetto/include/perfetto/tracing/traced_value_forward.h"
#include "components/chromeos_camera/common/dmabuf.mojom-features.h"
#include "components/chromeos_camera/common/dmabuf.mojom-shared.h"
#include "components/chromeos_camera/common/dmabuf.mojom-forward.h"
#include "media/mojo/mojom/media_types.mojom.h"
#include <string>
#include <vector>
#include "mojo/public/cpp/bindings/lib/control_message_handler.h"
#include "mojo/public/cpp/bindings/lib/message_size_estimator.h"
#include "mojo/public/cpp/bindings/raw_ptr_impl_ref_traits.h"
#include "mojo/public/cpp/bindings/lib/native_enum_serialization.h"
#include "mojo/public/cpp/bindings/lib/native_struct_serialization.h"
namespace chromeos_camera::mojom {
class DmaBufPlane {
public:
template <typename T>
using EnableIfSame = std::enable_if_t<std::is_same<DmaBufPlane, T>::value>;
using DataView = DmaBufPlaneDataView;
using Data_ = internal::DmaBufPlane_Data;
template <typename... Args>
static DmaBufPlanePtr New(Args&&... args) {
return DmaBufPlanePtr(
std::in_place, std::forward<Args>(args)...);
}
template <typename U>
static DmaBufPlanePtr From(const U& u) {
return mojo::TypeConverter<DmaBufPlanePtr, U>::Convert(u);
}
template <typename U>
U To() const {
return mojo::TypeConverter<U, DmaBufPlane>::Convert(*this);
}
DmaBufPlane();
DmaBufPlane(
::mojo::ScopedHandle fd_handle,
int32_t stride,
uint32_t offset,
uint32_t size);
DmaBufPlane(const DmaBufPlane&) = delete;
DmaBufPlane& operator=(const DmaBufPlane&) = delete;
~DmaBufPlane();
// Clone() is a template so it is only instantiated if it is used. Thus, the
// bindings generator does not need to know whether Clone() or copy
// constructor/assignment are available for members.
template <typename StructPtrType = DmaBufPlanePtr>
DmaBufPlanePtr Clone() const;
// Equals() is a template so it is only instantiated if it is used. Thus, the
// bindings generator does not need to know whether Equals() or == operator
// are available for members.
template <typename T, DmaBufPlane::EnableIfSame<T>* = nullptr>
bool Equals(const T& other) const;
template <typename T, DmaBufPlane::EnableIfSame<T>* = nullptr>
bool operator==(const T& rhs) const { return Equals(rhs); }
template <typename T, DmaBufPlane::EnableIfSame<T>* = nullptr>
bool operator!=(const T& rhs) const { return !operator==(rhs); }
template <typename UserType>
static mojo::Message SerializeAsMessage(UserType* input) {
return mojo::internal::SerializeAsMessageImpl<
DmaBufPlane::DataView>(input);
}
// The returned Message is serialized only if the message is moved
// cross-process or cross-language. Otherwise if the message is Deserialized
// as the same UserType |input| will just be moved to |output| in
// DeserializeFromMessage.
template <typename UserType>
static mojo::Message WrapAsMessage(UserType input) {
return mojo::Message(std::make_unique<
internal::DmaBufPlane_UnserializedMessageContext<
UserType, DmaBufPlane::DataView>>(0, 0, std::move(input)),
MOJO_CREATE_MESSAGE_FLAG_NONE);
}
template <typename UserType>
static bool Deserialize(const void* data,
size_t data_num_bytes,
UserType* output) {
mojo::Message message;
return mojo::internal::DeserializeImpl<DmaBufPlane::DataView>(
message, data, data_num_bytes, output, Validate);
}
template <typename UserType>
static bool Deserialize(const std::vector<uint8_t>& input,
UserType* output) {
return DmaBufPlane::Deserialize(
input.size() == 0 ? nullptr : &input.front(), input.size(), output);
}
template <typename UserType>
static bool DeserializeFromMessage(mojo::Message input,
UserType* output) {
auto context = input.TakeUnserializedContext<
internal::DmaBufPlane_UnserializedMessageContext<
UserType, DmaBufPlane::DataView>>();
if (context) {
*output = std::move(context->TakeData());
return true;
}
input.SerializeIfNecessary();
return mojo::internal::DeserializeImpl<DmaBufPlane::DataView>(
input, input.payload(), input.payload_num_bytes(), output, Validate);
}
::mojo::ScopedHandle fd_handle;
int32_t stride;
uint32_t offset;
uint32_t size;
// Serialise this struct into a trace.
void WriteIntoTrace(perfetto::TracedValue traced_context) const;
private:
static bool Validate(const void* data,
mojo::internal::ValidationContext* validation_context);
};
// The comparison operators are templates, so they are only instantiated if they
// are used. Thus, the bindings generator does not need to know whether
// comparison operators are available for members.
template <typename T, DmaBufPlane::EnableIfSame<T>* = nullptr>
bool operator<(const T& lhs, const T& rhs);
template <typename T, DmaBufPlane::EnableIfSame<T>* = nullptr>
bool operator<=(const T& lhs, const T& rhs) {
return !(rhs < lhs);
}
template <typename T, DmaBufPlane::EnableIfSame<T>* = nullptr>
bool operator>(const T& lhs, const T& rhs) {
return rhs < lhs;
}
template <typename T, DmaBufPlane::EnableIfSame<T>* = nullptr>
bool operator>=(const T& lhs, const T& rhs) {
return !(lhs < rhs);
}
class DmaBufVideoFrame {
public:
template <typename T>
using EnableIfSame = std::enable_if_t<std::is_same<DmaBufVideoFrame, T>::value>;
using DataView = DmaBufVideoFrameDataView;
using Data_ = internal::DmaBufVideoFrame_Data;
template <typename... Args>
static DmaBufVideoFramePtr New(Args&&... args) {
return DmaBufVideoFramePtr(
std::in_place, std::forward<Args>(args)...);
}
template <typename U>
static DmaBufVideoFramePtr From(const U& u) {
return mojo::TypeConverter<DmaBufVideoFramePtr, U>::Convert(u);
}
template <typename U>
U To() const {
return mojo::TypeConverter<U, DmaBufVideoFrame>::Convert(*this);
}
DmaBufVideoFrame();
DmaBufVideoFrame(
::media::VideoPixelFormat format,
uint32_t coded_width,
uint32_t coded_height,
std::vector<DmaBufPlanePtr> planes);
DmaBufVideoFrame(
::media::VideoPixelFormat format,
uint32_t coded_width,
uint32_t coded_height,
std::vector<DmaBufPlanePtr> planes,
bool has_modifier,
uint64_t modifier);
DmaBufVideoFrame(const DmaBufVideoFrame&) = delete;
DmaBufVideoFrame& operator=(const DmaBufVideoFrame&) = delete;
~DmaBufVideoFrame();
// Clone() is a template so it is only instantiated if it is used. Thus, the
// bindings generator does not need to know whether Clone() or copy
// constructor/assignment are available for members.
template <typename StructPtrType = DmaBufVideoFramePtr>
DmaBufVideoFramePtr Clone() const;
// Equals() is a template so it is only instantiated if it is used. Thus, the
// bindings generator does not need to know whether Equals() or == operator
// are available for members.
template <typename T, DmaBufVideoFrame::EnableIfSame<T>* = nullptr>
bool Equals(const T& other) const;
template <typename T, DmaBufVideoFrame::EnableIfSame<T>* = nullptr>
bool operator==(const T& rhs) const { return Equals(rhs); }
template <typename T, DmaBufVideoFrame::EnableIfSame<T>* = nullptr>
bool operator!=(const T& rhs) const { return !operator==(rhs); }
template <typename UserType>
static mojo::Message SerializeAsMessage(UserType* input) {
return mojo::internal::SerializeAsMessageImpl<
DmaBufVideoFrame::DataView>(input);
}
// The returned Message is serialized only if the message is moved
// cross-process or cross-language. Otherwise if the message is Deserialized
// as the same UserType |input| will just be moved to |output| in
// DeserializeFromMessage.
template <typename UserType>
static mojo::Message WrapAsMessage(UserType input) {
return mojo::Message(std::make_unique<
internal::DmaBufVideoFrame_UnserializedMessageContext<
UserType, DmaBufVideoFrame::DataView>>(0, 0, std::move(input)),
MOJO_CREATE_MESSAGE_FLAG_NONE);
}
template <typename UserType>
static bool Deserialize(const void* data,
size_t data_num_bytes,
UserType* output) {
mojo::Message message;
return mojo::internal::DeserializeImpl<DmaBufVideoFrame::DataView>(
message, data, data_num_bytes, output, Validate);
}
template <typename UserType>
static bool Deserialize(const std::vector<uint8_t>& input,
UserType* output) {
return DmaBufVideoFrame::Deserialize(
input.size() == 0 ? nullptr : &input.front(), input.size(), output);
}
template <typename UserType>
static bool DeserializeFromMessage(mojo::Message input,
UserType* output) {
auto context = input.TakeUnserializedContext<
internal::DmaBufVideoFrame_UnserializedMessageContext<
UserType, DmaBufVideoFrame::DataView>>();
if (context) {
*output = std::move(context->TakeData());
return true;
}
input.SerializeIfNecessary();
return mojo::internal::DeserializeImpl<DmaBufVideoFrame::DataView>(
input, input.payload(), input.payload_num_bytes(), output, Validate);
}
::media::VideoPixelFormat format;
uint32_t coded_width;
uint32_t coded_height;
std::vector<DmaBufPlanePtr> planes;
bool has_modifier;
uint64_t modifier;
// Serialise this struct into a trace.
void WriteIntoTrace(perfetto::TracedValue traced_context) const;
private:
static bool Validate(const void* data,
mojo::internal::ValidationContext* validation_context);
};
// The comparison operators are templates, so they are only instantiated if they
// are used. Thus, the bindings generator does not need to know whether
// comparison operators are available for members.
template <typename T, DmaBufVideoFrame::EnableIfSame<T>* = nullptr>
bool operator<(const T& lhs, const T& rhs);
template <typename T, DmaBufVideoFrame::EnableIfSame<T>* = nullptr>
bool operator<=(const T& lhs, const T& rhs) {
return !(rhs < lhs);
}
template <typename T, DmaBufVideoFrame::EnableIfSame<T>* = nullptr>
bool operator>(const T& lhs, const T& rhs) {
return rhs < lhs;
}
template <typename T, DmaBufVideoFrame::EnableIfSame<T>* = nullptr>
bool operator>=(const T& lhs, const T& rhs) {
return !(lhs < rhs);
}
template <typename StructPtrType>
DmaBufPlanePtr DmaBufPlane::Clone() const {
return New(
mojo::Clone(fd_handle),
mojo::Clone(stride),
mojo::Clone(offset),
mojo::Clone(size)
);
}
template <typename T, DmaBufPlane::EnableIfSame<T>*>
bool DmaBufPlane::Equals(const T& other_struct) const {
if (!mojo::Equals(this->fd_handle, other_struct.fd_handle))
return false;
if (!mojo::Equals(this->stride, other_struct.stride))
return false;
if (!mojo::Equals(this->offset, other_struct.offset))
return false;
if (!mojo::Equals(this->size, other_struct.size))
return false;
return true;
}
template <typename T, DmaBufPlane::EnableIfSame<T>*>
bool operator<(const T& lhs, const T& rhs) {
if (lhs.fd_handle < rhs.fd_handle)
return true;
if (rhs.fd_handle < lhs.fd_handle)
return false;
if (lhs.stride < rhs.stride)
return true;
if (rhs.stride < lhs.stride)
return false;
if (lhs.offset < rhs.offset)
return true;
if (rhs.offset < lhs.offset)
return false;
if (lhs.size < rhs.size)
return true;
if (rhs.size < lhs.size)
return false;
return false;
}
template <typename StructPtrType>
DmaBufVideoFramePtr DmaBufVideoFrame::Clone() const {
return New(
mojo::Clone(format),
mojo::Clone(coded_width),
mojo::Clone(coded_height),
mojo::Clone(planes),
mojo::Clone(has_modifier),
mojo::Clone(modifier)
);
}
template <typename T, DmaBufVideoFrame::EnableIfSame<T>*>
bool DmaBufVideoFrame::Equals(const T& other_struct) const {
if (!mojo::Equals(this->format, other_struct.format))
return false;
if (!mojo::Equals(this->coded_width, other_struct.coded_width))
return false;
if (!mojo::Equals(this->coded_height, other_struct.coded_height))
return false;
if (!mojo::Equals(this->planes, other_struct.planes))
return false;
if (!mojo::Equals(this->has_modifier, other_struct.has_modifier))
return false;
if (!mojo::Equals(this->modifier, other_struct.modifier))
return false;
return true;
}
template <typename T, DmaBufVideoFrame::EnableIfSame<T>*>
bool operator<(const T& lhs, const T& rhs) {
if (lhs.format < rhs.format)
return true;
if (rhs.format < lhs.format)
return false;
if (lhs.coded_width < rhs.coded_width)
return true;
if (rhs.coded_width < lhs.coded_width)
return false;
if (lhs.coded_height < rhs.coded_height)
return true;
if (rhs.coded_height < lhs.coded_height)
return false;
if (lhs.planes < rhs.planes)
return true;
if (rhs.planes < lhs.planes)
return false;
if (lhs.has_modifier < rhs.has_modifier)
return true;
if (rhs.has_modifier < lhs.has_modifier)
return false;
if (lhs.modifier < rhs.modifier)
return true;
if (rhs.modifier < lhs.modifier)
return false;
return false;
}
} // chromeos_camera::mojom
namespace mojo {
template <>
struct StructTraits<::chromeos_camera::mojom::DmaBufPlane::DataView,
::chromeos_camera::mojom::DmaBufPlanePtr> {
static bool IsNull(const ::chromeos_camera::mojom::DmaBufPlanePtr& input) { return !input; }
static void SetToNull(::chromeos_camera::mojom::DmaBufPlanePtr* output) { output->reset(); }
static decltype(::chromeos_camera::mojom::DmaBufPlane::fd_handle)& fd_handle(
::chromeos_camera::mojom::DmaBufPlanePtr& input) {
return input->fd_handle;
}
static decltype(::chromeos_camera::mojom::DmaBufPlane::stride) stride(
const ::chromeos_camera::mojom::DmaBufPlanePtr& input) {
return input->stride;
}
static decltype(::chromeos_camera::mojom::DmaBufPlane::offset) offset(
const ::chromeos_camera::mojom::DmaBufPlanePtr& input) {
return input->offset;
}
static decltype(::chromeos_camera::mojom::DmaBufPlane::size) size(
const ::chromeos_camera::mojom::DmaBufPlanePtr& input) {
return input->size;
}
static bool Read(::chromeos_camera::mojom::DmaBufPlane::DataView input, ::chromeos_camera::mojom::DmaBufPlanePtr* output);
};
template <>
struct StructTraits<::chromeos_camera::mojom::DmaBufVideoFrame::DataView,
::chromeos_camera::mojom::DmaBufVideoFramePtr> {
static bool IsNull(const ::chromeos_camera::mojom::DmaBufVideoFramePtr& input) { return !input; }
static void SetToNull(::chromeos_camera::mojom::DmaBufVideoFramePtr* output) { output->reset(); }
static decltype(::chromeos_camera::mojom::DmaBufVideoFrame::format) format(
const ::chromeos_camera::mojom::DmaBufVideoFramePtr& input) {
return input->format;
}
static decltype(::chromeos_camera::mojom::DmaBufVideoFrame::coded_width) coded_width(
const ::chromeos_camera::mojom::DmaBufVideoFramePtr& input) {
return input->coded_width;
}
static decltype(::chromeos_camera::mojom::DmaBufVideoFrame::coded_height) coded_height(
const ::chromeos_camera::mojom::DmaBufVideoFramePtr& input) {
return input->coded_height;
}
static decltype(::chromeos_camera::mojom::DmaBufVideoFrame::planes)& planes(
::chromeos_camera::mojom::DmaBufVideoFramePtr& input) {
return input->planes;
}
static decltype(::chromeos_camera::mojom::DmaBufVideoFrame::has_modifier) has_modifier(
const ::chromeos_camera::mojom::DmaBufVideoFramePtr& input) {
return input->has_modifier;
}
static decltype(::chromeos_camera::mojom::DmaBufVideoFrame::modifier) modifier(
const ::chromeos_camera::mojom::DmaBufVideoFramePtr& input) {
return input->modifier;
}
static bool Read(::chromeos_camera::mojom::DmaBufVideoFrame::DataView input, ::chromeos_camera::mojom::DmaBufVideoFramePtr* output);
};
} // namespace mojo
#endif // COMPONENTS_CHROMEOS_CAMERA_COMMON_DMABUF_MOJOM_H_