1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45

media / mojo / mojom / speech_recognition_recognition_context_mojom_traits.h [blame]

// Copyright 2024 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_RECOGNITION_CONTEXT_MOJOM_TRAITS_H_
#define MEDIA_MOJO_MOJOM_SPEECH_RECOGNITION_RECOGNITION_CONTEXT_MOJOM_TRAITS_H_

#include "media/mojo/mojom/speech_recognition_recognition_context.h"
#include "media/mojo/mojom/speech_recognition_recognition_context.mojom.h"

namespace mojo {

template <>
class StructTraits<media::mojom::SpeechRecognitionPhraseDataView,
                   media::SpeechRecognitionPhrase> {
 public:
  static const std::string& phrase(const media::SpeechRecognitionPhrase& r) {
    return r.phrase;
  }

  static float boost(const media::SpeechRecognitionPhrase& r) {
    return r.boost;
  }

  static bool Read(media::mojom::SpeechRecognitionPhraseDataView data,
                   media::SpeechRecognitionPhrase* out);
};

template <>
class StructTraits<media::mojom::SpeechRecognitionRecognitionContextDataView,
                   media::SpeechRecognitionRecognitionContext> {
 public:
  static const std::vector<media::SpeechRecognitionPhrase>& phrases(
      const media::SpeechRecognitionRecognitionContext& r) {
    return r.phrases;
  }

  static bool Read(
      media::mojom::SpeechRecognitionRecognitionContextDataView data,
      media::SpeechRecognitionRecognitionContext* out);
};

}  // namespace mojo

#endif  // MEDIA_MOJO_MOJOM_SPEECH_RECOGNITION_RECOGNITION_CONTEXT_MOJOM_TRAITS_H_