Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: content/browser/speech/audio_encoder.cc

Issue 6615020: Stream speech audio to server as it gets recorded, instead of waiting until end of recording. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include "content/browser/speech/audio_encoder.h" 5 #include "content/browser/speech/audio_encoder.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/scoped_ptr.h" 9 #include "base/scoped_ptr.h"
10 #include "base/stl_util-inl.h" 10 #include "base/stl_util-inl.h"
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 } 174 }
175 175
176 AudioEncoder::AudioEncoder(const std::string& mime_type) 176 AudioEncoder::AudioEncoder(const std::string& mime_type)
177 : mime_type_(mime_type) { 177 : mime_type_(mime_type) {
178 } 178 }
179 179
180 AudioEncoder::~AudioEncoder() { 180 AudioEncoder::~AudioEncoder() {
181 STLDeleteElements(&audio_buffers_); 181 STLDeleteElements(&audio_buffers_);
182 } 182 }
183 183
184 bool AudioEncoder::GetEncodedData(std::string* encoded_data) { 184 bool AudioEncoder::GetEncodedDataAndClear(std::string* encoded_data) {
185 if (!audio_buffers_.size()) 185 if (!audio_buffers_.size())
186 return false; 186 return false;
187 187
188 int audio_buffer_length = 0; 188 int audio_buffer_length = 0;
189 for (AudioBufferQueue::iterator it = audio_buffers_.begin(); 189 for (AudioBufferQueue::iterator it = audio_buffers_.begin();
190 it != audio_buffers_.end(); ++it) { 190 it != audio_buffers_.end(); ++it) {
191 audio_buffer_length += (*it)->length(); 191 audio_buffer_length += (*it)->length();
192 } 192 }
193 encoded_data->reserve(audio_buffer_length); 193 encoded_data->reserve(audio_buffer_length);
194 for (AudioBufferQueue::iterator it = audio_buffers_.begin(); 194 for (AudioBufferQueue::iterator it = audio_buffers_.begin();
195 it != audio_buffers_.end(); ++it) { 195 it != audio_buffers_.end(); ++it) {
196 encoded_data->append(*(*it)); 196 encoded_data->append(*(*it));
197 } 197 }
198 198
199 STLDeleteElements(&audio_buffers_);
200
199 return true; 201 return true;
200 } 202 }
201 203
202 void AudioEncoder::AppendToBuffer(std::string* item) { 204 void AudioEncoder::AppendToBuffer(std::string* item) {
203 audio_buffers_.push_back(item); 205 audio_buffers_.push_back(item);
204 } 206 }
205 207
206 } // namespace speech_input 208 } // namespace speech_input
OLDNEW
« no previous file with comments | « content/browser/speech/audio_encoder.h ('k') | content/browser/speech/speech_recognition_request.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698