Chromium Code Reviews| Index: webrtc/modules/audio_processing/echo_detector/echo_detector.h |
| diff --git a/webrtc/modules/audio_processing/echo_detector/echo_detector.h b/webrtc/modules/audio_processing/echo_detector/echo_detector.h |
| index d9c8bd5d18799c23d277c3883126759a3566f20d..71c70758f1e81d6306c1d8593286fa5accdc1c52 100644 |
| --- a/webrtc/modules/audio_processing/echo_detector/echo_detector.h |
| +++ b/webrtc/modules/audio_processing/echo_detector/echo_detector.h |
| @@ -11,21 +11,57 @@ |
| #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_DETECTOR_ECHO_DETECTOR_H_ |
| #define WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_DETECTOR_ECHO_DETECTOR_H_ |
| -#include <stddef.h> |
| +#include <vector> |
| + |
| #include "webrtc/base/array_view.h" |
| +#include "webrtc/modules/audio_processing/echo_detector/circular_buffer.h" |
| +#include "webrtc/modules/audio_processing/echo_detector/mean_variance_estimator.h" |
| +#include "webrtc/modules/audio_processing/echo_detector/normalized_covariance_estimator.h" |
| namespace webrtc { |
| class EchoDetector { |
| public: |
| - EchoDetector() {} |
| - ~EchoDetector() {} |
| + EchoDetector(); |
| + ~EchoDetector(); |
| + |
| + void BufferRender(rtc::ArrayView<const float> render); |
| + |
| + void Process(rtc::ArrayView<const float> capture); |
| + |
| + void Initialize(); |
| + |
| + float echo_likelihood() const { return echo_likelihood_; } |
| + |
| + private: |
| + static constexpr size_t kLookbackFrames = 650; |
| + // TODO(ivoc): Verify the size of this buffer. |
|
peah-webrtc
2016/10/20 15:08:24
Do these two constants need to be in the header fi
ivoc
2016/10/21 12:21:15
Not anymore, I will move them to the cc file.
|
| + static constexpr size_t kRenderBufferSize = 30; |
| + |
| + // Keep track if this is the first call to Process(). |
| + bool first_process_call_ = true; |
| - void BufferFarend(const rtc::ArrayView<const float>& farend); |
| + // Buffer for storing the power of incoming farend buffers. This is needed for |
| + // cases where calls to BufferFarend and Process are jittery. |
| + CircularBuffer render_buffer_; |
| + // Count how long ago it was that the size of |render_buffer_| was zero. |
| + size_t render_buffer_zero_ = 0; |
|
peah-webrtc
2016/10/20 15:08:24
I think this variable would benefit of being more
ivoc
2016/10/21 12:21:15
I changed it to frames_since_zero_buffer_size_.
|
| - void Process(const rtc::ArrayView<const float>& nearend); |
| + // Circular buffers containing delayed versions of the power, mean and |
| + // standard deviation, for calculating the delayed covariance values. |
| + std::vector<float> render_power_; |
| + std::vector<float> render_power_mean_; |
| + std::vector<float> render_power_std_dev_; |
| + // Covariance estimates for different delay values. |
| + std::vector<NormalizedCovarianceEstimator> covariances_; |
| + // Index where next element should be inserted in all of the above circular |
| + // buffers. |
| + size_t next_insertion_index_ = 0; |
| - void Initialize(int sample_rate_hz); |
| + MeanVarianceEstimator render_statistics_; |
| + MeanVarianceEstimator capture_statistics_; |
| + // Current echo likelihood. |
| + float echo_likelihood_ = 0.f; |
| }; |
| } // namespace webrtc |