// media/mojo/mojom/speech_recognition.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_MOJO_MOJOM_SPEECH_RECOGNITION_MOJOM_SHARED_H_
#define MEDIA_MOJO_MOJOM_SPEECH_RECOGNITION_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/map_data_view.h"
#include "mojo/public/cpp/bindings/string_data_view.h"
#include "mojo/public/cpp/system/message_pipe.h"

#include "third_party/perfetto/include/perfetto/tracing/traced_value_forward.h"

#include "media/mojo/mojom/speech_recognition.mojom-shared-internal.h"
#include "media/mojo/mojom/audio_data.mojom-shared.h"
#include "media/mojo/mojom/speech_recognition_audio_forwarder.mojom-shared.h"
#include "media/mojo/mojom/speech_recognition_recognition_context.mojom-shared.h"
#include "media/mojo/mojom/speech_recognizer.mojom-shared.h"
#include "mojo/public/mojom/base/time.mojom-shared.h"
#include "mojo/public/mojom/base/unguessable_token.mojom-shared.h"
#include "ui/gfx/geometry/mojom/geometry.mojom-shared.h"
#include "mojo/public/cpp/bindings/lib/interface_serialization.h"
#include "mojo/public/cpp/system/data_pipe.h"



#include "media/mojo/mojom/speech_recognition.mojom-data-view.h"  // IWYU pragma: export




namespace std {

template <>
struct hash<::media::mojom::ConfidenceLevel>
    : public mojo::internal::EnumHashImpl<::media::mojom::ConfidenceLevel> {};

template <>
struct hash<::media::mojom::AsrSwitchResult>
    : public mojo::internal::EnumHashImpl<::media::mojom::AsrSwitchResult> {};

template <>
struct hash<::media::mojom::SpeechRecognitionMode>
    : public mojo::internal::EnumHashImpl<::media::mojom::SpeechRecognitionMode> {};

template <>
struct hash<::media::mojom::RecognizerClientType>
    : public mojo::internal::EnumHashImpl<::media::mojom::RecognizerClientType> {};

}  // namespace std

namespace mojo {


namespace internal {

template <typename MaybeConstUserType>
struct Serializer<::media::mojom::ConfidenceLevel, MaybeConstUserType> {
  using UserType = typename std::remove_const<MaybeConstUserType>::type;
  using Traits = EnumTraits<::media::mojom::ConfidenceLevel, 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) {
    auto known_value = ::mojo::internal::ToKnownEnumValueHelper(
        static_cast<::media::mojom::ConfidenceLevel>(input));
    if constexpr (requires {
                    {
                      Traits::FromMojom(known_value)
                    } -> std::same_as<UserType>;
                  }) {
      static_assert(std::same_as<::media::mojom::ConfidenceLevel, UserType> ||
                        HasInfallibleConversion(::media::mojom::ConfidenceLevel()),
                    "::media::mojom::ConfidenceLevel does not have an infallible conversion, "
                    "use an optional return type.");
      *output = Traits::FromMojom(known_value);
      return true;
    } else {
      static_assert(
          requires {
            {
              Traits::FromMojom(known_value)
            } -> std::same_as<std::optional<UserType>>;
          }, "FromMojom must return by value or optional.");
      std::optional<UserType> from_mojom = Traits::FromMojom(known_value);
      if (from_mojom) {
        *output = *from_mojom;
      }
      return from_mojom.has_value();
    }
  }
};

}  // namespace internal


namespace internal {

template <typename MaybeConstUserType>
struct Serializer<::media::mojom::AsrSwitchResult, MaybeConstUserType> {
  using UserType = typename std::remove_const<MaybeConstUserType>::type;
  using Traits = EnumTraits<::media::mojom::AsrSwitchResult, 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) {
    auto known_value = ::mojo::internal::ToKnownEnumValueHelper(
        static_cast<::media::mojom::AsrSwitchResult>(input));
    if constexpr (requires {
                    {
                      Traits::FromMojom(known_value)
                    } -> std::same_as<UserType>;
                  }) {
      static_assert(std::same_as<::media::mojom::AsrSwitchResult, UserType> ||
                        HasInfallibleConversion(::media::mojom::AsrSwitchResult()),
                    "::media::mojom::AsrSwitchResult does not have an infallible conversion, "
                    "use an optional return type.");
      *output = Traits::FromMojom(known_value);
      return true;
    } else {
      static_assert(
          requires {
            {
              Traits::FromMojom(known_value)
            } -> std::same_as<std::optional<UserType>>;
          }, "FromMojom must return by value or optional.");
      std::optional<UserType> from_mojom = Traits::FromMojom(known_value);
      if (from_mojom) {
        *output = *from_mojom;
      }
      return from_mojom.has_value();
    }
  }
};

}  // namespace internal


