xref: /aosp_15_r20/external/webrtc/rtc_tools/rtc_event_log_visualizer/analyzer.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
2  *  Copyright (c) 2016 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 RTC_TOOLS_RTC_EVENT_LOG_VISUALIZER_ANALYZER_H_
12 #define RTC_TOOLS_RTC_EVENT_LOG_VISUALIZER_ANALYZER_H_
13 
14 #include <map>
15 #include <memory>
16 #include <set>
17 #include <string>
18 #include <utility>
19 #include <vector>
20 
21 #include "logging/rtc_event_log/rtc_event_log_parser.h"
22 #include "modules/audio_coding/neteq/tools/neteq_stats_getter.h"
23 #include "rtc_base/strings/string_builder.h"
24 #include "rtc_tools/rtc_event_log_visualizer/analyzer_common.h"
25 #include "rtc_tools/rtc_event_log_visualizer/plot_base.h"
26 
27 namespace webrtc {
28 
29 class EventLogAnalyzer {
30  public:
31   // The EventLogAnalyzer keeps a reference to the ParsedRtcEventLogNew for the
32   // duration of its lifetime. The ParsedRtcEventLogNew must not be destroyed or
33   // modified while the EventLogAnalyzer is being used.
34   EventLogAnalyzer(const ParsedRtcEventLog& log, bool normalize_time);
35   EventLogAnalyzer(const ParsedRtcEventLog& log, const AnalyzerConfig& config);
36 
37   void CreatePacketGraph(PacketDirection direction, Plot* plot);
38 
39   void CreateRtcpTypeGraph(PacketDirection direction, Plot* plot);
40 
41   void CreateAccumulatedPacketsGraph(PacketDirection direction, Plot* plot);
42 
43   void CreatePacketRateGraph(PacketDirection direction, Plot* plot);
44 
45   void CreateTotalPacketRateGraph(PacketDirection direction, Plot* plot);
46 
47   void CreatePlayoutGraph(Plot* plot);
48 
49   void CreateAudioLevelGraph(PacketDirection direction, Plot* plot);
50 
51   void CreateSequenceNumberGraph(Plot* plot);
52 
53   void CreateIncomingPacketLossGraph(Plot* plot);
54 
55   void CreateIncomingDelayGraph(Plot* plot);
56 
57   void CreateFractionLossGraph(Plot* plot);
58 
59   void CreateTotalIncomingBitrateGraph(Plot* plot);
60   void CreateTotalOutgoingBitrateGraph(Plot* plot,
61                                        bool show_detector_state = false,
62                                        bool show_alr_state = false,
63                                        bool show_link_capacity = false);
64 
65   void CreateStreamBitrateGraph(PacketDirection direction, Plot* plot);
66   void CreateBitrateAllocationGraph(PacketDirection direction, Plot* plot);
67 
68   void CreateGoogCcSimulationGraph(Plot* plot);
69   void CreateSendSideBweSimulationGraph(Plot* plot);
70   void CreateReceiveSideBweSimulationGraph(Plot* plot);
71 
72   void CreateNetworkDelayFeedbackGraph(Plot* plot);
73   void CreatePacerDelayGraph(Plot* plot);
74 
75   void CreateTimestampGraph(PacketDirection direction, Plot* plot);
76   void CreateSenderAndReceiverReportPlot(
77       PacketDirection direction,
78       rtc::FunctionView<float(const rtcp::ReportBlock&)> fy,
79       std::string title,
80       std::string yaxis_label,
81       Plot* plot);
82 
83   void CreateIceCandidatePairConfigGraph(Plot* plot);
84   void CreateIceConnectivityCheckGraph(Plot* plot);
85 
86   void CreateDtlsTransportStateGraph(Plot* plot);
87   void CreateDtlsWritableStateGraph(Plot* plot);
88 
89   void CreateTriageNotifications();
90   void PrintNotifications(FILE* file);
91 
92  private:
93   template <typename IterableType>
94   void CreateAccumulatedPacketsTimeSeries(Plot* plot,
95                                           const IterableType& packets,
96                                           const std::string& label);
97 
98   std::string GetCandidatePairLogDescriptionFromId(uint32_t candidate_pair_id);
99 
100   const ParsedRtcEventLog& parsed_log_;
101 
102   // A list of SSRCs we are interested in analysing.
103   // If left empty, all SSRCs will be considered relevant.
104   std::vector<uint32_t> desired_ssrc_;
105 
106   std::map<uint32_t, std::string> candidate_pair_desc_by_id_;
107 
108   AnalyzerConfig config_;
109 };
110 
111 }  // namespace webrtc
112 
113 #endif  // RTC_TOOLS_RTC_EVENT_LOG_VISUALIZER_ANALYZER_H_
114