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_RECOGNITION_MANAGER_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_MANAGER_IMPL_H_ |
6 #define CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_MANAGER_IMPL_H_ | 6 #define CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_MANAGER_IMPL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 // the catch-all snoop listener (optionally) provided by the delegate. | 51 // the catch-all snoop listener (optionally) provided by the delegate. |
52 class CONTENT_EXPORT SpeechRecognitionManagerImpl : | 52 class CONTENT_EXPORT SpeechRecognitionManagerImpl : |
53 public NON_EXPORTED_BASE(SpeechRecognitionManager), | 53 public NON_EXPORTED_BASE(SpeechRecognitionManager), |
54 public SpeechRecognitionEventListener { | 54 public SpeechRecognitionEventListener { |
55 public: | 55 public: |
56 // Returns the current SpeechRecognitionManagerImpl or NULL if the call is | 56 // Returns the current SpeechRecognitionManagerImpl or NULL if the call is |
57 // issued when it is not created yet or destroyed (by BrowserMainLoop). | 57 // issued when it is not created yet or destroyed (by BrowserMainLoop). |
58 static SpeechRecognitionManagerImpl* GetInstance(); | 58 static SpeechRecognitionManagerImpl* GetInstance(); |
59 | 59 |
60 // SpeechRecognitionManager implementation. | 60 // SpeechRecognitionManager implementation. |
61 virtual int CreateSession( | 61 int CreateSession(const SpeechRecognitionSessionConfig& config) override; |
62 const SpeechRecognitionSessionConfig& config) override; | 62 void StartSession(int session_id) override; |
63 virtual void StartSession(int session_id) override; | 63 void AbortSession(int session_id) override; |
64 virtual void AbortSession(int session_id) override; | 64 void AbortAllSessionsForRenderProcess(int render_process_id) override; |
65 virtual void AbortAllSessionsForRenderProcess(int render_process_id) override; | 65 void AbortAllSessionsForRenderView(int render_process_id, |
66 virtual void AbortAllSessionsForRenderView(int render_process_id, | 66 int render_view_id) override; |
67 int render_view_id) override; | 67 void StopAudioCaptureForSession(int session_id) override; |
68 virtual void StopAudioCaptureForSession(int session_id) override; | 68 const SpeechRecognitionSessionConfig& GetSessionConfig( |
69 virtual const SpeechRecognitionSessionConfig& GetSessionConfig( | |
70 int session_id) const override; | 69 int session_id) const override; |
71 virtual SpeechRecognitionSessionContext GetSessionContext( | 70 SpeechRecognitionSessionContext GetSessionContext( |
72 int session_id) const override; | 71 int session_id) const override; |
73 virtual int GetSession(int render_process_id, | 72 int GetSession(int render_process_id, |
74 int render_view_id, | 73 int render_view_id, |
75 int request_id) const override; | 74 int request_id) const override; |
76 virtual bool HasAudioInputDevices() override; | 75 bool HasAudioInputDevices() override; |
77 virtual base::string16 GetAudioInputDeviceModel() override; | 76 base::string16 GetAudioInputDeviceModel() override; |
78 virtual void ShowAudioInputSettings() override; | 77 void ShowAudioInputSettings() override; |
79 | 78 |
80 // SpeechRecognitionEventListener methods. | 79 // SpeechRecognitionEventListener methods. |
81 virtual void OnRecognitionStart(int session_id) override; | 80 void OnRecognitionStart(int session_id) override; |
82 virtual void OnAudioStart(int session_id) override; | 81 void OnAudioStart(int session_id) override; |
83 virtual void OnEnvironmentEstimationComplete(int session_id) override; | 82 void OnEnvironmentEstimationComplete(int session_id) override; |
84 virtual void OnSoundStart(int session_id) override; | 83 void OnSoundStart(int session_id) override; |
85 virtual void OnSoundEnd(int session_id) override; | 84 void OnSoundEnd(int session_id) override; |
86 virtual void OnAudioEnd(int session_id) override; | 85 void OnAudioEnd(int session_id) override; |
87 virtual void OnRecognitionEnd(int session_id) override; | 86 void OnRecognitionEnd(int session_id) override; |
88 virtual void OnRecognitionResults( | 87 void OnRecognitionResults(int session_id, |
89 int session_id, const SpeechRecognitionResults& result) override; | 88 const SpeechRecognitionResults& result) override; |
90 virtual void OnRecognitionError( | 89 void OnRecognitionError(int session_id, |
91 int session_id, const SpeechRecognitionError& error) override; | 90 const SpeechRecognitionError& error) override; |
92 virtual void OnAudioLevelsChange(int session_id, float volume, | 91 void OnAudioLevelsChange(int session_id, |
93 float noise_volume) override; | 92 float volume, |
| 93 float noise_volume) override; |
94 | 94 |
95 SpeechRecognitionManagerDelegate* delegate() const { return delegate_.get(); } | 95 SpeechRecognitionManagerDelegate* delegate() const { return delegate_.get(); } |
96 | 96 |
97 protected: | 97 protected: |
98 // BrowserMainLoop is the only one allowed to istantiate and free us. | 98 // BrowserMainLoop is the only one allowed to istantiate and free us. |
99 friend class BrowserMainLoop; | 99 friend class BrowserMainLoop; |
100 // Needed for dtor. | 100 // Needed for dtor. |
101 friend struct base::DefaultDeleter<SpeechRecognitionManagerImpl>; | 101 friend struct base::DefaultDeleter<SpeechRecognitionManagerImpl>; |
102 SpeechRecognitionManagerImpl(media::AudioManager* audio_manager, | 102 SpeechRecognitionManagerImpl(media::AudioManager* audio_manager, |
103 MediaStreamManager* media_stream_manager); | 103 MediaStreamManager* media_stream_manager); |
104 virtual ~SpeechRecognitionManagerImpl(); | 104 ~SpeechRecognitionManagerImpl() override; |
105 | 105 |
106 private: | 106 private: |
107 // Data types for the internal Finite State Machine (FSM). | 107 // Data types for the internal Finite State Machine (FSM). |
108 enum FSMState { | 108 enum FSMState { |
109 SESSION_STATE_IDLE = 0, | 109 SESSION_STATE_IDLE = 0, |
110 SESSION_STATE_CAPTURING_AUDIO, | 110 SESSION_STATE_CAPTURING_AUDIO, |
111 SESSION_STATE_WAITING_FOR_RESULT, | 111 SESSION_STATE_WAITING_FOR_RESULT, |
112 SESSION_STATE_MAX_VALUE = SESSION_STATE_WAITING_FOR_RESULT | 112 SESSION_STATE_MAX_VALUE = SESSION_STATE_WAITING_FOR_RESULT |
113 }; | 113 }; |
114 | 114 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 | 184 |
185 // Used for posting asynchronous tasks (on the IO thread) without worrying | 185 // Used for posting asynchronous tasks (on the IO thread) without worrying |
186 // about this class being destroyed in the meanwhile (due to browser shutdown) | 186 // about this class being destroyed in the meanwhile (due to browser shutdown) |
187 // since tasks pending on a destroyed WeakPtr are automatically discarded. | 187 // since tasks pending on a destroyed WeakPtr are automatically discarded. |
188 base::WeakPtrFactory<SpeechRecognitionManagerImpl> weak_factory_; | 188 base::WeakPtrFactory<SpeechRecognitionManagerImpl> weak_factory_; |
189 }; | 189 }; |
190 | 190 |
191 } // namespace content | 191 } // namespace content |
192 | 192 |
193 #endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_MANAGER_IMPL_H_ | 193 #endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_MANAGER_IMPL_H_ |
OLD | NEW |