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

Side by Side Diff: modules/audio_coding/acm2/audio_coding_module.cc

Issue 3014683002: Revert of Remove various IDs (Closed)
Patch Set: Created 3 years, 2 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 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 int PreprocessToAddData(const AudioFrame& in_frame, 262 int PreprocessToAddData(const AudioFrame& in_frame,
263 const AudioFrame** ptr_out) 263 const AudioFrame** ptr_out)
264 RTC_EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_); 264 RTC_EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_);
265 265
266 // Change required states after starting to receive the codec corresponding 266 // Change required states after starting to receive the codec corresponding
267 // to |index|. 267 // to |index|.
268 int UpdateUponReceivingCodec(int index); 268 int UpdateUponReceivingCodec(int index);
269 269
270 rtc::CriticalSection acm_crit_sect_; 270 rtc::CriticalSection acm_crit_sect_;
271 rtc::Buffer encode_buffer_ RTC_GUARDED_BY(acm_crit_sect_); 271 rtc::Buffer encode_buffer_ RTC_GUARDED_BY(acm_crit_sect_);
272 int id_; // TODO(henrik.lundin) Make const.
272 uint32_t expected_codec_ts_ RTC_GUARDED_BY(acm_crit_sect_); 273 uint32_t expected_codec_ts_ RTC_GUARDED_BY(acm_crit_sect_);
273 uint32_t expected_in_ts_ RTC_GUARDED_BY(acm_crit_sect_); 274 uint32_t expected_in_ts_ RTC_GUARDED_BY(acm_crit_sect_);
274 acm2::ACMResampler resampler_ RTC_GUARDED_BY(acm_crit_sect_); 275 acm2::ACMResampler resampler_ RTC_GUARDED_BY(acm_crit_sect_);
275 acm2::AcmReceiver receiver_; // AcmReceiver has it's own internal lock. 276 acm2::AcmReceiver receiver_; // AcmReceiver has it's own internal lock.
276 ChangeLogger bitrate_logger_ RTC_GUARDED_BY(acm_crit_sect_); 277 ChangeLogger bitrate_logger_ RTC_GUARDED_BY(acm_crit_sect_);
277 278
278 std::unique_ptr<EncoderFactory> encoder_factory_ 279 std::unique_ptr<EncoderFactory> encoder_factory_
279 RTC_GUARDED_BY(acm_crit_sect_); 280 RTC_GUARDED_BY(acm_crit_sect_);
280 281
281 // Current encoder stack, either obtained from 282 // Current encoder stack, either obtained from
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 void AudioCodingModuleImpl::ChangeLogger::MaybeLog(int value) { 449 void AudioCodingModuleImpl::ChangeLogger::MaybeLog(int value) {
449 if (value != last_value_ || first_time_) { 450 if (value != last_value_ || first_time_) {
450 first_time_ = false; 451 first_time_ = false;
451 last_value_ = value; 452 last_value_ = value;
452 RTC_HISTOGRAM_COUNTS_SPARSE_100(histogram_name_, value); 453 RTC_HISTOGRAM_COUNTS_SPARSE_100(histogram_name_, value);
453 } 454 }
454 } 455 }
455 456
456 AudioCodingModuleImpl::AudioCodingModuleImpl( 457 AudioCodingModuleImpl::AudioCodingModuleImpl(
457 const AudioCodingModule::Config& config) 458 const AudioCodingModule::Config& config)
458 : expected_codec_ts_(0xD87F3F9F), 459 : id_(config.id),
460 expected_codec_ts_(0xD87F3F9F),
459 expected_in_ts_(0xD87F3F9F), 461 expected_in_ts_(0xD87F3F9F),
460 receiver_(config), 462 receiver_(config),
461 bitrate_logger_("WebRTC.Audio.TargetBitrateInKbps"), 463 bitrate_logger_("WebRTC.Audio.TargetBitrateInKbps"),
462 encoder_factory_(new EncoderFactory), 464 encoder_factory_(new EncoderFactory),
463 encoder_stack_(nullptr), 465 encoder_stack_(nullptr),
464 previous_pltype_(255), 466 previous_pltype_(255),
465 receiver_initialized_(false), 467 receiver_initialized_(false),
466 first_10ms_data_(false), 468 first_10ms_data_(false),
467 first_frame_(true), 469 first_frame_(true),
468 packetization_callback_(NULL), 470 packetization_callback_(NULL),
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 // Get 10 milliseconds of raw audio data to play out. 1113 // Get 10 milliseconds of raw audio data to play out.
1112 // Automatic resample to the requested frequency. 1114 // Automatic resample to the requested frequency.
1113 int AudioCodingModuleImpl::PlayoutData10Ms(int desired_freq_hz, 1115 int AudioCodingModuleImpl::PlayoutData10Ms(int desired_freq_hz,
1114 AudioFrame* audio_frame, 1116 AudioFrame* audio_frame,
1115 bool* muted) { 1117 bool* muted) {
1116 // GetAudio always returns 10 ms, at the requested sample rate. 1118 // GetAudio always returns 10 ms, at the requested sample rate.
1117 if (receiver_.GetAudio(desired_freq_hz, audio_frame, muted) != 0) { 1119 if (receiver_.GetAudio(desired_freq_hz, audio_frame, muted) != 0) {
1118 LOG(LS_ERROR) << "PlayoutData failed, RecOut Failed"; 1120 LOG(LS_ERROR) << "PlayoutData failed, RecOut Failed";
1119 return -1; 1121 return -1;
1120 } 1122 }
1123 audio_frame->id_ = id_;
1121 return 0; 1124 return 0;
1122 } 1125 }
1123 1126
1124 int AudioCodingModuleImpl::PlayoutData10Ms(int desired_freq_hz, 1127 int AudioCodingModuleImpl::PlayoutData10Ms(int desired_freq_hz,
1125 AudioFrame* audio_frame) { 1128 AudioFrame* audio_frame) {
1126 bool muted; 1129 bool muted;
1127 int ret = PlayoutData10Ms(desired_freq_hz, audio_frame, &muted); 1130 int ret = PlayoutData10Ms(desired_freq_hz, audio_frame, &muted);
1128 RTC_DCHECK(!muted); 1131 RTC_DCHECK(!muted);
1129 return ret; 1132 return ret;
1130 } 1133 }
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1276 rtc::CritScope lock(&acm_crit_sect_); 1279 rtc::CritScope lock(&acm_crit_sect_);
1277 if (encoder_stack_) 1280 if (encoder_stack_)
1278 return encoder_stack_->GetANAStats(); 1281 return encoder_stack_->GetANAStats();
1279 // If no encoder is set, return default stats. 1282 // If no encoder is set, return default stats.
1280 return ANAStats(); 1283 return ANAStats();
1281 } 1284 }
1282 1285
1283 } // namespace 1286 } // namespace
1284 1287
1285 AudioCodingModule::Config::Config() 1288 AudioCodingModule::Config::Config()
1286 : neteq_config(), clock(Clock::GetRealTimeClock()) { 1289 : id(0), neteq_config(), clock(Clock::GetRealTimeClock()) {
1287 // Post-decode VAD is disabled by default in NetEq, however, Audio 1290 // Post-decode VAD is disabled by default in NetEq, however, Audio
1288 // Conference Mixer relies on VAD decisions and fails without them. 1291 // Conference Mixer relies on VAD decisions and fails without them.
1289 neteq_config.enable_post_decode_vad = true; 1292 neteq_config.enable_post_decode_vad = true;
1290 } 1293 }
1291 1294
1292 AudioCodingModule::Config::Config(const Config&) = default; 1295 AudioCodingModule::Config::Config(const Config&) = default;
1293 AudioCodingModule::Config::~Config() = default; 1296 AudioCodingModule::Config::~Config() = default;
1294 1297
1295 // Create module 1298 // Create module
1296 AudioCodingModule* AudioCodingModule::Create() { 1299 AudioCodingModule* AudioCodingModule::Create(int id) {
1297 Config config; 1300 Config config;
1301 config.id = id;
1298 config.clock = Clock::GetRealTimeClock(); 1302 config.clock = Clock::GetRealTimeClock();
1299 config.decoder_factory = CreateBuiltinAudioDecoderFactory(); 1303 config.decoder_factory = CreateBuiltinAudioDecoderFactory();
1300 return Create(config); 1304 return Create(config);
1301 } 1305 }
1302 1306
1303 AudioCodingModule* AudioCodingModule::Create(Clock* clock) { 1307 AudioCodingModule* AudioCodingModule::Create(int id, Clock* clock) {
1304 Config config; 1308 Config config;
1309 config.id = id;
1305 config.clock = clock; 1310 config.clock = clock;
1306 config.decoder_factory = CreateBuiltinAudioDecoderFactory(); 1311 config.decoder_factory = CreateBuiltinAudioDecoderFactory();
1307 return Create(config); 1312 return Create(config);
1308 } 1313 }
1309 1314
1310 AudioCodingModule* AudioCodingModule::Create(const Config& config) { 1315 AudioCodingModule* AudioCodingModule::Create(const Config& config) {
1311 if (!config.decoder_factory) { 1316 if (!config.decoder_factory) {
1312 // TODO(ossu): Backwards compatibility. Will be removed after a deprecation 1317 // TODO(ossu): Backwards compatibility. Will be removed after a deprecation
1313 // cycle. 1318 // cycle.
1314 Config config_copy = config; 1319 Config config_copy = config;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1368 1373
1369 // Checks the validity of the parameters of the given codec 1374 // Checks the validity of the parameters of the given codec
1370 bool AudioCodingModule::IsCodecValid(const CodecInst& codec) { 1375 bool AudioCodingModule::IsCodecValid(const CodecInst& codec) {
1371 bool valid = acm2::RentACodec::IsCodecValid(codec); 1376 bool valid = acm2::RentACodec::IsCodecValid(codec);
1372 if (!valid) 1377 if (!valid)
1373 LOG(LS_ERROR) << "Invalid codec setting"; 1378 LOG(LS_ERROR) << "Invalid codec setting";
1374 return valid; 1379 return valid;
1375 } 1380 }
1376 1381
1377 } // namespace webrtc 1382 } // namespace webrtc
OLDNEW
« no previous file with comments | « modules/audio_coding/acm2/acm_send_test.cc ('k') | modules/audio_coding/acm2/audio_coding_module_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698