OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 if (samples_per_channel_int < 0) { | 143 if (samples_per_channel_int < 0) { |
144 LOG(LERROR) << "AcmReceiver::GetAudio - " | 144 LOG(LERROR) << "AcmReceiver::GetAudio - " |
145 "Resampling last_audio_buffer_ failed."; | 145 "Resampling last_audio_buffer_ failed."; |
146 return -1; | 146 return -1; |
147 } | 147 } |
148 } | 148 } |
149 | 149 |
150 // TODO(henrik.lundin) Glitches in the output may appear if the output rate | 150 // TODO(henrik.lundin) Glitches in the output may appear if the output rate |
151 // from NetEq changes. See WebRTC issue 3923. | 151 // from NetEq changes. See WebRTC issue 3923. |
152 if (need_resampling) { | 152 if (need_resampling) { |
| 153 // TODO(yujo): handle this more efficiently for muted frames. |
153 int samples_per_channel_int = resampler_.Resample10Msec( | 154 int samples_per_channel_int = resampler_.Resample10Msec( |
154 audio_frame->data_, current_sample_rate_hz, desired_freq_hz, | 155 audio_frame->data(), current_sample_rate_hz, desired_freq_hz, |
155 audio_frame->num_channels_, AudioFrame::kMaxDataSizeSamples, | 156 audio_frame->num_channels_, AudioFrame::kMaxDataSizeSamples, |
156 audio_frame->data_); | 157 audio_frame->mutable_data()); |
157 if (samples_per_channel_int < 0) { | 158 if (samples_per_channel_int < 0) { |
158 LOG(LERROR) << "AcmReceiver::GetAudio - Resampling audio_buffer_ failed."; | 159 LOG(LERROR) << "AcmReceiver::GetAudio - Resampling audio_buffer_ failed."; |
159 return -1; | 160 return -1; |
160 } | 161 } |
161 audio_frame->samples_per_channel_ = | 162 audio_frame->samples_per_channel_ = |
162 static_cast<size_t>(samples_per_channel_int); | 163 static_cast<size_t>(samples_per_channel_int); |
163 audio_frame->sample_rate_hz_ = desired_freq_hz; | 164 audio_frame->sample_rate_hz_ = desired_freq_hz; |
164 RTC_DCHECK_EQ( | 165 RTC_DCHECK_EQ( |
165 audio_frame->sample_rate_hz_, | 166 audio_frame->sample_rate_hz_, |
166 rtc::dchecked_cast<int>(audio_frame->samples_per_channel_ * 100)); | 167 rtc::dchecked_cast<int>(audio_frame->samples_per_channel_ * 100)); |
167 resampled_last_output_frame_ = true; | 168 resampled_last_output_frame_ = true; |
168 } else { | 169 } else { |
169 resampled_last_output_frame_ = false; | 170 resampled_last_output_frame_ = false; |
170 // We might end up here ONLY if codec is changed. | 171 // We might end up here ONLY if codec is changed. |
171 } | 172 } |
172 | 173 |
173 // Store current audio in |last_audio_buffer_| for next time. | 174 // Store current audio in |last_audio_buffer_| for next time. |
174 memcpy(last_audio_buffer_.get(), audio_frame->data_, | 175 memcpy(last_audio_buffer_.get(), audio_frame->data(), |
175 sizeof(int16_t) * audio_frame->samples_per_channel_ * | 176 sizeof(int16_t) * audio_frame->samples_per_channel_ * |
176 audio_frame->num_channels_); | 177 audio_frame->num_channels_); |
177 | 178 |
178 call_stats_.DecodedByNetEq(audio_frame->speech_type_, *muted); | 179 call_stats_.DecodedByNetEq(audio_frame->speech_type_, *muted); |
179 return 0; | 180 return 0; |
180 } | 181 } |
181 | 182 |
182 int32_t AcmReceiver::AddCodec(int acm_codec_id, | 183 int32_t AcmReceiver::AddCodec(int acm_codec_id, |
183 uint8_t payload_type, | 184 uint8_t payload_type, |
184 size_t channels, | 185 size_t channels, |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 | 389 |
389 void AcmReceiver::GetDecodingCallStatistics( | 390 void AcmReceiver::GetDecodingCallStatistics( |
390 AudioDecodingCallStats* stats) const { | 391 AudioDecodingCallStats* stats) const { |
391 rtc::CritScope lock(&crit_sect_); | 392 rtc::CritScope lock(&crit_sect_); |
392 *stats = call_stats_.GetDecodingStatistics(); | 393 *stats = call_stats_.GetDecodingStatistics(); |
393 } | 394 } |
394 | 395 |
395 } // namespace acm2 | 396 } // namespace acm2 |
396 | 397 |
397 } // namespace webrtc | 398 } // namespace webrtc |
OLD | NEW |