| // media/capture/video/chromeos/mojom/effects_pipeline.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_EFFECTS_PIPELINE_MOJOM_SHARED_H_ |
| #define MEDIA_CAPTURE_VIDEO_CHROMEOS_MOJOM_EFFECTS_PIPELINE_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/effects_pipeline.mojom-shared-internal.h" |
| #include "mojo/public/mojom/base/file_path.mojom-shared.h" |
| |
| |
| |
| |
| |
| |
| |
| namespace cros::mojom { |
| class EffectsConfigDataView; |
| |
| |
| |
| } // cros::mojom |
| |
| namespace mojo { |
| namespace internal { |
| |
| template <> |
| struct MojomTypeTraits<::cros::mojom::EffectsConfigDataView> { |
| using Data = ::cros::mojom::internal::EffectsConfig_Data; |
| using DataAsArrayElement = Pointer<Data>; |
| static constexpr MojomTypeCategory category = MojomTypeCategory::kStruct; |
| }; |
| |
| } // namespace internal |
| } // namespace mojo |
| |
| |
| namespace cros::mojom { |
| |
| |
| enum class CameraEffect : int32_t { |
| |
| kNone = 0, |
| |
| kBackgroundBlur = 1, |
| |
| kBackgroundReplace = 2, |
| |
| kPortraitRelight = 3, |
| kMinValue = 0, |
| kMaxValue = 3, |
| kDefaultValue = 0 |
| }; |
| |
| std::ostream& operator<<(std::ostream& os, CameraEffect value); |
| inline bool IsKnownEnumValue(CameraEffect value) { |
| return internal::CameraEffect_Data::IsKnownValue( |
| static_cast<int32_t>(value)); |
| } |
| inline CameraEffect ToKnownEnumValue(CameraEffect value) { |
| if (IsKnownEnumValue(value)) { |
| return value; |
| } |
| return CameraEffect::kDefaultValue; |
| } |
| |
| |
| enum class GpuApi : int32_t { |
| |
| kOpenCL = 0, |
| |
| kOpenGL = 1, |
| kMinValue = 0, |
| kMaxValue = 1, |
| kDefaultValue = 1 |
| }; |
| |
| std::ostream& operator<<(std::ostream& os, GpuApi value); |
| inline bool IsKnownEnumValue(GpuApi value) { |
| return internal::GpuApi_Data::IsKnownValue( |
| static_cast<int32_t>(value)); |
| } |
| inline GpuApi ToKnownEnumValue(GpuApi value) { |
| if (IsKnownEnumValue(value)) { |
| return value; |
| } |
| return GpuApi::kDefaultValue; |
| } |
| |
| |
| enum class SetEffectResult : int32_t { |
| |
| kOk = 0, |
| |
| kError = 1, |
| kMinValue = 0, |
| kMaxValue = 1, |
| kDefaultValue = 0 |
| }; |
| |
| std::ostream& operator<<(std::ostream& os, SetEffectResult value); |
| inline bool IsKnownEnumValue(SetEffectResult value) { |
| return internal::SetEffectResult_Data::IsKnownValue( |
| static_cast<int32_t>(value)); |
| } |
| inline SetEffectResult ToKnownEnumValue(SetEffectResult value) { |
| if (IsKnownEnumValue(value)) { |
| return value; |
| } |
| return SetEffectResult::kDefaultValue; |
| } |
| |
| |
| enum class BlurLevel : int32_t { |
| |
| kLowest = 0, |
| |
| kLight = 1, |
| |
| kMedium = 2, |
| |
| kHeavy = 3, |
| |
| kMaximum = 4, |
| kMinValue = 0, |
| kMaxValue = 4, |
| kDefaultValue = 2 |
| }; |
| |
| std::ostream& operator<<(std::ostream& os, BlurLevel value); |
| inline bool IsKnownEnumValue(BlurLevel value) { |
| return internal::BlurLevel_Data::IsKnownValue( |
| static_cast<int32_t>(value)); |
| } |
| inline BlurLevel ToKnownEnumValue(BlurLevel value) { |
| if (IsKnownEnumValue(value)) { |
| return value; |
| } |
| return BlurLevel::kDefaultValue; |
| } |
| |
| |
| enum class SegmentationModel : int32_t { |
| |
| kAuto = 0, |
| |
| kHighResolution = 1, |
| |
| kLowerResolution = 2, |
| kMinValue = 0, |
| kMaxValue = 2, |
| kDefaultValue = 1 |
| }; |
| |
| std::ostream& operator<<(std::ostream& os, SegmentationModel value); |
| inline bool IsKnownEnumValue(SegmentationModel value) { |
| return internal::SegmentationModel_Data::IsKnownValue( |
| static_cast<int32_t>(value)); |
| } |
| inline SegmentationModel ToKnownEnumValue(SegmentationModel value) { |
| if (IsKnownEnumValue(value)) { |
| return value; |
| } |
| return SegmentationModel::kDefaultValue; |
| } |
| |
| |
| class EffectsConfigDataView { |
| public: |
| EffectsConfigDataView() = default; |
| |
| EffectsConfigDataView( |
| internal::EffectsConfig_Data* data, |
| mojo::Message* message) |
| : data_(data), message_(message) {} |
| |
| bool is_null() const { return !data_; } |
| template <typename UserType> |
| [[nodiscard]] bool ReadEffect(UserType* output) const { |
| auto data_value = data_->effect; |
| return mojo::internal::Deserialize<::cros::mojom::CameraEffect>( |
| data_value, output); |
| } |
| CameraEffect effect() const { |
| return ::mojo::internal::ToKnownEnumValueHelper( |
| static_cast<::cros::mojom::CameraEffect>(data_->effect)); |
| } |
| template <typename UserType> |
| [[nodiscard]] bool ReadBlurLevel(UserType* output) const { |
| auto data_value = data_->blur_level; |
| return mojo::internal::Deserialize<::cros::mojom::BlurLevel>( |
| data_value, output); |
| } |
| BlurLevel blur_level() const { |
| return ::mojo::internal::ToKnownEnumValueHelper( |
| static_cast<::cros::mojom::BlurLevel>(data_->blur_level)); |
| } |
| template <typename UserType> |
| [[nodiscard]] bool ReadSegmentationGpuApi(UserType* output) const { |
| auto data_value = data_->segmentation_gpu_api; |
| return mojo::internal::Deserialize<::cros::mojom::GpuApi>( |
| data_value, output); |
| } |
| GpuApi segmentation_gpu_api() const { |
| return ::mojo::internal::ToKnownEnumValueHelper( |
| static_cast<::cros::mojom::GpuApi>(data_->segmentation_gpu_api)); |
| } |
| uint16_t graph_max_frames_in_flight() const { |
| return data_->graph_max_frames_in_flight; |
| } |
| bool blur_enabled() const { |
| if (data_->header_.version < 1) |
| return bool{}; |
| return data_->blur_enabled; |
| } |
| bool replace_enabled() const { |
| if (data_->header_.version < 1) |
| return bool{}; |
| return data_->replace_enabled; |
| } |
| bool relight_enabled() const { |
| if (data_->header_.version < 1) |
| return bool{}; |
| return data_->relight_enabled; |
| } |
| template <typename UserType> |
| [[nodiscard]] bool ReadSegmentationModel(UserType* output) const { |
| auto data_value = data_->header_.version >= 2 |
| ? data_->segmentation_model : 0; |
| return mojo::internal::Deserialize<::cros::mojom::SegmentationModel>( |
| data_value, output); |
| } |
| SegmentationModel segmentation_model() const { |
| if (data_->header_.version < 2) |
| return SegmentationModel{}; |
| return ::mojo::internal::ToKnownEnumValueHelper( |
| static_cast<::cros::mojom::SegmentationModel>(data_->segmentation_model)); |
| } |
| inline void GetBackgroundFilepathDataView( |
| ::mojo_base::mojom::RelativeFilePathDataView* output); |
| |
| template <typename UserType> |
| [[nodiscard]] bool ReadBackgroundFilepath(UserType* output) { |
| |
| static_assert( |
| mojo::internal::IsValidUserTypeForOptionalValue< |
| ::mojo_base::mojom::RelativeFilePathDataView, UserType>(), |
| "Attempting to read the optional `background_filepath` 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 `MaybeReadBackgroundFilepath` instead " |
| "of `ReadBackgroundFilepath if you're fine with null values being " |
| "silently ignored in this case."); |
| auto* pointer = data_->header_.version >= 3 |
| ? data_->background_filepath.Get() : nullptr; |
| return mojo::internal::Deserialize<::mojo_base::mojom::RelativeFilePathDataView>( |
| pointer, output, message_); |
| } |
| std::optional<float> light_intensity() const { |
| if (data_->header_.version < 4) { |
| return std::nullopt; |
| } |
| |
| return data_->light_intensity_$flag |
| ? std::make_optional(data_->light_intensity_$value) |
| : std::nullopt; |
| } |
| private: |
| internal::EffectsConfig_Data* data_ = nullptr; |
| mojo::Message* message_ = nullptr; |
| }; |
| |
| |
| } // cros::mojom |
| |
| namespace std { |
| |
| template <> |
| struct hash<::cros::mojom::CameraEffect> |
| : public mojo::internal::EnumHashImpl<::cros::mojom::CameraEffect> {}; |
| |
| template <> |
| struct hash<::cros::mojom::GpuApi> |
| : public mojo::internal::EnumHashImpl<::cros::mojom::GpuApi> {}; |
| |
| template <> |
| struct hash<::cros::mojom::SetEffectResult> |
| : public mojo::internal::EnumHashImpl<::cros::mojom::SetEffectResult> {}; |
| |
| template <> |
| struct hash<::cros::mojom::BlurLevel> |
| : public mojo::internal::EnumHashImpl<::cros::mojom::BlurLevel> {}; |
| |
| template <> |
| struct hash<::cros::mojom::SegmentationModel> |
| : public mojo::internal::EnumHashImpl<::cros::mojom::SegmentationModel> {}; |
| |
| } // namespace std |
| |
| namespace mojo { |
| |
| |
| namespace internal { |
| |
| template <typename MaybeConstUserType> |
| struct Serializer<::cros::mojom::CameraEffect, MaybeConstUserType> { |
| using UserType = typename std::remove_const<MaybeConstUserType>::type; |
| using Traits = EnumTraits<::cros::mojom::CameraEffect, 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::CameraEffect>(input)), output); |
| } |
| }; |
| |
| } // namespace internal |
| |
| |
| namespace internal { |
| |
| template <typename MaybeConstUserType> |
| struct Serializer<::cros::mojom::GpuApi, MaybeConstUserType> { |
| using UserType = typename std::remove_const<MaybeConstUserType>::type; |
| using Traits = EnumTraits<::cros::mojom::GpuApi, 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::GpuApi>(input)), output); |
| } |
| }; |
| |
| } // namespace internal |
| |
| |
| namespace internal { |
| |
| template <typename MaybeConstUserType> |
| struct Serializer<::cros::mojom::SetEffectResult, MaybeConstUserType> { |
| using UserType = typename std::remove_const<MaybeConstUserType>::type; |
| using Traits = EnumTraits<::cros::mojom::SetEffectResult, 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::SetEffectResult>(input)), output); |
| } |
| }; |
| |
| } // namespace internal |
| |
| |
| namespace internal { |
| |
| template <typename MaybeConstUserType> |
| struct Serializer<::cros::mojom::BlurLevel, MaybeConstUserType> { |
| using UserType = typename std::remove_const<MaybeConstUserType>::type; |
| using Traits = EnumTraits<::cros::mojom::BlurLevel, 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::BlurLevel>(input)), output); |
| } |
| }; |
| |
| } // namespace internal |
| |
| |
| namespace internal { |
| |
| template <typename MaybeConstUserType> |
| struct Serializer<::cros::mojom::SegmentationModel, MaybeConstUserType> { |
| using UserType = typename std::remove_const<MaybeConstUserType>::type; |
| using Traits = EnumTraits<::cros::mojom::SegmentationModel, 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::SegmentationModel>(input)), output); |
| } |
| }; |
| |
| } // namespace internal |
| |
| |
| namespace internal { |
| |
| template <typename MaybeConstUserType> |
| struct Serializer<::cros::mojom::EffectsConfigDataView, MaybeConstUserType> { |
| using UserType = typename std::remove_const<MaybeConstUserType>::type; |
| using Traits = StructTraits<::cros::mojom::EffectsConfigDataView, UserType>; |
| |
| static void Serialize( |
| MaybeConstUserType& input, |
| mojo::internal::MessageFragment<::cros::mojom::internal::EffectsConfig_Data>& fragment) { |
| if (CallIsNullIfExists<Traits>(input)) |
| return; |
| fragment.Allocate(); |
| mojo::internal::Serialize<::cros::mojom::CameraEffect>( |
| Traits::effect(input), &fragment->effect); |
| mojo::internal::Serialize<::cros::mojom::BlurLevel>( |
| Traits::blur_level(input), &fragment->blur_level); |
| mojo::internal::Serialize<::cros::mojom::GpuApi>( |
| Traits::segmentation_gpu_api(input), &fragment->segmentation_gpu_api); |
| fragment->graph_max_frames_in_flight = Traits::graph_max_frames_in_flight(input); |
| fragment->blur_enabled = Traits::blur_enabled(input); |
| fragment->replace_enabled = Traits::replace_enabled(input); |
| fragment->relight_enabled = Traits::relight_enabled(input); |
| mojo::internal::Serialize<::cros::mojom::SegmentationModel>( |
| Traits::segmentation_model(input), &fragment->segmentation_model); |
| decltype(Traits::background_filepath(input)) in_background_filepath = Traits::background_filepath(input); |
| mojo::internal::MessageFragment< |
| typename decltype(fragment->background_filepath)::BaseType> background_filepath_fragment( |
| fragment.message()); |
| mojo::internal::Serialize<::mojo_base::mojom::RelativeFilePathDataView>( |
| in_background_filepath, background_filepath_fragment); |
| fragment->background_filepath.Set( |
| background_filepath_fragment.is_null() ? nullptr : background_filepath_fragment.data()); |
| fragment->light_intensity_$flag = Traits::light_intensity(input).has_value(); |
| if (Traits::light_intensity(input).has_value()) { |
| fragment->light_intensity_$value = Traits::light_intensity(input).value(); |
| } |
| } |
| |
| static bool Deserialize(::cros::mojom::internal::EffectsConfig_Data* input, |
| UserType* output, |
| Message* message) { |
| if (!input) |
| return CallSetToNullIfExists<Traits>(output); |
| |
| ::cros::mojom::EffectsConfigDataView data_view(input, message); |
| return Traits::Read(data_view, output); |
| } |
| }; |
| |
| } // namespace internal |
| |
| } // namespace mojo |
| |
| |
| namespace cros::mojom { |
| |
| inline void EffectsConfigDataView::GetBackgroundFilepathDataView( |
| ::mojo_base::mojom::RelativeFilePathDataView* output) { |
| auto pointer = data_->header_.version >= 3 |
| ? data_->background_filepath.Get() : nullptr; |
| *output = ::mojo_base::mojom::RelativeFilePathDataView(pointer, message_); |
| } |
| |
| |
| |
| } // cros::mojom |
| |
| // Declare TraceFormatTraits for enums, which should be defined in ::perfetto |
| // namespace. |
| |
| namespace perfetto { |
| |
| template <> |
| struct TraceFormatTraits<::cros::mojom::CameraEffect> { |
| static void WriteIntoTrace(perfetto::TracedValue context, ::cros::mojom::CameraEffect value); |
| }; |
| |
| } // namespace perfetto |
| |
| namespace perfetto { |
| |
| template <> |
| struct TraceFormatTraits<::cros::mojom::GpuApi> { |
| static void WriteIntoTrace(perfetto::TracedValue context, ::cros::mojom::GpuApi value); |
| }; |
| |
| } // namespace perfetto |
| |
| namespace perfetto { |
| |
| template <> |
| struct TraceFormatTraits<::cros::mojom::SetEffectResult> { |
| static void WriteIntoTrace(perfetto::TracedValue context, ::cros::mojom::SetEffectResult value); |
| }; |
| |
| } // namespace perfetto |
| |
| namespace perfetto { |
| |
| template <> |
| struct TraceFormatTraits<::cros::mojom::BlurLevel> { |
| static void WriteIntoTrace(perfetto::TracedValue context, ::cros::mojom::BlurLevel value); |
| }; |
| |
| } // namespace perfetto |
| |
| namespace perfetto { |
| |
| template <> |
| struct TraceFormatTraits<::cros::mojom::SegmentationModel> { |
| static void WriteIntoTrace(perfetto::TracedValue context, ::cros::mojom::SegmentationModel value); |
| }; |
| |
| } // namespace perfetto |
| |
| #endif // MEDIA_CAPTURE_VIDEO_CHROMEOS_MOJOM_EFFECTS_PIPELINE_MOJOM_SHARED_H_ |