Enable custom metrics gathering from stats API in PC framework.

It is done by making QualityMetricsReporter implements
StatsObserverInterface.

Bug: webrtc:10138
Change-Id: Ied6c9a7e53bf942d0e48ce107f668b6af8e42735
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/149807
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28916}
diff --git a/api/BUILD.gn b/api/BUILD.gn
index 54529ab..11b90c4 100644
--- a/api/BUILD.gn
+++ b/api/BUILD.gn
@@ -295,6 +295,7 @@
     ":libjingle_peerconnection_api",
     ":network_state_predictor_api",
     ":simulated_network_api",
+    ":stats_observer_interface",
     ":video_quality_analyzer_api",
     "../logging:rtc_event_log_api",
     "../media:rtc_media_base",
diff --git a/api/test/peerconnection_quality_test_fixture.h b/api/test/peerconnection_quality_test_fixture.h
index 12907bc..e51c975 100644
--- a/api/test/peerconnection_quality_test_fixture.h
+++ b/api/test/peerconnection_quality_test_fixture.h
@@ -26,6 +26,7 @@
 #include "api/task_queue/task_queue_factory.h"
 #include "api/test/audio_quality_analyzer_interface.h"
 #include "api/test/simulated_network.h"
+#include "api/test/stats_observer_interface.h"
 #include "api/test/video_quality_analyzer_interface.h"
 #include "api/transport/network_control.h"
 #include "api/units/time_delta.h"
@@ -317,7 +318,7 @@
   };
 
   // Represent an entity that will report quality metrics after test.
-  class QualityMetricsReporter {
+  class QualityMetricsReporter : public StatsObserverInterface {
    public:
     virtual ~QualityMetricsReporter() = default;
 
diff --git a/api/test/track_id_stream_label_map.h b/api/test/track_id_stream_label_map.h
index 9f8e121..e8dc947 100644
--- a/api/test/track_id_stream_label_map.h
+++ b/api/test/track_id_stream_label_map.h
@@ -16,7 +16,7 @@
 namespace webrtc {
 namespace webrtc_pc_e2e {
 
-// Instances of |TrackIdStreamLabelMap| provide bookkeeing capabilities that
+// Instances of |TrackIdStreamLabelMap| provide bookkeeping capabilities that
 // are useful to associate stats reports track_ids to the remote stream_id.
 class TrackIdStreamLabelMap {
  public:
diff --git a/api/test/video_quality_analyzer_interface.h b/api/test/video_quality_analyzer_interface.h
index 92224a4..53a34cb 100644
--- a/api/test/video_quality_analyzer_interface.h
+++ b/api/test/video_quality_analyzer_interface.h
@@ -96,7 +96,7 @@
   // All available codes are listed in
   // modules/video_coding/include/video_error_codes.h
   virtual void OnDecoderError(uint16_t frame_id, int32_t error_code) {}
-  // Will be called everytime new stats reports are available for the
+  // Will be called every time new stats reports are available for the
   // Peer Connection identified by |pc_label|.
   void OnStatsReports(const std::string& pc_label,
                       const StatsReports& stats_reports) override {}
diff --git a/test/pc/e2e/analyzer_helper.h b/test/pc/e2e/analyzer_helper.h
index 9a847e6..51cfe55 100644
--- a/test/pc/e2e/analyzer_helper.h
+++ b/test/pc/e2e/analyzer_helper.h
@@ -21,7 +21,7 @@
 namespace webrtc {
 namespace webrtc_pc_e2e {
 
-// This class is a utility that provides bookkeeing capabilities that
+// This class is a utility that provides bookkeeping capabilities that
 // are useful to associate stats reports track_ids to the remote stream_id.
 // The framework will populate an instance of this class and it will pass
 // it to the Start method of Media Quality Analyzers.
diff --git a/test/pc/e2e/network_quality_metrics_reporter.h b/test/pc/e2e/network_quality_metrics_reporter.h
index 52106ef..bee20fd 100644
--- a/test/pc/e2e/network_quality_metrics_reporter.h
+++ b/test/pc/e2e/network_quality_metrics_reporter.h
@@ -29,6 +29,8 @@
 
   // Network stats must be empty when this method will be invoked.
   void Start(absl::string_view test_case_name) override;
+  void OnStatsReports(const std::string& pc_label,
+                      const StatsReports& reports) override {}
   void StopAndReportResults() override;
 
  private:
diff --git a/test/pc/e2e/peer_connection_quality_test.cc b/test/pc/e2e/peer_connection_quality_test.cc
index e90b170..046955d 100644
--- a/test/pc/e2e/peer_connection_quality_test.cc
+++ b/test/pc/e2e/peer_connection_quality_test.cc
@@ -346,8 +346,13 @@
     }
   }
 
-  StatsPoller stats_poller({audio_quality_analyzer_.get(),
-                            video_quality_analyzer_injection_helper_.get()},
+  std::vector<StatsObserverInterface*> observers = {
+      audio_quality_analyzer_.get(),
+      video_quality_analyzer_injection_helper_.get()};
+  for (auto& reporter : quality_metrics_reporters_) {
+    observers.push_back(reporter.get());
+  }
+  StatsPoller stats_poller(observers,
                            {{"alice", alice_.get()}, {"bob", bob_.get()}});
 
   task_queue_->PostTask([&stats_poller, this]() {