| // media/capture/video/chromeos/mojom/camera_common.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 MEDIA_CAPTURE_VIDEO_CHROMEOS_MOJOM_CAMERA_COMMON_MOJOM_SHARED_H_ |
| #define MEDIA_CAPTURE_VIDEO_CHROMEOS_MOJOM_CAMERA_COMMON_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 "media/capture/video/chromeos/mojom/camera_common.mojom-shared-internal.h" |
| #include "media/capture/video/chromeos/mojom/camera3.mojom-shared.h" |
| #include "media/capture/video/chromeos/mojom/camera_metadata.mojom-shared.h" |
| #include "mojo/public/cpp/bindings/lib/interface_serialization.h" |
| #include "mojo/public/cpp/system/data_pipe.h" |
| |
| |
| |
| |
| |
| |
| namespace cros::mojom { |
| class CameraResourceCostDataView; |
| |
| class CameraInfoDataView; |
| |
| |
| |
| } // cros::mojom |
| |
| namespace mojo { |
| namespace internal { |
| |
| template <> |
| struct MojomTypeTraits<::cros::mojom::CameraResourceCostDataView> { |
| using Data = ::cros::mojom::internal::CameraResourceCost_Data; |
| using DataAsArrayElement = Pointer<Data>; |
| static constexpr MojomTypeCategory category = MojomTypeCategory::kStruct; |
| }; |
| |
| template <> |
| struct MojomTypeTraits<::cros::mojom::CameraInfoDataView> { |
| using Data = ::cros::mojom::internal::CameraInfo_Data; |
| using DataAsArrayElement = Pointer<Data>; |
| static constexpr MojomTypeCategory category = MojomTypeCategory::kStruct; |
| }; |
| |
| } // namespace internal |
| } // namespace mojo |
| |
| |
| namespace cros::mojom { |
| |
| |
| enum class CameraFacing : int32_t { |
| |
| CAMERA_FACING_BACK = 0, |
| |
| CAMERA_FACING_FRONT = 1, |
| |
| CAMERA_FACING_EXTERNAL = 2, |
| |
| CAMERA_FACING_VIRTUAL_BACK = 3, |
| |
| CAMERA_FACING_VIRTUAL_FRONT = 4, |
| |
| CAMERA_FACING_VIRTUAL_EXTERNAL = 5, |
| kMinValue = 0, |
| kMaxValue = 5, |
| }; |
| |
| std::ostream& operator<<(std::ostream& os, CameraFacing value); |
| inline bool IsKnownEnumValue(CameraFacing value) { |
| return internal::CameraFacing_Data::IsKnownValue( |
| static_cast<int32_t>(value)); |
| } |
| |
| |
| enum class CameraDeviceStatus : int32_t { |
| |
| CAMERA_DEVICE_STATUS_NOT_PRESENT = 0, |
| |
| CAMERA_DEVICE_STATUS_PRESENT = 1, |
| |
| CAMERA_DEVICE_STATUS_ENUMERATING = 2, |
| kMinValue = 0, |
| kMaxValue = 2, |
| }; |
| |
| std::ostream& operator<<(std::ostream& os, CameraDeviceStatus value); |
| inline bool IsKnownEnumValue(CameraDeviceStatus value) { |
| return internal::CameraDeviceStatus_Data::IsKnownValue( |
| static_cast<int32_t>(value)); |
| } |
| |
| |
| enum class TorchModeStatus : int32_t { |
| |
| TORCH_MODE_STATUS_NOT_AVAILABLE = 0, |
| |
| TORCH_MODE_STATUS_AVAILABLE_OFF = 1, |
| |
| TORCH_MODE_STATUS_AVAILABLE_ON = 2, |
| kMinValue = 0, |
| kMaxValue = 2, |
| }; |
| |
| std::ostream& operator<<(std::ostream& os, TorchModeStatus value); |
| inline bool IsKnownEnumValue(TorchModeStatus value) { |
| return internal::TorchModeStatus_Data::IsKnownValue( |
| static_cast<int32_t>(value)); |
| } |
| // Interface base classes. They are used for type safety check. |
| class CameraModuleCallbacksInterfaceBase {}; |
| |
| using CameraModuleCallbacksPtrDataView = |
| mojo::InterfacePtrDataView<CameraModuleCallbacksInterfaceBase>; |
| using CameraModuleCallbacksRequestDataView = |
| mojo::InterfaceRequestDataView<CameraModuleCallbacksInterfaceBase>; |
| using CameraModuleCallbacksAssociatedPtrInfoDataView = |
| mojo::AssociatedInterfacePtrInfoDataView<CameraModuleCallbacksInterfaceBase>; |
| using CameraModuleCallbacksAssociatedRequestDataView = |
| mojo::AssociatedInterfaceRequestDataView<CameraModuleCallbacksInterfaceBase>; |
| class VendorTagOpsInterfaceBase {}; |
| |
| using VendorTagOpsPtrDataView = |
| mojo::InterfacePtrDataView<VendorTagOpsInterfaceBase>; |
| using VendorTagOpsRequestDataView = |
| mojo::InterfaceRequestDataView<VendorTagOpsInterfaceBase>; |
| using VendorTagOpsAssociatedPtrInfoDataView = |
| mojo::AssociatedInterfacePtrInfoDataView<VendorTagOpsInterfaceBase>; |
| using VendorTagOpsAssociatedRequestDataView = |
| mojo::AssociatedInterfaceRequestDataView<VendorTagOpsInterfaceBase>; |
| class CameraModuleInterfaceBase {}; |
| |
| using CameraModulePtrDataView = |
| mojo::InterfacePtrDataView<CameraModuleInterfaceBase>; |
| using CameraModuleRequestDataView = |
| mojo::InterfaceRequestDataView<CameraModuleInterfaceBase>; |
| using CameraModuleAssociatedPtrInfoDataView = |
| mojo::AssociatedInterfacePtrInfoDataView<CameraModuleInterfaceBase>; |
| using CameraModuleAssociatedRequestDataView = |
| mojo::AssociatedInterfaceRequestDataView<CameraModuleInterfaceBase>; |
| |
| |
| class CameraResourceCostDataView { |
| public: |
| CameraResourceCostDataView() = default; |
| |
| CameraResourceCostDataView( |
| internal::CameraResourceCost_Data* data, |
| mojo::Message* message) |
| : data_(data) {} |
| |
| bool is_null() const { return !data_; } |
| uint32_t resource_cost() const { |
| return data_->resource_cost; |
| } |
| private: |
| internal::CameraResourceCost_Data* data_ = nullptr; |
| }; |
| |
| |
| class CameraInfoDataView { |
| public: |
| CameraInfoDataView() = default; |
| |
| CameraInfoDataView( |
| internal::CameraInfo_Data* data, |
| mojo::Message* message) |
| : data_(data), message_(message) {} |
| |
| bool is_null() const { return !data_; } |
| template <typename UserType> |
| [[nodiscard]] bool ReadFacing(UserType* output) const { |
| auto data_value = data_->facing; |
| return mojo::internal::Deserialize<::cros::mojom::CameraFacing>( |
| data_value, output); |
| } |
| CameraFacing facing() const { |
| return ::mojo::internal::ToKnownEnumValueHelper( |
| static_cast<::cros::mojom::CameraFacing>(data_->facing)); |
| } |
| int32_t orientation() const { |
| return data_->orientation; |
| } |
| uint32_t device_version() const { |
| return data_->device_version; |
| } |
| inline void GetStaticCameraCharacteristicsDataView( |
| ::cros::mojom::CameraMetadataDataView* output); |
| |
| template <typename UserType> |
| [[nodiscard]] bool ReadStaticCameraCharacteristics(UserType* output) { |
| |
| auto* pointer = data_->static_camera_characteristics.Get(); |
| return mojo::internal::Deserialize<::cros::mojom::CameraMetadataDataView>( |
| pointer, output, message_); |
| } |
| inline void GetResourceCostDataView( |
| CameraResourceCostDataView* output); |
| |
| template <typename UserType> |
| [[nodiscard]] bool ReadResourceCost(UserType* output) { |
| |
| static_assert( |
| mojo::internal::IsValidUserTypeForOptionalValue< |
| ::cros::mojom::CameraResourceCostDataView, UserType>(), |
| "Attempting to read the optional `resource_cost` field into a type which " |
| "cannot represent a null value. Either wrap the destination object " |
| "with std::optional, ensure that any corresponding " |
| "{Struct/Union/Array/String}Traits define the necessary IsNull and " |
| "SetToNull methods, or use `MaybeReadResourceCost` instead " |
| "of `ReadResourceCost if you're fine with null values being " |
| "silently ignored in this case."); |
| auto* pointer = data_->header_.version >= 1 |
| ? data_->resource_cost.Get() : nullptr; |
| return mojo::internal::Deserialize<::cros::mojom::CameraResourceCostDataView>( |
| pointer, output, message_); |
| } |
| inline void GetConflictingDevicesDataView( |
| mojo::ArrayDataView<mojo::StringDataView>* output); |
| |
| template <typename UserType> |
| [[nodiscard]] bool ReadConflictingDevices(UserType* output) { |
| |
| static_assert( |
| mojo::internal::IsValidUserTypeForOptionalValue< |
| mojo::ArrayDataView<mojo::StringDataView>, UserType>(), |
| "Attempting to read the optional `conflicting_devices` field into a type which " |
| "cannot represent a null value. Either wrap the destination object " |
| "with std::optional, ensure that any corresponding " |
| "{Struct/Union/Array/String}Traits define the necessary IsNull and " |
| "SetToNull methods, or use `MaybeReadConflictingDevices` instead " |
| "of `ReadConflictingDevices if you're fine with null values being " |
| "silently ignored in this case."); |
| auto* pointer = data_->header_.version >= 1 |
| ? data_->conflicting_devices.Get() : nullptr; |
| return mojo::internal::Deserialize<mojo::ArrayDataView<mojo::StringDataView>>( |
| pointer, output, message_); |
| } |
| private: |
| internal::CameraInfo_Data* data_ = nullptr; |
| mojo::Message* message_ = nullptr; |
| }; |
| |
| |
| } // cros::mojom |
| |
| namespace std { |
| |
| template <> |
| struct hash<::cros::mojom::CameraFacing> |
| : public mojo::internal::EnumHashImpl<::cros::mojom::CameraFacing> {}; |
| |
| template <> |
| struct hash<::cros::mojom::CameraDeviceStatus> |
| : public mojo::internal::EnumHashImpl<::cros::mojom::CameraDeviceStatus> {}; |
| |
| template <> |
| struct hash<::cros::mojom::TorchModeStatus> |
| : public mojo::internal::EnumHashImpl<::cros::mojom::TorchModeStatus> {}; |
| |
| } // namespace std |
| |
| namespace mojo { |
| |
| |
| namespace internal { |
| |
| template <typename MaybeConstUserType> |
| struct Serializer<::cros::mojom::CameraFacing, MaybeConstUserType> { |
| using UserType = typename std::remove_const<MaybeConstUserType>::type; |
| using Traits = EnumTraits<::cros::mojom::CameraFacing, 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<::cros::mojom::CameraFacing>(input)), output); |
| } |
| }; |
| |
| } // namespace internal |
| |
| |
| namespace internal { |
| |
| template <typename MaybeConstUserType> |
| struct Serializer<::cros::mojom::CameraDeviceStatus, MaybeConstUserType> { |
| using UserType = typename std::remove_const<MaybeConstUserType>::type; |
| using Traits = EnumTraits<::cros::mojom::CameraDeviceStatus, 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<::cros::mojom::CameraDeviceStatus>(input)), output); |
| } |
| }; |
| |
| } // namespace internal |
| |
| |
| namespace internal { |
| |
| template <typename MaybeConstUserType> |
| struct Serializer<::cros::mojom::TorchModeStatus, MaybeConstUserType> { |
| using UserType = typename std::remove_const<MaybeConstUserType>::type; |
| using Traits = EnumTraits<::cros::mojom::TorchModeStatus, 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<::cros::mojom::TorchModeStatus>(input)), output); |
| } |
| }; |
| |
| } // namespace internal |
| |
| |
| namespace internal { |
| |
| template <typename MaybeConstUserType> |
| struct Serializer<::cros::mojom::CameraResourceCostDataView, MaybeConstUserType> { |
| using UserType = typename std::remove_const<MaybeConstUserType>::type; |
| using Traits = StructTraits<::cros::mojom::CameraResourceCostDataView, UserType>; |
| |
| static void Serialize( |
| MaybeConstUserType& input, |
| mojo::internal::MessageFragment<::cros::mojom::internal::CameraResourceCost_Data>& fragment) { |
| if (CallIsNullIfExists<Traits>(input)) |
| return; |
| fragment.Allocate(); |
| fragment->resource_cost = Traits::resource_cost(input); |
| } |
| |
| static bool Deserialize(::cros::mojom::internal::CameraResourceCost_Data* input, |
| UserType* output, |
| Message* message) { |
| if (!input) |
| return CallSetToNullIfExists<Traits>(output); |
| |
| ::cros::mojom::CameraResourceCostDataView data_view(input, message); |
| return Traits::Read(data_view, output); |
| } |
| }; |
| |
| } // namespace internal |
| |
| |
| namespace internal { |
| |
| template <typename MaybeConstUserType> |
| struct Serializer<::cros::mojom::CameraInfoDataView, MaybeConstUserType> { |
| using UserType = typename std::remove_const<MaybeConstUserType>::type; |
| using Traits = StructTraits<::cros::mojom::CameraInfoDataView, UserType>; |
| |
| static void Serialize( |
| MaybeConstUserType& input, |
| mojo::internal::MessageFragment<::cros::mojom::internal::CameraInfo_Data>& fragment) { |
| if (CallIsNullIfExists<Traits>(input)) |
| return; |
| fragment.Allocate(); |
| mojo::internal::Serialize<::cros::mojom::CameraFacing>( |
| Traits::facing(input), &fragment->facing); |
| fragment->orientation = Traits::orientation(input); |
| fragment->device_version = Traits::device_version(input); |
| decltype(Traits::static_camera_characteristics(input)) in_static_camera_characteristics = Traits::static_camera_characteristics(input); |
| mojo::internal::MessageFragment< |
| typename decltype(fragment->static_camera_characteristics)::BaseType> static_camera_characteristics_fragment( |
| fragment.message()); |
| mojo::internal::Serialize<::cros::mojom::CameraMetadataDataView>( |
| in_static_camera_characteristics, static_camera_characteristics_fragment); |
| fragment->static_camera_characteristics.Set( |
| static_camera_characteristics_fragment.is_null() ? nullptr : static_camera_characteristics_fragment.data()); |
| MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( |
| fragment->static_camera_characteristics.is_null(), |
| mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER, |
| "null static_camera_characteristics in CameraInfo struct"); |
| decltype(Traits::resource_cost(input)) in_resource_cost = Traits::resource_cost(input); |
| mojo::internal::MessageFragment< |
| typename decltype(fragment->resource_cost)::BaseType> resource_cost_fragment( |
| fragment.message()); |
| mojo::internal::Serialize<::cros::mojom::CameraResourceCostDataView>( |
| in_resource_cost, resource_cost_fragment); |
| fragment->resource_cost.Set( |
| resource_cost_fragment.is_null() ? nullptr : resource_cost_fragment.data()); |
| decltype(Traits::conflicting_devices(input)) in_conflicting_devices = Traits::conflicting_devices(input); |
| mojo::internal::MessageFragment< |
| typename decltype(fragment->conflicting_devices)::BaseType> |
| conflicting_devices_fragment(fragment.message()); |
| constexpr const mojo::internal::ContainerValidateParams& conflicting_devices_validate_params = |
| mojo::internal::GetArrayValidator<0, false, &mojo::internal::GetArrayValidator<0, false, nullptr>()>(); |
| mojo::internal::Serialize<mojo::ArrayDataView<mojo::StringDataView>>( |
| in_conflicting_devices, conflicting_devices_fragment, &conflicting_devices_validate_params); |
| fragment->conflicting_devices.Set( |
| conflicting_devices_fragment.is_null() ? nullptr : conflicting_devices_fragment.data()); |
| } |
| |
| static bool Deserialize(::cros::mojom::internal::CameraInfo_Data* input, |
| UserType* output, |
| Message* message) { |
| if (!input) |
| return CallSetToNullIfExists<Traits>(output); |
| |
| ::cros::mojom::CameraInfoDataView data_view(input, message); |
| return Traits::Read(data_view, output); |
| } |
| }; |
| |
| } // namespace internal |
| |
| } // namespace mojo |
| |
| |
| namespace cros::mojom { |
| |
| |
| |
| inline void CameraInfoDataView::GetStaticCameraCharacteristicsDataView( |
| ::cros::mojom::CameraMetadataDataView* output) { |
| auto pointer = data_->static_camera_characteristics.Get(); |
| *output = ::cros::mojom::CameraMetadataDataView(pointer, message_); |
| } |
| inline void CameraInfoDataView::GetResourceCostDataView( |
| CameraResourceCostDataView* output) { |
| auto pointer = data_->header_.version >= 1 |
| ? data_->resource_cost.Get() : nullptr; |
| *output = CameraResourceCostDataView(pointer, message_); |
| } |
| inline void CameraInfoDataView::GetConflictingDevicesDataView( |
| mojo::ArrayDataView<mojo::StringDataView>* output) { |
| auto pointer = data_->header_.version >= 1 |
| ? data_->conflicting_devices.Get() : nullptr; |
| *output = mojo::ArrayDataView<mojo::StringDataView>(pointer, message_); |
| } |
| |
| |
| |
| } // cros::mojom |
| |
| // Declare TraceFormatTraits for enums, which should be defined in ::perfetto |
| // namespace. |
| |
| namespace perfetto { |
| |
| template <> |
| struct TraceFormatTraits<::cros::mojom::CameraFacing> { |
| static void WriteIntoTrace(perfetto::TracedValue context, ::cros::mojom::CameraFacing value); |
| }; |
| |
| } // namespace perfetto |
| |
| namespace perfetto { |
| |
| template <> |
| struct TraceFormatTraits<::cros::mojom::CameraDeviceStatus> { |
| static void WriteIntoTrace(perfetto::TracedValue context, ::cros::mojom::CameraDeviceStatus value); |
| }; |
| |
| } // namespace perfetto |
| |
| namespace perfetto { |
| |
| template <> |
| struct TraceFormatTraits<::cros::mojom::TorchModeStatus> { |
| static void WriteIntoTrace(perfetto::TracedValue context, ::cros::mojom::TorchModeStatus value); |
| }; |
| |
| } // namespace perfetto |
| |
| #endif // MEDIA_CAPTURE_VIDEO_CHROMEOS_MOJOM_CAMERA_COMMON_MOJOM_SHARED_H_ |