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_GOOGLE_STREAMING_REMOTE_ENGINE_H_ | 5 #ifndef CONTENT_BROWSER_SPEECH_GOOGLE_STREAMING_REMOTE_ENGINE_H_ |
6 #define CONTENT_BROWSER_SPEECH_GOOGLE_STREAMING_REMOTE_ENGINE_H_ | 6 #define CONTENT_BROWSER_SPEECH_GOOGLE_STREAMING_REMOTE_ENGINE_H_ |
7 | 7 |
| 8 #include <stddef.h> |
| 9 #include <stdint.h> |
| 10 |
8 #include <string> | 11 #include <string> |
9 #include <vector> | 12 #include <vector> |
10 | 13 |
11 #include "base/basictypes.h" | 14 #include "base/macros.h" |
12 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
14 #include "base/threading/non_thread_safe.h" | 17 #include "base/threading/non_thread_safe.h" |
15 #include "content/browser/speech/audio_encoder.h" | 18 #include "content/browser/speech/audio_encoder.h" |
16 #include "content/browser/speech/chunked_byte_buffer.h" | 19 #include "content/browser/speech/chunked_byte_buffer.h" |
17 #include "content/browser/speech/speech_recognition_engine.h" | 20 #include "content/browser/speech/speech_recognition_engine.h" |
18 #include "content/common/content_export.h" | 21 #include "content/common/content_export.h" |
19 #include "content/public/common/speech_recognition_error.h" | 22 #include "content/public/common/speech_recognition_error.h" |
20 #include "net/url_request/url_fetcher_delegate.h" | 23 #include "net/url_request/url_fetcher_delegate.h" |
21 | 24 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 void StartRecognition() override; | 67 void StartRecognition() override; |
65 void EndRecognition() override; | 68 void EndRecognition() override; |
66 void TakeAudioChunk(const AudioChunk& data) override; | 69 void TakeAudioChunk(const AudioChunk& data) override; |
67 void AudioChunksEnded() override; | 70 void AudioChunksEnded() override; |
68 bool IsRecognitionPending() const override; | 71 bool IsRecognitionPending() const override; |
69 int GetDesiredAudioChunkDurationMs() const override; | 72 int GetDesiredAudioChunkDurationMs() const override; |
70 | 73 |
71 // net::URLFetcherDelegate methods. | 74 // net::URLFetcherDelegate methods. |
72 void OnURLFetchComplete(const net::URLFetcher* source) override; | 75 void OnURLFetchComplete(const net::URLFetcher* source) override; |
73 void OnURLFetchDownloadProgress(const net::URLFetcher* source, | 76 void OnURLFetchDownloadProgress(const net::URLFetcher* source, |
74 int64 current, | 77 int64_t current, |
75 int64 total) override; | 78 int64_t total) override; |
76 | 79 |
77 private: | 80 private: |
78 // Response status codes from the speech recognition webservice. | 81 // Response status codes from the speech recognition webservice. |
79 static const int kWebserviceStatusNoError; | 82 static const int kWebserviceStatusNoError; |
80 static const int kWebserviceStatusErrorNoMatch; | 83 static const int kWebserviceStatusErrorNoMatch; |
81 | 84 |
82 // Frame type for framed POST data. Do NOT change these. They must match | 85 // Frame type for framed POST data. Do NOT change these. They must match |
83 // values the server expects. | 86 // values the server expects. |
84 enum FrameType { | 87 enum FrameType { |
85 FRAME_PREAMBLE_AUDIO = 0, | 88 FRAME_PREAMBLE_AUDIO = 0, |
(...skipping 23 matching lines...) Expand all Loading... |
109 struct FSMEventArgs { | 112 struct FSMEventArgs { |
110 explicit FSMEventArgs(FSMEvent event_value); | 113 explicit FSMEventArgs(FSMEvent event_value); |
111 ~FSMEventArgs(); | 114 ~FSMEventArgs(); |
112 | 115 |
113 FSMEvent event; | 116 FSMEvent event; |
114 | 117 |
115 // In case of EVENT_AUDIO_CHUNK, holds the chunk pushed by |TakeAudioChunk|. | 118 // In case of EVENT_AUDIO_CHUNK, holds the chunk pushed by |TakeAudioChunk|. |
116 scoped_refptr<const AudioChunk> audio_data; | 119 scoped_refptr<const AudioChunk> audio_data; |
117 | 120 |
118 // In case of EVENT_DOWNSTREAM_RESPONSE, hold the current chunk bytes. | 121 // In case of EVENT_DOWNSTREAM_RESPONSE, hold the current chunk bytes. |
119 scoped_ptr<std::vector<uint8> > response; | 122 scoped_ptr<std::vector<uint8_t>> response; |
120 | 123 |
121 private: | 124 private: |
122 DISALLOW_COPY_AND_ASSIGN(FSMEventArgs); | 125 DISALLOW_COPY_AND_ASSIGN(FSMEventArgs); |
123 }; | 126 }; |
124 | 127 |
125 // Invoked by both upstream and downstream URLFetcher callbacks to handle | 128 // Invoked by both upstream and downstream URLFetcher callbacks to handle |
126 // new chunk data, connection closed or errors notifications. | 129 // new chunk data, connection closed or errors notifications. |
127 void DispatchHTTPResponse(const net::URLFetcher* source, | 130 void DispatchHTTPResponse(const net::URLFetcher* source, |
128 bool end_of_response); | 131 bool end_of_response); |
129 | 132 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 bool is_dispatching_event_; | 169 bool is_dispatching_event_; |
167 bool use_framed_post_data_; | 170 bool use_framed_post_data_; |
168 FSMState state_; | 171 FSMState state_; |
169 | 172 |
170 DISALLOW_COPY_AND_ASSIGN(GoogleStreamingRemoteEngine); | 173 DISALLOW_COPY_AND_ASSIGN(GoogleStreamingRemoteEngine); |
171 }; | 174 }; |
172 | 175 |
173 } // namespace content | 176 } // namespace content |
174 | 177 |
175 #endif // CONTENT_BROWSER_SPEECH_GOOGLE_STREAMING_REMOTE_ENGINE_H_ | 178 #endif // CONTENT_BROWSER_SPEECH_GOOGLE_STREAMING_REMOTE_ENGINE_H_ |
OLD | NEW |