blob: 72f1241d50ab6940d6a537ffb93fad3c8334941f [file] [log] [blame]
Bjorn Terelius48b82792020-05-19 10:57:24 +02001/*
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 RTC_TOOLS_RTC_EVENT_LOG_VISUALIZER_ALERTS_H_
12#define RTC_TOOLS_RTC_EVENT_LOG_VISUALIZER_ALERTS_H_
13
14#include <stdio.h>
15
16#include <map>
17#include <string>
18#include <utility>
19
20#include "absl/strings/string_view.h"
21#include "logging/rtc_event_log/rtc_event_log_parser.h"
Bjorn Terelius48b82792020-05-19 10:57:24 +020022#include "rtc_tools/rtc_event_log_visualizer/analyzer_common.h"
23
24namespace webrtc {
25
26enum class TriageAlertType {
27 kUnknown = 0,
28 kIncomingRtpGap,
29 kOutgoingRtpGap,
30 kIncomingRtcpGap,
31 kOutgoingRtcpGap,
32 kIncomingSeqNumJump,
33 kOutgoingSeqNumJump,
34 kIncomingCaptureTimeJump,
35 kOutgoingCaptureTimeJump,
36 kOutgoingHighLoss,
37 kLast,
38};
39
40struct TriageAlert {
41 TriageAlertType type = TriageAlertType::kUnknown;
42 int count = 0;
Bjorn Tereliusb9148192020-05-19 14:30:35 +020043 float first_occurrence = -1;
Bjorn Terelius48b82792020-05-19 10:57:24 +020044 std::string explanation;
45};
46
47class TriageHelper {
48 public:
49 explicit TriageHelper(const AnalyzerConfig& config) : config_(config) {}
50
Byoungchan Lee5f0eb932022-01-26 09:36:49 +090051 TriageHelper(const TriageHelper&) = delete;
52 TriageHelper& operator=(const TriageHelper&) = delete;
53
Bjorn Terelius48b82792020-05-19 10:57:24 +020054 void AnalyzeLog(const ParsedRtcEventLog& parsed_log);
55
56 void AnalyzeStreamGaps(const ParsedRtcEventLog& parsed_log,
57 PacketDirection direction);
58 void AnalyzeTransmissionGaps(const ParsedRtcEventLog& parsed_log,
59 PacketDirection direction);
60 void Print(FILE* file);
61
Bjorn Terelius7634ea72020-10-02 14:53:50 +020062 void ProcessAlerts(std::function<void(int, float, std::string)> f);
63
Bjorn Terelius48b82792020-05-19 10:57:24 +020064 private:
65 AnalyzerConfig config_;
66 std::map<TriageAlertType, TriageAlert> triage_alerts_;
67
68 void Alert(TriageAlertType type,
69 float time_seconds,
70 absl::string_view explanation) {
71 std::map<TriageAlertType, TriageAlert>::iterator it =
72 triage_alerts_.find(type);
73
74 if (it == triage_alerts_.end()) {
75 TriageAlert alert;
76 alert.type = type;
Bjorn Tereliusb9148192020-05-19 14:30:35 +020077 alert.first_occurrence = time_seconds;
Bjorn Terelius48b82792020-05-19 10:57:24 +020078 alert.count = 1;
79 alert.explanation = std::string(explanation);
80 triage_alerts_.insert(std::make_pair(type, alert));
81 } else {
82 it->second.count += 1;
83 }
84 }
Bjorn Terelius48b82792020-05-19 10:57:24 +020085};
86
87} // namespace webrtc
88
89#endif // RTC_TOOLS_RTC_EVENT_LOG_VISUALIZER_ALERTS_H_