Correct/update the activation of the multi-channel processing in APM

This CL removes the experimental status of the multi-channel processing
in APM, and accordingly updates the variable naming.

It also splits the activation of multi-channel processing to be separate
for render and capture.


Bug: webrtc:10859
Change-Id: I0e5d04dcb94b6637c33d97146231b8ddddbaea39
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/160707
Commit-Queue: Per Åhgren <peah@webrtc.org>
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29926}
diff --git a/modules/audio_processing/audio_processing_impl.cc b/modules/audio_processing/audio_processing_impl.cc
index b6e79be..0e375c9 100644
--- a/modules/audio_processing/audio_processing_impl.cc
+++ b/modules/audio_processing/audio_processing_impl.cc
@@ -586,11 +586,10 @@
   if (submodule_states_.RenderMultiBandSubModulesActive()) {
     // By default, downmix the render stream to mono for analysis. This has been
     // demonstrated to work well for AEC in most practical scenarios.
-    const bool experimental_multi_channel_render =
-        config_.pipeline.experimental_multi_channel &&
-        constants_.experimental_multi_channel_render_support;
+    const bool multi_channel_render = config_.pipeline.multi_channel_render &&
+                                      constants_.multi_channel_render_support;
     int render_processing_num_channels =
-        experimental_multi_channel_render
+        multi_channel_render
             ? formats_.api_format.reverse_input_stream().num_channels()
             : 1;
     formats_.render_processing_format =
@@ -622,8 +621,10 @@
   rtc::CritScope cs_capture(&crit_capture_);
 
   const bool pipeline_config_changed =
-      config_.pipeline.experimental_multi_channel !=
-      config.pipeline.experimental_multi_channel;
+      config_.pipeline.multi_channel_render !=
+          config.pipeline.multi_channel_render ||
+      config_.pipeline.multi_channel_capture !=
+          config.pipeline.multi_channel_capture;
 
   const bool aec_config_changed =
       config_.echo_canceller.enabled != config.echo_canceller.enabled ||
@@ -769,11 +770,9 @@
 
 size_t AudioProcessingImpl::num_proc_channels() const {
   // Used as callback from submodules, hence locking is not allowed.
-  const bool experimental_multi_channel_capture =
-      config_.pipeline.experimental_multi_channel &&
-      constants_.experimental_multi_channel_capture_support;
-  if (capture_nonlocked_.echo_controller_enabled &&
-      !experimental_multi_channel_capture) {
+  const bool multi_channel_capture = config_.pipeline.multi_channel_capture &&
+                                     constants_.multi_channel_capture_support;
+  if (capture_nonlocked_.echo_controller_enabled && !multi_channel_capture) {
     return 1;
   }
   return num_output_channels();
@@ -1291,10 +1290,9 @@
     capture_buffer->SplitIntoFrequencyBands();
   }
 
-  const bool experimental_multi_channel_capture =
-      config_.pipeline.experimental_multi_channel &&
-      constants_.experimental_multi_channel_capture_support;
-  if (submodules_.echo_controller && !experimental_multi_channel_capture) {
+  const bool multi_channel_capture = config_.pipeline.multi_channel_capture &&
+                                     constants_.multi_channel_capture_support;
+  if (submodules_.echo_controller && !multi_channel_capture) {
     // Force down-mixing of the number of channels after the detection of
     // capture signal saturation.
     // TODO(peah): Look into ensuring that this kind of tampering with the
diff --git a/modules/audio_processing/audio_processing_impl.h b/modules/audio_processing/audio_processing_impl.h
index 61bf151..5f1d12f 100644
--- a/modules/audio_processing/audio_processing_impl.h
+++ b/modules/audio_processing/audio_processing_impl.h
@@ -374,8 +374,8 @@
                  bool use_experimental_agc,
                  bool use_experimental_agc_agc2_level_estimation,
                  bool use_experimental_agc_agc2_digital_adaptive,
-                 bool experimental_multi_channel_render_support,
-                 bool experimental_multi_channel_capture_support)
+                 bool multi_channel_render_support,
+                 bool multi_channel_capture_support)
         : agc_startup_min_volume(agc_startup_min_volume),
           agc_clipped_level_min(agc_clipped_level_min),
           use_experimental_agc(use_experimental_agc),
@@ -383,17 +383,15 @@
               use_experimental_agc_agc2_level_estimation),
           use_experimental_agc_agc2_digital_adaptive(
               use_experimental_agc_agc2_digital_adaptive),
-          experimental_multi_channel_render_support(
-              experimental_multi_channel_render_support),
-          experimental_multi_channel_capture_support(
-              experimental_multi_channel_capture_support) {}
+          multi_channel_render_support(multi_channel_render_support),
+          multi_channel_capture_support(multi_channel_capture_support) {}
     int agc_startup_min_volume;
     int agc_clipped_level_min;
     bool use_experimental_agc;
     bool use_experimental_agc_agc2_level_estimation;
     bool use_experimental_agc_agc2_digital_adaptive;
-    bool experimental_multi_channel_render_support;
-    bool experimental_multi_channel_capture_support;
+    bool multi_channel_render_support;
+    bool multi_channel_capture_support;
   } constants_;
 
   struct ApmCaptureState {
diff --git a/modules/audio_processing/include/audio_processing.cc b/modules/audio_processing/include/audio_processing.cc
index b085605..eccc365 100644
--- a/modules/audio_processing/include/audio_processing.cc
+++ b/modules/audio_processing/include/audio_processing.cc
@@ -75,8 +75,9 @@
           << "pipeline: {"
           << "maximum_internal_processing_rate: "
           << pipeline.maximum_internal_processing_rate
-          << ", experimental_multi_channel: "
-          << pipeline.experimental_multi_channel << "}, "
+          << ", multi_channel_render: " << pipeline.multi_channel_render << ", "
+          << ", multi_channel_capture: " << pipeline.multi_channel_capture
+          << "}, "
           << "pre_amplifier: { enabled: " << pre_amplifier.enabled
           << ", fixed_gain_factor: " << pre_amplifier.fixed_gain_factor
           << " }, high_pass_filter: { enabled: " << high_pass_filter.enabled
diff --git a/modules/audio_processing/include/audio_processing.h b/modules/audio_processing/include/audio_processing.h
index 113bd2a..9ef4e26 100644
--- a/modules/audio_processing/include/audio_processing.h
+++ b/modules/audio_processing/include/audio_processing.h
@@ -256,8 +256,14 @@
       // default rate is currently selected based on the CPU architecture, but
       // that logic may change.
       int maximum_internal_processing_rate;
-      // Force multi-channel processing on playout and capture audio. This is an
-      // experimental feature, and is likely to change without warning.
+      // Allow multi-channel processing of render audio.
+      bool multi_channel_render = false;
+      // Allow multi-channel processing of capture audio when AEC3 is active
+      // or a custom AEC is injected..
+      bool multi_channel_capture = false;
+
+      // Deprecated.
+      // TODO(peah): Remove.
       bool experimental_multi_channel = false;
     } pipeline;
 