namespace internal {

template <typename MaybeConstUserType>
struct Serializer<::media::mojom::SpeechRecognitionMode, MaybeConstUserType> {
  using UserType = typename std::remove_const<MaybeConstUserType>::type;
  using Traits = EnumTraits<::media::mojom::SpeechRecognitionMode, 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) {
    auto known_value = ::mojo::internal::ToKnownEnumValueHelper(
        static_cast<::media::mojom::SpeechRecognitionMode>(input));
    if constexpr (requires {
                    {
                      Traits::FromMojom(known_value)
                    } -> std::same_as<UserType>;
                  }) {
      static_assert(std::same_as<::media::mojom::SpeechRecognitionMode, UserType> ||
                        HasInfallibleConversion(::media::mojom::SpeechRecognitionMode()),
                    "::media::mojom::SpeechRecognitionMode does not have an infallible conversion, "
                    "use an optional return type.");
      *output = Traits::FromMojom(known_value);
      return true;
    } else {
      static_assert(
          requires {
            {
              Traits::FromMojom(known_value)
            } -> std::same_as<std::optional<UserType>>;
          }, "FromMojom must return by value or optional.");
      std::optional<UserType> from_mojom = Traits::FromMojom(known_value);
      if (from_mojom) {
        *output = *from_mojom;
      }
      return from_mojom.has_value();
    }
  }
};

}  // namespace internal


namespace internal {

template <typename MaybeConstUserType>
struct Serializer<::media::mojom::RecognizerClientType, MaybeConstUserType> {
  using UserType = typename std::remove_const<MaybeConstUserType>::type;
  using Traits = EnumTraits<::media::mojom::RecognizerClientType, 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) {
    auto known_value = ::mojo::internal::ToKnownEnumValueHelper(
        static_cast<::media::mojom::RecognizerClientType>(input));
    if constexpr (requires {
                    {
                      Traits::FromMojom(known_value)
                    } -> std::same_as<UserType>;
                  }) {
      static_assert(std::same_as<::media::mojom::RecognizerClientType, UserType> ||
                        HasInfallibleConversion(::media::mojom::RecognizerClientType()),
                    "::media::mojom::RecognizerClientType does not have an infallible conversion, "
                    "use an optional return type.");
      *output = Traits::FromMojom(known_value);
      return true;
    } else {
      static_assert(
          requires {
            {
              Traits::FromMojom(known_value)
            } -> std::same_as<std::optional<UserType>>;
          }, "FromMojom must return by value or optional.");
      std::optional<UserType> from_mojom = Traits::FromMojom(known_value);
      if (from_mojom) {
        *output = *from_mojom;
      }
      return from_mojom.has_value();
    }
  }
};

}  // namespace internal


namespace internal {

template <typename MaybeConstUserType>
struct Serializer<::media::mojom::HypothesisPartsDataView, MaybeConstUserType> {
  using UserType = typename std::remove_const<MaybeConstUserType>::type;
  using Traits = StructTraits<::media::mojom::HypothesisPartsDataView, UserType>;

