| 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_ENGINE_H_ | 5 #ifndef CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_ENGINE_H_ |
| 6 #define CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_ENGINE_H_ | 6 #define CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_ENGINE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/threading/non_thread_safe.h" | 15 #include "base/sequence_checker.h" |
| 16 #include "content/browser/speech/audio_encoder.h" | 16 #include "content/browser/speech/audio_encoder.h" |
| 17 #include "content/browser/speech/chunked_byte_buffer.h" | 17 #include "content/browser/speech/chunked_byte_buffer.h" |
| 18 #include "content/common/content_export.h" | 18 #include "content/common/content_export.h" |
| 19 #include "content/public/browser/speech_recognition_session_preamble.h" | 19 #include "content/public/browser/speech_recognition_session_preamble.h" |
| 20 #include "content/public/common/speech_recognition_error.h" | 20 #include "content/public/common/speech_recognition_error.h" |
| 21 #include "content/public/common/speech_recognition_grammar.h" | 21 #include "content/public/common/speech_recognition_grammar.h" |
| 22 #include "content/public/common/speech_recognition_result.h" | 22 #include "content/public/common/speech_recognition_result.h" |
| 23 #include "net/url_request/url_fetcher_delegate.h" | 23 #include "net/url_request/url_fetcher_delegate.h" |
| 24 | 24 |
| 25 namespace net { | 25 namespace net { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 50 // The expected call sequence is: | 50 // The expected call sequence is: |
| 51 // StartRecognition Mandatory at beginning of SR. | 51 // StartRecognition Mandatory at beginning of SR. |
| 52 // TakeAudioChunk For every audio chunk pushed. | 52 // TakeAudioChunk For every audio chunk pushed. |
| 53 // AudioChunksEnded Finalize the audio stream (omitted in case of errors). | 53 // AudioChunksEnded Finalize the audio stream (omitted in case of errors). |
| 54 // EndRecognition Mandatory at end of SR (even on errors). | 54 // EndRecognition Mandatory at end of SR (even on errors). |
| 55 // | 55 // |
| 56 // No delegate callbacks are performed before StartRecognition or after | 56 // No delegate callbacks are performed before StartRecognition or after |
| 57 // EndRecognition. If a recognition was started, the caller can free the | 57 // EndRecognition. If a recognition was started, the caller can free the |
| 58 // SpeechRecognitionEngine only after calling EndRecognition. | 58 // SpeechRecognitionEngine only after calling EndRecognition. |
| 59 | 59 |
| 60 class CONTENT_EXPORT SpeechRecognitionEngine | 60 class CONTENT_EXPORT SpeechRecognitionEngine : public net::URLFetcherDelegate { |
| 61 : public net::URLFetcherDelegate, | |
| 62 public NON_EXPORTED_BASE(base::NonThreadSafe) { | |
| 63 public: | 61 public: |
| 64 class Delegate { | 62 class Delegate { |
| 65 public: | 63 public: |
| 66 // Called whenever a result is retrieved. | 64 // Called whenever a result is retrieved. |
| 67 virtual void OnSpeechRecognitionEngineResults( | 65 virtual void OnSpeechRecognitionEngineResults( |
| 68 const SpeechRecognitionResults& results) = 0; | 66 const SpeechRecognitionResults& results) = 0; |
| 69 virtual void OnSpeechRecognitionEngineEndOfUtterance() = 0; | 67 virtual void OnSpeechRecognitionEngineEndOfUtterance() = 0; |
| 70 virtual void OnSpeechRecognitionEngineError( | 68 virtual void OnSpeechRecognitionEngineError( |
| 71 const SpeechRecognitionError& error) = 0; | 69 const SpeechRecognitionError& error) = 0; |
| 72 | 70 |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 scoped_refptr<net::URLRequestContextGetter> url_context_; | 207 scoped_refptr<net::URLRequestContextGetter> url_context_; |
| 210 std::unique_ptr<AudioEncoder> encoder_; | 208 std::unique_ptr<AudioEncoder> encoder_; |
| 211 std::unique_ptr<AudioEncoder> preamble_encoder_; | 209 std::unique_ptr<AudioEncoder> preamble_encoder_; |
| 212 ChunkedByteBuffer chunked_byte_buffer_; | 210 ChunkedByteBuffer chunked_byte_buffer_; |
| 213 size_t previous_response_length_; | 211 size_t previous_response_length_; |
| 214 bool got_last_definitive_result_; | 212 bool got_last_definitive_result_; |
| 215 bool is_dispatching_event_; | 213 bool is_dispatching_event_; |
| 216 bool use_framed_post_data_; | 214 bool use_framed_post_data_; |
| 217 FSMState state_; | 215 FSMState state_; |
| 218 | 216 |
| 217 SEQUENCE_CHECKER(sequence_checker_); |
| 218 |
| 219 DISALLOW_COPY_AND_ASSIGN(SpeechRecognitionEngine); | 219 DISALLOW_COPY_AND_ASSIGN(SpeechRecognitionEngine); |
| 220 }; | 220 }; |
| 221 | 221 |
| 222 } // namespace content | 222 } // namespace content |
| 223 | 223 |
| 224 #endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_ENGINE_H_ | 224 #endif // CONTENT_BROWSER_SPEECH_SPEECH_RECOGNITION_ENGINE_H_ |
| OLD | NEW |