Reland "Remove APM internal usage of EchoCancellation"

Original CL:
https://webrtc-review.googlesource.com/c/src/+/97603
 - Changes EchoCancellationImpl to inherit privately from
   EchoCancellation.
 - Removes usage of AudioProcessing::echo_cancellation() inside most of
   the audio processing module and unit tests.
 - Default-enables metrics collection in AEC2.

The CL breaks audioproc_f backwards compatibility: It can no longer
use all recorded settings (drift compensation, suppression level), but
prints an error message when such settings are encountered.

Revert CL:
https://webrtc-review.googlesource.com/c/src/+/100305

Bug: webrtc:9535
TBR: gustaf@webrtc.org
Change-Id: I9248046b3a6a82df6221e502481836948643a991
Reviewed-on: https://webrtc-review.googlesource.com/100461
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24749}
diff --git a/modules/audio_processing/audio_processing_impl_locking_unittest.cc b/modules/audio_processing/audio_processing_impl_locking_unittest.cc
index b770fef..0e0a33f 100644
--- a/modules/audio_processing/audio_processing_impl_locking_unittest.cc
+++ b/modules/audio_processing/audio_processing_impl_locking_unittest.cc
@@ -540,31 +540,23 @@
   ASSERT_EQ(apm_->kNoError, apm_->noise_suppression()->Enable(true));
   ASSERT_EQ(apm_->kNoError, apm_->voice_detection()->Enable(true));
 
+  AudioProcessing::Config apm_config;
+  apm_config.echo_canceller.enabled =
+      (test_config_.aec_type != AecType::AecTurnedOff);
+  apm_config.echo_canceller.mobile_mode =
+      (test_config_.aec_type == AecType::BasicWebRtcAecSettingsWithAecMobile);
+  apm_->ApplyConfig(apm_config);
+
   Config config;
-  if (test_config_.aec_type == AecType::AecTurnedOff) {
-    ASSERT_EQ(apm_->kNoError, apm_->echo_control_mobile()->Enable(false));
-    ASSERT_EQ(apm_->kNoError, apm_->echo_cancellation()->Enable(false));
-  } else if (test_config_.aec_type ==
-             AecType::BasicWebRtcAecSettingsWithAecMobile) {
-    ASSERT_EQ(apm_->kNoError, apm_->echo_control_mobile()->Enable(true));
-    ASSERT_EQ(apm_->kNoError, apm_->echo_cancellation()->Enable(false));
-  } else {
-    ASSERT_EQ(apm_->kNoError, apm_->echo_control_mobile()->Enable(false));
-    ASSERT_EQ(apm_->kNoError, apm_->echo_cancellation()->Enable(true));
-    ASSERT_EQ(apm_->kNoError, apm_->echo_cancellation()->enable_metrics(true));
-    ASSERT_EQ(apm_->kNoError,
-              apm_->echo_cancellation()->enable_delay_logging(true));
+  config.Set<ExtendedFilter>(
+      new ExtendedFilter(test_config_.aec_type ==
+                         AecType::BasicWebRtcAecSettingsWithExtentedFilter));
 
-    config.Set<ExtendedFilter>(
-        new ExtendedFilter(test_config_.aec_type ==
-                           AecType::BasicWebRtcAecSettingsWithExtentedFilter));
+  config.Set<DelayAgnostic>(
+      new DelayAgnostic(test_config_.aec_type ==
+                        AecType::BasicWebRtcAecSettingsWithDelayAgnosticAec));
 
-    config.Set<DelayAgnostic>(
-        new DelayAgnostic(test_config_.aec_type ==
-                          AecType::BasicWebRtcAecSettingsWithDelayAgnosticAec));
-
-    apm_->SetExtraOptions(config);
-  }
+  apm_->SetExtraOptions(config);
 }
 
 void AudioProcessingImplLockTest::TearDown() {
@@ -585,15 +577,15 @@
 bool StatsProcessor::Process() {
   SleepRandomMs(100, rand_gen_);
 
-  EXPECT_EQ(apm_->echo_cancellation()->is_enabled(),
-            ((test_config_->aec_type != AecType::AecTurnedOff) &&
-             (test_config_->aec_type !=
-              AecType::BasicWebRtcAecSettingsWithAecMobile)));
-  apm_->echo_cancellation()->stream_drift_samples();
-  EXPECT_EQ(apm_->echo_control_mobile()->is_enabled(),
-            (test_config_->aec_type != AecType::AecTurnedOff) &&
-                (test_config_->aec_type ==
-                 AecType::BasicWebRtcAecSettingsWithAecMobile));
+  AudioProcessing::Config apm_config = apm_->GetConfig();
+  if (test_config_->aec_type != AecType::AecTurnedOff) {
+    EXPECT_TRUE(apm_config.echo_canceller.enabled);
+    EXPECT_EQ(apm_config.echo_canceller.mobile_mode,
+              (test_config_->aec_type ==
+               AecType::BasicWebRtcAecSettingsWithAecMobile));
+  } else {
+    EXPECT_FALSE(apm_config.echo_canceller.enabled);
+  }
   EXPECT_TRUE(apm_->gain_control()->is_enabled());
   EXPECT_TRUE(apm_->noise_suppression()->is_enabled());