1 /* 2 * Copyright (c) 2020 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef TEST_PC_E2E_CROSS_MEDIA_METRICS_REPORTER_H_ 12 #define TEST_PC_E2E_CROSS_MEDIA_METRICS_REPORTER_H_ 13 14 #include <map> 15 #include <string> 16 17 #include "absl/strings/string_view.h" 18 #include "absl/types/optional.h" 19 #include "api/numerics/samples_stats_counter.h" 20 #include "api/test/metrics/metrics_logger.h" 21 #include "api/test/peerconnection_quality_test_fixture.h" 22 #include "api/test/track_id_stream_info_map.h" 23 #include "api/units/timestamp.h" 24 #include "rtc_base/synchronization/mutex.h" 25 26 namespace webrtc { 27 namespace webrtc_pc_e2e { 28 29 class CrossMediaMetricsReporter 30 : public PeerConnectionE2EQualityTestFixture::QualityMetricsReporter { 31 public: 32 explicit CrossMediaMetricsReporter(test::MetricsLogger* metrics_logger); 33 ~CrossMediaMetricsReporter() override = default; 34 35 void Start(absl::string_view test_case_name, 36 const TrackIdStreamInfoMap* reporter_helper) override; 37 void OnStatsReports( 38 absl::string_view pc_label, 39 const rtc::scoped_refptr<const RTCStatsReport>& report) override; 40 void StopAndReportResults() override; 41 42 private: 43 struct StatsInfo { 44 SamplesStatsCounter audio_ahead_ms; 45 SamplesStatsCounter video_ahead_ms; 46 47 TrackIdStreamInfoMap::StreamInfo audio_stream_info; 48 TrackIdStreamInfoMap::StreamInfo video_stream_info; 49 std::string audio_stream_label; 50 std::string video_stream_label; 51 }; 52 53 std::string GetTestCaseName(const std::string& stream_label, 54 const std::string& sync_group) const; 55 56 test::MetricsLogger* const metrics_logger_; 57 58 std::string test_case_name_; 59 const TrackIdStreamInfoMap* reporter_helper_; 60 61 Mutex mutex_; 62 std::map<std::string, StatsInfo> stats_info_ RTC_GUARDED_BY(mutex_); 63 }; 64 65 } // namespace webrtc_pc_e2e 66 } // namespace webrtc 67 68 #endif // TEST_PC_E2E_CROSS_MEDIA_METRICS_REPORTER_H_ 69