  static void Serialize(
      MaybeConstUserType& input,
      mojo::internal::MessageFragment<::media::mojom::internal::HypothesisParts_Data>& fragment) {
    if (CallIsNullIfExists<Traits>(input))
      return;
    fragment.Allocate();

    decltype(Traits::text(input)) in_text = Traits::text(input);
    mojo::internal::MessageFragment<
        typename decltype(fragment->text)::BaseType>
        text_fragment(fragment.message());
    constexpr const mojo::internal::ContainerValidateParams& text_validate_params =
        mojo::internal::GetArrayValidator<0, false, &mojo::internal::GetArrayValidator<0, false, nullptr>()>();
    
    mojo::internal::Serialize<mojo::ArrayDataView<mojo::StringDataView>>(
      in_text,
      text_fragment,
      &text_validate_params);

    fragment->text.Set(
        text_fragment.is_null() ? nullptr : text_fragment.data());

    
    MOJO_INTERNAL_CHECK_SERIALIZATION(
      mojo::internal::SendValidation::kDefault,
      !(fragment->text.is_null()),
      mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
      "null text in HypothesisParts struct");

    decltype(Traits::hypothesis_part_offset(input)) in_hypothesis_part_offset = Traits::hypothesis_part_offset(input);
    mojo::internal::MessageFragment<
        typename decltype(fragment->hypothesis_part_offset)::BaseType> hypothesis_part_offset_fragment(
            fragment.message());
    
    mojo::internal::Serialize<::mojo_base::mojom::TimeDeltaDataView>(
      in_hypothesis_part_offset,
      hypothesis_part_offset_fragment);

    fragment->hypothesis_part_offset.Set(
        hypothesis_part_offset_fragment.is_null() ? nullptr : hypothesis_part_offset_fragment.data());

    
    MOJO_INTERNAL_CHECK_SERIALIZATION(
      mojo::internal::SendValidation::kDefault,
      !(fragment->hypothesis_part_offset.is_null()),
      mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
      "null hypothesis_part_offset in HypothesisParts struct");
  }

  static bool Deserialize(::media::mojom::internal::HypothesisParts_Data* input,
                          UserType* output,
                          Message* message) {
    if (!input)
      return CallSetToNullIfExists<Traits>(output);

    ::media::mojom::HypothesisPartsDataView data_view(input, message);
    return CallTraitsRead<Traits>(data_view, output);
  }
};

}  // namespace internal


namespace internal {

template <typename MaybeConstUserType>
struct Serializer<::media::mojom::MediaTimestampRangeDataView, MaybeConstUserType> {
  using UserType = typename std::remove_const<MaybeConstUserType>::type;
  using Traits = StructTraits<::media::mojom::MediaTimestampRangeDataView, UserType>;

  static void Serialize(
      MaybeConstUserType& input,
      mojo::internal::MessageFragment<::media::mojom::internal::MediaTimestampRange_Data>& fragment) {
    if (CallIsNullIfExists<Traits>(input))
      return;
    fragment.Allocate();

    decltype(Traits::start(input)) in_start = Traits::start(input);
    mojo::internal::MessageFragment<
        typename decltype(fragment->start)::BaseType> start_fragment(
            fragment.message());
    
    mojo::internal::Serialize<::mojo_base::mojom::TimeDeltaDataView>(
      in_start,
      start_fragment);

    fragment->start.Set(
        start_fragment.is_null() ? nullptr : start_fragment.data());

    
    MOJO_INTERNAL_CHECK_SERIALIZATION(
      mojo::internal::SendValidation::kDefault,
      !(fragment->start.is_null()),
      mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
      "null start in MediaTimestampRange struct");

    decltype(Traits::end(input)) in_end = Traits::end(input);
    mojo::internal::MessageFragment<
        typename decltype(fragment->end)::BaseType> end_fragment(
            fragment.message());
    
    mojo::internal::Serialize<::mojo_base::mojom::TimeDeltaDataView>(
      in_end,
      end_fragment);

    fragment->end.Set(
        end_fragment.is_null() ? nullptr : end_fragment.data());

    
    MOJO_INTERNAL_CHECK_SERIALIZATION(
      mojo::internal::SendValidation::kDefault,
      !(fragment->end.is_null()),
      mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
      "null end in MediaTimestampRange struct");
  }

  static bool Deserialize(::media::mojom::internal::MediaTimestampRange_Data* input,
                          UserType* output,
                          Message* message) {
    if (!input)
      return CallSetToNullIfExists<Traits>(output);

    ::media::mojom::MediaTimestampRangeDataView data_view(input, message);
    return CallTraitsRead<Traits>(data_view, output);
  }
};

}  // namespace internal


namespace internal {

template <typename MaybeConstUserType>
struct Serializer<::media::mojom::TimingInformationDataView, MaybeConstUserType> {
  using UserType = typename std::remove_const<MaybeConstUserType>::type;
  using Traits = StructTraits<::media::mojom::TimingInformationDataView, UserType>;

