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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 nack_enabled_(false) { | 99 nack_enabled_(false) { |
100 LOG(LS_INFO) << "NetEq config: " << config.ToString(); | 100 LOG(LS_INFO) << "NetEq config: " << config.ToString(); |
101 int fs = config.sample_rate_hz; | 101 int fs = config.sample_rate_hz; |
102 if (fs != 8000 && fs != 16000 && fs != 32000 && fs != 48000) { | 102 if (fs != 8000 && fs != 16000 && fs != 32000 && fs != 48000) { |
103 LOG(LS_ERROR) << "Sample rate " << fs << " Hz not supported. " << | 103 LOG(LS_ERROR) << "Sample rate " << fs << " Hz not supported. " << |
104 "Changing to 8000 Hz."; | 104 "Changing to 8000 Hz."; |
105 fs = 8000; | 105 fs = 8000; |
106 } | 106 } |
107 fs_hz_ = fs; | 107 fs_hz_ = fs; |
108 fs_mult_ = fs / 8000; | 108 fs_mult_ = fs / 8000; |
| 109 last_output_sample_rate_hz_ = fs; |
109 output_size_samples_ = static_cast<size_t>(kOutputSizeMs * 8 * fs_mult_); | 110 output_size_samples_ = static_cast<size_t>(kOutputSizeMs * 8 * fs_mult_); |
110 decoder_frame_length_ = 3 * output_size_samples_; | 111 decoder_frame_length_ = 3 * output_size_samples_; |
111 WebRtcSpl_Init(); | 112 WebRtcSpl_Init(); |
112 if (create_components) { | 113 if (create_components) { |
113 SetSampleRateAndChannels(fs, 1); // Default is 1 channel. | 114 SetSampleRateAndChannels(fs, 1); // Default is 1 channel. |
114 } | 115 } |
115 RTC_DCHECK(!vad_->enabled()); | 116 RTC_DCHECK(!vad_->enabled()); |
116 if (config.enable_post_decode_vad) { | 117 if (config.enable_post_decode_vad) { |
117 vad_->Enable(); | 118 vad_->Enable(); |
118 } | 119 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 CriticalSectionScoped lock(crit_sect_.get()); | 154 CriticalSectionScoped lock(crit_sect_.get()); |
154 int error = GetAudioInternal(max_length, output_audio, samples_per_channel, | 155 int error = GetAudioInternal(max_length, output_audio, samples_per_channel, |
155 num_channels); | 156 num_channels); |
156 if (error != 0) { | 157 if (error != 0) { |
157 error_code_ = error; | 158 error_code_ = error; |
158 return kFail; | 159 return kFail; |
159 } | 160 } |
160 if (type) { | 161 if (type) { |
161 *type = LastOutputType(); | 162 *type = LastOutputType(); |
162 } | 163 } |
| 164 last_output_sample_rate_hz_ = |
| 165 rtc::checked_cast<int>(*samples_per_channel * 100); |
| 166 RTC_DCHECK(last_output_sample_rate_hz_ == 8000 || |
| 167 last_output_sample_rate_hz_ == 16000 || |
| 168 last_output_sample_rate_hz_ == 32000 || |
| 169 last_output_sample_rate_hz_ == 48000) |
| 170 << "Unexpected sample rate " << last_output_sample_rate_hz_; |
163 return kOK; | 171 return kOK; |
164 } | 172 } |
165 | 173 |
166 int NetEqImpl::RegisterPayloadType(NetEqDecoder codec, | 174 int NetEqImpl::RegisterPayloadType(NetEqDecoder codec, |
167 uint8_t rtp_payload_type) { | 175 uint8_t rtp_payload_type) { |
168 CriticalSectionScoped lock(crit_sect_.get()); | 176 CriticalSectionScoped lock(crit_sect_.get()); |
169 LOG(LS_VERBOSE) << "RegisterPayloadType " | 177 LOG(LS_VERBOSE) << "RegisterPayloadType " |
170 << static_cast<int>(rtp_payload_type) << " " | 178 << static_cast<int>(rtp_payload_type) << " " |
171 << static_cast<int>(codec); | 179 << static_cast<int>(codec); |
172 int ret = decoder_database_->RegisterPayload(rtp_payload_type, codec); | 180 int ret = decoder_database_->RegisterPayload(rtp_payload_type, codec); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 CriticalSectionScoped lock(crit_sect_.get()); | 360 CriticalSectionScoped lock(crit_sect_.get()); |
353 if (first_packet_) { | 361 if (first_packet_) { |
354 // We don't have a valid RTP timestamp until we have decoded our first | 362 // We don't have a valid RTP timestamp until we have decoded our first |
355 // RTP packet. | 363 // RTP packet. |
356 return false; | 364 return false; |
357 } | 365 } |
358 *timestamp = timestamp_scaler_->ToExternal(playout_timestamp_); | 366 *timestamp = timestamp_scaler_->ToExternal(playout_timestamp_); |
359 return true; | 367 return true; |
360 } | 368 } |
361 | 369 |
| 370 int NetEqImpl::last_output_sample_rate_hz() const { |
| 371 CriticalSectionScoped lock(crit_sect_.get()); |
| 372 return last_output_sample_rate_hz_; |
| 373 } |
| 374 |
362 int NetEqImpl::SetTargetNumberOfChannels() { | 375 int NetEqImpl::SetTargetNumberOfChannels() { |
363 return kNotImplemented; | 376 return kNotImplemented; |
364 } | 377 } |
365 | 378 |
366 int NetEqImpl::SetTargetSampleRate() { | 379 int NetEqImpl::SetTargetSampleRate() { |
367 return kNotImplemented; | 380 return kNotImplemented; |
368 } | 381 } |
369 | 382 |
370 int NetEqImpl::LastError() const { | 383 int NetEqImpl::LastError() const { |
371 CriticalSectionScoped lock(crit_sect_.get()); | 384 CriticalSectionScoped lock(crit_sect_.get()); |
(...skipping 1655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2027 | 2040 |
2028 void NetEqImpl::CreateDecisionLogic() { | 2041 void NetEqImpl::CreateDecisionLogic() { |
2029 decision_logic_.reset(DecisionLogic::Create(fs_hz_, output_size_samples_, | 2042 decision_logic_.reset(DecisionLogic::Create(fs_hz_, output_size_samples_, |
2030 playout_mode_, | 2043 playout_mode_, |
2031 decoder_database_.get(), | 2044 decoder_database_.get(), |
2032 *packet_buffer_.get(), | 2045 *packet_buffer_.get(), |
2033 delay_manager_.get(), | 2046 delay_manager_.get(), |
2034 buffer_level_filter_.get())); | 2047 buffer_level_filter_.get())); |
2035 } | 2048 } |
2036 } // namespace webrtc | 2049 } // namespace webrtc |
OLD | NEW |