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

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

Issue 1549113002: Switch to standard integer types in content/browser/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 12 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
OLDNEW
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 #include "content/browser/speech/google_one_shot_remote_engine.h" 5 #include "content/browser/speech/google_one_shot_remote_engine.h"
6 6
7 #include <stddef.h>
8 #include <stdint.h>
9
7 #include <vector> 10 #include <vector>
8 11
9 #include "base/json/json_reader.h" 12 #include "base/json/json_reader.h"
10 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
12 #include "base/values.h" 15 #include "base/values.h"
13 #include "content/browser/speech/audio_buffer.h" 16 #include "content/browser/speech/audio_buffer.h"
14 #include "content/public/common/speech_recognition_error.h" 17 #include "content/public/common/speech_recognition_error.h"
15 #include "content/public/common/speech_recognition_result.h" 18 #include "content/public/common/speech_recognition_result.h"
16 #include "google_apis/google_api_keys.h" 19 #include "google_apis/google_api_keys.h"
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 243
241 void GoogleOneShotRemoteEngine::AudioChunksEnded() { 244 void GoogleOneShotRemoteEngine::AudioChunksEnded() {
242 DCHECK(url_fetcher_.get()); 245 DCHECK(url_fetcher_.get());
243 DCHECK(encoder_.get()); 246 DCHECK(encoder_.get());
244 247
245 // UploadAudioChunk requires a non-empty final buffer. So we encode a packet 248 // UploadAudioChunk requires a non-empty final buffer. So we encode a packet
246 // of silence in case encoder had no data already. 249 // of silence in case encoder had no data already.
247 size_t sample_count = 250 size_t sample_count =
248 config_.audio_sample_rate * kAudioPacketIntervalMs / 1000; 251 config_.audio_sample_rate * kAudioPacketIntervalMs / 1000;
249 scoped_refptr<AudioChunk> dummy_chunk(new AudioChunk( 252 scoped_refptr<AudioChunk> dummy_chunk(new AudioChunk(
250 sample_count * sizeof(int16), encoder_->GetBitsPerSample() / 8)); 253 sample_count * sizeof(int16_t), encoder_->GetBitsPerSample() / 8));
251 encoder_->Encode(*dummy_chunk.get()); 254 encoder_->Encode(*dummy_chunk.get());
252 encoder_->Flush(); 255 encoder_->Flush();
253 scoped_refptr<AudioChunk> encoded_dummy_data( 256 scoped_refptr<AudioChunk> encoded_dummy_data(
254 encoder_->GetEncodedDataAndClear()); 257 encoder_->GetEncodedDataAndClear());
255 DCHECK(!encoded_dummy_data->IsEmpty()); 258 DCHECK(!encoded_dummy_data->IsEmpty());
256 encoder_.reset(); 259 encoder_.reset();
257 260
258 url_fetcher_->AppendChunkToUpload(encoded_dummy_data->AsString(), true); 261 url_fetcher_->AppendChunkToUpload(encoded_dummy_data->AsString(), true);
259 } 262 }
260 263
(...skipping 24 matching lines...) Expand all
285 288
286 bool GoogleOneShotRemoteEngine::IsRecognitionPending() const { 289 bool GoogleOneShotRemoteEngine::IsRecognitionPending() const {
287 return url_fetcher_ != NULL; 290 return url_fetcher_ != NULL;
288 } 291 }
289 292
290 int GoogleOneShotRemoteEngine::GetDesiredAudioChunkDurationMs() const { 293 int GoogleOneShotRemoteEngine::GetDesiredAudioChunkDurationMs() const {
291 return kAudioPacketIntervalMs; 294 return kAudioPacketIntervalMs;
292 } 295 }
293 296
294 } // namespace content 297 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/speech/google_one_shot_remote_engine.h ('k') | content/browser/speech/google_streaming_remote_engine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698