  static void Serialize(
      MaybeConstUserType& input,
      mojo::internal::MessageFragment<::media::mojom::internal::TimingInformation_Data>& fragment) {
    if (CallIsNullIfExists<Traits>(input))
      return;
    fragment.Allocate();

    decltype(Traits::audio_start_time(input)) in_audio_start_time = Traits::audio_start_time(input);
    mojo::internal::MessageFragment<
        typename decltype(fragment->audio_start_time)::BaseType> audio_start_time_fragment(
            fragment.message());
    
    mojo::internal::Serialize<::mojo_base::mojom::TimeDeltaDataView>(
      in_audio_start_time,
      audio_start_time_fragment);

    fragment->audio_start_time.Set(
        audio_start_time_fragment.is_null() ? nullptr : audio_start_time_fragment.data());

    
    MOJO_INTERNAL_CHECK_SERIALIZATION(
      mojo::internal::SendValidation::kDefault,
      !(fragment->audio_start_time.is_null()),
      mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
      "null audio_start_time in TimingInformation struct");

    decltype(Traits::audio_end_time(input)) in_audio_end_time = Traits::audio_end_time(input);
    mojo::internal::MessageFragment<
        typename decltype(fragment->audio_end_time)::BaseType> audio_end_time_fragment(
            fragment.message());
    
    mojo::internal::Serialize<::mojo_base::mojom::TimeDeltaDataView>(
      in_audio_end_time,
      audio_end_time_fragment);

    fragment->audio_end_time.Set(
        audio_end_time_fragment.is_null() ? nullptr : audio_end_time_fragment.data());

    
    MOJO_INTERNAL_CHECK_SERIALIZATION(
      mojo::internal::SendValidation::kDefault,
      !(fragment->audio_end_time.is_null()),
      mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
      "null audio_end_time in TimingInformation struct");

    decltype(Traits::hypothesis_parts(input)) in_hypothesis_parts = Traits::hypothesis_parts(input);
    mojo::internal::MessageFragment<
        typename decltype(fragment->hypothesis_parts)::BaseType>
        hypothesis_parts_fragment(fragment.message());
    constexpr const mojo::internal::ContainerValidateParams& hypothesis_parts_validate_params =
        mojo::internal::GetArrayValidator<0, false, nullptr>();
    
    mojo::internal::Serialize<mojo::ArrayDataView<::media::mojom::HypothesisPartsDataView>>(
      in_hypothesis_parts,
      hypothesis_parts_fragment,
      &hypothesis_parts_validate_params);

    fragment->hypothesis_parts.Set(
        hypothesis_parts_fragment.is_null() ? nullptr : hypothesis_parts_fragment.data());

    decltype(Traits::originating_media_timestamps(input)) in_originating_media_timestamps = Traits::originating_media_timestamps(input);
    mojo::internal::MessageFragment<
        typename decltype(fragment->originating_media_timestamps)::BaseType>
        originating_media_timestamps_fragment(fragment.message());
    constexpr const mojo::internal::ContainerValidateParams& originating_media_timestamps_validate_params =
        mojo::internal::GetArrayValidator<0, false, nullptr>();
    
    mojo::internal::Serialize<mojo::ArrayDataView<::media::mojom::MediaTimestampRangeDataView>>(
      in_originating_media_timestamps,
      originating_media_timestamps_fragment,
      &originating_media_timestamps_validate_params);

    fragment->originating_media_timestamps.Set(
        originating_media_timestamps_fragment.is_null() ? nullptr : originating_media_timestamps_fragment.data());
  }

  static bool Deserialize(::media::mojom::internal::TimingInformation_Data* input,
                          UserType* output,
                          Message* message) {
    if (!input)
      return CallSetToNullIfExists<Traits>(output);

    ::media::mojom::TimingInformationDataView data_view(input, message);
    return CallTraitsRead<Traits>(data_view, output);
  }
};

}  // namespace internal


namespace internal {

template <typename MaybeConstUserType>
struct Serializer<::media::mojom::SpeechRecognitionResultDataView, MaybeConstUserType> {
  using UserType = typename std::remove_const<MaybeConstUserType>::type;
  using Traits = StructTraits<::media::mojom::SpeechRecognitionResultDataView, UserType>;

