| // components/chromeos_camera/common/mjpeg_decode_accelerator.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_MJPEG_DECODE_ACCELERATOR_MOJOM_H_ |
| #define COMPONENTS_CHROMEOS_CAMERA_COMMON_MJPEG_DECODE_ACCELERATOR_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/mjpeg_decode_accelerator.mojom-features.h" |
| #include "components/chromeos_camera/common/mjpeg_decode_accelerator.mojom-shared.h" |
| #include "components/chromeos_camera/common/mjpeg_decode_accelerator.mojom-forward.h" |
| #include "components/chromeos_camera/common/dmabuf.mojom-forward.h" |
| #include "media/mojo/mojom/media_types.mojom.h" |
| #include "mojo/public/mojom/base/time.mojom.h" |
| #include "ui/gfx/geometry/mojom/geometry.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" |
| #include "components/chromeos_camera/common/mjpeg_decode_accelerator_mojom_traits.h" |
| |
| |
| |
| |
| namespace chromeos_camera::mojom { |
| |
| class MjpegDecodeAcceleratorProxy; |
| |
| template <typename ImplRefTraits> |
| class MjpegDecodeAcceleratorStub; |
| |
| class MjpegDecodeAcceleratorRequestValidator; |
| class MjpegDecodeAcceleratorResponseValidator; |
| |
| |
| class MjpegDecodeAccelerator |
| : public MjpegDecodeAcceleratorInterfaceBase { |
| 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_ = MjpegDecodeAcceleratorInterfaceBase; |
| using Proxy_ = MjpegDecodeAcceleratorProxy; |
| |
| template <typename ImplRefTraits> |
| using Stub_ = MjpegDecodeAcceleratorStub<ImplRefTraits>; |
| |
| using RequestValidator_ = MjpegDecodeAcceleratorRequestValidator; |
| using ResponseValidator_ = MjpegDecodeAcceleratorResponseValidator; |
| enum MethodMinVersions : uint32_t { |
| kInitializeMinVersion = 0, |
| kDecodeMinVersion = 0, |
| kDecodeWithDmaBufMinVersion = 0, |
| kUninitializeMinVersion = 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 Initialize_Sym { |
| NOINLINE static uint32_t IPCStableHash(); |
| }; |
| struct Decode_Sym { |
| NOINLINE static uint32_t IPCStableHash(); |
| }; |
| struct DecodeWithDmaBuf_Sym { |
| NOINLINE static uint32_t IPCStableHash(); |
| }; |
| struct Uninitialize_Sym { |
| NOINLINE static uint32_t IPCStableHash(); |
| }; |
| #endif // !BUILDFLAG(IS_FUCHSIA) |
| virtual ~MjpegDecodeAccelerator() = default; |
| |
| |
| using InitializeCallback = base::OnceCallback<void(bool)>; |
| |
| virtual void Initialize(InitializeCallback callback) = 0; |
| |
| |
| using DecodeCallback = base::OnceCallback<void(int32_t, ::chromeos_camera::MjpegDecodeAccelerator::Error)>; |
| |
| virtual void Decode(::media::BitstreamBuffer input_buffer, const ::gfx::Size& coded_size, ::mojo::ScopedSharedBufferHandle output_handle, uint32_t output_buffer_size, DecodeCallback callback) = 0; |
| |
| |
| using DecodeWithDmaBufCallback = base::OnceCallback<void(::chromeos_camera::MjpegDecodeAccelerator::Error)>; |
| |
| virtual void DecodeWithDmaBuf(int32_t task_id, ::mojo::ScopedHandle src_dmabuf_fd, uint32_t src_size, uint32_t src_offset, ::chromeos_camera::mojom::DmaBufVideoFramePtr dst_frame, DecodeWithDmaBufCallback callback) = 0; |
| |
| |
| virtual void Uninitialize() = 0; |
| }; |
| |
| |
| |
| class MjpegDecodeAcceleratorProxy |
| : public MjpegDecodeAccelerator { |
| public: |
| using InterfaceType = MjpegDecodeAccelerator; |
| |
| explicit MjpegDecodeAcceleratorProxy(mojo::MessageReceiverWithResponder* receiver); |
| |
| void Initialize(InitializeCallback callback) final; |
| |
| void Decode(::media::BitstreamBuffer input_buffer, const ::gfx::Size& coded_size, ::mojo::ScopedSharedBufferHandle output_handle, uint32_t output_buffer_size, DecodeCallback callback) final; |
| |
| void DecodeWithDmaBuf(int32_t task_id, ::mojo::ScopedHandle src_dmabuf_fd, uint32_t src_size, uint32_t src_offset, ::chromeos_camera::mojom::DmaBufVideoFramePtr dst_frame, DecodeWithDmaBufCallback callback) final; |
| |
| void Uninitialize() final; |
| |
| private: |
| mojo::MessageReceiverWithResponder* receiver_; |
| }; |
| class MjpegDecodeAcceleratorStubDispatch { |
| public: |
| static bool Accept(MjpegDecodeAccelerator* impl, mojo::Message* message); |
| static bool AcceptWithResponder( |
| MjpegDecodeAccelerator* impl, |
| mojo::Message* message, |
| std::unique_ptr<mojo::MessageReceiverWithStatus> responder); |
| }; |
| |
| template <typename ImplRefTraits = |
| mojo::RawPtrImplRefTraits<MjpegDecodeAccelerator>> |
| class MjpegDecodeAcceleratorStub |
| : public mojo::MessageReceiverWithResponderStatus { |
| public: |
| using ImplPointerType = typename ImplRefTraits::PointerType; |
| |
| MjpegDecodeAcceleratorStub() = default; |
| ~MjpegDecodeAcceleratorStub() 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 MjpegDecodeAcceleratorStubDispatch::Accept( |
| ImplRefTraits::GetRawPointer(&sink_), message); |
| } |
| |
| bool AcceptWithResponder( |
| mojo::Message* message, |
| std::unique_ptr<mojo::MessageReceiverWithStatus> responder) override { |
| if (ImplRefTraits::IsNull(sink_)) |
| return false; |
| return MjpegDecodeAcceleratorStubDispatch::AcceptWithResponder( |
| ImplRefTraits::GetRawPointer(&sink_), message, std::move(responder)); |
| } |
| |
| private: |
| ImplPointerType sink_; |
| }; |
| class MjpegDecodeAcceleratorRequestValidator : public mojo::MessageReceiver { |
| public: |
| bool Accept(mojo::Message* message) override; |
| }; |
| class MjpegDecodeAcceleratorResponseValidator : public mojo::MessageReceiver { |
| public: |
| bool Accept(mojo::Message* message) override; |
| }; |
| |
| |
| |
| |
| |
| |
| |
| |
| class BitstreamBuffer { |
| public: |
| template <typename T> |
| using EnableIfSame = std::enable_if_t<std::is_same<BitstreamBuffer, T>::value>; |
| using DataView = BitstreamBufferDataView; |
| using Data_ = internal::BitstreamBuffer_Data; |
| |
| template <typename... Args> |
| static BitstreamBufferPtr New(Args&&... args) { |
| return BitstreamBufferPtr( |
| std::in_place, std::forward<Args>(args)...); |
| } |
| |
| template <typename U> |
| static BitstreamBufferPtr From(const U& u) { |
| return mojo::TypeConverter<BitstreamBufferPtr, U>::Convert(u); |
| } |
| |
| template <typename U> |
| U To() const { |
| return mojo::TypeConverter<U, BitstreamBuffer>::Convert(*this); |
| } |
| |
| |
| BitstreamBuffer(); |
| |
| BitstreamBuffer( |
| int32_t id, |
| ::mojo::ScopedSharedBufferHandle memory_handle, |
| uint32_t size, |
| int64_t offset, |
| ::base::TimeDelta timestamp, |
| const std::string& key_id, |
| const std::string& iv, |
| std::vector<::media::SubsampleEntry> subsamples); |
| |
| BitstreamBuffer(const BitstreamBuffer&) = delete; |
| BitstreamBuffer& operator=(const BitstreamBuffer&) = delete; |
| |
| ~BitstreamBuffer(); |
| |
| // 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 = BitstreamBufferPtr> |
| BitstreamBufferPtr 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, BitstreamBuffer::EnableIfSame<T>* = nullptr> |
| bool Equals(const T& other) const; |
| |
| template <typename T, BitstreamBuffer::EnableIfSame<T>* = nullptr> |
| bool operator==(const T& rhs) const { return Equals(rhs); } |
| |
| template <typename T, BitstreamBuffer::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< |
| BitstreamBuffer::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::BitstreamBuffer_UnserializedMessageContext< |
| UserType, BitstreamBuffer::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<BitstreamBuffer::DataView>( |
| message, data, data_num_bytes, output, Validate); |
| } |
| |
| template <typename UserType> |
| static bool Deserialize(const std::vector<uint8_t>& input, |
| UserType* output) { |
| return BitstreamBuffer::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::BitstreamBuffer_UnserializedMessageContext< |
| UserType, BitstreamBuffer::DataView>>(); |
| if (context) { |
| *output = std::move(context->TakeData()); |
| return true; |
| } |
| input.SerializeIfNecessary(); |
| return mojo::internal::DeserializeImpl<BitstreamBuffer::DataView>( |
| input, input.payload(), input.payload_num_bytes(), output, Validate); |
| } |
| |
| |
| int32_t id; |
| |
| ::mojo::ScopedSharedBufferHandle memory_handle; |
| |
| uint32_t size; |
| |
| int64_t offset; |
| |
| ::base::TimeDelta timestamp; |
| |
| std::string key_id; |
| |
| std::string iv; |
| |
| std::vector<::media::SubsampleEntry> subsamples; |
| |
| // 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, BitstreamBuffer::EnableIfSame<T>* = nullptr> |
| bool operator<(const T& lhs, const T& rhs); |
| |
| template <typename T, BitstreamBuffer::EnableIfSame<T>* = nullptr> |
| bool operator<=(const T& lhs, const T& rhs) { |
| return !(rhs < lhs); |
| } |
| |
| template <typename T, BitstreamBuffer::EnableIfSame<T>* = nullptr> |
| bool operator>(const T& lhs, const T& rhs) { |
| return rhs < lhs; |
| } |
| |
| template <typename T, BitstreamBuffer::EnableIfSame<T>* = nullptr> |
| bool operator>=(const T& lhs, const T& rhs) { |
| return !(lhs < rhs); |
| } |
| |
| template <typename StructPtrType> |
| BitstreamBufferPtr BitstreamBuffer::Clone() const { |
| return New( |
| mojo::Clone(id), |
| mojo::Clone(memory_handle), |
| mojo::Clone(size), |
| mojo::Clone(offset), |
| mojo::Clone(timestamp), |
| mojo::Clone(key_id), |
| mojo::Clone(iv), |
| mojo::Clone(subsamples) |
| ); |
| } |
| |
| template <typename T, BitstreamBuffer::EnableIfSame<T>*> |
| bool BitstreamBuffer::Equals(const T& other_struct) const { |
| if (!mojo::Equals(this->id, other_struct.id)) |
| return false; |
| if (!mojo::Equals(this->memory_handle, other_struct.memory_handle)) |
| return false; |
| if (!mojo::Equals(this->size, other_struct.size)) |
| return false; |
| if (!mojo::Equals(this->offset, other_struct.offset)) |
| return false; |
| if (!mojo::Equals(this->timestamp, other_struct.timestamp)) |
| return false; |
| if (!mojo::Equals(this->key_id, other_struct.key_id)) |
| return false; |
| if (!mojo::Equals(this->iv, other_struct.iv)) |
| return false; |
| if (!mojo::Equals(this->subsamples, other_struct.subsamples)) |
| return false; |
| return true; |
| } |
| |
| template <typename T, BitstreamBuffer::EnableIfSame<T>*> |
| bool operator<(const T& lhs, const T& rhs) { |
| if (lhs.id < rhs.id) |
| return true; |
| if (rhs.id < lhs.id) |
| return false; |
| if (lhs.memory_handle < rhs.memory_handle) |
| return true; |
| if (rhs.memory_handle < lhs.memory_handle) |
| return false; |
| if (lhs.size < rhs.size) |
| return true; |
| if (rhs.size < lhs.size) |
| return false; |
| if (lhs.offset < rhs.offset) |
| return true; |
| if (rhs.offset < lhs.offset) |
| return false; |
| if (lhs.timestamp < rhs.timestamp) |
| return true; |
| if (rhs.timestamp < lhs.timestamp) |
| return false; |
| if (lhs.key_id < rhs.key_id) |
| return true; |
| if (rhs.key_id < lhs.key_id) |
| return false; |
| if (lhs.iv < rhs.iv) |
| return true; |
| if (rhs.iv < lhs.iv) |
| return false; |
| if (lhs.subsamples < rhs.subsamples) |
| return true; |
| if (rhs.subsamples < lhs.subsamples) |
| return false; |
| return false; |
| } |
| |
| |
| } // chromeos_camera::mojom |
| |
| namespace mojo { |
| |
| |
| template <> |
| struct StructTraits<::chromeos_camera::mojom::BitstreamBuffer::DataView, |
| ::chromeos_camera::mojom::BitstreamBufferPtr> { |
| static bool IsNull(const ::chromeos_camera::mojom::BitstreamBufferPtr& input) { return !input; } |
| static void SetToNull(::chromeos_camera::mojom::BitstreamBufferPtr* output) { output->reset(); } |
| |
| static decltype(::chromeos_camera::mojom::BitstreamBuffer::id) id( |
| const ::chromeos_camera::mojom::BitstreamBufferPtr& input) { |
| return input->id; |
| } |
| |
| static decltype(::chromeos_camera::mojom::BitstreamBuffer::memory_handle)& memory_handle( |
| ::chromeos_camera::mojom::BitstreamBufferPtr& input) { |
| return input->memory_handle; |
| } |
| |
| static decltype(::chromeos_camera::mojom::BitstreamBuffer::size) size( |
| const ::chromeos_camera::mojom::BitstreamBufferPtr& input) { |
| return input->size; |
| } |
| |
| static decltype(::chromeos_camera::mojom::BitstreamBuffer::offset) offset( |
| const ::chromeos_camera::mojom::BitstreamBufferPtr& input) { |
| return input->offset; |
| } |
| |
| static const decltype(::chromeos_camera::mojom::BitstreamBuffer::timestamp)& timestamp( |
| const ::chromeos_camera::mojom::BitstreamBufferPtr& input) { |
| return input->timestamp; |
| } |
| |
| static const decltype(::chromeos_camera::mojom::BitstreamBuffer::key_id)& key_id( |
| const ::chromeos_camera::mojom::BitstreamBufferPtr& input) { |
| return input->key_id; |
| } |
| |
| static const decltype(::chromeos_camera::mojom::BitstreamBuffer::iv)& iv( |
| const ::chromeos_camera::mojom::BitstreamBufferPtr& input) { |
| return input->iv; |
| } |
| |
| static const decltype(::chromeos_camera::mojom::BitstreamBuffer::subsamples)& subsamples( |
| const ::chromeos_camera::mojom::BitstreamBufferPtr& input) { |
| return input->subsamples; |
| } |
| |
| static bool Read(::chromeos_camera::mojom::BitstreamBuffer::DataView input, ::chromeos_camera::mojom::BitstreamBufferPtr* output); |
| }; |
| |
| } // namespace mojo |
| |
| #endif // COMPONENTS_CHROMEOS_CAMERA_COMMON_MJPEG_DECODE_ACCELERATOR_MOJOM_H_ |