AGC2: adding level estimation option (RMS or peak-based).

This CL makes possible to choose the level estimation for the adaptive
digital GC of AGC2. The options are RMS (default and currently used
estimator) and peak-based (already computed, but not used).

Besides adding the new AGC2 config param for the level estimator, this CL
also refactors the config class by making it more structured.

Bug: webrtc:7494
Change-Id: I20eb558ca50f13536aa7bdea08d21de3b630f8bc
Reviewed-on: https://webrtc-review.googlesource.com/c/110144
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Alex Loiko <aleloi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25620}
diff --git a/modules/audio_processing/include/audio_processing.h b/modules/audio_processing/include/audio_processing.h
index b105ef1..b04629b 100644
--- a/modules/audio_processing/include/audio_processing.h
+++ b/modules/audio_processing/include/audio_processing.h
@@ -270,10 +270,23 @@
     // first applies a fixed gain. The adaptive digital AGC can be turned off by
     // setting |adaptive_digital_mode=false|.
     struct GainController2 {
+      enum LevelEstimator { kRms, kPeak };
       bool enabled = false;
-      bool adaptive_digital_mode = true;
-      float extra_saturation_margin_db = 2.f;
+      struct {
+        float gain_db = 0.f;
+      } fixed_digital;
+      struct {
+        bool enabled = true;
+        LevelEstimator level_estimator = kRms;
+        bool use_saturation_protector = true;
+        float extra_saturation_margin_db = 2.f;
+      } adaptive_digital;
+      // Deprecated.
+      // TODO(webrtc:7494): Switch to fixed_digital.gain_db and remove.
       float fixed_gain_db = 0.f;
+      // Deprecated.
+      // TODO(webrtc:7494): Switch to adaptive_digital.enabled and remove.
+      bool adaptive_digital_mode = false;
     } gain_controller2;
 
     // Explicit copy assignment implementation to avoid issues with memory