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 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1129 return _fileRecording; | 1129 return _fileRecording; |
1130 } | 1130 } |
1131 | 1131 |
1132 void TransmitMixer::GenerateAudioFrame(const int16_t* audio, | 1132 void TransmitMixer::GenerateAudioFrame(const int16_t* audio, |
1133 size_t samples_per_channel, | 1133 size_t samples_per_channel, |
1134 int num_channels, | 1134 int num_channels, |
1135 int sample_rate_hz) { | 1135 int sample_rate_hz) { |
1136 int codec_rate; | 1136 int codec_rate; |
1137 int num_codec_channels; | 1137 int num_codec_channels; |
1138 GetSendCodecInfo(&codec_rate, &num_codec_channels); | 1138 GetSendCodecInfo(&codec_rate, &num_codec_channels); |
1139 // TODO(ajm): This currently restricts the sample rate to 32 kHz. | 1139 stereo_codec_ = num_codec_channels == 2; |
1140 // See: https://code.google.com/p/webrtc/issues/detail?id=3146 | 1140 |
1141 // When 48 kHz is supported natively by AudioProcessing, this will have | 1141 // We want to process at the lowest rate possible without losing information. |
1142 // to be changed to handle 44.1 kHz. | 1142 // Choose the lowest native rate at least equal to the input and codec rates. |
1143 int max_sample_rate_hz = kAudioProcMaxNativeSampleRateHz; | 1143 const int min_processing_rate = std::min(sample_rate_hz, codec_rate); |
| 1144 for (size_t i = 0; i < AudioProcessing::kNumNativeSampleRates; ++i) { |
| 1145 _audioFrame.sample_rate_hz_ = AudioProcessing::kNativeSampleRatesHz[i]; |
| 1146 if (_audioFrame.sample_rate_hz_ >= min_processing_rate) { |
| 1147 break; |
| 1148 } |
| 1149 } |
1144 if (audioproc_->echo_control_mobile()->is_enabled()) { | 1150 if (audioproc_->echo_control_mobile()->is_enabled()) { |
1145 // AECM only supports 8 and 16 kHz. | 1151 // AECM only supports 8 and 16 kHz. |
1146 max_sample_rate_hz = 16000; | 1152 _audioFrame.sample_rate_hz_ = std::min( |
| 1153 _audioFrame.sample_rate_hz_, AudioProcessing::kMaxAECMSampleRateHz); |
1147 } | 1154 } |
1148 codec_rate = std::min(codec_rate, max_sample_rate_hz); | 1155 _audioFrame.num_channels_ = std::min(num_channels, num_codec_channels); |
1149 stereo_codec_ = num_codec_channels == 2; | 1156 RemixAndResample(audio, samples_per_channel, num_channels, sample_rate_hz, |
1150 | 1157 &resampler_, &_audioFrame); |
1151 if (!mono_buffer_.get()) { | |
1152 // Temporary space for DownConvertToCodecFormat. | |
1153 mono_buffer_.reset(new int16_t[kMaxMonoDataSizeSamples]); | |
1154 } | |
1155 DownConvertToCodecFormat(audio, | |
1156 samples_per_channel, | |
1157 num_channels, | |
1158 sample_rate_hz, | |
1159 num_codec_channels, | |
1160 codec_rate, | |
1161 mono_buffer_.get(), | |
1162 &resampler_, | |
1163 &_audioFrame); | |
1164 } | 1158 } |
1165 | 1159 |
1166 int32_t TransmitMixer::RecordAudioToFile( | 1160 int32_t TransmitMixer::RecordAudioToFile( |
1167 uint32_t mixingFrequency) | 1161 uint32_t mixingFrequency) |
1168 { | 1162 { |
1169 CriticalSectionScoped cs(&_critSect); | 1163 CriticalSectionScoped cs(&_critSect); |
1170 if (_fileRecorderPtr == NULL) | 1164 if (_fileRecorderPtr == NULL) |
1171 { | 1165 { |
1172 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, -1), | 1166 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, -1), |
1173 "TransmitMixer::RecordAudioToFile() filerecorder doesnot" | 1167 "TransmitMixer::RecordAudioToFile() filerecorder doesnot" |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1337 void TransmitMixer::EnableStereoChannelSwapping(bool enable) { | 1331 void TransmitMixer::EnableStereoChannelSwapping(bool enable) { |
1338 swap_stereo_channels_ = enable; | 1332 swap_stereo_channels_ = enable; |
1339 } | 1333 } |
1340 | 1334 |
1341 bool TransmitMixer::IsStereoChannelSwappingEnabled() { | 1335 bool TransmitMixer::IsStereoChannelSwappingEnabled() { |
1342 return swap_stereo_channels_; | 1336 return swap_stereo_channels_; |
1343 } | 1337 } |
1344 | 1338 |
1345 } // namespace voe | 1339 } // namespace voe |
1346 } // namespace webrtc | 1340 } // namespace webrtc |
OLD | NEW |