Chromium Code Reviews| Index: webrtc/modules/audio_processing/residual_echo_detector.cc |
| diff --git a/webrtc/modules/audio_processing/residual_echo_detector.cc b/webrtc/modules/audio_processing/residual_echo_detector.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9586c15494ef93e7387c2f75e971c49862e19eca |
| --- /dev/null |
| +++ b/webrtc/modules/audio_processing/residual_echo_detector.cc |
| @@ -0,0 +1,69 @@ |
| +/* |
| + * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
| + * |
| + * Use of this source code is governed by a BSD-style license |
| + * that can be found in the LICENSE file in the root of the source |
| + * tree. An additional intellectual property rights grant can be found |
| + * in the file PATENTS. All contributing project authors may |
| + * be found in the AUTHORS file in the root of the source tree. |
| + */ |
| + |
| +#include "webrtc/modules/audio_processing/residual_echo_detector.h" |
| +#include "webrtc/modules/audio_processing/audio_buffer.h" |
| +#include "webrtc/modules/audio_processing/echo_detector/echo_detector.h" |
| + |
| +namespace webrtc { |
| + |
| +ResidualEchoDetector::ResidualEchoDetector() = default; |
| + |
| +ResidualEchoDetector::~ResidualEchoDetector() = default; |
| + |
| +int ResidualEchoDetector::AnalyzeRenderAudio(const AudioBuffer* audio) const { |
|
hlundin-webrtc
2016/10/14 12:36:21
This is clearly not a const method. Remove const,
peah-webrtc
2016/10/14 13:34:48
I proposed this offline. The underlying idea is th
|
| + RTC_DCHECK_GE(160u, audio->num_frames_per_band()); |
| + |
| + render_queue_buffer_.clear(); |
| + |
| + // Buffer the samples in the render queue. |
| + render_queue_buffer_.insert(render_queue_buffer_.end(), |
| + audio->split_bands_const_f(0)[kBand0To8kHz], |
| + (audio->split_bands_const_f(0)[kBand0To8kHz] + |
| + audio->num_frames_per_band())); |
| + |
| + // Insert the samples into the queue. |
| + if (!render_signal_queue_->Insert(&render_queue_buffer_)) { |
| + // The buffer is full. |
| + return -1; |
| + } |
| + return 0; |
| +} |
| + |
| +void ResidualEchoDetector::AnalyzeCaptureAudio(const AudioBuffer* audio) { |
| + RTC_DCHECK_GE(160u, audio->num_frames_per_band()); |
| + |
| + detector_->Process( |
| + rtc::ArrayView<const float>(audio->split_bands_const_f(0)[kBand0To8kHz], |
| + audio->num_frames_per_band())); |
| +} |
| + |
| +void ResidualEchoDetector::Initialize(int sample_rate_hz) { |
| + RTC_DCHECK(sample_rate_hz == AudioProcessing::kSampleRate8kHz || |
| + sample_rate_hz == AudioProcessing::kSampleRate16kHz || |
| + sample_rate_hz == AudioProcessing::kSampleRate32kHz || |
| + sample_rate_hz == AudioProcessing::kSampleRate48kHz); |
| + |
| + detector_->Initialize(sample_rate_hz); |
| +} |
| + |
| +void ResidualEchoDetector::ReadQueuedRenderData() { |
| + while (render_signal_queue_->Remove(&capture_queue_buffer_)) { |
| + const size_t num_frames_per_band = capture_queue_buffer_.size(); |
| + detector_->BufferFarend(rtc::ArrayView<const float>( |
| + capture_queue_buffer_.data(), num_frames_per_band)); |
| + } |
| +} |
| + |
| +float ResidualEchoDetector::get_echo_likelihood() const { |
| + return 0.0f; |
| +} |
| + |
| +} // namespace webrtc |