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

Side by Side Diff: media/cast/sender/audio_encoder.cc

Issue 2234753002: media: 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
« no previous file with comments | « media/cast/net/cast_transport_config.h ('k') | media/cast/test/end2end_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "media/cast/sender/audio_encoder.h" 5 #include "media/cast/sender/audio_encoder.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <limits> 10 #include <limits>
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 DCHECK_EQ(audio_bus->channels(), num_channels_); 285 DCHECK_EQ(audio_bus->channels(), num_channels_);
286 float* dest = buffer_.get() + (buffer_fill_offset * num_channels_); 286 float* dest = buffer_.get() + (buffer_fill_offset * num_channels_);
287 audio_bus->ToInterleavedPartial<Float32SampleTypeTraits>(source_offset, 287 audio_bus->ToInterleavedPartial<Float32SampleTypeTraits>(source_offset,
288 num_samples, dest); 288 num_samples, dest);
289 } 289 }
290 290
291 bool EncodeFromFilledBuffer(std::string* out) final { 291 bool EncodeFromFilledBuffer(std::string* out) final {
292 out->resize(kOpusMaxPayloadSize); 292 out->resize(kOpusMaxPayloadSize);
293 const opus_int32 result = opus_encode_float( 293 const opus_int32 result = opus_encode_float(
294 opus_encoder_, buffer_.get(), samples_per_frame_, 294 opus_encoder_, buffer_.get(), samples_per_frame_,
295 reinterpret_cast<uint8_t*>(string_as_array(out)), kOpusMaxPayloadSize); 295 reinterpret_cast<uint8_t*>(base::string_as_array(out)),
296 kOpusMaxPayloadSize);
296 if (result > 1) { 297 if (result > 1) {
297 out->resize(result); 298 out->resize(result);
298 return true; 299 return true;
299 } else if (result < 0) { 300 } else if (result < 0) {
300 LOG(ERROR) << "Error code from opus_encode_float(): " << result; 301 LOG(ERROR) << "Error code from opus_encode_float(): " << result;
301 return false; 302 return false;
302 } else { 303 } else {
303 // Do nothing: The documentation says that a return value of zero or 304 // Do nothing: The documentation says that a return value of zero or
304 // one byte means the packet does not need to be transmitted. 305 // one byte means the packet does not need to be transmitted.
305 return false; 306 return false;
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 cast_environment_->PostTask(CastEnvironment::AUDIO, 836 cast_environment_->PostTask(CastEnvironment::AUDIO,
836 FROM_HERE, 837 FROM_HERE,
837 base::Bind(&AudioEncoder::ImplBase::EncodeAudio, 838 base::Bind(&AudioEncoder::ImplBase::EncodeAudio,
838 impl_, 839 impl_,
839 base::Passed(&audio_bus), 840 base::Passed(&audio_bus),
840 recorded_time)); 841 recorded_time));
841 } 842 }
842 843
843 } // namespace cast 844 } // namespace cast
844 } // namespace media 845 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/net/cast_transport_config.h ('k') | media/cast/test/end2end_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698