  static void Serialize(
      MaybeConstUserType& input,
      mojo::internal::MessageFragment<::media::mojom::internal::SpeechRecognitionResult_Data>& fragment) {
    if (CallIsNullIfExists<Traits>(input))
      return;
    fragment.Allocate();

    decltype(Traits::transcription(input)) in_transcription = Traits::transcription(input);
    mojo::internal::MessageFragment<
        typename decltype(fragment->transcription)::BaseType> transcription_fragment(
            fragment.message());
    
    mojo::internal::Serialize<mojo::StringDataView>(
      in_transcription,
      transcription_fragment);

    fragment->transcription.Set(
        transcription_fragment.is_null() ? nullptr : transcription_fragment.data());

    
    MOJO_INTERNAL_CHECK_SERIALIZATION(
      mojo::internal::SendValidation::kDefault,
      !(fragment->transcription.is_null()),
      mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
      "null transcription in SpeechRecognitionResult struct");

    fragment->is_final = Traits::is_final(input);

    decltype(Traits::timing_information(input)) in_timing_information = Traits::timing_information(input);
    mojo::internal::MessageFragment<
        typename decltype(fragment->timing_information)::BaseType> timing_information_fragment(
            fragment.message());
    
    mojo::internal::Serialize<::media::mojom::TimingInformationDataView>(
      in_timing_information,
      timing_information_fragment);

    fragment->timing_information.Set(
        timing_information_fragment.is_null() ? nullptr : timing_information_fragment.data());
  }

  static bool Deserialize(::media::mojom::internal::SpeechRecognitionResult_Data* input,
                          UserType* output,
                          Message* message) {
    if (!input)
      return CallSetToNullIfExists<Traits>(output);

    ::media::mojom::SpeechRecognitionResultDataView data_view(input, message);
    return CallTraitsRead<Traits>(data_view, output);
  }
};

}  // namespace internal


namespace internal {

template <typename MaybeConstUserType>
struct Serializer<::media::mojom::LanguageIdentificationEventDataView, MaybeConstUserType> {
  using UserType = typename std::remove_const<MaybeConstUserType>::type;
  using Traits = StructTraits<::media::mojom::LanguageIdentificationEventDataView, UserType>;

  static void Serialize(
      MaybeConstUserType& input,
      mojo::internal::MessageFragment<::media::mojom::internal::LanguageIdentificationEvent_Data>& fragment) {
    if (CallIsNullIfExists<Traits>(input))
      return;
    fragment.Allocate();

    decltype(Traits::language(input)) in_language = Traits::language(input);
    mojo::internal::MessageFragment<
        typename decltype(fragment->language)::BaseType> language_fragment(
            fragment.message());
    
    mojo::internal::Serialize<mojo::StringDataView>(
      in_language,
      language_fragment);

    fragment->language.Set(
        language_fragment.is_null() ? nullptr : language_fragment.data());

    
    MOJO_INTERNAL_CHECK_SERIALIZATION(
      mojo::internal::SendValidation::kDefault,
      !(fragment->language.is_null()),
      mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER,
      "null language in LanguageIdentificationEvent struct");

    
    mojo::internal::Serialize<::media::mojom::ConfidenceLevel>(
      Traits::confidence_level(input),
      &fragment->confidence_level);
    fragment->asr_switch_result_$flag = Traits::asr_switch_result(input).has_value();
    if (Traits::asr_switch_result(input).has_value()) {
      
      mojo::internal::Serialize<::media::mojom::AsrSwitchResult>(
        Traits::asr_switch_result(input).value(),
        &fragment->asr_switch_result_$value);
    } else {
      fragment->asr_switch_result_$value =
          static_cast<int32_t>(::media::mojom::AsrSwitchResult::kMinValue);
    }
  }

  static bool Deserialize(::media::mojom::internal::LanguageIdentificationEvent_Data* input,
                          UserType* output,
                          Message* message) {
    if (!input)
      return CallSetToNullIfExists<Traits>(output);

    ::media::mojom::LanguageIdentificationEventDataView data_view(input, message);
    return CallTraitsRead<Traits>(data_view, output);
  }
};

}  // namespace internal


