// media/mojo/mojom/audio_parameters.mojom-data-view.h is auto generated by mojom_bindings_generator.py, do not edit

// Copyright 2025 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// This file defines XDataView for type traits and can be included in
// _mojom_traits.h definitions but otherwise please use .mojom-forward.h,
// .mojom-shared.h or .mojom.h.

// IWYU pragma: private
// IWYU pragma: friend "traits"

#ifndef MEDIA_MOJO_MOJOM_AUDIO_PARAMETERS_MOJOM_DATA_VIEW_H_
#define MEDIA_MOJO_MOJOM_AUDIO_PARAMETERS_MOJOM_DATA_VIEW_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/string_data_view.h"
#include "mojo/public/cpp/bindings/lib/serialization.h"

#include "media/mojo/mojom/audio_parameters.mojom-shared-internal.h"
#include "media/mojo/mojom/channel_layout.mojom-shared.h"
#include "ui/gfx/geometry/mojom/geometry.mojom-shared.h"


namespace media::mojom {
class AudioParametersHardwareCapabilitiesDataView;

class AudioParametersDataView;



}  // media::mojom


namespace mojo {
namespace internal {

template <>
struct MojomTypeTraits<::media::mojom::AudioParametersHardwareCapabilitiesDataView> {
  using Data = ::media::mojom::internal::AudioParametersHardwareCapabilities_Data;
  using DataAsArrayElement = Pointer<Data>;
  static constexpr MojomTypeCategory category = MojomTypeCategory::kStruct;
};

template <>
struct MojomTypeTraits<::media::mojom::AudioParametersDataView> {
  using Data = ::media::mojom::internal::AudioParameters_Data;
  using DataAsArrayElement = Pointer<Data>;
  static constexpr MojomTypeCategory category = MojomTypeCategory::kStruct;
};

}  // namespace internal
}  // namespace mojo


namespace media::mojom {


enum class AudioParametersFormat : int32_t {
  
  kFake = 0,
  
  kPcmLinear = 1,
  
  kPcmLowLatency = 2,
  
  kBitstreamAc3 = 4,
  
  kBitstreamEac3 = 8,
  
  kBitstreamDts = 16,
  
  kBitstreamDtsHd = 32,
  
  kBitstreamDtsxP2 = 64,
  
  kBitstreamIec61937 = 128,
  
  kBitstreamDtsHdMa = 256,
  kMinValue = 0,
  kMaxValue = 256,
};

 std::ostream& operator<<(std::ostream& os, AudioParametersFormat value);
inline bool IsKnownEnumValue(AudioParametersFormat value) {
  return internal::AudioParametersFormat_Data::IsKnownValue(
      static_cast<int32_t>(value));
}

// Returns true if the enum has an infallible conversion from the mojom enum.
consteval bool HasInfallibleConversion(AudioParametersFormat) {
  return true;
}


enum class AudioLatencyType : int32_t {
  
  kExactMs = 0,
  
  kInteractive = 1,
  
  kRtc = 2,
  
  kPlayback = 3,
  
  kUnknown = 4,
  kMinValue = 0,
  kMaxValue = 4,
};

 std::ostream& operator<<(std::ostream& os, AudioLatencyType value);
inline bool IsKnownEnumValue(AudioLatencyType value) {
  return internal::AudioLatencyType_Data::IsKnownValue(
      static_cast<int32_t>(value));
}

// Returns true if the enum has an infallible conversion from the mojom enum.
consteval bool HasInfallibleConversion(AudioLatencyType) {
  return true;
}


class AudioParametersHardwareCapabilitiesDataView {
 public:
  AudioParametersHardwareCapabilitiesDataView() = default;

  AudioParametersHardwareCapabilitiesDataView(
      internal::AudioParametersHardwareCapabilities_Data* data,
      mojo::Message* message)
      : data_(data) {}

