Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(835)

Side by Side Diff: webrtc/voice_engine/transmit_mixer.cc

Issue 1338833002: Fix the maximum native sample rate in AudioProcessing (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Refactor conversions Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 int max_sample_rate_hz = AudioProcessing::kMaxNativeSampleRateHz;
1140 // See: https://code.google.com/p/webrtc/issues/detail?id=3146
1141 // When 48 kHz is supported natively by AudioProcessing, this will have
1142 // to be changed to handle 44.1 kHz.
1143 int max_sample_rate_hz = kAudioProcMaxNativeSampleRateHz;
1144 if (audioproc_->echo_control_mobile()->is_enabled()) { 1140 if (audioproc_->echo_control_mobile()->is_enabled()) {
1145 // AECM only supports 8 and 16 kHz. 1141 // AECM only supports 8 and 16 kHz.
1146 max_sample_rate_hz = 16000; 1142 max_sample_rate_hz = 16000;
1147 } 1143 }
1148 codec_rate = std::min(codec_rate, max_sample_rate_hz); 1144 codec_rate = std::min(codec_rate, max_sample_rate_hz);
1149 stereo_codec_ = num_codec_channels == 2; 1145 stereo_codec_ = num_codec_channels == 2;
1150 1146
1151 if (!mono_buffer_.get()) { 1147 // Chose the lowest native sample rate which is higher or equal than at least
Andrew MacDonald 2015/09/23 02:35:52 A bit neater is to use the minimum of them. I'd re
aluebs-webrtc 2015/09/23 17:13:43 Done.
1152 // Temporary space for DownConvertToCodecFormat. 1148 // one of the input or codec rates.
1153 mono_buffer_.reset(new int16_t[kMaxMonoDataSizeSamples]); 1149 for (size_t i = 0; i < AudioProcessing::kNumNativeSampleRates; ++i) {
1150 _audioFrame.sample_rate_hz_ = AudioProcessing::kNativeSampleRatesHz[i];
1151 if (_audioFrame.sample_rate_hz_ >= sample_rate_hz ||
1152 _audioFrame.sample_rate_hz_ >= codec_rate) {
1153 break;
1154 }
1154 } 1155 }
1155 DownConvertToCodecFormat(audio, 1156 _audioFrame.num_channels_ = num_codec_channels;
1156 samples_per_channel, 1157 RemixAndResample(audio, samples_per_channel, num_channels, sample_rate_hz,
1157 num_channels, 1158 &resampler_, &_audioFrame);
1158 sample_rate_hz,
1159 num_codec_channels,
1160 codec_rate,
1161 mono_buffer_.get(),
1162 &resampler_,
1163 &_audioFrame);
1164 } 1159 }
1165 1160
1166 int32_t TransmitMixer::RecordAudioToFile( 1161 int32_t TransmitMixer::RecordAudioToFile(
1167 uint32_t mixingFrequency) 1162 uint32_t mixingFrequency)
1168 { 1163 {
1169 CriticalSectionScoped cs(&_critSect); 1164 CriticalSectionScoped cs(&_critSect);
1170 if (_fileRecorderPtr == NULL) 1165 if (_fileRecorderPtr == NULL)
1171 { 1166 {
1172 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, -1), 1167 WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, -1),
1173 "TransmitMixer::RecordAudioToFile() filerecorder doesnot" 1168 "TransmitMixer::RecordAudioToFile() filerecorder doesnot"
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1337 void TransmitMixer::EnableStereoChannelSwapping(bool enable) { 1332 void TransmitMixer::EnableStereoChannelSwapping(bool enable) {
1338 swap_stereo_channels_ = enable; 1333 swap_stereo_channels_ = enable;
1339 } 1334 }
1340 1335
1341 bool TransmitMixer::IsStereoChannelSwappingEnabled() { 1336 bool TransmitMixer::IsStereoChannelSwappingEnabled() {
1342 return swap_stereo_channels_; 1337 return swap_stereo_channels_;
1343 } 1338 }
1344 1339
1345 } // namespace voe 1340 } // namespace voe
1346 } // namespace webrtc 1341 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698