• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/test/peerconnection_quality_test_fixture.h"
20 #include "api/test/track_id_stream_info_map.h"
21 #include "api/units/timestamp.h"
22 #include "rtc_base/numerics/samples_stats_counter.h"
23 #include "rtc_base/synchronization/mutex.h"
24 #include "test/testsupport/perf_test.h"
25 
26 namespace webrtc {
27 namespace webrtc_pc_e2e {
28 
29 class CrossMediaMetricsReporter
30     : public PeerConnectionE2EQualityTestFixture::QualityMetricsReporter {
31  public:
32   CrossMediaMetricsReporter() = default;
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     std::string audio_stream_label;
48     std::string video_stream_label;
49   };
50 
51   static void ReportResult(const std::string& metric_name,
52                            const std::string& test_case_name,
53                            const SamplesStatsCounter& counter,
54                            const std::string& unit,
55                            webrtc::test::ImproveDirection improve_direction =
56                                webrtc::test::ImproveDirection::kNone);
57   std::string GetTestCaseName(const std::string& stream_label,
58                               const std::string& sync_group) const;
59 
60   std::string test_case_name_;
61   const TrackIdStreamInfoMap* reporter_helper_;
62 
63   Mutex mutex_;
64   std::map<std::string, StatsInfo> stats_info_ RTC_GUARDED_BY(mutex_);
65 };
66 
67 }  // namespace webrtc_pc_e2e
68 }  // namespace webrtc
69 
70 #endif  // TEST_PC_E2E_CROSS_MEDIA_METRICS_REPORTER_H_
71