namespace internal {

template <typename MaybeConstUserType>
struct Serializer<::media::mojom::SpeechRecognitionOptionsDataView, MaybeConstUserType> {
  using UserType = typename std::remove_const<MaybeConstUserType>::type;
  using Traits = StructTraits<::media::mojom::SpeechRecognitionOptionsDataView, UserType>;

  static void Serialize(
      MaybeConstUserType& input,
      mojo::internal::MessageFragment<::media::mojom::internal::SpeechRecognitionOptions_Data>& fragment) {
    if (CallIsNullIfExists<Traits>(input))
      return;
    fragment.Allocate();

    
    mojo::internal::Serialize<::media::mojom::SpeechRecognitionMode>(
      Traits::recognition_mode(input),
      &fragment->recognition_mode);

    fragment->enable_formatting = Traits::enable_formatting(input);

    decltype(Traits::language(input)) in_language = Traits::language(input);
    mojo::internal::MessageFragment<
        typename decltype(fragment->language)::BaseType> language_fragment(
            fragment.message());
    
    mojo::internal::Serialize<mojo::StringDataView>(
      in_language,
      language_fragment);

    fragment->language.Set(
        language_fragment.is_null() ? nullptr : language_fragment.data());

    fragment->is_server_based = Traits::is_server_based(input);

    
    mojo::internal::Serialize<::media::mojom::RecognizerClientType>(
      Traits::recognizer_client_type(input),
      &fragment->recognizer_client_type);

    fragment->skip_continuously_empty_audio = Traits::skip_continuously_empty_audio(input);

    decltype(Traits::experiment_recognizer_routing_key(input)) in_experiment_recognizer_routing_key = Traits::experiment_recognizer_routing_key(input);
    mojo::internal::MessageFragment<
        typename decltype(fragment->experiment_recognizer_routing_key)::BaseType> experiment_recognizer_routing_key_fragment(
            fragment.message());
    
    mojo::internal::Serialize<mojo::StringDataView>(
      in_experiment_recognizer_routing_key,
      experiment_recognizer_routing_key_fragment);

    fragment->experiment_recognizer_routing_key.Set(
        experiment_recognizer_routing_key_fragment.is_null() ? nullptr : experiment_recognizer_routing_key_fragment.data());

    fragment->channel_count = Traits::channel_count(input);

    fragment->sample_rate = Traits::sample_rate(input);

    decltype(Traits::recognition_context(input)) in_recognition_context = Traits::recognition_context(input);
    mojo::internal::MessageFragment<
        typename decltype(fragment->recognition_context)::BaseType> recognition_context_fragment(
            fragment.message());
    
    mojo::internal::Serialize<::media::mojom::SpeechRecognitionRecognitionContextDataView>(
      in_recognition_context,
      recognition_context_fragment);

    fragment->recognition_context.Set(
        recognition_context_fragment.is_null() ? nullptr : recognition_context_fragment.data());

    fragment->allow_multi_language = Traits::allow_multi_language(input);
  }

  static bool Deserialize(::media::mojom::internal::SpeechRecognitionOptions_Data* input,
                          UserType* output,
                          Message* message) {
    if (!input)
      return CallSetToNullIfExists<Traits>(output);

    ::media::mojom::SpeechRecognitionOptionsDataView data_view(input, message);
    return CallTraitsRead<Traits>(data_view, output);
  }
};

}  // namespace internal

}  // namespace mojo


