| 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 if (samples_per_channel_int < 0) { | 147 if (samples_per_channel_int < 0) { |
| 148 LOG(LERROR) << "AcmReceiver::GetAudio - " | 148 LOG(LERROR) << "AcmReceiver::GetAudio - " |
| 149 "Resampling last_audio_buffer_ failed."; | 149 "Resampling last_audio_buffer_ failed."; |
| 150 return -1; | 150 return -1; |
| 151 } | 151 } |
| 152 } | 152 } |
| 153 | 153 |
| 154 // TODO(henrik.lundin) Glitches in the output may appear if the output rate | 154 // TODO(henrik.lundin) Glitches in the output may appear if the output rate |
| 155 // from NetEq changes. See WebRTC issue 3923. | 155 // from NetEq changes. See WebRTC issue 3923. |
| 156 if (need_resampling) { | 156 if (need_resampling) { |
| 157 // TODO(yujo): handle this more efficiently for muted frames. |
| 157 int samples_per_channel_int = resampler_.Resample10Msec( | 158 int samples_per_channel_int = resampler_.Resample10Msec( |
| 158 audio_frame->data_, current_sample_rate_hz, desired_freq_hz, | 159 audio_frame->data(), current_sample_rate_hz, desired_freq_hz, |
| 159 audio_frame->num_channels_, AudioFrame::kMaxDataSizeSamples, | 160 audio_frame->num_channels_, AudioFrame::kMaxDataSizeSamples, |
| 160 audio_frame->data_); | 161 audio_frame->mutable_data()); |
| 161 if (samples_per_channel_int < 0) { | 162 if (samples_per_channel_int < 0) { |
| 162 LOG(LERROR) << "AcmReceiver::GetAudio - Resampling audio_buffer_ failed."; | 163 LOG(LERROR) << "AcmReceiver::GetAudio - Resampling audio_buffer_ failed."; |
| 163 return -1; | 164 return -1; |
| 164 } | 165 } |
| 165 audio_frame->samples_per_channel_ = | 166 audio_frame->samples_per_channel_ = |
| 166 static_cast<size_t>(samples_per_channel_int); | 167 static_cast<size_t>(samples_per_channel_int); |
| 167 audio_frame->sample_rate_hz_ = desired_freq_hz; | 168 audio_frame->sample_rate_hz_ = desired_freq_hz; |
| 168 RTC_DCHECK_EQ( | 169 RTC_DCHECK_EQ( |
| 169 audio_frame->sample_rate_hz_, | 170 audio_frame->sample_rate_hz_, |
| 170 rtc::dchecked_cast<int>(audio_frame->samples_per_channel_ * 100)); | 171 rtc::dchecked_cast<int>(audio_frame->samples_per_channel_ * 100)); |
| 171 resampled_last_output_frame_ = true; | 172 resampled_last_output_frame_ = true; |
| 172 } else { | 173 } else { |
| 173 resampled_last_output_frame_ = false; | 174 resampled_last_output_frame_ = false; |
| 174 // We might end up here ONLY if codec is changed. | 175 // We might end up here ONLY if codec is changed. |
| 175 } | 176 } |
| 176 | 177 |
| 177 // Store current audio in |last_audio_buffer_| for next time. | 178 // Store current audio in |last_audio_buffer_| for next time. |
| 178 memcpy(last_audio_buffer_.get(), audio_frame->data_, | 179 memcpy(last_audio_buffer_.get(), audio_frame->data(), |
| 179 sizeof(int16_t) * audio_frame->samples_per_channel_ * | 180 sizeof(int16_t) * audio_frame->samples_per_channel_ * |
| 180 audio_frame->num_channels_); | 181 audio_frame->num_channels_); |
| 181 | 182 |
| 182 call_stats_.DecodedByNetEq(audio_frame->speech_type_, *muted); | 183 call_stats_.DecodedByNetEq(audio_frame->speech_type_, *muted); |
| 183 return 0; | 184 return 0; |
| 184 } | 185 } |
| 185 | 186 |
| 186 void AcmReceiver::SetCodecs(const std::map<int, SdpAudioFormat>& codecs) { | 187 void AcmReceiver::SetCodecs(const std::map<int, SdpAudioFormat>& codecs) { |
| 187 neteq_->SetCodecs(codecs); | 188 neteq_->SetCodecs(codecs); |
| 188 } | 189 } |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 | 397 |
| 397 void AcmReceiver::GetDecodingCallStatistics( | 398 void AcmReceiver::GetDecodingCallStatistics( |
| 398 AudioDecodingCallStats* stats) const { | 399 AudioDecodingCallStats* stats) const { |
| 399 rtc::CritScope lock(&crit_sect_); | 400 rtc::CritScope lock(&crit_sect_); |
| 400 *stats = call_stats_.GetDecodingStatistics(); | 401 *stats = call_stats_.GetDecodingStatistics(); |
| 401 } | 402 } |
| 402 | 403 |
| 403 } // namespace acm2 | 404 } // namespace acm2 |
| 404 | 405 |
| 405 } // namespace webrtc | 406 } // namespace webrtc |
| OLD | NEW |