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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 // - Handles the instantiation of SpeechRecognitionEngine objects when | 44 // - Handles the instantiation of SpeechRecognitionEngine objects when |
45 // requested by SpeechRecognitionSessions. | 45 // requested by SpeechRecognitionSessions. |
46 // - Relays recognition results/status/error events of each session to the | 46 // - Relays recognition results/status/error events of each session to the |
47 // corresponding listener (demuxing on the base of their session_id). | 47 // corresponding listener (demuxing on the base of their session_id). |
48 // - Relays also recognition results/status/error events of every session to | 48 // - Relays also recognition results/status/error events of every session to |
49 // the catch-all snoop listener (optionally) provided by the delegate. | 49 // the catch-all snoop listener (optionally) provided by the delegate. |
50 class CONTENT_EXPORT SpeechRecognitionManagerImpl : | 50 class CONTENT_EXPORT SpeechRecognitionManagerImpl : |
51 public NON_EXPORTED_BASE(content::SpeechRecognitionManager), | 51 public NON_EXPORTED_BASE(content::SpeechRecognitionManager), |
52 public content::SpeechRecognitionEventListener { | 52 public content::SpeechRecognitionEventListener { |
53 public: | 53 public: |
54 // Returns the current SpeechRecognitionManagerImpl. May return NULL if it | |
55 // hasn't been created yet. | |
54 static SpeechRecognitionManagerImpl* GetInstance(); | 56 static SpeechRecognitionManagerImpl* GetInstance(); |
55 | 57 |
58 SpeechRecognitionManagerImpl(); | |
hans
2012/05/15 15:32:31
hmm, it feels weird having a public constructor wh
Primiano Tucci (use gerrit)
2012/05/15 16:04:03
Hmm, the singleton was removed because it had a to
| |
59 virtual ~SpeechRecognitionManagerImpl(); | |
60 | |
56 // SpeechRecognitionManager implementation. | 61 // SpeechRecognitionManager implementation. |
57 virtual int CreateSession( | 62 virtual int CreateSession( |
58 const content::SpeechRecognitionSessionConfig& config) OVERRIDE; | 63 const content::SpeechRecognitionSessionConfig& config) OVERRIDE; |
59 virtual void StartSession(int session_id) OVERRIDE; | 64 virtual void StartSession(int session_id) OVERRIDE; |
60 virtual void AbortSession(int session_id) OVERRIDE; | 65 virtual void AbortSession(int session_id) OVERRIDE; |
61 virtual void AbortAllSessionsForListener( | 66 virtual void AbortAllSessionsForListener( |
62 content::SpeechRecognitionEventListener* listener) OVERRIDE; | 67 content::SpeechRecognitionEventListener* listener) OVERRIDE; |
63 virtual void StopAudioCaptureForSession(int session_id) OVERRIDE; | 68 virtual void StopAudioCaptureForSession(int session_id) OVERRIDE; |
64 virtual const content::SpeechRecognitionSessionConfig& GetSessionConfig( | 69 virtual const content::SpeechRecognitionSessionConfig& GetSessionConfig( |
65 int session_id) const OVERRIDE; | 70 int session_id) const OVERRIDE; |
(...skipping 16 matching lines...) Expand all Loading... | |
82 virtual void OnSoundEnd(int session_id) OVERRIDE; | 87 virtual void OnSoundEnd(int session_id) OVERRIDE; |
83 virtual void OnAudioEnd(int session_id) OVERRIDE; | 88 virtual void OnAudioEnd(int session_id) OVERRIDE; |
84 virtual void OnRecognitionEnd(int session_id) OVERRIDE; | 89 virtual void OnRecognitionEnd(int session_id) OVERRIDE; |
85 virtual void OnRecognitionResult( | 90 virtual void OnRecognitionResult( |
86 int session_id, const content::SpeechRecognitionResult& result) OVERRIDE; | 91 int session_id, const content::SpeechRecognitionResult& result) OVERRIDE; |
87 virtual void OnRecognitionError( | 92 virtual void OnRecognitionError( |
88 int session_id, const content::SpeechRecognitionError& error) OVERRIDE; | 93 int session_id, const content::SpeechRecognitionError& error) OVERRIDE; |
89 virtual void OnAudioLevelsChange(int session_id, float volume, | 94 virtual void OnAudioLevelsChange(int session_id, float volume, |
90 float noise_volume) OVERRIDE; | 95 float noise_volume) OVERRIDE; |
91 | 96 |
92 protected: | |
93 // Private constructor to enforce singleton. | |
94 friend struct DefaultSingletonTraits<SpeechRecognitionManagerImpl>; | |
95 SpeechRecognitionManagerImpl(); | |
96 virtual ~SpeechRecognitionManagerImpl(); | |
97 | |
98 private: | 97 private: |
99 // Data types for the internal Finite State Machine (FSM). | 98 // Data types for the internal Finite State Machine (FSM). |
100 enum FSMState { | 99 enum FSMState { |
101 SESSION_STATE_IDLE = 0, | 100 SESSION_STATE_IDLE = 0, |
102 SESSION_STATE_CAPTURING_AUDIO, | 101 SESSION_STATE_CAPTURING_AUDIO, |
103 SESSION_STATE_WAITING_FOR_RESULT, | 102 SESSION_STATE_WAITING_FOR_RESULT, |
104 SESSION_STATE_MAX_VALUE = SESSION_STATE_WAITING_FOR_RESULT | 103 SESSION_STATE_MAX_VALUE = SESSION_STATE_WAITING_FOR_RESULT |
105 }; | 104 }; |
106 | 105 |
107 enum FSMEvent { | 106 enum FSMEvent { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
151 const Session& GetSession(int session_id) const; | 150 const Session& GetSession(int session_id) const; |
152 content::SpeechRecognitionEventListener* GetListener(int session_id) const; | 151 content::SpeechRecognitionEventListener* GetListener(int session_id) const; |
153 content::SpeechRecognitionEventListener* GetDelegateListener() const; | 152 content::SpeechRecognitionEventListener* GetDelegateListener() const; |
154 int GetNextSessionID(); | 153 int GetNextSessionID(); |
155 | 154 |
156 typedef std::map<int, Session> SessionsTable; | 155 typedef std::map<int, Session> SessionsTable; |
157 SessionsTable sessions_; | 156 SessionsTable sessions_; |
158 int session_id_capturing_audio_; | 157 int session_id_capturing_audio_; |
159 int last_session_id_; | 158 int last_session_id_; |
160 bool is_dispatching_event_; | 159 bool is_dispatching_event_; |
161 content::SpeechRecognitionManagerDelegate* delegate_; | 160 scoped_ptr<content::SpeechRecognitionManagerDelegate> delegate_; |
162 }; | 161 }; |
163 | 162 |
164 } // namespace speech | 163 } // namespace speech |
165 | 164 |
166 #endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_MANAGER_IMPL_H_ | 165 #endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_MANAGER_IMPL_H_ |
OLD | NEW |