namespace media::mojom {

inline void HypothesisPartsDataView::GetTextDataView(
    mojo::ArrayDataView<mojo::StringDataView>* output) {
  auto pointer = data_->text.Get();
  *output = mojo::ArrayDataView<mojo::StringDataView>(pointer, message_);
}
inline void HypothesisPartsDataView::GetHypothesisPartOffsetDataView(
    ::mojo_base::mojom::TimeDeltaDataView* output) {
  auto pointer = data_->hypothesis_part_offset.Get();
  *output = ::mojo_base::mojom::TimeDeltaDataView(pointer, message_);
}


inline void MediaTimestampRangeDataView::GetStartDataView(
    ::mojo_base::mojom::TimeDeltaDataView* output) {
  auto pointer = data_->start.Get();
  *output = ::mojo_base::mojom::TimeDeltaDataView(pointer, message_);
}
inline void MediaTimestampRangeDataView::GetEndDataView(
    ::mojo_base::mojom::TimeDeltaDataView* output) {
  auto pointer = data_->end.Get();
  *output = ::mojo_base::mojom::TimeDeltaDataView(pointer, message_);
}


inline void TimingInformationDataView::GetAudioStartTimeDataView(
    ::mojo_base::mojom::TimeDeltaDataView* output) {
  auto pointer = data_->audio_start_time.Get();
  *output = ::mojo_base::mojom::TimeDeltaDataView(pointer, message_);
}
inline void TimingInformationDataView::GetAudioEndTimeDataView(
    ::mojo_base::mojom::TimeDeltaDataView* output) {
  auto pointer = data_->audio_end_time.Get();
  *output = ::mojo_base::mojom::TimeDeltaDataView(pointer, message_);
}
inline void TimingInformationDataView::GetHypothesisPartsDataView(
    mojo::ArrayDataView<HypothesisPartsDataView>* output) {
  auto pointer = data_->hypothesis_parts.Get();
  *output = mojo::ArrayDataView<HypothesisPartsDataView>(pointer, message_);
}
inline void TimingInformationDataView::GetOriginatingMediaTimestampsDataView(
    mojo::ArrayDataView<MediaTimestampRangeDataView>* output) {
  auto pointer = data_->header_.version >= 11
                 ? data_->originating_media_timestamps.Get() : nullptr;
  *output = mojo::ArrayDataView<MediaTimestampRangeDataView>(pointer, message_);
}


inline void SpeechRecognitionResultDataView::GetTranscriptionDataView(
    mojo::StringDataView* output) {
  auto pointer = data_->transcription.Get();
  *output = mojo::StringDataView(pointer, message_);
}
inline void SpeechRecognitionResultDataView::GetTimingInformationDataView(
    TimingInformationDataView* output) {
  auto pointer = data_->timing_information.Get();
  *output = TimingInformationDataView(pointer, message_);
}


inline void LanguageIdentificationEventDataView::GetLanguageDataView(
    mojo::StringDataView* output) {
  auto pointer = data_->language.Get();
  *output = mojo::StringDataView(pointer, message_);
}


inline void SpeechRecognitionOptionsDataView::GetLanguageDataView(
    mojo::StringDataView* output) {
  auto pointer = data_->language.Get();
  *output = mojo::StringDataView(pointer, message_);
}
inline void SpeechRecognitionOptionsDataView::GetExperimentRecognizerRoutingKeyDataView(
    mojo::StringDataView* output) {
  auto pointer = data_->header_.version >= 5
                 ? data_->experiment_recognizer_routing_key.Get() : nullptr;
  *output = mojo::StringDataView(pointer, message_);
}
inline void SpeechRecognitionOptionsDataView::GetRecognitionContextDataView(
    ::media::mojom::SpeechRecognitionRecognitionContextDataView* output) {
  auto pointer = data_->header_.version >= 8
                 ? data_->recognition_context.Get() : nullptr;
  *output = ::media::mojom::SpeechRecognitionRecognitionContextDataView(pointer, message_);
}



}  // media::mojom

// Declare TraceFormatTraits for enums, which should be defined in ::perfetto
// namespace.

namespace perfetto {

template <>
struct  TraceFormatTraits<::media::mojom::ConfidenceLevel> {
 static void WriteIntoTrace(perfetto::TracedValue context, ::media::mojom::ConfidenceLevel value);
};

} // namespace perfetto

namespace perfetto {

template <>
struct  TraceFormatTraits<::media::mojom::AsrSwitchResult> {
 static void WriteIntoTrace(perfetto::TracedValue context, ::media::mojom::AsrSwitchResult value);
};

} // namespace perfetto

namespace perfetto {

template <>
struct  TraceFormatTraits<::media::mojom::SpeechRecognitionMode> {
 static void WriteIntoTrace(perfetto::TracedValue context, ::media::mojom::SpeechRecognitionMode value);
};

} // namespace perfetto

namespace perfetto {

template <>
struct  TraceFormatTraits<::media::mojom::RecognizerClientType> {
 static void WriteIntoTrace(perfetto::TracedValue context, ::media::mojom::RecognizerClientType value);
};

} // namespace perfetto

#endif  // MEDIA_MOJO_MOJOM_SPEECH_RECOGNITION_MOJOM_SHARED_H_