Separate AEC3 config from AudioProcessing::Config.

The struct containing the config for AEC3 is removed from
AudioProcessing::Config and is put in a new struct called
EchoCanceller3Config.

AEC3 should no longer be activated through
AudioProcessing::ApplyConfig. Instead an EchoCanceller3Factory
can be injected at AudioProcessing creation.

Bug: webrtc:8346
Change-Id: I27e3592e675eec3632a60c45d9e0d12514c2c567
Reviewed-on: https://webrtc-review.googlesource.com/11420
Reviewed-by: Per Ã…hgren <peah@webrtc.org>
Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org>
Commit-Queue: Gustaf Ullberg <gustaf@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20342}
diff --git a/modules/audio_processing/test/debug_dump_test.cc b/modules/audio_processing/test/debug_dump_test.cc
index a450950..2c839d3 100644
--- a/modules/audio_processing/test/debug_dump_test.cc
+++ b/modules/audio_processing/test/debug_dump_test.cc
@@ -46,10 +46,15 @@
                      int reverse_rate_hz,
                      int reverse_channels,
                      const Config& config,
-                     const std::string& dump_file_name);
+                     const std::string& dump_file_name,
+                     bool enable_aec3);
 
   // Constructor that uses default input files.
   explicit DebugDumpGenerator(const Config& config,
+                              const AudioProcessing::Config& apm_config,
+                              bool enable_aec3);
+
+  explicit DebugDumpGenerator(const Config& config,
                               const AudioProcessing::Config& apm_config);
 
   ~DebugDumpGenerator();
@@ -118,7 +123,8 @@
                                        int reverse_rate_hz,
                                        int reverse_channels,
                                        const Config& config,
-                                       const std::string& dump_file_name)
+                                       const std::string& dump_file_name,
+                                       bool enable_aec3)
     : input_config_(input_rate_hz, input_channels),
       reverse_config_(reverse_rate_hz, reverse_channels),
       output_config_(input_rate_hz, input_channels),
@@ -133,12 +139,19 @@
       output_(new ChannelBuffer<float>(output_config_.num_frames(),
                                        output_config_.num_channels())),
       worker_queue_("debug_dump_generator_worker_queue"),
-      apm_(AudioProcessing::Create(config)),
+      apm_(AudioProcessing::Create(
+          config,
+          nullptr,
+          (enable_aec3 ? std::unique_ptr<EchoControlFactory>(
+                             new EchoCanceller3Factory())
+                       : nullptr),
+          nullptr)),
       dump_file_name_(dump_file_name) {}
 
 DebugDumpGenerator::DebugDumpGenerator(
     const Config& config,
-    const AudioProcessing::Config& apm_config)
+    const AudioProcessing::Config& apm_config,
+    bool enable_aec3)
     : DebugDumpGenerator(ResourcePath("near32_stereo", "pcm"),
                          32000,
                          2,
@@ -146,7 +159,15 @@
                          32000,
                          2,
                          config,
-                         TempFilename(OutputPath(), "debug_aec")) {
+                         TempFilename(OutputPath(), "debug_aec"),
+                         enable_aec3) {
+  apm_->ApplyConfig(apm_config);
+}
+
+DebugDumpGenerator::DebugDumpGenerator(
+    const Config& config,
+    const AudioProcessing::Config& apm_config)
+    : DebugDumpGenerator(config, apm_config, false) {
   apm_->ApplyConfig(apm_config);
 }
 
@@ -384,8 +405,8 @@
   config.Set<RefinedAdaptiveFilter>(new RefinedAdaptiveFilter(true));
   // Arbitrarily set clipping gain to 17, which will never be the default.
   config.Set<ExperimentalAgc>(new ExperimentalAgc(true, 0, 17));
-  apm_config.echo_canceller3.enabled = true;
-  DebugDumpGenerator generator(config, apm_config);
+  bool enable_aec3 = true;
+  DebugDumpGenerator generator(config, apm_config, enable_aec3);
   generator.StartRecording();
   generator.Process(100);
   generator.StopRecording();
@@ -441,8 +462,7 @@
 TEST_F(DebugDumpTest, VerifyAec3ExperimentalString) {
   Config config;
   AudioProcessing::Config apm_config;
-  apm_config.echo_canceller3.enabled = true;
-  DebugDumpGenerator generator(config, apm_config);
+  DebugDumpGenerator generator(config, apm_config, true);
   generator.StartRecording();
   generator.Process(100);
   generator.StopRecording();