  bool is_null() const { return !data_; }
  int32_t min_frames_per_buffer() const {
    return data_->min_frames_per_buffer;
  }
  int32_t max_frames_per_buffer() const {
    return data_->max_frames_per_buffer;
  }
  int32_t default_frames_per_buffer() const {
    return data_->default_frames_per_buffer;
  }
  int32_t bitstream_formats() const {
    return data_->bitstream_formats;
  }
  bool require_encapsulation() const {
    return data_->require_encapsulation;
  }
  bool require_audio_offload() const {
    return data_->require_audio_offload;
  }
 private:
  internal::AudioParametersHardwareCapabilities_Data* data_ = nullptr;
};


class AudioParametersDataView {
 public:
  AudioParametersDataView() = default;

  AudioParametersDataView(
      internal::AudioParameters_Data* data,
      mojo::Message* message)
      : data_(data), message_(message) {}

  bool is_null() const { return !data_; }
  template <typename UserType>
  [[nodiscard]] bool ReadFormat(UserType* output) const {
    auto data_value = data_->format;
    return mojo::internal::Deserialize<::media::mojom::AudioParametersFormat>(
        data_value, output);
  }
  AudioParametersFormat format() const {
    return ::mojo::internal::ToKnownEnumValueHelper(
          static_cast<::media::mojom::AudioParametersFormat>(data_->format));
  }
  inline void GetChannelLayoutConfigDataView(
      ::media::mojom::ChannelLayoutConfigDataView* output);

  template <typename UserType>
  [[nodiscard]] bool ReadChannelLayoutConfig(UserType* output) {
    
    auto* pointer = !data_->channel_layout_config.is_null() ? &data_->channel_layout_config : nullptr;
    return mojo::internal::Deserialize<::media::mojom::ChannelLayoutConfigDataView>(
        pointer, output, message_);
  }
  int32_t sample_rate() const {
    return data_->sample_rate;
  }
  int32_t frames_per_buffer() const {
    return data_->frames_per_buffer;
  }
  uint32_t effects() const {
    return data_->effects;
  }
  inline void GetMicPositionsDataView(
      mojo::ArrayDataView<::gfx::mojom::Point3FDataView>* output);

  template <typename UserType>
  [[nodiscard]] bool ReadMicPositions(UserType* output) {
    
    auto* pointer = data_->mic_positions.Get();
    return mojo::internal::Deserialize<mojo::ArrayDataView<::gfx::mojom::Point3FDataView>>(
        pointer, output, message_);
  }
  template <typename UserType>
  [[nodiscard]] bool ReadLatencyTag(UserType* output) const {
    auto data_value = data_->latency_tag;
    return mojo::internal::Deserialize<::media::mojom::AudioLatencyType>(
        data_value, output);
  }
  AudioLatencyType latency_tag() const {
    return ::mojo::internal::ToKnownEnumValueHelper(
          static_cast<::media::mojom::AudioLatencyType>(data_->latency_tag));
  }
  inline void GetHardwareCapabilitiesDataView(
      AudioParametersHardwareCapabilitiesDataView* output);

  template <typename UserType>
  [[nodiscard]] bool ReadHardwareCapabilities(UserType* output) {
    
static_assert(
    mojo::internal::IsValidUserTypeForOptionalValue<
        ::media::mojom::AudioParametersHardwareCapabilitiesDataView, UserType>(),
    "Attempting to read the optional `hardware_capabilities` 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 `MaybeReadHardwareCapabilities` instead "
    "of `ReadHardwareCapabilities if you're fine with null values being "
    "silently ignored in this case.");
    auto* pointer = data_->hardware_capabilities.Get();
    return mojo::internal::Deserialize<::media::mojom::AudioParametersHardwareCapabilitiesDataView>(
        pointer, output, message_);
  }
 private:
  internal::AudioParameters_Data* data_ = nullptr;
  mojo::Message* message_ = nullptr;
};


}  // media::mojom

#endif  // MEDIA_MOJO_MOJOM_AUDIO_PARAMETERS_MOJOM_DATA_VIEW_H_