blob: 3be40b687764efeb9497696d1b3ca21750abd07c [file] [log] [blame]
// camera/mojo/camera_diagnostics.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 CAMERA_MOJO_CAMERA_DIAGNOSTICS_MOJOM_H_
#define CAMERA_MOJO_CAMERA_DIAGNOSTICS_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 "camera/mojo/camera_diagnostics.mojom-features.h"
#include "camera/mojo/camera_diagnostics.mojom-shared.h"
#include "camera/mojo/camera_diagnostics.mojom-forward.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"
namespace cros::camera_diag::mojom {
class CameraDiagnosticsProxy;
template <typename ImplRefTraits>
class CameraDiagnosticsStub;
class CameraDiagnosticsRequestValidator;
class CameraDiagnosticsResponseValidator;
class CameraDiagnostics
: public CameraDiagnosticsInterfaceBase {
public:
using IPCStableHashFunction = uint32_t(*)();
static const char Name_[];
static IPCStableHashFunction MessageToMethodInfo_(mojo::Message& message);
static const char* MessageToMethodName_(mojo::Message& message);
static constexpr uint32_t Version_ = 0;
static constexpr bool PassesAssociatedKinds_ = false;
static constexpr bool HasUninterruptableMethods_ = false;
using Base_ = CameraDiagnosticsInterfaceBase;
using Proxy_ = CameraDiagnosticsProxy;
template <typename ImplRefTraits>
using Stub_ = CameraDiagnosticsStub<ImplRefTraits>;
using RequestValidator_ = CameraDiagnosticsRequestValidator;
using ResponseValidator_ = CameraDiagnosticsResponseValidator;
enum MethodMinVersions : uint32_t {
kRunFrameAnalysisMinVersion = 0,
};
// crbug.com/1340245 - this causes binary size bloat on Fuchsia, and we're OK
// with not having this data in traces there.
#if !BUILDFLAG(IS_FUCHSIA)
struct RunFrameAnalysis_Sym {
NOINLINE static uint32_t IPCStableHash();
};
#endif // !BUILDFLAG(IS_FUCHSIA)
virtual ~CameraDiagnostics() = default;
using RunFrameAnalysisCallback = base::OnceCallback<void(FrameAnalysisResultPtr)>;
virtual void RunFrameAnalysis(FrameAnalysisConfigPtr config, RunFrameAnalysisCallback callback) = 0;
};
class CrosCameraDiagnosticsServiceProxy;
template <typename ImplRefTraits>
class CrosCameraDiagnosticsServiceStub;
class CrosCameraDiagnosticsServiceRequestValidator;
class CrosCameraDiagnosticsService
: public CrosCameraDiagnosticsServiceInterfaceBase {
public:
using IPCStableHashFunction = uint32_t(*)();
static const char Name_[];
static IPCStableHashFunction MessageToMethodInfo_(mojo::Message& message);
static const char* MessageToMethodName_(mojo::Message& message);
static constexpr uint32_t Version_ = 0;
static constexpr bool PassesAssociatedKinds_ = false;
static constexpr bool HasUninterruptableMethods_ = false;
using Base_ = CrosCameraDiagnosticsServiceInterfaceBase;
using Proxy_ = CrosCameraDiagnosticsServiceProxy;
template <typename ImplRefTraits>
using Stub_ = CrosCameraDiagnosticsServiceStub<ImplRefTraits>;
using RequestValidator_ = CrosCameraDiagnosticsServiceRequestValidator;
using ResponseValidator_ = mojo::PassThroughFilter;
enum MethodMinVersions : uint32_t {
kSendFrameMinVersion = 0,
};
// crbug.com/1340245 - this causes binary size bloat on Fuchsia, and we're OK
// with not having this data in traces there.
#if !BUILDFLAG(IS_FUCHSIA)
struct SendFrame_Sym {
NOINLINE static uint32_t IPCStableHash();
};
#endif // !BUILDFLAG(IS_FUCHSIA)
virtual ~CrosCameraDiagnosticsService() = default;
virtual void SendFrame(CameraFramePtr frame) = 0;
};
class CrosCameraControllerProxy;
template <typename ImplRefTraits>
class CrosCameraControllerStub;
class CrosCameraControllerRequestValidator;
class CrosCameraControllerResponseValidator;
class CrosCameraController
: public CrosCameraControllerInterfaceBase {
public:
using IPCStableHashFunction = uint32_t(*)();
static const char Name_[];
static IPCStableHashFunction MessageToMethodInfo_(mojo::Message& message);
static const char* MessageToMethodName_(mojo::Message& message);
static constexpr uint32_t Version_ = 0;
static constexpr bool PassesAssociatedKinds_ = false;
static constexpr bool HasUninterruptableMethods_ = false;
using Base_ = CrosCameraControllerInterfaceBase;
using Proxy_ = CrosCameraControllerProxy;
template <typename ImplRefTraits>
using Stub_ = CrosCameraControllerStub<ImplRefTraits>;
using RequestValidator_ = CrosCameraControllerRequestValidator;
using ResponseValidator_ = CrosCameraControllerResponseValidator;
enum MethodMinVersions : uint32_t {
kStartStreamingMinVersion = 0,
kStopStreamingMinVersion = 0,
kRequestFrameMinVersion = 0,
};
// crbug.com/1340245 - this causes binary size bloat on Fuchsia, and we're OK
// with not having this data in traces there.
#if !BUILDFLAG(IS_FUCHSIA)
struct StartStreaming_Sym {
NOINLINE static uint32_t IPCStableHash();
};
struct StopStreaming_Sym {
NOINLINE static uint32_t IPCStableHash();
};
struct RequestFrame_Sym {
NOINLINE static uint32_t IPCStableHash();
};
#endif // !BUILDFLAG(IS_FUCHSIA)
virtual ~CrosCameraController() = default;
using StartStreamingCallback = base::OnceCallback<void(StartStreamingResultPtr)>;
virtual void StartStreaming(StreamingConfigPtr config, StartStreamingCallback callback) = 0;
virtual void StopStreaming() = 0;
virtual void RequestFrame(CameraFramePtr frame) = 0;
};
class CameraDiagnosticsProxy
: public CameraDiagnostics {
public:
using InterfaceType = CameraDiagnostics;
explicit CameraDiagnosticsProxy(mojo::MessageReceiverWithResponder* receiver);
void RunFrameAnalysis(FrameAnalysisConfigPtr config, RunFrameAnalysisCallback callback) final;
private:
mojo::MessageReceiverWithResponder* receiver_;
};
class CrosCameraDiagnosticsServiceProxy
: public CrosCameraDiagnosticsService {
public:
using InterfaceType = CrosCameraDiagnosticsService;
explicit CrosCameraDiagnosticsServiceProxy(mojo::MessageReceiverWithResponder* receiver);
void SendFrame(CameraFramePtr frame) final;
private:
mojo::MessageReceiverWithResponder* receiver_;
};
class CrosCameraControllerProxy
: public CrosCameraController {
public:
using InterfaceType = CrosCameraController;
explicit CrosCameraControllerProxy(mojo::MessageReceiverWithResponder* receiver);
void StartStreaming(StreamingConfigPtr config, StartStreamingCallback callback) final;
void StopStreaming() final;
void RequestFrame(CameraFramePtr frame) final;
private:
mojo::MessageReceiverWithResponder* receiver_;
};
class CameraDiagnosticsStubDispatch {
public:
static bool Accept(CameraDiagnostics* impl, mojo::Message* message);
static bool AcceptWithResponder(
CameraDiagnostics* impl,
mojo::Message* message,
std::unique_ptr<mojo::MessageReceiverWithStatus> responder);
};
template <typename ImplRefTraits =
mojo::RawPtrImplRefTraits<CameraDiagnostics>>
class CameraDiagnosticsStub
: public mojo::MessageReceiverWithResponderStatus {
public:
using ImplPointerType = typename ImplRefTraits::PointerType;
CameraDiagnosticsStub() = default;
~CameraDiagnosticsStub() override = default;
void set_sink(ImplPointerType sink) { sink_ = std::move(sink); }
ImplPointerType& sink() { return sink_; }
bool Accept(mojo::Message* message) override {
if (ImplRefTraits::IsNull(sink_))
return false;
return CameraDiagnosticsStubDispatch::Accept(
ImplRefTraits::GetRawPointer(&sink_), message);
}
bool AcceptWithResponder(
mojo::Message* message,
std::unique_ptr<mojo::MessageReceiverWithStatus> responder) override {
if (ImplRefTraits::IsNull(sink_))
return false;
return CameraDiagnosticsStubDispatch::AcceptWithResponder(
ImplRefTraits::GetRawPointer(&sink_), message, std::move(responder));
}
private:
ImplPointerType sink_;
};
class CrosCameraDiagnosticsServiceStubDispatch {
public:
static bool Accept(CrosCameraDiagnosticsService* impl, mojo::Message* message);
static bool AcceptWithResponder(
CrosCameraDiagnosticsService* impl,
mojo::Message* message,
std::unique_ptr<mojo::MessageReceiverWithStatus> responder);
};
template <typename ImplRefTraits =
mojo::RawPtrImplRefTraits<CrosCameraDiagnosticsService>>
class CrosCameraDiagnosticsServiceStub
: public mojo::MessageReceiverWithResponderStatus {
public:
using ImplPointerType = typename ImplRefTraits::PointerType;
CrosCameraDiagnosticsServiceStub() = default;
~CrosCameraDiagnosticsServiceStub() override = default;
void set_sink(ImplPointerType sink) { sink_ = std::move(sink); }
ImplPointerType& sink() { return sink_; }
bool Accept(mojo::Message* message) override {
if (ImplRefTraits::IsNull(sink_))
return false;
return CrosCameraDiagnosticsServiceStubDispatch::Accept(
ImplRefTraits::GetRawPointer(&sink_), message);
}
bool AcceptWithResponder(
mojo::Message* message,
std::unique_ptr<mojo::MessageReceiverWithStatus> responder) override {
if (ImplRefTraits::IsNull(sink_))
return false;
return CrosCameraDiagnosticsServiceStubDispatch::AcceptWithResponder(
ImplRefTraits::GetRawPointer(&sink_), message, std::move(responder));
}
private:
ImplPointerType sink_;
};
class CrosCameraControllerStubDispatch {
public:
static bool Accept(CrosCameraController* impl, mojo::Message* message);
static bool AcceptWithResponder(
CrosCameraController* impl,
mojo::Message* message,
std::unique_ptr<mojo::MessageReceiverWithStatus> responder);
};
template <typename ImplRefTraits =
mojo::RawPtrImplRefTraits<CrosCameraController>>
class CrosCameraControllerStub
: public mojo::MessageReceiverWithResponderStatus {
public:
using ImplPointerType = typename ImplRefTraits::PointerType;
CrosCameraControllerStub() = default;
~CrosCameraControllerStub() override = default;
void set_sink(ImplPointerType sink) { sink_ = std::move(sink); }
ImplPointerType& sink() { return sink_; }
bool Accept(mojo::Message* message) override {
if (ImplRefTraits::IsNull(sink_))
return false;
return CrosCameraControllerStubDispatch::Accept(
ImplRefTraits::GetRawPointer(&sink_), message);
}
bool AcceptWithResponder(
mojo::Message* message,
std::unique_ptr<mojo::MessageReceiverWithStatus> responder) override {
if (ImplRefTraits::IsNull(sink_))
return false;
return CrosCameraControllerStubDispatch::AcceptWithResponder(
ImplRefTraits::GetRawPointer(&sink_), message, std::move(responder));
}
private:
ImplPointerType sink_;
};
class CameraDiagnosticsRequestValidator : public mojo::MessageReceiver {
public:
bool Accept(mojo::Message* message) override;
};
class CrosCameraDiagnosticsServiceRequestValidator : public mojo::MessageReceiver {
public:
bool Accept(mojo::Message* message) override;
};
class CrosCameraControllerRequestValidator : public mojo::MessageReceiver {
public:
bool Accept(mojo::Message* message) override;
};
class CameraDiagnosticsResponseValidator : public mojo::MessageReceiver {
public:
bool Accept(mojo::Message* message) override;
};
class CrosCameraControllerResponseValidator : public mojo::MessageReceiver {
public:
bool Accept(mojo::Message* message) override;
};
class AnalyzerResult {
public:
template <typename T>
using EnableIfSame = std::enable_if_t<std::is_same<AnalyzerResult, T>::value>;
using DataView = AnalyzerResultDataView;
using Data_ = internal::AnalyzerResult_Data;
template <typename... Args>
static AnalyzerResultPtr New(Args&&... args) {
return AnalyzerResultPtr(
std::in_place, std::forward<Args>(args)...);
}
template <typename U>
static AnalyzerResultPtr From(const U& u) {
return mojo::TypeConverter<AnalyzerResultPtr, U>::Convert(u);
}
template <typename U>
U To() const {
return mojo::TypeConverter<U, AnalyzerResult>::Convert(*this);
}
AnalyzerResult();
AnalyzerResult(
AnalyzerType type,
AnalyzerStatus status);
~AnalyzerResult();
// 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 = AnalyzerResultPtr>
AnalyzerResultPtr 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, AnalyzerResult::EnableIfSame<T>* = nullptr>
bool Equals(const T& other) const;
template <typename T, AnalyzerResult::EnableIfSame<T>* = nullptr>
bool operator==(const T& rhs) const { return Equals(rhs); }
template <typename T, AnalyzerResult::EnableIfSame<T>* = nullptr>
bool operator!=(const T& rhs) const { return !operator==(rhs); }
size_t Hash(size_t seed) const;
template <typename UserType>
static std::vector<uint8_t> Serialize(UserType* input) {
return mojo::internal::SerializeImpl<
AnalyzerResult::DataView, std::vector<uint8_t>>(input);
}
template <typename UserType>
static mojo::Message SerializeAsMessage(UserType* input) {
return mojo::internal::SerializeAsMessageImpl<
AnalyzerResult::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::AnalyzerResult_UnserializedMessageContext<
UserType, AnalyzerResult::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<AnalyzerResult::DataView>(
message, data, data_num_bytes, output, Validate);
}
template <typename UserType>
static bool Deserialize(const std::vector<uint8_t>& input,
UserType* output) {
return AnalyzerResult::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::AnalyzerResult_UnserializedMessageContext<
UserType, AnalyzerResult::DataView>>();
if (context) {
*output = std::move(context->TakeData());
return true;
}
input.SerializeIfNecessary();
return mojo::internal::DeserializeImpl<AnalyzerResult::DataView>(
input, input.payload(), input.payload_num_bytes(), output, Validate);
}
AnalyzerType type;
AnalyzerStatus status;
// 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, AnalyzerResult::EnableIfSame<T>* = nullptr>
bool operator<(const T& lhs, const T& rhs);
template <typename T, AnalyzerResult::EnableIfSame<T>* = nullptr>
bool operator<=(const T& lhs, const T& rhs) {
return !(rhs < lhs);
}
template <typename T, AnalyzerResult::EnableIfSame<T>* = nullptr>
bool operator>(const T& lhs, const T& rhs) {
return rhs < lhs;
}
template <typename T, AnalyzerResult::EnableIfSame<T>* = nullptr>
bool operator>=(const T& lhs, const T& rhs) {
return !(lhs < rhs);
}
class FrameAnalysisConfig {
public:
template <typename T>
using EnableIfSame = std::enable_if_t<std::is_same<FrameAnalysisConfig, T>::value>;
using DataView = FrameAnalysisConfigDataView;
using Data_ = internal::FrameAnalysisConfig_Data;
static constexpr uint32_t kMinDurationMs = 5000U;
static constexpr uint32_t kMaxDurationMs = 60000U;
template <typename... Args>
static FrameAnalysisConfigPtr New(Args&&... args) {
return FrameAnalysisConfigPtr(
std::in_place, std::forward<Args>(args)...);
}
template <typename U>
static FrameAnalysisConfigPtr From(const U& u) {
return mojo::TypeConverter<FrameAnalysisConfigPtr, U>::Convert(u);
}
template <typename U>
U To() const {
return mojo::TypeConverter<U, FrameAnalysisConfig>::Convert(*this);
}
FrameAnalysisConfig();
FrameAnalysisConfig(
ClientType client_type,
uint32_t duration_ms);
~FrameAnalysisConfig();
// 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 = FrameAnalysisConfigPtr>
FrameAnalysisConfigPtr 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, FrameAnalysisConfig::EnableIfSame<T>* = nullptr>
bool Equals(const T& other) const;
template <typename T, FrameAnalysisConfig::EnableIfSame<T>* = nullptr>
bool operator==(const T& rhs) const { return Equals(rhs); }
template <typename T, FrameAnalysisConfig::EnableIfSame<T>* = nullptr>
bool operator!=(const T& rhs) const { return !operator==(rhs); }
size_t Hash(size_t seed) const;
template <typename UserType>
static std::vector<uint8_t> Serialize(UserType* input) {
return mojo::internal::SerializeImpl<
FrameAnalysisConfig::DataView, std::vector<uint8_t>>(input);
}
template <typename UserType>
static mojo::Message SerializeAsMessage(UserType* input) {
return mojo::internal::SerializeAsMessageImpl<
FrameAnalysisConfig::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::FrameAnalysisConfig_UnserializedMessageContext<
UserType, FrameAnalysisConfig::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<FrameAnalysisConfig::DataView>(
message, data, data_num_bytes, output, Validate);
}
template <typename UserType>
static bool Deserialize(const std::vector<uint8_t>& input,
UserType* output) {
return FrameAnalysisConfig::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::FrameAnalysisConfig_UnserializedMessageContext<
UserType, FrameAnalysisConfig::DataView>>();
if (context) {
*output = std::move(context->TakeData());
return true;
}
input.SerializeIfNecessary();
return mojo::internal::DeserializeImpl<FrameAnalysisConfig::DataView>(
input, input.payload(), input.payload_num_bytes(), output, Validate);
}
ClientType client_type;
uint32_t duration_ms;
// 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, FrameAnalysisConfig::EnableIfSame<T>* = nullptr>
bool operator<(const T& lhs, const T& rhs);
template <typename T, FrameAnalysisConfig::EnableIfSame<T>* = nullptr>
bool operator<=(const T& lhs, const T& rhs) {
return !(rhs < lhs);
}
template <typename T, FrameAnalysisConfig::EnableIfSame<T>* = nullptr>
bool operator>(const T& lhs, const T& rhs) {
return rhs < lhs;
}
template <typename T, FrameAnalysisConfig::EnableIfSame<T>* = nullptr>
bool operator>=(const T& lhs, const T& rhs) {
return !(lhs < rhs);
}
class CameraStream {
public:
template <typename T>
using EnableIfSame = std::enable_if_t<std::is_same<CameraStream, T>::value>;
using DataView = CameraStreamDataView;
using Data_ = internal::CameraStream_Data;
template <typename... Args>
static CameraStreamPtr New(Args&&... args) {
return CameraStreamPtr(
std::in_place, std::forward<Args>(args)...);
}
template <typename U>
static CameraStreamPtr From(const U& u) {
return mojo::TypeConverter<CameraStreamPtr, U>::Convert(u);
}
template <typename U>
U To() const {
return mojo::TypeConverter<U, CameraStream>::Convert(*this);
}
CameraStream();
CameraStream(
uint32_t width,
uint32_t height,
PixelFormat pixel_format);
~CameraStream();
// 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 = CameraStreamPtr>
CameraStreamPtr 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, CameraStream::EnableIfSame<T>* = nullptr>
bool Equals(const T& other) const;
template <typename T, CameraStream::EnableIfSame<T>* = nullptr>
bool operator==(const T& rhs) const { return Equals(rhs); }
template <typename T, CameraStream::EnableIfSame<T>* = nullptr>
bool operator!=(const T& rhs) const { return !operator==(rhs); }
size_t Hash(size_t seed) const;
template <typename UserType>
static std::vector<uint8_t> Serialize(UserType* input) {
return mojo::internal::SerializeImpl<
CameraStream::DataView, std::vector<uint8_t>>(input);
}
template <typename UserType>
static mojo::Message SerializeAsMessage(UserType* input) {
return mojo::internal::SerializeAsMessageImpl<
CameraStream::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::CameraStream_UnserializedMessageContext<
UserType, CameraStream::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<CameraStream::DataView>(
message, data, data_num_bytes, output, Validate);
}
template <typename UserType>
static bool Deserialize(const std::vector<uint8_t>& input,
UserType* output) {
return CameraStream::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::CameraStream_UnserializedMessageContext<
UserType, CameraStream::DataView>>();
if (context) {
*output = std::move(context->TakeData());
return true;
}
input.SerializeIfNecessary();
return mojo::internal::DeserializeImpl<CameraStream::DataView>(
input, input.payload(), input.payload_num_bytes(), output, Validate);
}
uint32_t width;
uint32_t height;
PixelFormat pixel_format;
// 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, CameraStream::EnableIfSame<T>* = nullptr>
bool operator<(const T& lhs, const T& rhs);
template <typename T, CameraStream::EnableIfSame<T>* = nullptr>
bool operator<=(const T& lhs, const T& rhs) {
return !(rhs < lhs);
}
template <typename T, CameraStream::EnableIfSame<T>* = nullptr>
bool operator>(const T& lhs, const T& rhs) {
return rhs < lhs;
}
template <typename T, CameraStream::EnableIfSame<T>* = nullptr>
bool operator>=(const T& lhs, const T& rhs) {
return !(lhs < rhs);
}
class StreamingConfig {
public:
template <typename T>
using EnableIfSame = std::enable_if_t<std::is_same<StreamingConfig, T>::value>;
using DataView = StreamingConfigDataView;
using Data_ = internal::StreamingConfig_Data;
template <typename... Args>
static StreamingConfigPtr New(Args&&... args) {
return StreamingConfigPtr(
std::in_place, std::forward<Args>(args)...);
}
template <typename U>
static StreamingConfigPtr From(const U& u) {
return mojo::TypeConverter<StreamingConfigPtr, U>::Convert(u);
}
template <typename U>
U To() const {
return mojo::TypeConverter<U, StreamingConfig>::Convert(*this);
}
StreamingConfig();
explicit StreamingConfig(
uint32_t frame_interval);
~StreamingConfig();
// 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 = StreamingConfigPtr>
StreamingConfigPtr 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, StreamingConfig::EnableIfSame<T>* = nullptr>
bool Equals(const T& other) const;
template <typename T, StreamingConfig::EnableIfSame<T>* = nullptr>
bool operator==(const T& rhs) const { return Equals(rhs); }
template <typename T, StreamingConfig::EnableIfSame<T>* = nullptr>
bool operator!=(const T& rhs) const { return !operator==(rhs); }
size_t Hash(size_t seed) const;
template <typename UserType>
static std::vector<uint8_t> Serialize(UserType* input) {
return mojo::internal::SerializeImpl<
StreamingConfig::DataView, std::vector<uint8_t>>(input);
}
template <typename UserType>
static mojo::Message SerializeAsMessage(UserType* input) {
return mojo::internal::SerializeAsMessageImpl<
StreamingConfig::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::StreamingConfig_UnserializedMessageContext<
UserType, StreamingConfig::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<StreamingConfig::DataView>(
message, data, data_num_bytes, output, Validate);
}
template <typename UserType>
static bool Deserialize(const std::vector<uint8_t>& input,
UserType* output) {
return StreamingConfig::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::StreamingConfig_UnserializedMessageContext<
UserType, StreamingConfig::DataView>>();
if (context) {
*output = std::move(context->TakeData());
return true;
}
input.SerializeIfNecessary();
return mojo::internal::DeserializeImpl<StreamingConfig::DataView>(
input, input.payload(), input.payload_num_bytes(), output, Validate);
}
uint32_t frame_interval;
// 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, StreamingConfig::EnableIfSame<T>* = nullptr>
bool operator<(const T& lhs, const T& rhs);
template <typename T, StreamingConfig::EnableIfSame<T>* = nullptr>
bool operator<=(const T& lhs, const T& rhs) {
return !(rhs < lhs);
}
template <typename T, StreamingConfig::EnableIfSame<T>* = nullptr>
bool operator>(const T& lhs, const T& rhs) {
return rhs < lhs;
}
template <typename T, StreamingConfig::EnableIfSame<T>* = nullptr>
bool operator>=(const T& lhs, const T& rhs) {
return !(lhs < rhs);
}
class FrameAnalysisResult {
public:
using DataView = FrameAnalysisResultDataView;
using Data_ = internal::FrameAnalysisResult_Data;
using Tag = Data_::FrameAnalysisResult_Tag;
template <typename... Args>
static FrameAnalysisResultPtr New(Args&&... args) {
static_assert(
sizeof...(args) < 0,
"Do not use Union::New(); to create a union of a given subtype, use "
"New<SubType>(), not New() followed by set_<sub_type>(). To represent "
"an empty union, mark the field or parameter as nullable in the mojom "
"definition.");
return nullptr;
}
// Construct an instance holding |error|.
static FrameAnalysisResultPtr
NewError(
ErrorCode value) {
auto result = FrameAnalysisResultPtr(std::in_place);
result->set_error(std::move(value));
return result;
}
// Construct an instance holding |res|.
static FrameAnalysisResultPtr
NewRes(
DiagnosticsResultPtr value) {
auto result = FrameAnalysisResultPtr(std::in_place);
result->set_res(std::move(value));
return result;
}
template <typename U>
static FrameAnalysisResultPtr From(const U& u) {
return mojo::TypeConverter<FrameAnalysisResultPtr, U>::Convert(u);
}
template <typename U>
U To() const {
return mojo::TypeConverter<U, FrameAnalysisResult>::Convert(*this);
}
FrameAnalysisResult();
~FrameAnalysisResult();
// Delete the copy constructor and copy assignment operators because `data_`
// contains raw pointers that must not be copied.
FrameAnalysisResult(const FrameAnalysisResult& other) = delete;
FrameAnalysisResult& operator=(const FrameAnalysisResult& other) = delete;
// 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 UnionPtrType = FrameAnalysisResultPtr>
FrameAnalysisResultPtr 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,
typename std::enable_if<std::is_same<
T, FrameAnalysisResult>::value>::type* = nullptr>
bool Equals(const T& other) const;
template <typename T,
typename std::enable_if<std::is_same<
T, FrameAnalysisResult>::value>::type* = nullptr>
bool operator==(const T& rhs) const { return Equals(rhs); }
Tag which() const {
return tag_;
}
bool is_error() const { return tag_ == Tag::kError; }
ErrorCode get_error() const {
CHECK(tag_ == Tag::kError);
return data_.error;
}
void set_error(
ErrorCode error);
bool is_res() const { return tag_ == Tag::kRes; }
DiagnosticsResultPtr& get_res() const {
CHECK(tag_ == Tag::kRes);
return *(data_.res);
}
void set_res(
DiagnosticsResultPtr res);
template <typename UserType>
static mojo::Message SerializeAsMessage(UserType* input) {
return mojo::internal::SerializeAsMessageImpl<
FrameAnalysisResult::DataView>(input);
}
template <typename UserType>
static bool DeserializeFromMessage(mojo::Message input,
UserType* output) {
return mojo::internal::DeserializeImpl<FrameAnalysisResult::DataView>(
input, input.payload(), input.payload_num_bytes(), output, Validate);
}
private:
union Union_ {
Union_() = default;
~Union_() = default;
ErrorCode error;
DiagnosticsResultPtr* res;
};
static bool Validate(const void* data,
mojo::internal::ValidationContext* validation_context);
void DestroyActive();
Tag tag_;
Union_ data_;
};
class StartStreamingResult {
public:
using DataView = StartStreamingResultDataView;
using Data_ = internal::StartStreamingResult_Data;
using Tag = Data_::StartStreamingResult_Tag;
template <typename... Args>
static StartStreamingResultPtr New(Args&&... args) {
static_assert(
sizeof...(args) < 0,
"Do not use Union::New(); to create a union of a given subtype, use "
"New<SubType>(), not New() followed by set_<sub_type>(). To represent "
"an empty union, mark the field or parameter as nullable in the mojom "
"definition.");
return nullptr;
}
// Construct an instance holding |error|.
static StartStreamingResultPtr
NewError(
ErrorCode value) {
auto result = StartStreamingResultPtr(std::in_place);
result->set_error(std::move(value));
return result;
}
// Construct an instance holding |stream|.
static StartStreamingResultPtr
NewStream(
CameraStreamPtr value) {
auto result = StartStreamingResultPtr(std::in_place);
result->set_stream(std::move(value));
return result;
}
template <typename U>
static StartStreamingResultPtr From(const U& u) {
return mojo::TypeConverter<StartStreamingResultPtr, U>::Convert(u);
}
template <typename U>
U To() const {
return mojo::TypeConverter<U, StartStreamingResult>::Convert(*this);
}
StartStreamingResult();
~StartStreamingResult();
// Delete the copy constructor and copy assignment operators because `data_`
// contains raw pointers that must not be copied.
StartStreamingResult(const StartStreamingResult& other) = delete;
StartStreamingResult& operator=(const StartStreamingResult& other) = delete;
// 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 UnionPtrType = StartStreamingResultPtr>
StartStreamingResultPtr 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,
typename std::enable_if<std::is_same<
T, StartStreamingResult>::value>::type* = nullptr>
bool Equals(const T& other) const;
template <typename T,
typename std::enable_if<std::is_same<
T, StartStreamingResult>::value>::type* = nullptr>
bool operator==(const T& rhs) const { return Equals(rhs); }
size_t Hash(size_t seed) const;
Tag which() const {
return tag_;
}
bool is_error() const { return tag_ == Tag::kError; }
ErrorCode get_error() const {
CHECK(tag_ == Tag::kError);
return data_.error;
}
void set_error(
ErrorCode error);
bool is_stream() const { return tag_ == Tag::kStream; }
CameraStreamPtr& get_stream() const {
CHECK(tag_ == Tag::kStream);
return *(data_.stream);
}
void set_stream(
CameraStreamPtr stream);
template <typename UserType>
static mojo::Message SerializeAsMessage(UserType* input) {
return mojo::internal::SerializeAsMessageImpl<
StartStreamingResult::DataView>(input);
}
template <typename UserType>
static bool DeserializeFromMessage(mojo::Message input,
UserType* output) {
return mojo::internal::DeserializeImpl<StartStreamingResult::DataView>(
input, input.payload(), input.payload_num_bytes(), output, Validate);
}
private:
union Union_ {
Union_() = default;
~Union_() = default;
ErrorCode error;
CameraStreamPtr* stream;
};
static bool Validate(const void* data,
mojo::internal::ValidationContext* validation_context);
void DestroyActive();
Tag tag_;
Union_ data_;
};
class DiagnosticsResult {
public:
template <typename T>
using EnableIfSame = std::enable_if_t<std::is_same<DiagnosticsResult, T>::value>;
using DataView = DiagnosticsResultDataView;
using Data_ = internal::DiagnosticsResult_Data;
template <typename... Args>
static DiagnosticsResultPtr New(Args&&... args) {
return DiagnosticsResultPtr(
std::in_place, std::forward<Args>(args)...);
}
template <typename U>
static DiagnosticsResultPtr From(const U& u) {
return mojo::TypeConverter<DiagnosticsResultPtr, U>::Convert(u);
}
template <typename U>
U To() const {
return mojo::TypeConverter<U, DiagnosticsResult>::Convert(*this);
}
DiagnosticsResult();
DiagnosticsResult(
uint32_t numeber_of_analyzed_frames,
std::vector<AnalyzerResultPtr> analyzer_results,
CameraIssue suggested_issue);
DiagnosticsResult(const DiagnosticsResult&) = delete;
DiagnosticsResult& operator=(const DiagnosticsResult&) = delete;
~DiagnosticsResult();
// 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 = DiagnosticsResultPtr>
DiagnosticsResultPtr 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, DiagnosticsResult::EnableIfSame<T>* = nullptr>
bool Equals(const T& other) const;
template <typename T, DiagnosticsResult::EnableIfSame<T>* = nullptr>
bool operator==(const T& rhs) const { return Equals(rhs); }
template <typename T, DiagnosticsResult::EnableIfSame<T>* = nullptr>
bool operator!=(const T& rhs) const { return !operator==(rhs); }
template <typename UserType>
static std::vector<uint8_t> Serialize(UserType* input) {
return mojo::internal::SerializeImpl<
DiagnosticsResult::DataView, std::vector<uint8_t>>(input);
}
template <typename UserType>
static mojo::Message SerializeAsMessage(UserType* input) {
return mojo::internal::SerializeAsMessageImpl<
DiagnosticsResult::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::DiagnosticsResult_UnserializedMessageContext<
UserType, DiagnosticsResult::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<DiagnosticsResult::DataView>(
message, data, data_num_bytes, output, Validate);
}
template <typename UserType>
static bool Deserialize(const std::vector<uint8_t>& input,
UserType* output) {
return DiagnosticsResult::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::DiagnosticsResult_UnserializedMessageContext<
UserType, DiagnosticsResult::DataView>>();
if (context) {
*output = std::move(context->TakeData());
return true;
}
input.SerializeIfNecessary();
return mojo::internal::DeserializeImpl<DiagnosticsResult::DataView>(
input, input.payload(), input.payload_num_bytes(), output, Validate);
}
uint32_t numeber_of_analyzed_frames;
std::vector<AnalyzerResultPtr> analyzer_results;
CameraIssue suggested_issue;
// 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, DiagnosticsResult::EnableIfSame<T>* = nullptr>
bool operator<(const T& lhs, const T& rhs);
template <typename T, DiagnosticsResult::EnableIfSame<T>* = nullptr>
bool operator<=(const T& lhs, const T& rhs) {
return !(rhs < lhs);
}
template <typename T, DiagnosticsResult::EnableIfSame<T>* = nullptr>
bool operator>(const T& lhs, const T& rhs) {
return rhs < lhs;
}
template <typename T, DiagnosticsResult::EnableIfSame<T>* = nullptr>
bool operator>=(const T& lhs, const T& rhs) {
return !(lhs < rhs);
}
class CameraFrameBuffer {
public:
template <typename T>
using EnableIfSame = std::enable_if_t<std::is_same<CameraFrameBuffer, T>::value>;
using DataView = CameraFrameBufferDataView;
using Data_ = internal::CameraFrameBuffer_Data;
template <typename... Args>
static CameraFrameBufferPtr New(Args&&... args) {
return CameraFrameBufferPtr(
std::in_place, std::forward<Args>(args)...);
}
template <typename U>
static CameraFrameBufferPtr From(const U& u) {
return mojo::TypeConverter<CameraFrameBufferPtr, U>::Convert(u);
}
template <typename U>
U To() const {
return mojo::TypeConverter<U, CameraFrameBuffer>::Convert(*this);
}
CameraFrameBuffer();
CameraFrameBuffer(
uint32_t size,
::mojo::ScopedSharedBufferHandle shm_handle);
CameraFrameBuffer(const CameraFrameBuffer&) = delete;
CameraFrameBuffer& operator=(const CameraFrameBuffer&) = delete;
~CameraFrameBuffer();
// 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 = CameraFrameBufferPtr>
CameraFrameBufferPtr 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, CameraFrameBuffer::EnableIfSame<T>* = nullptr>
bool Equals(const T& other) const;
template <typename T, CameraFrameBuffer::EnableIfSame<T>* = nullptr>
bool operator==(const T& rhs) const { return Equals(rhs); }
template <typename T, CameraFrameBuffer::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<
CameraFrameBuffer::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::CameraFrameBuffer_UnserializedMessageContext<
UserType, CameraFrameBuffer::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<CameraFrameBuffer::DataView>(
message, data, data_num_bytes, output, Validate);
}
template <typename UserType>
static bool Deserialize(const std::vector<uint8_t>& input,
UserType* output) {
return CameraFrameBuffer::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::CameraFrameBuffer_UnserializedMessageContext<
UserType, CameraFrameBuffer::DataView>>();
if (context) {
*output = std::move(context->TakeData());
return true;
}
input.SerializeIfNecessary();
return mojo::internal::DeserializeImpl<CameraFrameBuffer::DataView>(
input, input.payload(), input.payload_num_bytes(), output, Validate);
}
uint32_t size;
::mojo::ScopedSharedBufferHandle shm_handle;
// 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, CameraFrameBuffer::EnableIfSame<T>* = nullptr>
bool operator<(const T& lhs, const T& rhs);
template <typename T, CameraFrameBuffer::EnableIfSame<T>* = nullptr>
bool operator<=(const T& lhs, const T& rhs) {
return !(rhs < lhs);
}
template <typename T, CameraFrameBuffer::EnableIfSame<T>* = nullptr>
bool operator>(const T& lhs, const T& rhs) {
return rhs < lhs;
}
template <typename T, CameraFrameBuffer::EnableIfSame<T>* = nullptr>
bool operator>=(const T& lhs, const T& rhs) {
return !(lhs < rhs);
}
class CameraFrame {
public:
template <typename T>
using EnableIfSame = std::enable_if_t<std::is_same<CameraFrame, T>::value>;
using DataView = CameraFrameDataView;
using Data_ = internal::CameraFrame_Data;
template <typename... Args>
static CameraFramePtr New(Args&&... args) {
return CameraFramePtr(
std::in_place, std::forward<Args>(args)...);
}
template <typename U>
static CameraFramePtr From(const U& u) {
return mojo::TypeConverter<CameraFramePtr, U>::Convert(u);
}
template <typename U>
U To() const {
return mojo::TypeConverter<U, CameraFrame>::Convert(*this);
}
CameraFrame();
CameraFrame(
CameraStreamPtr stream,
std::optional<uint32_t> frame_number,
DataSource source,
CameraFrameBufferPtr buffer,
bool is_empty);
CameraFrame(const CameraFrame&) = delete;
CameraFrame& operator=(const CameraFrame&) = delete;
~CameraFrame();
// 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 = CameraFramePtr>
CameraFramePtr 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, CameraFrame::EnableIfSame<T>* = nullptr>
bool Equals(const T& other) const;
template <typename T, CameraFrame::EnableIfSame<T>* = nullptr>
bool operator==(const T& rhs) const { return Equals(rhs); }
template <typename T, CameraFrame::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<
CameraFrame::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::CameraFrame_UnserializedMessageContext<
UserType, CameraFrame::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<CameraFrame::DataView>(
message, data, data_num_bytes, output, Validate);
}
template <typename UserType>
static bool Deserialize(const std::vector<uint8_t>& input,
UserType* output) {
return CameraFrame::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::CameraFrame_UnserializedMessageContext<
UserType, CameraFrame::DataView>>();
if (context) {
*output = std::move(context->TakeData());
return true;
}
input.SerializeIfNecessary();
return mojo::internal::DeserializeImpl<CameraFrame::DataView>(
input, input.payload(), input.payload_num_bytes(), output, Validate);
}
CameraStreamPtr stream;
std::optional<uint32_t> frame_number;
DataSource source;
CameraFrameBufferPtr buffer;
bool is_empty;
// 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, CameraFrame::EnableIfSame<T>* = nullptr>
bool operator<(const T& lhs, const T& rhs);
template <typename T, CameraFrame::EnableIfSame<T>* = nullptr>
bool operator<=(const T& lhs, const T& rhs) {
return !(rhs < lhs);
}
template <typename T, CameraFrame::EnableIfSame<T>* = nullptr>
bool operator>(const T& lhs, const T& rhs) {
return rhs < lhs;
}
template <typename T, CameraFrame::EnableIfSame<T>* = nullptr>
bool operator>=(const T& lhs, const T& rhs) {
return !(lhs < rhs);
}
template <typename UnionPtrType>
FrameAnalysisResultPtr FrameAnalysisResult::Clone() const {
switch (tag_) {
case Tag::kError:
return NewError(
mojo::Clone(data_.error));
case Tag::kRes:
return NewRes(
mojo::Clone(*data_.res));
}
return nullptr;
}
template <typename T,
typename std::enable_if<std::is_same<
T, FrameAnalysisResult>::value>::type*>
bool FrameAnalysisResult::Equals(const T& other) const {
if (tag_ != other.which())
return false;
switch (tag_) {
case Tag::kError:
return mojo::Equals(data_.error, other.data_.error);
case Tag::kRes:
return mojo::Equals(*(data_.res), *(other.data_.res));
}
return false;
}
template <typename UnionPtrType>
StartStreamingResultPtr StartStreamingResult::Clone() const {
switch (tag_) {
case Tag::kError:
return NewError(
mojo::Clone(data_.error));
case Tag::kStream:
return NewStream(
mojo::Clone(*data_.stream));
}
return nullptr;
}
template <typename T,
typename std::enable_if<std::is_same<
T, StartStreamingResult>::value>::type*>
bool StartStreamingResult::Equals(const T& other) const {
if (tag_ != other.which())
return false;
switch (tag_) {
case Tag::kError:
return mojo::Equals(data_.error, other.data_.error);
case Tag::kStream:
return mojo::Equals(*(data_.stream), *(other.data_.stream));
}
return false;
}
template <typename StructPtrType>
AnalyzerResultPtr AnalyzerResult::Clone() const {
return New(
mojo::Clone(type),
mojo::Clone(status)
);
}
template <typename T, AnalyzerResult::EnableIfSame<T>*>
bool AnalyzerResult::Equals(const T& other_struct) const {
if (!mojo::Equals(this->type, other_struct.type))
return false;
if (!mojo::Equals(this->status, other_struct.status))
return false;
return true;
}
template <typename T, AnalyzerResult::EnableIfSame<T>*>
bool operator<(const T& lhs, const T& rhs) {
if (lhs.type < rhs.type)
return true;
if (rhs.type < lhs.type)
return false;
if (lhs.status < rhs.status)
return true;
if (rhs.status < lhs.status)
return false;
return false;
}
template <typename StructPtrType>
DiagnosticsResultPtr DiagnosticsResult::Clone() const {
return New(
mojo::Clone(numeber_of_analyzed_frames),
mojo::Clone(analyzer_results),
mojo::Clone(suggested_issue)
);
}
template <typename T, DiagnosticsResult::EnableIfSame<T>*>
bool DiagnosticsResult::Equals(const T& other_struct) const {
if (!mojo::Equals(this->numeber_of_analyzed_frames, other_struct.numeber_of_analyzed_frames))
return false;
if (!mojo::Equals(this->analyzer_results, other_struct.analyzer_results))
return false;
if (!mojo::Equals(this->suggested_issue, other_struct.suggested_issue))
return false;
return true;
}
template <typename T, DiagnosticsResult::EnableIfSame<T>*>
bool operator<(const T& lhs, const T& rhs) {
if (lhs.numeber_of_analyzed_frames < rhs.numeber_of_analyzed_frames)
return true;
if (rhs.numeber_of_analyzed_frames < lhs.numeber_of_analyzed_frames)
return false;
if (lhs.analyzer_results < rhs.analyzer_results)
return true;
if (rhs.analyzer_results < lhs.analyzer_results)
return false;
if (lhs.suggested_issue < rhs.suggested_issue)
return true;
if (rhs.suggested_issue < lhs.suggested_issue)
return false;
return false;
}
template <typename StructPtrType>
FrameAnalysisConfigPtr FrameAnalysisConfig::Clone() const {
return New(
mojo::Clone(client_type),
mojo::Clone(duration_ms)
);
}
template <typename T, FrameAnalysisConfig::EnableIfSame<T>*>
bool FrameAnalysisConfig::Equals(const T& other_struct) const {
if (!mojo::Equals(this->client_type, other_struct.client_type))
return false;
if (!mojo::Equals(this->duration_ms, other_struct.duration_ms))
return false;
return true;
}
template <typename T, FrameAnalysisConfig::EnableIfSame<T>*>
bool operator<(const T& lhs, const T& rhs) {
if (lhs.client_type < rhs.client_type)
return true;
if (rhs.client_type < lhs.client_type)
return false;
if (lhs.duration_ms < rhs.duration_ms)
return true;
if (rhs.duration_ms < lhs.duration_ms)
return false;
return false;
}
template <typename StructPtrType>
CameraFrameBufferPtr CameraFrameBuffer::Clone() const {
return New(
mojo::Clone(size),
mojo::Clone(shm_handle)
);
}
template <typename T, CameraFrameBuffer::EnableIfSame<T>*>
bool CameraFrameBuffer::Equals(const T& other_struct) const {
if (!mojo::Equals(this->size, other_struct.size))
return false;
if (!mojo::Equals(this->shm_handle, other_struct.shm_handle))
return false;
return true;
}
template <typename T, CameraFrameBuffer::EnableIfSame<T>*>
bool operator<(const T& lhs, const T& rhs) {
if (lhs.size < rhs.size)
return true;
if (rhs.size < lhs.size)
return false;
if (lhs.shm_handle < rhs.shm_handle)
return true;
if (rhs.shm_handle < lhs.shm_handle)
return false;
return false;
}
template <typename StructPtrType>
CameraStreamPtr CameraStream::Clone() const {
return New(
mojo::Clone(width),
mojo::Clone(height),
mojo::Clone(pixel_format)
);
}
template <typename T, CameraStream::EnableIfSame<T>*>
bool CameraStream::Equals(const T& other_struct) const {
if (!mojo::Equals(this->width, other_struct.width))
return false;
if (!mojo::Equals(this->height, other_struct.height))
return false;
if (!mojo::Equals(this->pixel_format, other_struct.pixel_format))
return false;
return true;
}
template <typename T, CameraStream::EnableIfSame<T>*>
bool operator<(const T& lhs, const T& rhs) {
if (lhs.width < rhs.width)
return true;
if (rhs.width < lhs.width)
return false;
if (lhs.height < rhs.height)
return true;
if (rhs.height < lhs.height)
return false;
if (lhs.pixel_format < rhs.pixel_format)
return true;
if (rhs.pixel_format < lhs.pixel_format)
return false;
return false;
}
template <typename StructPtrType>
CameraFramePtr CameraFrame::Clone() const {
return New(
mojo::Clone(stream),
mojo::Clone(frame_number),
mojo::Clone(source),
mojo::Clone(buffer),
mojo::Clone(is_empty)
);
}
template <typename T, CameraFrame::EnableIfSame<T>*>
bool CameraFrame::Equals(const T& other_struct) const {
if (!mojo::Equals(this->stream, other_struct.stream))
return false;
if (!mojo::Equals(this->frame_number, other_struct.frame_number))
return false;
if (!mojo::Equals(this->source, other_struct.source))
return false;
if (!mojo::Equals(this->buffer, other_struct.buffer))
return false;
if (!mojo::Equals(this->is_empty, other_struct.is_empty))
return false;
return true;
}
template <typename T, CameraFrame::EnableIfSame<T>*>
bool operator<(const T& lhs, const T& rhs) {
if (lhs.stream < rhs.stream)
return true;
if (rhs.stream < lhs.stream)
return false;
if (lhs.frame_number < rhs.frame_number)
return true;
if (rhs.frame_number < lhs.frame_number)
return false;
if (lhs.source < rhs.source)
return true;
if (rhs.source < lhs.source)
return false;
if (lhs.buffer < rhs.buffer)
return true;
if (rhs.buffer < lhs.buffer)
return false;
if (lhs.is_empty < rhs.is_empty)
return true;
if (rhs.is_empty < lhs.is_empty)
return false;
return false;
}
template <typename StructPtrType>
StreamingConfigPtr StreamingConfig::Clone() const {
return New(
mojo::Clone(frame_interval)
);
}
template <typename T, StreamingConfig::EnableIfSame<T>*>
bool StreamingConfig::Equals(const T& other_struct) const {
if (!mojo::Equals(this->frame_interval, other_struct.frame_interval))
return false;
return true;
}
template <typename T, StreamingConfig::EnableIfSame<T>*>
bool operator<(const T& lhs, const T& rhs) {
if (lhs.frame_interval < rhs.frame_interval)
return true;
if (rhs.frame_interval < lhs.frame_interval)
return false;
return false;
}
} // cros::camera_diag::mojom
namespace mojo {
template <>
struct StructTraits<::cros::camera_diag::mojom::AnalyzerResult::DataView,
::cros::camera_diag::mojom::AnalyzerResultPtr> {
static bool IsNull(const ::cros::camera_diag::mojom::AnalyzerResultPtr& input) { return !input; }
static void SetToNull(::cros::camera_diag::mojom::AnalyzerResultPtr* output) { output->reset(); }
static decltype(::cros::camera_diag::mojom::AnalyzerResult::type) type(
const ::cros::camera_diag::mojom::AnalyzerResultPtr& input) {
return input->type;
}
static decltype(::cros::camera_diag::mojom::AnalyzerResult::status) status(
const ::cros::camera_diag::mojom::AnalyzerResultPtr& input) {
return input->status;
}
static bool Read(::cros::camera_diag::mojom::AnalyzerResult::DataView input, ::cros::camera_diag::mojom::AnalyzerResultPtr* output);
};
template <>
struct StructTraits<::cros::camera_diag::mojom::DiagnosticsResult::DataView,
::cros::camera_diag::mojom::DiagnosticsResultPtr> {
static bool IsNull(const ::cros::camera_diag::mojom::DiagnosticsResultPtr& input) { return !input; }
static void SetToNull(::cros::camera_diag::mojom::DiagnosticsResultPtr* output) { output->reset(); }
static decltype(::cros::camera_diag::mojom::DiagnosticsResult::numeber_of_analyzed_frames) numeber_of_analyzed_frames(
const ::cros::camera_diag::mojom::DiagnosticsResultPtr& input) {
return input->numeber_of_analyzed_frames;
}
static const decltype(::cros::camera_diag::mojom::DiagnosticsResult::analyzer_results)& analyzer_results(
const ::cros::camera_diag::mojom::DiagnosticsResultPtr& input) {
return input->analyzer_results;
}
static decltype(::cros::camera_diag::mojom::DiagnosticsResult::suggested_issue) suggested_issue(
const ::cros::camera_diag::mojom::DiagnosticsResultPtr& input) {
return input->suggested_issue;
}
static bool Read(::cros::camera_diag::mojom::DiagnosticsResult::DataView input, ::cros::camera_diag::mojom::DiagnosticsResultPtr* output);
};
template <>
struct StructTraits<::cros::camera_diag::mojom::FrameAnalysisConfig::DataView,
::cros::camera_diag::mojom::FrameAnalysisConfigPtr> {
static bool IsNull(const ::cros::camera_diag::mojom::FrameAnalysisConfigPtr& input) { return !input; }
static void SetToNull(::cros::camera_diag::mojom::FrameAnalysisConfigPtr* output) { output->reset(); }
static decltype(::cros::camera_diag::mojom::FrameAnalysisConfig::client_type) client_type(
const ::cros::camera_diag::mojom::FrameAnalysisConfigPtr& input) {
return input->client_type;
}
static decltype(::cros::camera_diag::mojom::FrameAnalysisConfig::duration_ms) duration_ms(
const ::cros::camera_diag::mojom::FrameAnalysisConfigPtr& input) {
return input->duration_ms;
}
static bool Read(::cros::camera_diag::mojom::FrameAnalysisConfig::DataView input, ::cros::camera_diag::mojom::FrameAnalysisConfigPtr* output);
};
template <>
struct StructTraits<::cros::camera_diag::mojom::CameraFrameBuffer::DataView,
::cros::camera_diag::mojom::CameraFrameBufferPtr> {
static bool IsNull(const ::cros::camera_diag::mojom::CameraFrameBufferPtr& input) { return !input; }
static void SetToNull(::cros::camera_diag::mojom::CameraFrameBufferPtr* output) { output->reset(); }
static decltype(::cros::camera_diag::mojom::CameraFrameBuffer::size) size(
const ::cros::camera_diag::mojom::CameraFrameBufferPtr& input) {
return input->size;
}
static decltype(::cros::camera_diag::mojom::CameraFrameBuffer::shm_handle)& shm_handle(
::cros::camera_diag::mojom::CameraFrameBufferPtr& input) {
return input->shm_handle;
}
static bool Read(::cros::camera_diag::mojom::CameraFrameBuffer::DataView input, ::cros::camera_diag::mojom::CameraFrameBufferPtr* output);
};
template <>
struct StructTraits<::cros::camera_diag::mojom::CameraStream::DataView,
::cros::camera_diag::mojom::CameraStreamPtr> {
static bool IsNull(const ::cros::camera_diag::mojom::CameraStreamPtr& input) { return !input; }
static void SetToNull(::cros::camera_diag::mojom::CameraStreamPtr* output) { output->reset(); }
static decltype(::cros::camera_diag::mojom::CameraStream::width) width(
const ::cros::camera_diag::mojom::CameraStreamPtr& input) {
return input->width;
}
static decltype(::cros::camera_diag::mojom::CameraStream::height) height(
const ::cros::camera_diag::mojom::CameraStreamPtr& input) {
return input->height;
}
static decltype(::cros::camera_diag::mojom::CameraStream::pixel_format) pixel_format(
const ::cros::camera_diag::mojom::CameraStreamPtr& input) {
return input->pixel_format;
}
static bool Read(::cros::camera_diag::mojom::CameraStream::DataView input, ::cros::camera_diag::mojom::CameraStreamPtr* output);
};
template <>
struct StructTraits<::cros::camera_diag::mojom::CameraFrame::DataView,
::cros::camera_diag::mojom::CameraFramePtr> {
static bool IsNull(const ::cros::camera_diag::mojom::CameraFramePtr& input) { return !input; }
static void SetToNull(::cros::camera_diag::mojom::CameraFramePtr* output) { output->reset(); }
static const decltype(::cros::camera_diag::mojom::CameraFrame::stream)& stream(
const ::cros::camera_diag::mojom::CameraFramePtr& input) {
return input->stream;
}
static decltype(::cros::camera_diag::mojom::CameraFrame::frame_number) frame_number(
const ::cros::camera_diag::mojom::CameraFramePtr& input) {
return input->frame_number;
}
static decltype(::cros::camera_diag::mojom::CameraFrame::source) source(
const ::cros::camera_diag::mojom::CameraFramePtr& input) {
return input->source;
}
static decltype(::cros::camera_diag::mojom::CameraFrame::buffer)& buffer(
::cros::camera_diag::mojom::CameraFramePtr& input) {
return input->buffer;
}
static decltype(::cros::camera_diag::mojom::CameraFrame::is_empty) is_empty(
const ::cros::camera_diag::mojom::CameraFramePtr& input) {
return input->is_empty;
}
static bool Read(::cros::camera_diag::mojom::CameraFrame::DataView input, ::cros::camera_diag::mojom::CameraFramePtr* output);
};
template <>
struct StructTraits<::cros::camera_diag::mojom::StreamingConfig::DataView,
::cros::camera_diag::mojom::StreamingConfigPtr> {
static bool IsNull(const ::cros::camera_diag::mojom::StreamingConfigPtr& input) { return !input; }
static void SetToNull(::cros::camera_diag::mojom::StreamingConfigPtr* output) { output->reset(); }
static decltype(::cros::camera_diag::mojom::StreamingConfig::frame_interval) frame_interval(
const ::cros::camera_diag::mojom::StreamingConfigPtr& input) {
return input->frame_interval;
}
static bool Read(::cros::camera_diag::mojom::StreamingConfig::DataView input, ::cros::camera_diag::mojom::StreamingConfigPtr* output);
};
template <>
struct UnionTraits<::cros::camera_diag::mojom::FrameAnalysisResult::DataView,
::cros::camera_diag::mojom::FrameAnalysisResultPtr> {
static bool IsNull(const ::cros::camera_diag::mojom::FrameAnalysisResultPtr& input) { return !input; }
static void SetToNull(::cros::camera_diag::mojom::FrameAnalysisResultPtr* output) { output->reset(); }
static ::cros::camera_diag::mojom::FrameAnalysisResult::Tag GetTag(const ::cros::camera_diag::mojom::FrameAnalysisResultPtr& input) {
return input->which();
}
static ::cros::camera_diag::mojom::ErrorCode error(const ::cros::camera_diag::mojom::FrameAnalysisResultPtr& input) {
return input->get_error();
}
static const ::cros::camera_diag::mojom::DiagnosticsResultPtr& res(const ::cros::camera_diag::mojom::FrameAnalysisResultPtr& input) {
return input->get_res();
}
static bool Read(::cros::camera_diag::mojom::FrameAnalysisResult::DataView input, ::cros::camera_diag::mojom::FrameAnalysisResultPtr* output);
};
template <>
struct UnionTraits<::cros::camera_diag::mojom::StartStreamingResult::DataView,
::cros::camera_diag::mojom::StartStreamingResultPtr> {
static bool IsNull(const ::cros::camera_diag::mojom::StartStreamingResultPtr& input) { return !input; }
static void SetToNull(::cros::camera_diag::mojom::StartStreamingResultPtr* output) { output->reset(); }
static ::cros::camera_diag::mojom::StartStreamingResult::Tag GetTag(const ::cros::camera_diag::mojom::StartStreamingResultPtr& input) {
return input->which();
}
static ::cros::camera_diag::mojom::ErrorCode error(const ::cros::camera_diag::mojom::StartStreamingResultPtr& input) {
return input->get_error();
}
static const ::cros::camera_diag::mojom::CameraStreamPtr& stream(const ::cros::camera_diag::mojom::StartStreamingResultPtr& input) {
return input->get_stream();
}
static bool Read(::cros::camera_diag::mojom::StartStreamingResult::DataView input, ::cros::camera_diag::mojom::StartStreamingResultPtr* output);
};
} // namespace mojo
#endif // CAMERA_MOJO_CAMERA_DIAGNOSTICS_MOJOM_H_