diff --git a/modules/audio_processing/test/audio_processing_simulator.cc b/modules/audio_processing/test/audio_processing_simulator.cc
index 38b97ca..cb1d1ed 100644
--- a/modules/audio_processing/test/audio_processing_simulator.cc
+++ b/modules/audio_processing/test/audio_processing_simulator.cc
@@ -403,9 +403,13 @@
   if (settings_.use_ts) {
     config.Set<ExperimentalNs>(new ExperimentalNs(*settings_.use_ts));
   }
-  if (settings_.experimental_multi_channel) {
-    apm_config.pipeline.experimental_multi_channel =
-        *settings_.experimental_multi_channel;
+  if (settings_.multi_channel_render) {
+    apm_config.pipeline.multi_channel_render = *settings_.multi_channel_render;
+  }
+
+  if (settings_.multi_channel_capture) {
+    apm_config.pipeline.multi_channel_capture =
+        *settings_.multi_channel_capture;
   }
 
   if (settings_.use_agc2) {
diff --git a/modules/audio_processing/test/audio_processing_simulator.h b/modules/audio_processing/test/audio_processing_simulator.h
index 8ee2db8..5b26b5f 100644
--- a/modules/audio_processing/test/audio_processing_simulator.h
+++ b/modules/audio_processing/test/audio_processing_simulator.h
@@ -85,7 +85,8 @@
   absl::optional<bool> use_refined_adaptive_filter;
   int initial_mic_level;
   bool simulate_mic_gain = false;
-  absl::optional<bool> experimental_multi_channel;
+  absl::optional<bool> multi_channel_render;
+  absl::optional<bool> multi_channel_capture;
   absl::optional<int> simulated_mic_kind;
   bool report_performance = false;
   absl::optional<std::string> performance_report_output_filename;
diff --git a/modules/audio_processing/test/audioproc_float_impl.cc b/modules/audio_processing/test/audioproc_float_impl.cc
index 8301c4e..4902acb 100644
--- a/modules/audio_processing/test/audioproc_float_impl.cc
+++ b/modules/audio_processing/test/audioproc_float_impl.cc
@@ -217,9 +217,15 @@
           0,
           "Activate (1) or deactivate(0) the analog mic gain simulation");
 ABSL_FLAG(int,
-          experimental_multi_channel,
+          multi_channel_render,
           kParameterNotSpecifiedValue,
-          "Activate (1) or deactivate(0) multi-channel audio in APM pipeline");
+          "Activate (1) or deactivate(0) multi-channel render processing in "
+          "APM pipeline");
+ABSL_FLAG(int,
+          multi_channel_capture,
+          kParameterNotSpecifiedValue,
+          "Activate (1) or deactivate(0) multi-channel capture processing in "
+          "APM pipeline");
 ABSL_FLAG(int,
           simulated_mic_kind,
           kParameterNotSpecifiedValue,
@@ -443,8 +449,10 @@
   SetSettingIfSpecified(absl::GetFlag(FLAGS_aec_settings),
                         &settings.aec_settings_filename);
   settings.initial_mic_level = absl::GetFlag(FLAGS_initial_mic_level);
-  SetSettingIfFlagSet(absl::GetFlag(FLAGS_experimental_multi_channel),
-                      &settings.experimental_multi_channel);
+  SetSettingIfFlagSet(absl::GetFlag(FLAGS_multi_channel_render),
+                      &settings.multi_channel_render);
+  SetSettingIfFlagSet(absl::GetFlag(FLAGS_multi_channel_capture),
+                      &settings.multi_channel_capture);
   settings.simulate_mic_gain = absl::GetFlag(FLAGS_simulate_mic_gain);
   SetSettingIfSpecified(absl::GetFlag(FLAGS_simulated_mic_kind),
                         &settings.simulated_mic_kind);