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

Side by Side Diff: content/renderer/media/audio_track_recorder.cc

Issue 2228403003: content: Use stl utilities from the base namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 4 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/renderer/media/audio_track_recorder.h" 5 #include "content/renderer/media/audio_track_recorder.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 // Tries to encode |data_in|'s |num_samples| into |data_out|. 56 // Tries to encode |data_in|'s |num_samples| into |data_out|.
57 bool DoEncode(OpusEncoder* opus_encoder, 57 bool DoEncode(OpusEncoder* opus_encoder,
58 float* data_in, 58 float* data_in,
59 int num_samples, 59 int num_samples,
60 std::string* data_out) { 60 std::string* data_out) {
61 DCHECK_EQ(kOpusPreferredFramesPerBuffer, num_samples); 61 DCHECK_EQ(kOpusPreferredFramesPerBuffer, num_samples);
62 62
63 data_out->resize(kOpusMaxDataBytes); 63 data_out->resize(kOpusMaxDataBytes);
64 const opus_int32 result = opus_encode_float( 64 const opus_int32 result = opus_encode_float(
65 opus_encoder, data_in, num_samples, 65 opus_encoder, data_in, num_samples,
66 reinterpret_cast<uint8_t*>(string_as_array(data_out)), kOpusMaxDataBytes); 66 reinterpret_cast<uint8_t*>(base::string_as_array(data_out)),
67 kOpusMaxDataBytes);
67 68
68 if (result > 1) { 69 if (result > 1) {
69 // TODO(ajose): Investigate improving this. http://crbug.com/547918 70 // TODO(ajose): Investigate improving this. http://crbug.com/547918
70 data_out->resize(result); 71 data_out->resize(result);
71 return true; 72 return true;
72 } 73 }
73 // If |result| in {0,1}, do nothing; the documentation says that a return 74 // If |result| in {0,1}, do nothing; the documentation says that a return
74 // value of zero or one means the packet does not need to be transmitted. 75 // value of zero or one means the packet does not need to be transmitted.
75 // Otherwise, we have an error. 76 // Otherwise, we have an error.
76 DLOG_IF(ERROR, result < 0) << " encode failed: " << opus_strerror(result); 77 DLOG_IF(ERROR, result < 0) << " encode failed: " << opus_strerror(result);
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 } 340 }
340 341
341 void AudioTrackRecorder::Resume() { 342 void AudioTrackRecorder::Resume() {
342 DCHECK(main_render_thread_checker_.CalledOnValidThread()); 343 DCHECK(main_render_thread_checker_.CalledOnValidThread());
343 DCHECK(encoder_); 344 DCHECK(encoder_);
344 encoder_thread_.task_runner()->PostTask( 345 encoder_thread_.task_runner()->PostTask(
345 FROM_HERE, base::Bind(&AudioEncoder::set_paused, encoder_, false)); 346 FROM_HERE, base::Bind(&AudioEncoder::set_paused, encoder_, false));
346 } 347 }
347 348
348 } // namespace content 349 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/gpu/frame_swap_message_queue.cc ('k') | content/renderer/media/audio_track_recorder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698