// media/mojo/mojom/audio_parameters.mojom-blink.cc 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.

#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-private-field"
#endif

#include "media/mojo/mojom/audio_parameters.mojom-blink.h"
#include <stdint.h>
#include <utility>
#include "mojo/public/cpp/bindings/lib/default_construct_tag_internal.h"
#include "mojo/public/cpp/bindings/lib/serialization.h"
#include "mojo/public/cpp/bindings/lib/validate_params.h"
#include "mojo/public/cpp/bindings/lib/validation_errors.h"
#include "mojo/public/cpp/bindings/mojo_buildflags.h"
#include "third_party/perfetto/include/perfetto/tracing/traced_value.h"

#include "media/mojo/mojom/audio_parameters.mojom-params-data.h"
#include "media/mojo/mojom/audio_parameters.mojom-shared-message-ids.h"

#include "media/mojo/mojom/audio_parameters.mojom-blink-import-headers.h"
#include "media/mojo/mojom/audio_parameters.mojom-blink-test-utils.h"
#include "mojo/public/cpp/bindings/lib/wtf_serialization.h"


namespace media::mojom::blink {
AudioParametersHardwareCapabilities::AudioParametersHardwareCapabilities()
    : min_frames_per_buffer(),
      max_frames_per_buffer(),
      default_frames_per_buffer(),
      bitstream_formats(),
      require_encapsulation(),
      require_audio_offload() {}

AudioParametersHardwareCapabilities::AudioParametersHardwareCapabilities(
    int32_t min_frames_per_buffer_in,
    int32_t max_frames_per_buffer_in,
    int32_t default_frames_per_buffer_in,
    int32_t bitstream_formats_in,
    bool require_encapsulation_in,
    bool require_audio_offload_in)
    : min_frames_per_buffer(std::move(min_frames_per_buffer_in)),
      max_frames_per_buffer(std::move(max_frames_per_buffer_in)),
      default_frames_per_buffer(std::move(default_frames_per_buffer_in)),
      bitstream_formats(std::move(bitstream_formats_in)),
      require_encapsulation(std::move(require_encapsulation_in)),
      require_audio_offload(std::move(require_audio_offload_in)) {}

AudioParametersHardwareCapabilities::~AudioParametersHardwareCapabilities() = default;

void AudioParametersHardwareCapabilities::WriteIntoTrace(
    perfetto::TracedValue traced_context) const {
  [[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "min_frames_per_buffer"), this->min_frames_per_buffer,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type int32_t>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "max_frames_per_buffer"), this->max_frames_per_buffer,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type int32_t>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "default_frames_per_buffer"), this->default_frames_per_buffer,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type int32_t>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "bitstream_formats"), this->bitstream_formats,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type int32_t>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "require_encapsulation"), this->require_encapsulation,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type bool>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "require_audio_offload"), this->require_audio_offload,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type bool>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
}

bool AudioParametersHardwareCapabilities::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  return Data_::Validate(data, validation_context);
}
AudioParameters::AudioParameters()
    : format(),
      channel_layout_config(),
      sample_rate(),
      frames_per_buffer(),
      effects(),
      mic_positions(),
      latency_tag(),
      hardware_capabilities() {}

AudioParameters::AudioParameters(
    ::media::AudioParameters::Format format_in,
    ::media::mojom::blink::ChannelLayoutConfigPtr channel_layout_config_in,
    int32_t sample_rate_in,
    int32_t frames_per_buffer_in,
    uint32_t effects_in,
    ::blink::Vector<::gfx::Point3F> mic_positions_in,
    ::media::AudioLatency::Type latency_tag_in,
    const std::optional<::media::AudioParameters::HardwareCapabilities>& hardware_capabilities_in)
    : format(std::move(format_in)),
      channel_layout_config(std::move(channel_layout_config_in)),
      sample_rate(std::move(sample_rate_in)),
      frames_per_buffer(std::move(frames_per_buffer_in)),
      effects(std::move(effects_in)),
      mic_positions(std::move(mic_positions_in)),
      latency_tag(std::move(latency_tag_in)),
      hardware_capabilities(std::move(hardware_capabilities_in)) {}

AudioParameters::~AudioParameters() = default;

void AudioParameters::WriteIntoTrace(
    perfetto::TracedValue traced_context) const {
  [[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "format"), this->format,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type ::media::AudioParameters::Format>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "channel_layout_config"), this->channel_layout_config,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type ::media::mojom::blink::ChannelLayoutConfigPtr>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "sample_rate"), this->sample_rate,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type int32_t>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "frames_per_buffer"), this->frames_per_buffer,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type int32_t>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "effects"), this->effects,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type uint32_t>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "mic_positions"), this->mic_positions,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::blink::Vector<::gfx::Point3F>&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "latency_tag"), this->latency_tag,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type ::media::AudioLatency::Type>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "hardware_capabilities"), this->hardware_capabilities,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const std::optional<::media::AudioParameters::HardwareCapabilities>&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
}

bool AudioParameters::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  return Data_::Validate(data, validation_context);
}


}  // media::mojom::blink


namespace mojo {


// static
bool StructTraits<::media::mojom::blink::AudioParametersHardwareCapabilities::DataView, ::media::mojom::blink::AudioParametersHardwareCapabilitiesPtr>::Read(
    ::media::mojom::blink::AudioParametersHardwareCapabilities::DataView input,
    ::media::mojom::blink::AudioParametersHardwareCapabilitiesPtr* output) {
  bool success = true;
  ::media::mojom::blink::AudioParametersHardwareCapabilitiesPtr result(::media::mojom::blink::AudioParametersHardwareCapabilities::New());
  
      if (success)
        result->min_frames_per_buffer = input.min_frames_per_buffer();
      if (success)
        result->max_frames_per_buffer = input.max_frames_per_buffer();
      if (success)
        result->default_frames_per_buffer = input.default_frames_per_buffer();
      if (success)
        result->bitstream_formats = input.bitstream_formats();
      if (success)
        result->require_encapsulation = input.require_encapsulation();
      if (success)
        result->require_audio_offload = input.require_audio_offload();
  *output = std::move(result);
  return success;
}


// static
bool StructTraits<::media::mojom::blink::AudioParameters::DataView, ::media::mojom::blink::AudioParametersPtr>::Read(
    ::media::mojom::blink::AudioParameters::DataView input,
    ::media::mojom::blink::AudioParametersPtr* output) {
  bool success = true;
  ::media::mojom::blink::AudioParametersPtr result(::media::mojom::blink::AudioParameters::New());
  
      if (success && !input.ReadFormat(&result->format))
        success = false;
      if (success && !input.ReadChannelLayoutConfig(&result->channel_layout_config))
        success = false;
      if (success)
        result->sample_rate = input.sample_rate();
      if (success)
        result->frames_per_buffer = input.frames_per_buffer();
      if (success)
        result->effects = input.effects();
      if (success && !input.ReadMicPositions(&result->mic_positions))
        success = false;
      if (success && !input.ReadLatencyTag(&result->latency_tag))
        success = false;
      if (success && !input.ReadHardwareCapabilities(&result->hardware_capabilities))
        success = false;
  *output = std::move(result);
  return success;
}

}  // namespace mojo


// Symbols declared in the -test-utils.h header are defined here instead of a
// separate .cc file to save compile time.


namespace media::mojom::blink {




}  // media::mojom::blink


#if defined(__clang__)
#pragma clang diagnostic pop
#endif