OLD | NEW |
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 Loading... |
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. | |
273 uint32_t expected_codec_ts_ RTC_GUARDED_BY(acm_crit_sect_); | 272 uint32_t expected_codec_ts_ RTC_GUARDED_BY(acm_crit_sect_); |
274 uint32_t expected_in_ts_ RTC_GUARDED_BY(acm_crit_sect_); | 273 uint32_t expected_in_ts_ RTC_GUARDED_BY(acm_crit_sect_); |
275 acm2::ACMResampler resampler_ RTC_GUARDED_BY(acm_crit_sect_); | 274 acm2::ACMResampler resampler_ RTC_GUARDED_BY(acm_crit_sect_); |
276 acm2::AcmReceiver receiver_; // AcmReceiver has it's own internal lock. | 275 acm2::AcmReceiver receiver_; // AcmReceiver has it's own internal lock. |
277 ChangeLogger bitrate_logger_ RTC_GUARDED_BY(acm_crit_sect_); | 276 ChangeLogger bitrate_logger_ RTC_GUARDED_BY(acm_crit_sect_); |
278 | 277 |
279 std::unique_ptr<EncoderFactory> encoder_factory_ | 278 std::unique_ptr<EncoderFactory> encoder_factory_ |
280 RTC_GUARDED_BY(acm_crit_sect_); | 279 RTC_GUARDED_BY(acm_crit_sect_); |
281 | 280 |
282 // Current encoder stack, either obtained from | 281 // Current encoder stack, either obtained from |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 void AudioCodingModuleImpl::ChangeLogger::MaybeLog(int value) { | 448 void AudioCodingModuleImpl::ChangeLogger::MaybeLog(int value) { |
450 if (value != last_value_ || first_time_) { | 449 if (value != last_value_ || first_time_) { |
451 first_time_ = false; | 450 first_time_ = false; |
452 last_value_ = value; | 451 last_value_ = value; |
453 RTC_HISTOGRAM_COUNTS_SPARSE_100(histogram_name_, value); | 452 RTC_HISTOGRAM_COUNTS_SPARSE_100(histogram_name_, value); |
454 } | 453 } |
455 } | 454 } |
456 | 455 |
457 AudioCodingModuleImpl::AudioCodingModuleImpl( | 456 AudioCodingModuleImpl::AudioCodingModuleImpl( |
458 const AudioCodingModule::Config& config) | 457 const AudioCodingModule::Config& config) |
459 : id_(config.id), | 458 : expected_codec_ts_(0xD87F3F9F), |
460 expected_codec_ts_(0xD87F3F9F), | |
461 expected_in_ts_(0xD87F3F9F), | 459 expected_in_ts_(0xD87F3F9F), |
462 receiver_(config), | 460 receiver_(config), |
463 bitrate_logger_("WebRTC.Audio.TargetBitrateInKbps"), | 461 bitrate_logger_("WebRTC.Audio.TargetBitrateInKbps"), |
464 encoder_factory_(new EncoderFactory), | 462 encoder_factory_(new EncoderFactory), |
465 encoder_stack_(nullptr), | 463 encoder_stack_(nullptr), |
466 previous_pltype_(255), | 464 previous_pltype_(255), |
467 receiver_initialized_(false), | 465 receiver_initialized_(false), |
468 first_10ms_data_(false), | 466 first_10ms_data_(false), |
469 first_frame_(true), | 467 first_frame_(true), |
470 packetization_callback_(NULL), | 468 packetization_callback_(NULL), |
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1113 // Get 10 milliseconds of raw audio data to play out. | 1111 // Get 10 milliseconds of raw audio data to play out. |
1114 // Automatic resample to the requested frequency. | 1112 // Automatic resample to the requested frequency. |
1115 int AudioCodingModuleImpl::PlayoutData10Ms(int desired_freq_hz, | 1113 int AudioCodingModuleImpl::PlayoutData10Ms(int desired_freq_hz, |
1116 AudioFrame* audio_frame, | 1114 AudioFrame* audio_frame, |
1117 bool* muted) { | 1115 bool* muted) { |
1118 // GetAudio always returns 10 ms, at the requested sample rate. | 1116 // GetAudio always returns 10 ms, at the requested sample rate. |
1119 if (receiver_.GetAudio(desired_freq_hz, audio_frame, muted) != 0) { | 1117 if (receiver_.GetAudio(desired_freq_hz, audio_frame, muted) != 0) { |
1120 LOG(LS_ERROR) << "PlayoutData failed, RecOut Failed"; | 1118 LOG(LS_ERROR) << "PlayoutData failed, RecOut Failed"; |
1121 return -1; | 1119 return -1; |
1122 } | 1120 } |
1123 audio_frame->id_ = id_; | |
1124 return 0; | 1121 return 0; |
1125 } | 1122 } |
1126 | 1123 |
1127 int AudioCodingModuleImpl::PlayoutData10Ms(int desired_freq_hz, | 1124 int AudioCodingModuleImpl::PlayoutData10Ms(int desired_freq_hz, |
1128 AudioFrame* audio_frame) { | 1125 AudioFrame* audio_frame) { |
1129 bool muted; | 1126 bool muted; |
1130 int ret = PlayoutData10Ms(desired_freq_hz, audio_frame, &muted); | 1127 int ret = PlayoutData10Ms(desired_freq_hz, audio_frame, &muted); |
1131 RTC_DCHECK(!muted); | 1128 RTC_DCHECK(!muted); |
1132 return ret; | 1129 return ret; |
1133 } | 1130 } |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1279 rtc::CritScope lock(&acm_crit_sect_); | 1276 rtc::CritScope lock(&acm_crit_sect_); |
1280 if (encoder_stack_) | 1277 if (encoder_stack_) |
1281 return encoder_stack_->GetANAStats(); | 1278 return encoder_stack_->GetANAStats(); |
1282 // If no encoder is set, return default stats. | 1279 // If no encoder is set, return default stats. |
1283 return ANAStats(); | 1280 return ANAStats(); |
1284 } | 1281 } |
1285 | 1282 |
1286 } // namespace | 1283 } // namespace |
1287 | 1284 |
1288 AudioCodingModule::Config::Config() | 1285 AudioCodingModule::Config::Config() |
1289 : id(0), neteq_config(), clock(Clock::GetRealTimeClock()) { | 1286 : neteq_config(), clock(Clock::GetRealTimeClock()) { |
1290 // Post-decode VAD is disabled by default in NetEq, however, Audio | 1287 // Post-decode VAD is disabled by default in NetEq, however, Audio |
1291 // Conference Mixer relies on VAD decisions and fails without them. | 1288 // Conference Mixer relies on VAD decisions and fails without them. |
1292 neteq_config.enable_post_decode_vad = true; | 1289 neteq_config.enable_post_decode_vad = true; |
1293 } | 1290 } |
1294 | 1291 |
1295 AudioCodingModule::Config::Config(const Config&) = default; | 1292 AudioCodingModule::Config::Config(const Config&) = default; |
1296 AudioCodingModule::Config::~Config() = default; | 1293 AudioCodingModule::Config::~Config() = default; |
1297 | 1294 |
| 1295 AudioCodingModule* AudioCodingModule::Create(int id) { |
| 1296 RTC_UNUSED(id); |
| 1297 return Create(); |
| 1298 } |
| 1299 |
1298 // Create module | 1300 // Create module |
1299 AudioCodingModule* AudioCodingModule::Create(int id) { | 1301 AudioCodingModule* AudioCodingModule::Create() { |
1300 Config config; | 1302 Config config; |
1301 config.id = id; | |
1302 config.clock = Clock::GetRealTimeClock(); | 1303 config.clock = Clock::GetRealTimeClock(); |
1303 config.decoder_factory = CreateBuiltinAudioDecoderFactory(); | 1304 config.decoder_factory = CreateBuiltinAudioDecoderFactory(); |
1304 return Create(config); | 1305 return Create(config); |
1305 } | 1306 } |
1306 | 1307 |
1307 AudioCodingModule* AudioCodingModule::Create(int id, Clock* clock) { | 1308 AudioCodingModule* AudioCodingModule::Create(Clock* clock) { |
1308 Config config; | 1309 Config config; |
1309 config.id = id; | |
1310 config.clock = clock; | 1310 config.clock = clock; |
1311 config.decoder_factory = CreateBuiltinAudioDecoderFactory(); | 1311 config.decoder_factory = CreateBuiltinAudioDecoderFactory(); |
1312 return Create(config); | 1312 return Create(config); |
1313 } | 1313 } |
1314 | 1314 |
1315 AudioCodingModule* AudioCodingModule::Create(const Config& config) { | 1315 AudioCodingModule* AudioCodingModule::Create(const Config& config) { |
1316 if (!config.decoder_factory) { | 1316 if (!config.decoder_factory) { |
1317 // TODO(ossu): Backwards compatibility. Will be removed after a deprecation | 1317 // TODO(ossu): Backwards compatibility. Will be removed after a deprecation |
1318 // cycle. | 1318 // cycle. |
1319 Config config_copy = config; | 1319 Config config_copy = config; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1373 | 1373 |
1374 // Checks the validity of the parameters of the given codec | 1374 // Checks the validity of the parameters of the given codec |
1375 bool AudioCodingModule::IsCodecValid(const CodecInst& codec) { | 1375 bool AudioCodingModule::IsCodecValid(const CodecInst& codec) { |
1376 bool valid = acm2::RentACodec::IsCodecValid(codec); | 1376 bool valid = acm2::RentACodec::IsCodecValid(codec); |
1377 if (!valid) | 1377 if (!valid) |
1378 LOG(LS_ERROR) << "Invalid codec setting"; | 1378 LOG(LS_ERROR) << "Invalid codec setting"; |
1379 return valid; | 1379 return valid; |
1380 } | 1380 } |
1381 | 1381 |
1382 } // namespace webrtc | 1382 } // namespace webrtc |
OLD | NEW |