| OLD | NEW |
| 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_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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 10 #include "content/browser/speech/endpointer/endpointer.h" | 11 #include "content/browser/speech/endpointer/endpointer.h" |
| 11 #include "content/browser/speech/speech_recognition_engine.h" | 12 #include "content/browser/speech/speech_recognition_engine.h" |
| 12 #include "content/public/browser/speech_recognizer.h" | 13 #include "content/public/browser/speech_recognizer.h" |
| 13 #include "content/public/common/speech_recognition_error.h" | 14 #include "content/public/common/speech_recognition_error.h" |
| 14 #include "media/audio/audio_input_controller.h" | 15 #include "media/audio/audio_input_controller.h" |
| 15 #include "net/url_request/url_request_context_getter.h" | 16 #include "net/url_request/url_request_context_getter.h" |
| 16 | 17 |
| 17 namespace content { | 18 namespace content { |
| 18 class SpeechRecognitionEventListener; | 19 class SpeechRecognitionEventListener; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 75 |
| 75 private: | 76 private: |
| 76 friend class SpeechRecognizerImplTest; | 77 friend class SpeechRecognizerImplTest; |
| 77 | 78 |
| 78 void InformErrorAndAbortRecognition( | 79 void InformErrorAndAbortRecognition( |
| 79 content::SpeechRecognitionErrorCode error); | 80 content::SpeechRecognitionErrorCode error); |
| 80 void SendRecordedAudioToServer(); | 81 void SendRecordedAudioToServer(); |
| 81 | 82 |
| 82 void HandleOnError(int error_code); // Handles OnError in the IO thread. | 83 void HandleOnError(int error_code); // Handles OnError in the IO thread. |
| 83 | 84 |
| 84 // Handles OnData in the IO thread. Takes ownership of |raw_audio|. | 85 // Handles OnData in the IO thread. |
| 85 void HandleOnData(AudioChunk* raw_audio); | 86 void HandleOnData(scoped_refptr<AudioChunk> raw_audio); |
| 86 | 87 |
| 87 // Helper method which closes the audio controller and frees it asynchronously | 88 // Helper method which closes the audio controller and frees it asynchronously |
| 88 // without blocking the IO thread. | 89 // without blocking the IO thread. |
| 89 void CloseAudioControllerAsynchronously(); | 90 void CloseAudioControllerAsynchronously(); |
| 90 | 91 |
| 91 void SetAudioManagerForTesting(AudioManager* audio_manager); | 92 void SetAudioManagerForTesting(AudioManager* audio_manager); |
| 92 | 93 |
| 93 content::SpeechRecognitionEventListener* listener_; | 94 content::SpeechRecognitionEventListener* listener_; |
| 94 AudioManager* testing_audio_manager_; | 95 AudioManager* testing_audio_manager_; |
| 95 scoped_ptr<SpeechRecognitionEngine> recognition_engine_; | 96 scoped_ptr<SpeechRecognitionEngine> recognition_engine_; |
| 96 Endpointer endpointer_; | 97 Endpointer endpointer_; |
| 97 scoped_refptr<media::AudioInputController> audio_controller_; | 98 scoped_refptr<media::AudioInputController> audio_controller_; |
| 98 scoped_refptr<net::URLRequestContextGetter> context_getter_; | 99 scoped_refptr<net::URLRequestContextGetter> context_getter_; |
| 99 int caller_id_; | 100 int caller_id_; |
| 100 std::string language_; | 101 std::string language_; |
| 101 std::string grammar_; | 102 std::string grammar_; |
| 102 bool filter_profanities_; | 103 bool filter_profanities_; |
| 103 std::string hardware_info_; | 104 std::string hardware_info_; |
| 104 std::string origin_url_; | 105 std::string origin_url_; |
| 105 int num_samples_recorded_; | 106 int num_samples_recorded_; |
| 106 float audio_level_; | 107 float audio_level_; |
| 107 | 108 |
| 108 DISALLOW_COPY_AND_ASSIGN(SpeechRecognizerImpl); | 109 DISALLOW_COPY_AND_ASSIGN(SpeechRecognizerImpl); |
| 109 }; | 110 }; |
| 110 | 111 |
| 111 } // namespace speech | 112 } // namespace speech |
| 112 | 113 |
| 113 #endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_IMPL_H_ | 114 #endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNIZER_IMPL_H_ |
| OLD | NEW |