Use the new AudioProcessing statistics everywhere.

The new interface uses optionals instead of default values, and only values that are actually used are included. To make it easy to add/remove stats in the future, the struct itself is copied around on all layers, instead of copying the values one by one. This CL also fixes a bug which caused several APM statistics to get stuck at a fixed level when there are no more receive streams (after some period where there were receive streams). Since APM doesn't know this happens, an argument was added to the GetStats call to pass this information down to APM.

Bug: webrtc:8563, b/67926135
Change-Id: I96cc008353355bb520c4523f5c5379860f73ee24
Reviewed-on: https://webrtc-review.googlesource.com/25621
Commit-Queue: Ivo Creusen <ivoc@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20877}
diff --git a/media/base/mediachannel.h b/media/base/mediachannel.h
index 0b84ff7..7306ebf 100644
--- a/media/base/mediachannel.h
+++ b/media/base/mediachannel.h
@@ -27,6 +27,7 @@
 #include "media/base/streamparams.h"
 #include "media/base/videosinkinterface.h"
 #include "media/base/videosourceinterface.h"
+#include "modules/audio_processing/include/audio_processing_statistics.h"
 #include "rtc_base/basictypes.h"
 #include "rtc_base/buffer.h"
 #include "rtc_base/copyonwritebuffer.h"
@@ -624,6 +625,8 @@
   // https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats-totalaudioenergy
   double total_input_energy;
   double total_input_duration;
+  // TODO(bugs.webrtc.org/8572): Remove APM stats from this struct, since they
+  // are no longer needed now that we have apm_statistics.
   float aec_quality_min;
   int echo_delay_median_ms;
   int echo_delay_std_ms;
@@ -633,6 +636,7 @@
   float residual_echo_likelihood_recent_max;
   bool typing_noise_detected;
   webrtc::ANAStats ana_statistics;
+  webrtc::AudioProcessingStats apm_statistics;
 };
 
 struct VoiceReceiverInfo : public MediaReceiverInfo {