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

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

Issue 10704154: Small refactor to media architecture in order to allow end-to-end tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changed MockAudioManager ctor Created 8 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_H_ 5 #ifndef CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_H_
6 #define CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_H_ 6 #define CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 20 matching lines...) Expand all
31 : public base::RefCountedThreadSafe<SpeechRecognizer>, 31 : public base::RefCountedThreadSafe<SpeechRecognizer>,
32 public media::AudioInputController::EventHandler, 32 public media::AudioInputController::EventHandler,
33 public NON_EXPORTED_BASE(SpeechRecognitionEngineDelegate) { 33 public NON_EXPORTED_BASE(SpeechRecognitionEngineDelegate) {
34 public: 34 public:
35 static const int kAudioSampleRate; 35 static const int kAudioSampleRate;
36 static const ChannelLayout kChannelLayout; 36 static const ChannelLayout kChannelLayout;
37 static const int kNumBitsPerAudioSample; 37 static const int kNumBitsPerAudioSample;
38 static const int kNoSpeechTimeoutMs; 38 static const int kNoSpeechTimeoutMs;
39 static const int kEndpointerEstimationTimeMs; 39 static const int kEndpointerEstimationTimeMs;
40 40
41 static void SetAudioManagerForTests(media::AudioManager* audio_manager);
42
41 SpeechRecognizer( 43 SpeechRecognizer(
42 content::SpeechRecognitionEventListener* listener, 44 content::SpeechRecognitionEventListener* listener,
43 int session_id, 45 int session_id,
44 bool is_single_shot, 46 bool is_single_shot,
45 SpeechRecognitionEngine* engine); 47 SpeechRecognitionEngine* engine);
46 48
47 void StartRecognition(); 49 void StartRecognition();
48 void AbortRecognition(); 50 void AbortRecognition();
49 void StopAudioCapture(); 51 void StopAudioCapture();
50 bool IsActive() const; 52 bool IsActive() const;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 FSMState NotFeasible(const FSMEventArgs& event_args); 117 FSMState NotFeasible(const FSMEventArgs& event_args);
116 118
117 // Returns the time span of captured audio samples since the start of capture. 119 // Returns the time span of captured audio samples since the start of capture.
118 int GetElapsedTimeMs() const; 120 int GetElapsedTimeMs() const;
119 121
120 // Calculates the input volume to be displayed in the UI, triggering the 122 // Calculates the input volume to be displayed in the UI, triggering the
121 // OnAudioLevelsChange event accordingly. 123 // OnAudioLevelsChange event accordingly.
122 void UpdateSignalAndNoiseLevels(const float& rms, bool clip_detected); 124 void UpdateSignalAndNoiseLevels(const float& rms, bool clip_detected);
123 125
124 void CloseAudioControllerAsynchronously(); 126 void CloseAudioControllerAsynchronously();
125 void SetAudioManagerForTesting(media::AudioManager* audio_manager);
126 127
127 // Callback called on IO thread by audio_controller->Close(). 128 // Callback called on IO thread by audio_controller->Close().
128 void OnAudioClosed(media::AudioInputController*); 129 void OnAudioClosed(media::AudioInputController*);
129 130
130 // AudioInputController::EventHandler methods. 131 // AudioInputController::EventHandler methods.
131 virtual void OnCreated(media::AudioInputController* controller) OVERRIDE {} 132 virtual void OnCreated(media::AudioInputController* controller) OVERRIDE {}
132 virtual void OnRecording(media::AudioInputController* controller) OVERRIDE {} 133 virtual void OnRecording(media::AudioInputController* controller) OVERRIDE {}
133 virtual void OnError(media::AudioInputController* controller, 134 virtual void OnError(media::AudioInputController* controller,
134 int error_code) OVERRIDE; 135 int error_code) OVERRIDE;
135 virtual void OnData(media::AudioInputController* controller, 136 virtual void OnData(media::AudioInputController* controller,
136 const uint8* data, uint32 size) OVERRIDE; 137 const uint8* data, uint32 size) OVERRIDE;
137 138
138 // SpeechRecognitionEngineDelegate methods. 139 // SpeechRecognitionEngineDelegate methods.
139 virtual void OnSpeechRecognitionEngineResult( 140 virtual void OnSpeechRecognitionEngineResult(
140 const content::SpeechRecognitionResult& result) OVERRIDE; 141 const content::SpeechRecognitionResult& result) OVERRIDE;
141 virtual void OnSpeechRecognitionEngineError( 142 virtual void OnSpeechRecognitionEngineError(
142 const content::SpeechRecognitionError& error) OVERRIDE; 143 const content::SpeechRecognitionError& error) OVERRIDE;
143 144
145 static media::AudioManager* audio_manager_for_tests_;
146
144 content::SpeechRecognitionEventListener* listener_; 147 content::SpeechRecognitionEventListener* listener_;
145 media::AudioManager* testing_audio_manager_;
146 scoped_ptr<SpeechRecognitionEngine> recognition_engine_; 148 scoped_ptr<SpeechRecognitionEngine> recognition_engine_;
147 Endpointer endpointer_; 149 Endpointer endpointer_;
148 scoped_refptr<media::AudioInputController> audio_controller_; 150 scoped_refptr<media::AudioInputController> audio_controller_;
149 int session_id_; 151 int session_id_;
150 int num_samples_recorded_; 152 int num_samples_recorded_;
151 float audio_level_; 153 float audio_level_;
152 bool is_dispatching_event_; 154 bool is_dispatching_event_;
153 bool is_single_shot_; 155 bool is_single_shot_;
154 FSMState state_; 156 FSMState state_;
155 157
156 DISALLOW_COPY_AND_ASSIGN(SpeechRecognizer); 158 DISALLOW_COPY_AND_ASSIGN(SpeechRecognizer);
157 }; 159 };
158 160
159 } // namespace speech 161 } // namespace speech
160 162
161 #endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_H_ 163 #endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/speech/speech_recognizer.cc » ('j') | media/audio/mock_audio_manager.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698