| // components/chromeos_camera/common/mjpeg_decode_accelerator.mojom-shared.h is auto generated by mojom_bindings_generator.py, do not edit |
| |
| // Copyright 2016 The Chromium Authors |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #ifndef COMPONENTS_CHROMEOS_CAMERA_COMMON_MJPEG_DECODE_ACCELERATOR_MOJOM_SHARED_H_ |
| #define COMPONENTS_CHROMEOS_CAMERA_COMMON_MJPEG_DECODE_ACCELERATOR_MOJOM_SHARED_H_ |
| |
| #include <stdint.h> |
| |
| #include <functional> |
| #include <iosfwd> |
| #include <type_traits> |
| #include <utility> |
| #include "mojo/public/cpp/bindings/array_data_view.h" |
| #include "mojo/public/cpp/bindings/enum_traits.h" |
| #include "mojo/public/cpp/bindings/interface_data_view.h" |
| #include "mojo/public/cpp/bindings/lib/bindings_internal.h" |
| #include "mojo/public/cpp/bindings/lib/serialization.h" |
| #include "mojo/public/cpp/bindings/map_data_view.h" |
| #include "mojo/public/cpp/bindings/string_data_view.h" |
| |
| #include "third_party/perfetto/include/perfetto/tracing/traced_value_forward.h" |
| |
| #include "components/chromeos_camera/common/mjpeg_decode_accelerator.mojom-shared-internal.h" |
| #include "components/chromeos_camera/common/dmabuf.mojom-shared.h" |
| #include "media/mojo/mojom/media_types.mojom-shared.h" |
| #include "mojo/public/mojom/base/time.mojom-shared.h" |
| #include "ui/gfx/geometry/mojom/geometry.mojom-shared.h" |
| #include "mojo/public/cpp/bindings/lib/interface_serialization.h" |
| #include "mojo/public/cpp/system/data_pipe.h" |
| |
| |
| #include "mojo/public/cpp/bindings/native_enum.h" |
| #include "mojo/public/cpp/bindings/lib/native_struct_serialization.h" |
| |
| |
| |
| |
| namespace chromeos_camera::mojom { |
| class BitstreamBufferDataView; |
| |
| |
| |
| } // chromeos_camera::mojom |
| |
| namespace mojo { |
| namespace internal { |
| |
| template <> |
| struct MojomTypeTraits<::chromeos_camera::mojom::BitstreamBufferDataView> { |
| using Data = ::chromeos_camera::mojom::internal::BitstreamBuffer_Data; |
| using DataAsArrayElement = Pointer<Data>; |
| static constexpr MojomTypeCategory category = MojomTypeCategory::kStruct; |
| }; |
| |
| } // namespace internal |
| } // namespace mojo |
| |
| |
| namespace chromeos_camera::mojom { |
| |
| |
| enum class DecodeError : int32_t { |
| |
| NO_ERRORS = 0, |
| |
| INVALID_ARGUMENT = 1, |
| |
| UNREADABLE_INPUT = 2, |
| |
| PARSE_JPEG_FAILED = 3, |
| |
| UNSUPPORTED_JPEG = 4, |
| |
| PLATFORM_FAILURE = 5, |
| kMinValue = 0, |
| kMaxValue = 5, |
| }; |
| |
| std::ostream& operator<<(std::ostream& os, DecodeError value); |
| inline bool IsKnownEnumValue(DecodeError value) { |
| return internal::DecodeError_Data::IsKnownValue( |
| static_cast<int32_t>(value)); |
| } |
| // Interface base classes. They are used for type safety check. |
| class MjpegDecodeAcceleratorInterfaceBase {}; |
| |
| using MjpegDecodeAcceleratorPtrDataView = |
| mojo::InterfacePtrDataView<MjpegDecodeAcceleratorInterfaceBase>; |
| using MjpegDecodeAcceleratorRequestDataView = |
| mojo::InterfaceRequestDataView<MjpegDecodeAcceleratorInterfaceBase>; |
| using MjpegDecodeAcceleratorAssociatedPtrInfoDataView = |
| mojo::AssociatedInterfacePtrInfoDataView<MjpegDecodeAcceleratorInterfaceBase>; |
| using MjpegDecodeAcceleratorAssociatedRequestDataView = |
| mojo::AssociatedInterfaceRequestDataView<MjpegDecodeAcceleratorInterfaceBase>; |
| |
| |
| class BitstreamBufferDataView { |
| public: |
| BitstreamBufferDataView() = default; |
| |
| BitstreamBufferDataView( |
| internal::BitstreamBuffer_Data* data, |
| mojo::Message* message) |
| : data_(data), message_(message) {} |
| |
| bool is_null() const { return !data_; } |
| int32_t id() const { |
| return data_->id; |
| } |
| mojo::ScopedSharedBufferHandle TakeMemoryHandle() { |
| mojo::ScopedSharedBufferHandle result; |
| bool ret = |
| mojo::internal::Deserialize<mojo::ScopedSharedBufferHandle>( |
| &data_->memory_handle, &result, message_); |
| DCHECK(ret); |
| return result; |
| } |
| uint32_t size() const { |
| return data_->size; |
| } |
| int64_t offset() const { |
| return data_->offset; |
| } |
| inline void GetTimestampDataView( |
| ::mojo_base::mojom::TimeDeltaDataView* output); |
| |
| template <typename UserType> |
| [[nodiscard]] bool ReadTimestamp(UserType* output) { |
| |
| auto* pointer = data_->timestamp.Get(); |
| return mojo::internal::Deserialize<::mojo_base::mojom::TimeDeltaDataView>( |
| pointer, output, message_); |
| } |
| inline void GetKeyIdDataView( |
| mojo::StringDataView* output); |
| |
| template <typename UserType> |
| [[nodiscard]] bool ReadKeyId(UserType* output) { |
| |
| auto* pointer = data_->key_id.Get(); |
| return mojo::internal::Deserialize<mojo::StringDataView>( |
| pointer, output, message_); |
| } |
| inline void GetIvDataView( |
| mojo::StringDataView* output); |
| |
| template <typename UserType> |
| [[nodiscard]] bool ReadIv(UserType* output) { |
| |
| auto* pointer = data_->iv.Get(); |
| return mojo::internal::Deserialize<mojo::StringDataView>( |
| pointer, output, message_); |
| } |
| inline void GetSubsamplesDataView( |
| mojo::ArrayDataView<::media::mojom::SubsampleEntryDataView>* output); |
| |
| template <typename UserType> |
| [[nodiscard]] bool ReadSubsamples(UserType* output) { |
| |
| auto* pointer = data_->subsamples.Get(); |
| return mojo::internal::Deserialize<mojo::ArrayDataView<::media::mojom::SubsampleEntryDataView>>( |
| pointer, output, message_); |
| } |
| private: |
| internal::BitstreamBuffer_Data* data_ = nullptr; |
| mojo::Message* message_ = nullptr; |
| }; |
| |
| |
| } // chromeos_camera::mojom |
| |
| namespace std { |
| |
| template <> |
| struct hash<::chromeos_camera::mojom::DecodeError> |
| : public mojo::internal::EnumHashImpl<::chromeos_camera::mojom::DecodeError> {}; |
| |
| } // namespace std |
| |
| namespace mojo { |
| |
| |
| namespace internal { |
| |
| template <typename MaybeConstUserType> |
| struct Serializer<::chromeos_camera::mojom::DecodeError, MaybeConstUserType> { |
| using UserType = typename std::remove_const<MaybeConstUserType>::type; |
| using Traits = EnumTraits<::chromeos_camera::mojom::DecodeError, UserType>; |
| |
| static void Serialize(UserType input, int32_t* output) { |
| *output = static_cast<int32_t>(Traits::ToMojom(input)); |
| } |
| |
| static bool Deserialize(int32_t input, UserType* output) { |
| return Traits::FromMojom(::mojo::internal::ToKnownEnumValueHelper( |
| static_cast<::chromeos_camera::mojom::DecodeError>(input)), output); |
| } |
| }; |
| |
| } // namespace internal |
| |
| |
| namespace internal { |
| |
| template <typename MaybeConstUserType> |
| struct Serializer<::chromeos_camera::mojom::BitstreamBufferDataView, MaybeConstUserType> { |
| using UserType = typename std::remove_const<MaybeConstUserType>::type; |
| using Traits = StructTraits<::chromeos_camera::mojom::BitstreamBufferDataView, UserType>; |
| |
| static void Serialize( |
| MaybeConstUserType& input, |
| mojo::internal::MessageFragment<::chromeos_camera::mojom::internal::BitstreamBuffer_Data>& fragment) { |
| if (CallIsNullIfExists<Traits>(input)) |
| return; |
| fragment.Allocate(); |
| fragment->id = Traits::id(input); |
| decltype(Traits::memory_handle(input)) in_memory_handle = Traits::memory_handle(input); |
| mojo::internal::Serialize<mojo::ScopedSharedBufferHandle>( |
| in_memory_handle, &fragment->memory_handle, &fragment.message()); |
| MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( |
| !mojo::internal::IsHandleOrInterfaceValid(fragment->memory_handle), |
| mojo::internal::VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE, |
| "invalid memory_handle in BitstreamBuffer struct"); |
| fragment->size = Traits::size(input); |
| fragment->offset = Traits::offset(input); |
| decltype(Traits::timestamp(input)) in_timestamp = Traits::timestamp(input); |
| mojo::internal::MessageFragment< |
| typename decltype(fragment->timestamp)::BaseType> timestamp_fragment( |
| fragment.message()); |
| mojo::internal::Serialize<::mojo_base::mojom::TimeDeltaDataView>( |
| in_timestamp, timestamp_fragment); |
| fragment->timestamp.Set( |
| timestamp_fragment.is_null() ? nullptr : timestamp_fragment.data()); |
| MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( |
| fragment->timestamp.is_null(), |
| mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER, |
| "null timestamp in BitstreamBuffer struct"); |
| decltype(Traits::key_id(input)) in_key_id = Traits::key_id(input); |
| mojo::internal::MessageFragment< |
| typename decltype(fragment->key_id)::BaseType> key_id_fragment( |
| fragment.message()); |
| mojo::internal::Serialize<mojo::StringDataView>( |
| in_key_id, key_id_fragment); |
| fragment->key_id.Set( |
| key_id_fragment.is_null() ? nullptr : key_id_fragment.data()); |
| MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( |
| fragment->key_id.is_null(), |
| mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER, |
| "null key_id in BitstreamBuffer struct"); |
| decltype(Traits::iv(input)) in_iv = Traits::iv(input); |
| mojo::internal::MessageFragment< |
| typename decltype(fragment->iv)::BaseType> iv_fragment( |
| fragment.message()); |
| mojo::internal::Serialize<mojo::StringDataView>( |
| in_iv, iv_fragment); |
| fragment->iv.Set( |
| iv_fragment.is_null() ? nullptr : iv_fragment.data()); |
| MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( |
| fragment->iv.is_null(), |
| mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER, |
| "null iv in BitstreamBuffer struct"); |
| decltype(Traits::subsamples(input)) in_subsamples = Traits::subsamples(input); |
| mojo::internal::MessageFragment< |
| typename decltype(fragment->subsamples)::BaseType> |
| subsamples_fragment(fragment.message()); |
| constexpr const mojo::internal::ContainerValidateParams& subsamples_validate_params = |
| mojo::internal::GetArrayValidator<0, false, nullptr>(); |
| mojo::internal::Serialize<mojo::ArrayDataView<::media::mojom::SubsampleEntryDataView>>( |
| in_subsamples, subsamples_fragment, &subsamples_validate_params); |
| fragment->subsamples.Set( |
| subsamples_fragment.is_null() ? nullptr : subsamples_fragment.data()); |
| MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( |
| fragment->subsamples.is_null(), |
| mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER, |
| "null subsamples in BitstreamBuffer struct"); |
| } |
| |
| static bool Deserialize(::chromeos_camera::mojom::internal::BitstreamBuffer_Data* input, |
| UserType* output, |
| Message* message) { |
| if (!input) |
| return CallSetToNullIfExists<Traits>(output); |
| |
| ::chromeos_camera::mojom::BitstreamBufferDataView data_view(input, message); |
| return Traits::Read(data_view, output); |
| } |
| }; |
| |
| } // namespace internal |
| |
| } // namespace mojo |
| |
| |
| namespace chromeos_camera::mojom { |
| |
| inline void BitstreamBufferDataView::GetTimestampDataView( |
| ::mojo_base::mojom::TimeDeltaDataView* output) { |
| auto pointer = data_->timestamp.Get(); |
| *output = ::mojo_base::mojom::TimeDeltaDataView(pointer, message_); |
| } |
| inline void BitstreamBufferDataView::GetKeyIdDataView( |
| mojo::StringDataView* output) { |
| auto pointer = data_->key_id.Get(); |
| *output = mojo::StringDataView(pointer, message_); |
| } |
| inline void BitstreamBufferDataView::GetIvDataView( |
| mojo::StringDataView* output) { |
| auto pointer = data_->iv.Get(); |
| *output = mojo::StringDataView(pointer, message_); |
| } |
| inline void BitstreamBufferDataView::GetSubsamplesDataView( |
| mojo::ArrayDataView<::media::mojom::SubsampleEntryDataView>* output) { |
| auto pointer = data_->subsamples.Get(); |
| *output = mojo::ArrayDataView<::media::mojom::SubsampleEntryDataView>(pointer, message_); |
| } |
| |
| |
| |
| } // chromeos_camera::mojom |
| |
| // Declare TraceFormatTraits for enums, which should be defined in ::perfetto |
| // namespace. |
| |
| namespace perfetto { |
| |
| template <> |
| struct TraceFormatTraits<::chromeos_camera::mojom::DecodeError> { |
| static void WriteIntoTrace(perfetto::TracedValue context, ::chromeos_camera::mojom::DecodeError value); |
| }; |
| |
| } // namespace perfetto |
| |
| #endif // COMPONENTS_CHROMEOS_CAMERA_COMMON_MJPEG_DECODE_ACCELERATOR_MOJOM_SHARED_H_ |