// media/mojo/mojom/speech_recognition_result.mojom.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/speech_recognition_result.mojom.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/speech_recognition_result.mojom-params-data.h"
#include "media/mojo/mojom/speech_recognition_result.mojom-shared-message-ids.h"

#include "media/mojo/mojom/speech_recognition_result.mojom-import-headers.h"
#include "media/mojo/mojom/speech_recognition_result.mojom-test-utils.h"


namespace media::mojom {
SpeechRecognitionHypothesis::SpeechRecognitionHypothesis()
    : utterance(),
      confidence() {}

SpeechRecognitionHypothesis::SpeechRecognitionHypothesis(
    const ::std::u16string& utterance_in,
    double confidence_in)
    : utterance(std::move(utterance_in)),
      confidence(std::move(confidence_in)) {}

SpeechRecognitionHypothesis::~SpeechRecognitionHypothesis() = default;

void SpeechRecognitionHypothesis::WriteIntoTrace(
    perfetto::TracedValue traced_context) const {
  [[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "utterance"), this->utterance,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::std::u16string&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "confidence"), this->confidence,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type double>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
}

bool SpeechRecognitionHypothesis::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  return Data_::Validate(data, validation_context);
}
WebSpeechRecognitionResult::WebSpeechRecognitionResult()
    : hypotheses(),
      is_provisional(),
      audio_start_time(),
      audio_end_time() {}

WebSpeechRecognitionResult::WebSpeechRecognitionResult(
    std::vector<SpeechRecognitionHypothesisPtr> hypotheses_in,
    bool is_provisional_in,
    std::optional<::base::TimeDelta> audio_start_time_in,
    std::optional<::base::TimeDelta> audio_end_time_in)
    : hypotheses(std::move(hypotheses_in)),
      is_provisional(std::move(is_provisional_in)),
      audio_start_time(std::move(audio_start_time_in)),
      audio_end_time(std::move(audio_end_time_in)) {}

WebSpeechRecognitionResult::~WebSpeechRecognitionResult() = default;

void WebSpeechRecognitionResult::WriteIntoTrace(
    perfetto::TracedValue traced_context) const {
  [[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "hypotheses"), this->hypotheses,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type std::vector<SpeechRecognitionHypothesisPtr>>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "is_provisional"), this->is_provisional,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type bool>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "audio_start_time"), this->audio_start_time,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type std::optional<::base::TimeDelta>>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "audio_end_time"), this->audio_end_time,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type std::optional<::base::TimeDelta>>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
}

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


}  // media::mojom


namespace mojo {


// static
bool StructTraits<::media::mojom::SpeechRecognitionHypothesis::DataView, ::media::mojom::SpeechRecognitionHypothesisPtr>::Read(
    ::media::mojom::SpeechRecognitionHypothesis::DataView input,
    ::media::mojom::SpeechRecognitionHypothesisPtr* output) {
  bool success = true;
  ::media::mojom::SpeechRecognitionHypothesisPtr result(::media::mojom::SpeechRecognitionHypothesis::New());
  
      if (success && !input.ReadUtterance(&result->utterance))
        success = false;
      if (success)
        result->confidence = input.confidence();
  *output = std::move(result);
  return success;
}


// static
bool StructTraits<::media::mojom::WebSpeechRecognitionResult::DataView, ::media::mojom::WebSpeechRecognitionResultPtr>::Read(
    ::media::mojom::WebSpeechRecognitionResult::DataView input,
    ::media::mojom::WebSpeechRecognitionResultPtr* output) {
  bool success = true;
  ::media::mojom::WebSpeechRecognitionResultPtr result(::media::mojom::WebSpeechRecognitionResult::New());
  
      if (success && !input.ReadHypotheses(&result->hypotheses))
        success = false;
      if (success)
        result->is_provisional = input.is_provisional();
      if (success && !input.ReadAudioStartTime(&result->audio_start_time))
        success = false;
      if (success && !input.ReadAudioEndTime(&result->audio_end_time))
        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 {




}  // media::mojom


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