From a85492181380011523ffa495a7d800e58d8d8bdd Mon Sep 17 00:00:00 2001 From: Artem Titov Date: Mon, 19 Aug 2019 14:38:06 +0200 Subject: [PATCH] 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 Reviewed-by: Mirko Bonadei Reviewed-by: Karl Wiberg Cr-Commit-Position: refs/heads/master@{#28916} --- api/BUILD.gn | 1 + api/test/peerconnection_quality_test_fixture.h | 3 ++- api/test/track_id_stream_label_map.h | 2 +- api/test/video_quality_analyzer_interface.h | 2 +- test/pc/e2e/analyzer_helper.h | 2 +- test/pc/e2e/network_quality_metrics_reporter.h | 2 ++ test/pc/e2e/peer_connection_quality_test.cc | 9 +++++++-- 7 files changed, 15 insertions(+), 6 deletions(-) diff --git a/api/BUILD.gn b/api/BUILD.gn index 54529ab5b8..11b90c4fa5 100644 --- a/api/BUILD.gn +++ b/api/BUILD.gn @@ -295,6 +295,7 @@ rtc_source_set("peer_connection_quality_test_fixture_api") { ":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 12907bc9ae..e51c975bab 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 @@ class PeerConnectionE2EQualityTestFixture { }; // 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 9f8e1216a3..e8dc947ab1 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 92224a4b9d..53a34cbbc0 100644 --- a/api/test/video_quality_analyzer_interface.h +++ b/api/test/video_quality_analyzer_interface.h @@ -96,7 +96,7 @@ class VideoQualityAnalyzerInterface : public StatsObserverInterface { // 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 9a847e6cc4..51cfe5587d 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 52106ef580..bee20fd9ea 100644 --- a/test/pc/e2e/network_quality_metrics_reporter.h +++ b/test/pc/e2e/network_quality_metrics_reporter.h @@ -29,6 +29,8 @@ class NetworkQualityMetricsReporter // 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 e90b170099..046955dc0d 100644 --- a/test/pc/e2e/peer_connection_quality_test.cc +++ b/test/pc/e2e/peer_connection_quality_test.cc @@ -346,8 +346,13 @@ void PeerConnectionE2EQualityTest::Run(RunParams run_params) { } } - StatsPoller stats_poller({audio_quality_analyzer_.get(), - video_quality_analyzer_injection_helper_.get()}, + std::vector 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]() {