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

Unified Diff: webrtc/modules/audio_processing/aec3/echo_canceller3.h

Issue 2584493002: Added first layer of the echo canceller 3 functionality (Closed)
Patch Set: Changes in response to reviewer comments Created 4 years 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_processing/aec3/echo_canceller3.h
diff --git a/webrtc/modules/audio_processing/aec3/echo_canceller3.h b/webrtc/modules/audio_processing/aec3/echo_canceller3.h
index c65ecdea758b309e8a5b1d439825600c9f78de45..cb80ab4c453846823420170becf9b5460e5854f7 100644
--- a/webrtc/modules/audio_processing/aec3/echo_canceller3.h
+++ b/webrtc/modules/audio_processing/aec3/echo_canceller3.h
@@ -11,16 +11,57 @@
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_ECHO_CANCELLER3_H_
#define WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_ECHO_CANCELLER3_H_
-#include <string>
-
#include "webrtc/base/constructormagic.h"
+#include "webrtc/base/swap_queue.h"
+#include "webrtc/modules/audio_processing/aec3/block_framer.h"
+#include "webrtc/modules/audio_processing/aec3/block_processor.h"
+#include "webrtc/modules/audio_processing/aec3/cascaded_biquad_filter.h"
+#include "webrtc/modules/audio_processing/aec3/frame_blocker.h"
#include "webrtc/modules/audio_processing/audio_buffer.h"
+#include "webrtc/modules/audio_processing/include/audio_processing.h"
+#include "webrtc/modules/audio_processing/logging/apm_data_dumper.h"
namespace webrtc {
+// Functor for verifying the invariance of the frames being put into the render
+// queue.
+class Aec3RenderQueueItemVerifier {
+ public:
+ explicit Aec3RenderQueueItemVerifier(size_t num_bands, size_t frame_length)
+ : num_bands_(num_bands), frame_length_(frame_length) {}
+
+ bool operator()(const std::vector<std::vector<float>>& v) const {
+ bool result = true;
+ result &= v.size() == num_bands_;
ivoc 2016/12/21 13:04:05 This is the bitwise-AND operator (like a = a & b),
peah-webrtc 2016/12/21 23:13:51 Good one! Done.
+ for (auto v_k : v) {
aleloi 2016/12/20 15:55:35 const auto &.
peah-webrtc 2016/12/21 23:13:51 Good find!!! Thanks! Done.
+ result &= v_k.size() == frame_length_;
ivoc 2016/12/21 13:04:05 I suggest using an early return here: if (v_k.size
peah-webrtc 2016/12/21 23:13:51 Done.
+ }
+ return result;
+ }
+
+ private:
+ const size_t num_bands_;
+ const size_t frame_length_;
+};
+
+// Main class for the echo canceller3. It does 4 things:
+// -Receives 10 ms frames of band-split audio.
+// -Optionally applies an anti-hum (high-pass) filter on the
+// received signals.
+// -Provides the lower level echo canceller functionality with
+// blocks of 64 samples of audio data.
+// -Partially handles the jitter in the render and capture API
+// call sequence.
+// The class is supposed to be used in a non-concurrent manner apart from the
+// AnalyzeRender call which can be called concurrently with the other methods.
class EchoCanceller3 {
public:
- EchoCanceller3(int sample_rate_hz, bool use_anti_hum_filter);
+ // Normal c-tor to use.
+ EchoCanceller3(int sample_rate_hz, bool use_highpass_filter);
+ // Testing c-tor that is used only for testing purposes.
+ EchoCanceller3(int sample_rate_hz,
+ bool use_highpass_filter,
+ BlockProcessor* block_processor);
hlundin-webrtc 2016/12/20 15:10:35 It is not obvious to the caller that the ownership
aleloi 2016/12/20 15:55:35 I think block_processor should be a unique_ptr<Blo
peah-webrtc 2016/12/21 23:13:51 Done.
peah-webrtc 2016/12/21 23:13:51 Done.
~EchoCanceller3();
// Analyzes and stores an internal copy of the split-band domain render
// signal.
@@ -31,6 +72,14 @@ class EchoCanceller3 {
// present in the signal.
void ProcessCapture(AudioBuffer* capture, bool known_echo_path_change);
+ // Signals whether an external detector has detected echo leakage from the
+ // echo canceller.
+ // Note that in the case echo leakage has been flagged, it should be unflagged
+ // once it is no longer occurring.
+ void ReportEchoLeakage(bool leakage_detected) {
+ block_processor_->ReportEchoLeakage(leakage_detected);
+ }
+
// Validates a config.
static bool Validate(const AudioProcessing::Config::EchoCanceller3& config);
// Dumps a config to a string.
@@ -38,8 +87,29 @@ class EchoCanceller3 {
const AudioProcessing::Config::EchoCanceller3& config);
private:
+ class RenderWriter;
+
+ bool EmptyRenderQueue();
+
+ // State that is accessed by the AnalyzeRender call.
+ std::unique_ptr<RenderWriter> render_writer_;
+
+ // State that may be accessed by the capture thread.
static int instance_count_;
- size_t frame_length_;
+ std::unique_ptr<ApmDataDumper> data_dumper_;
+ const int sample_rate_hz_;
+ const int num_bands_;
+ const size_t frame_length_;
+ BlockFramer output_framer_;
+ FrameBlocker capture_blocker_;
+ FrameBlocker render_blocker_;
+ SwapQueue<std::vector<std::vector<float>>, Aec3RenderQueueItemVerifier>
+ render_transfer_queue_;
+ std::unique_ptr<BlockProcessor> block_processor_;
+ std::vector<std::vector<float>> render_queue_output_frame_;
+ std::unique_ptr<CascadedBiQuadFilter> capture_highpass_filter_;
+ bool saturated_microphone_signal_ = false;
+ std::vector<std::vector<float>> block_;
RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(EchoCanceller3);
};

Powered by Google App Engine
This is Rietveld 408576698