Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1569)

Side by Side Diff: content/browser/speech/speech_recognizer_impl.h

Issue 2624403002: Refactor AudioInputController and related interfaces. (Closed)
Patch Set: Address comments Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_IMPL_H_ 5 #ifndef CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_IMPL_H_
6 #define CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_IMPL_H_ 6 #define CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_IMPL_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 14 matching lines...) Expand all
25 namespace content { 25 namespace content {
26 26
27 class SpeechRecognitionEventListener; 27 class SpeechRecognitionEventListener;
28 28
29 // Handles speech recognition for a session (identified by |session_id|), taking 29 // Handles speech recognition for a session (identified by |session_id|), taking
30 // care of audio capture, silence detection/endpointer and interaction with the 30 // care of audio capture, silence detection/endpointer and interaction with the
31 // SpeechRecognitionEngine. 31 // SpeechRecognitionEngine.
32 class CONTENT_EXPORT SpeechRecognizerImpl 32 class CONTENT_EXPORT SpeechRecognizerImpl
33 : public SpeechRecognizer, 33 : public SpeechRecognizer,
34 public media::AudioInputController::EventHandler, 34 public media::AudioInputController::EventHandler,
35 public media::AudioInputController::SyncWriter,
35 public NON_EXPORTED_BASE(SpeechRecognitionEngine::Delegate) { 36 public NON_EXPORTED_BASE(SpeechRecognitionEngine::Delegate) {
36 public: 37 public:
37 static const int kAudioSampleRate; 38 static const int kAudioSampleRate;
38 static const media::ChannelLayout kChannelLayout; 39 static const media::ChannelLayout kChannelLayout;
39 static const int kNumBitsPerAudioSample; 40 static const int kNumBitsPerAudioSample;
40 static const int kNoSpeechTimeoutMs; 41 static const int kNoSpeechTimeoutMs;
41 static const int kEndpointerEstimationTimeMs; 42 static const int kEndpointerEstimationTimeMs;
42 43
43 static void SetAudioManagerForTesting(media::AudioManager* audio_manager); 44 static void SetAudioManagerForTesting(media::AudioManager* audio_manager);
44 45
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 128
128 void CloseAudioControllerAsynchronously(); 129 void CloseAudioControllerAsynchronously();
129 130
130 // Callback called on IO thread by audio_controller->Close(). 131 // Callback called on IO thread by audio_controller->Close().
131 void OnAudioClosed(media::AudioInputController*); 132 void OnAudioClosed(media::AudioInputController*);
132 133
133 // AudioInputController::EventHandler methods. 134 // AudioInputController::EventHandler methods.
134 void OnCreated(media::AudioInputController* controller) override {} 135 void OnCreated(media::AudioInputController* controller) override {}
135 void OnError(media::AudioInputController* controller, 136 void OnError(media::AudioInputController* controller,
136 media::AudioInputController::ErrorCode error_code) override; 137 media::AudioInputController::ErrorCode error_code) override;
137 void OnData(media::AudioInputController* controller,
138 const media::AudioBus* data) override;
139 void OnLog(media::AudioInputController* controller, 138 void OnLog(media::AudioInputController* controller,
140 const std::string& message) override {} 139 const std::string& message) override {}
141 140
141 // AudioInputController::SyncWriter methods.
142 void Write(const media::AudioBus* data,
143 double volume,
144 bool key_pressed,
145 uint32_t hardware_delay_bytes) override;
146 void Close() override;
147
142 // SpeechRecognitionEngineDelegate methods. 148 // SpeechRecognitionEngineDelegate methods.
143 void OnSpeechRecognitionEngineResults( 149 void OnSpeechRecognitionEngineResults(
144 const SpeechRecognitionResults& results) override; 150 const SpeechRecognitionResults& results) override;
145 void OnSpeechRecognitionEngineEndOfUtterance() override; 151 void OnSpeechRecognitionEngineEndOfUtterance() override;
146 void OnSpeechRecognitionEngineError( 152 void OnSpeechRecognitionEngineError(
147 const SpeechRecognitionError& error) override; 153 const SpeechRecognitionError& error) override;
148 154
149 static media::AudioManager* audio_manager_for_tests_; 155 static media::AudioManager* audio_manager_for_tests_;
150 156
151 std::unique_ptr<SpeechRecognitionEngine> recognition_engine_; 157 std::unique_ptr<SpeechRecognitionEngine> recognition_engine_;
(...skipping 13 matching lines...) Expand all
165 // Converts data between native input format and a WebSpeech specific 171 // Converts data between native input format and a WebSpeech specific
166 // output format. 172 // output format.
167 std::unique_ptr<SpeechRecognizerImpl::OnDataConverter> audio_converter_; 173 std::unique_ptr<SpeechRecognizerImpl::OnDataConverter> audio_converter_;
168 174
169 DISALLOW_COPY_AND_ASSIGN(SpeechRecognizerImpl); 175 DISALLOW_COPY_AND_ASSIGN(SpeechRecognizerImpl);
170 }; 176 };
171 177
172 } // namespace content 178 } // namespace content
173 179
174 #endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_IMPL_H_ 180 #endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_IMPL_H_
OLDNEW
« no previous file with comments | « content/browser/speech/speech_recognition_browsertest.cc ('k') | content/browser/speech/speech_recognizer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698