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

Side by Side Diff: webrtc/audio/audio_transport_proxy.cc

Issue 2948763002: Allow an external audio processing module to be used in WebRTC (Closed)
Patch Set: tracking linux32_rel issue Created 3 years, 6 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) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 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 16 matching lines...) Expand all
27 27
28 // TODO(yujo): make resampler take an AudioFrame, and add special case 28 // TODO(yujo): make resampler take an AudioFrame, and add special case
29 // handling of muted frames. 29 // handling of muted frames.
30 return resampler->Resample( 30 return resampler->Resample(
31 frame.data(), frame.samples_per_channel_ * number_of_channels, 31 frame.data(), frame.samples_per_channel_ * number_of_channels,
32 destination, number_of_channels * target_number_of_samples_per_channel); 32 destination, number_of_channels * target_number_of_samples_per_channel);
33 } 33 }
34 } // namespace 34 } // namespace
35 35
36 AudioTransportProxy::AudioTransportProxy(AudioTransport* voe_audio_transport, 36 AudioTransportProxy::AudioTransportProxy(AudioTransport* voe_audio_transport,
37 AudioProcessing* apm, 37 AudioProcessing* audio_processing,
38 AudioMixer* mixer) 38 AudioMixer* mixer)
39 : voe_audio_transport_(voe_audio_transport), apm_(apm), mixer_(mixer) { 39 : voe_audio_transport_(voe_audio_transport),
40 audio_processing_(audio_processing), mixer_(mixer) {
40 RTC_DCHECK(voe_audio_transport); 41 RTC_DCHECK(voe_audio_transport);
41 RTC_DCHECK(apm); 42 RTC_DCHECK(audio_processing);
42 RTC_DCHECK(mixer); 43 RTC_DCHECK(mixer);
43 } 44 }
44 45
45 AudioTransportProxy::~AudioTransportProxy() {} 46 AudioTransportProxy::~AudioTransportProxy() {}
46 47
47 int32_t AudioTransportProxy::RecordedDataIsAvailable( 48 int32_t AudioTransportProxy::RecordedDataIsAvailable(
48 const void* audioSamples, 49 const void* audioSamples,
49 const size_t nSamples, 50 const size_t nSamples,
50 const size_t nBytesPerSample, 51 const size_t nBytesPerSample,
51 const size_t nChannels, 52 const size_t nChannels,
(...skipping 26 matching lines...) Expand all
78 79
79 // 100 = 1 second / data duration (10 ms). 80 // 100 = 1 second / data duration (10 ms).
80 RTC_DCHECK_EQ(nSamples * 100, samplesPerSec); 81 RTC_DCHECK_EQ(nSamples * 100, samplesPerSec);
81 RTC_DCHECK_LE(nBytesPerSample * nSamples * nChannels, 82 RTC_DCHECK_LE(nBytesPerSample * nSamples * nChannels,
82 AudioFrame::kMaxDataSizeBytes); 83 AudioFrame::kMaxDataSizeBytes);
83 84
84 mixer_->Mix(nChannels, &mixed_frame_); 85 mixer_->Mix(nChannels, &mixed_frame_);
85 *elapsed_time_ms = mixed_frame_.elapsed_time_ms_; 86 *elapsed_time_ms = mixed_frame_.elapsed_time_ms_;
86 *ntp_time_ms = mixed_frame_.ntp_time_ms_; 87 *ntp_time_ms = mixed_frame_.ntp_time_ms_;
87 88
88 const auto error = apm_->ProcessReverseStream(&mixed_frame_); 89 const auto error = audio_processing_->ProcessReverseStream(&mixed_frame_);
89 RTC_DCHECK_EQ(error, AudioProcessing::kNoError); 90 RTC_DCHECK_EQ(error, AudioProcessing::kNoError);
90 91
91 nSamplesOut = Resample(mixed_frame_, samplesPerSec, &resampler_, 92 nSamplesOut = Resample(mixed_frame_, samplesPerSec, &resampler_,
92 static_cast<int16_t*>(audioSamples)); 93 static_cast<int16_t*>(audioSamples));
93 RTC_DCHECK_EQ(nSamplesOut, nChannels * nSamples); 94 RTC_DCHECK_EQ(nSamplesOut, nChannels * nSamples);
94 return 0; 95 return 0;
95 } 96 }
96 97
97 void AudioTransportProxy::PushCaptureData(int voe_channel, 98 void AudioTransportProxy::PushCaptureData(int voe_channel,
98 const void* audio_data, 99 const void* audio_data,
(...skipping 27 matching lines...) Expand all
126 mixer_->Mix(number_of_channels, &mixed_frame_); 127 mixer_->Mix(number_of_channels, &mixed_frame_);
127 *elapsed_time_ms = mixed_frame_.elapsed_time_ms_; 128 *elapsed_time_ms = mixed_frame_.elapsed_time_ms_;
128 *ntp_time_ms = mixed_frame_.ntp_time_ms_; 129 *ntp_time_ms = mixed_frame_.ntp_time_ms_;
129 130
130 const auto output_samples = Resample(mixed_frame_, sample_rate, &resampler_, 131 const auto output_samples = Resample(mixed_frame_, sample_rate, &resampler_,
131 static_cast<int16_t*>(audio_data)); 132 static_cast<int16_t*>(audio_data));
132 RTC_DCHECK_EQ(output_samples, number_of_channels * number_of_frames); 133 RTC_DCHECK_EQ(output_samples, number_of_channels * number_of_frames);
133 } 134 }
134 135
135 } // namespace webrtc 136 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698