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

Side by Side Diff: remoting/codec/audio_encoder_opus.cc

Issue 2230193002: remoting: 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 | « remoting/codec/audio_decoder_opus.cc ('k') | remoting/codec/video_encoder_verbatim.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 (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 "remoting/codec/audio_encoder_opus.h" 5 #include "remoting/codec/audio_encoder_opus.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "media/base/audio_bus.h" 10 #include "media/base/audio_bus.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 } else { 191 } else {
192 samples_consumed = frame_size_; 192 samples_consumed = frame_size_;
193 } 193 }
194 194
195 // Initialize output buffer. 195 // Initialize output buffer.
196 std::string* data = encoded_packet->add_data(); 196 std::string* data = encoded_packet->add_data();
197 data->resize(kFrameSamples * kBytesPerSample * channels_); 197 data->resize(kFrameSamples * kBytesPerSample * channels_);
198 198
199 // Encode. 199 // Encode.
200 unsigned char* buffer = 200 unsigned char* buffer =
201 reinterpret_cast<unsigned char*>(string_as_array(data)); 201 reinterpret_cast<unsigned char*>(base::string_as_array(data));
202 int result = opus_encode(encoder_, pcm_buffer, kFrameSamples, 202 int result = opus_encode(encoder_, pcm_buffer, kFrameSamples,
203 buffer, data->length()); 203 buffer, data->length());
204 if (result < 0) { 204 if (result < 0) {
205 LOG(ERROR) << "opus_encode() failed with error code: " << result; 205 LOG(ERROR) << "opus_encode() failed with error code: " << result;
206 return nullptr; 206 return nullptr;
207 } 207 }
208 208
209 DCHECK_LE(result, static_cast<int>(data->length())); 209 DCHECK_LE(result, static_cast<int>(data->length()));
210 data->resize(result); 210 data->resize(result);
211 211
(...skipping 20 matching lines...) Expand all
232 } 232 }
233 233
234 // Return nullptr if there's nothing in the packet. 234 // Return nullptr if there's nothing in the packet.
235 if (encoded_packet->data_size() == 0) 235 if (encoded_packet->data_size() == 0)
236 return nullptr; 236 return nullptr;
237 237
238 return encoded_packet; 238 return encoded_packet;
239 } 239 }
240 240
241 } // namespace remoting 241 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/codec/audio_decoder_opus.cc ('k') | remoting/codec/video_encoder_verbatim.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698