terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef RTC_TOOLS_EVENT_LOG_VISUALIZER_ANALYZER_H_ |
| 12 | #define RTC_TOOLS_EVENT_LOG_VISUALIZER_ANALYZER_H_ |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 13 | |
terelius | 88e64e5 | 2016-07-19 01:51:06 -0700 | [diff] [blame] | 14 | #include <map> |
Stefan Holmer | 1318103 | 2016-07-29 14:48:54 +0200 | [diff] [blame] | 15 | #include <memory> |
terelius | 0740a20 | 2016-08-08 10:21:04 -0700 | [diff] [blame] | 16 | #include <set> |
philipel | ccd7489 | 2016-09-05 02:46:25 -0700 | [diff] [blame] | 17 | #include <string> |
Stefan Holmer | 1318103 | 2016-07-29 14:48:54 +0200 | [diff] [blame] | 18 | #include <utility> |
philipel | ccd7489 | 2016-09-05 02:46:25 -0700 | [diff] [blame] | 19 | #include <vector> |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 20 | |
Bjorn Terelius | c4ca1d3 | 2018-04-27 14:33:34 +0200 | [diff] [blame^] | 21 | #include "logging/rtc_event_log/rtc_event_log_parser_new.h" |
| 22 | #include "rtc_base/strings/string_builder.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 23 | #include "rtc_tools/event_log_visualizer/plot_base.h" |
Bjorn Terelius | 2eb3188 | 2017-11-30 15:15:25 +0100 | [diff] [blame] | 24 | #include "rtc_tools/event_log_visualizer/triage_notifications.h" |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 25 | |
| 26 | namespace webrtc { |
michaelt | 6e5b219 | 2017-02-22 07:33:27 -0800 | [diff] [blame] | 27 | |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 28 | class EventLogAnalyzer { |
| 29 | public: |
Bjorn Terelius | c4ca1d3 | 2018-04-27 14:33:34 +0200 | [diff] [blame^] | 30 | // The EventLogAnalyzer keeps a reference to the ParsedRtcEventLogNew for the |
| 31 | // duration of its lifetime. The ParsedRtcEventLogNew must not be destroyed or |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 32 | // modified while the EventLogAnalyzer is being used. |
Bjorn Terelius | c4ca1d3 | 2018-04-27 14:33:34 +0200 | [diff] [blame^] | 33 | explicit EventLogAnalyzer(const ParsedRtcEventLogNew& log); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 34 | |
Bjorn Terelius | c4ca1d3 | 2018-04-27 14:33:34 +0200 | [diff] [blame^] | 35 | void CreatePacketGraph(PacketDirection direction, Plot* plot); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 36 | |
Bjorn Terelius | c4ca1d3 | 2018-04-27 14:33:34 +0200 | [diff] [blame^] | 37 | void CreateAccumulatedPacketsGraph(PacketDirection direction, Plot* plot); |
philipel | ccd7489 | 2016-09-05 02:46:25 -0700 | [diff] [blame] | 38 | |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 39 | void CreatePlayoutGraph(Plot* plot); |
| 40 | |
Bjorn Terelius | c4ca1d3 | 2018-04-27 14:33:34 +0200 | [diff] [blame^] | 41 | void CreateAudioLevelGraph(PacketDirection direction, Plot* plot); |
ivoc | aac9d6f | 2016-09-22 07:01:47 -0700 | [diff] [blame] | 42 | |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 43 | void CreateSequenceNumberGraph(Plot* plot); |
| 44 | |
Stefan Holmer | 99f8e08 | 2016-09-09 13:37:50 +0200 | [diff] [blame] | 45 | void CreateIncomingPacketLossGraph(Plot* plot); |
| 46 | |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 47 | void CreateIncomingDelayDeltaGraph(Plot* plot); |
| 48 | void CreateIncomingDelayGraph(Plot* plot); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 49 | |
terelius | f736d23 | 2016-08-04 10:00:11 -0700 | [diff] [blame] | 50 | void CreateFractionLossGraph(Plot* plot); |
| 51 | |
Bjorn Terelius | c4ca1d3 | 2018-04-27 14:33:34 +0200 | [diff] [blame^] | 52 | void CreateTotalIncomingBitrateGraph(Plot* plot); |
| 53 | void CreateTotalOutgoingBitrateGraph(Plot* plot, |
| 54 | bool show_detector_state = false, |
| 55 | bool show_alr_state = false); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 56 | |
Bjorn Terelius | c4ca1d3 | 2018-04-27 14:33:34 +0200 | [diff] [blame^] | 57 | void CreateStreamBitrateGraph(PacketDirection direction, Plot* plot); |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 58 | |
Bjorn Terelius | 28db266 | 2017-10-04 14:22:43 +0200 | [diff] [blame] | 59 | void CreateSendSideBweSimulationGraph(Plot* plot); |
| 60 | void CreateReceiveSideBweSimulationGraph(Plot* plot); |
Stefan Holmer | 1318103 | 2016-07-29 14:48:54 +0200 | [diff] [blame] | 61 | |
terelius | e34c19c | 2016-08-15 08:47:14 -0700 | [diff] [blame] | 62 | void CreateNetworkDelayFeedbackGraph(Plot* plot); |
Bjorn Terelius | 0295a96 | 2017-10-25 17:42:41 +0200 | [diff] [blame] | 63 | void CreatePacerDelayGraph(Plot* plot); |
Bjorn Terelius | c4ca1d3 | 2018-04-27 14:33:34 +0200 | [diff] [blame^] | 64 | |
| 65 | void CreateTimestampGraph(PacketDirection direction, Plot* plot); |
stefan | c3de033 | 2016-08-02 07:22:17 -0700 | [diff] [blame] | 66 | |
michaelt | 6e5b219 | 2017-02-22 07:33:27 -0800 | [diff] [blame] | 67 | void CreateAudioEncoderTargetBitrateGraph(Plot* plot); |
| 68 | void CreateAudioEncoderFrameLengthGraph(Plot* plot); |
terelius | 2ee076d | 2017-08-15 02:04:02 -0700 | [diff] [blame] | 69 | void CreateAudioEncoderPacketLossGraph(Plot* plot); |
michaelt | 6e5b219 | 2017-02-22 07:33:27 -0800 | [diff] [blame] | 70 | void CreateAudioEncoderEnableFecGraph(Plot* plot); |
| 71 | void CreateAudioEncoderEnableDtxGraph(Plot* plot); |
| 72 | void CreateAudioEncoderNumChannelsGraph(Plot* plot); |
henrik.lundin | 3c938fc | 2017-06-14 06:09:58 -0700 | [diff] [blame] | 73 | void CreateAudioJitterBufferGraph(const std::string& replacement_file_name, |
| 74 | int file_sample_rate_hz, |
| 75 | Plot* plot); |
michaelt | 6e5b219 | 2017-02-22 07:33:27 -0800 | [diff] [blame] | 76 | |
Qingsi Wang | 8eca1ff | 2018-02-02 11:49:44 -0800 | [diff] [blame] | 77 | void CreateIceCandidatePairConfigGraph(Plot* plot); |
| 78 | void CreateIceConnectivityCheckGraph(Plot* plot); |
| 79 | |
Bjorn Terelius | 2eb3188 | 2017-11-30 15:15:25 +0100 | [diff] [blame] | 80 | void CreateTriageNotifications(); |
| 81 | void PrintNotifications(FILE* file); |
| 82 | |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 83 | private: |
Bjorn Terelius | c4ca1d3 | 2018-04-27 14:33:34 +0200 | [diff] [blame^] | 84 | bool IsRtxSsrc(PacketDirection direction, uint32_t ssrc) const { |
| 85 | if (direction == kIncomingPacket) { |
| 86 | return parsed_log_.incoming_rtx_ssrcs().find(ssrc) != |
| 87 | parsed_log_.incoming_rtx_ssrcs().end(); |
| 88 | } else { |
| 89 | return parsed_log_.outgoing_rtx_ssrcs().find(ssrc) != |
| 90 | parsed_log_.outgoing_rtx_ssrcs().end(); |
terelius | 0740a20 | 2016-08-08 10:21:04 -0700 | [diff] [blame] | 91 | } |
Bjorn Terelius | c4ca1d3 | 2018-04-27 14:33:34 +0200 | [diff] [blame^] | 92 | } |
| 93 | |
| 94 | bool IsVideoSsrc(PacketDirection direction, uint32_t ssrc) const { |
| 95 | if (direction == kIncomingPacket) { |
| 96 | return parsed_log_.incoming_video_ssrcs().find(ssrc) != |
| 97 | parsed_log_.incoming_video_ssrcs().end(); |
| 98 | } else { |
| 99 | return parsed_log_.outgoing_video_ssrcs().find(ssrc) != |
| 100 | parsed_log_.outgoing_video_ssrcs().end(); |
terelius | 0740a20 | 2016-08-08 10:21:04 -0700 | [diff] [blame] | 101 | } |
Bjorn Terelius | c4ca1d3 | 2018-04-27 14:33:34 +0200 | [diff] [blame^] | 102 | } |
terelius | 88e64e5 | 2016-07-19 01:51:06 -0700 | [diff] [blame] | 103 | |
Bjorn Terelius | c4ca1d3 | 2018-04-27 14:33:34 +0200 | [diff] [blame^] | 104 | bool IsAudioSsrc(PacketDirection direction, uint32_t ssrc) const { |
| 105 | if (direction == kIncomingPacket) { |
| 106 | return parsed_log_.incoming_audio_ssrcs().find(ssrc) != |
| 107 | parsed_log_.incoming_audio_ssrcs().end(); |
| 108 | } else { |
| 109 | return parsed_log_.outgoing_audio_ssrcs().find(ssrc) != |
| 110 | parsed_log_.outgoing_audio_ssrcs().end(); |
| 111 | } |
| 112 | } |
terelius | 88e64e5 | 2016-07-19 01:51:06 -0700 | [diff] [blame] | 113 | |
Bjorn Terelius | c4ca1d3 | 2018-04-27 14:33:34 +0200 | [diff] [blame^] | 114 | template <typename IterableType> |
| 115 | void CreateAccumulatedPacketsTimeSeries(Plot* plot, |
| 116 | const IterableType& packets, |
| 117 | const std::string& label); |
philipel | ccd7489 | 2016-09-05 02:46:25 -0700 | [diff] [blame] | 118 | |
Bjorn Terelius | c4ca1d3 | 2018-04-27 14:33:34 +0200 | [diff] [blame^] | 119 | void CreateStreamGapAlerts(PacketDirection direction); |
| 120 | void CreateTransmissionGapAlerts(PacketDirection direction); |
terelius | 0740a20 | 2016-08-08 10:21:04 -0700 | [diff] [blame] | 121 | |
Bjorn Terelius | c4ca1d3 | 2018-04-27 14:33:34 +0200 | [diff] [blame^] | 122 | std::string GetStreamName(PacketDirection direction, uint32_t ssrc) const { |
| 123 | char buffer[200]; |
| 124 | rtc::SimpleStringBuilder name(buffer); |
| 125 | if (IsAudioSsrc(direction, ssrc)) { |
| 126 | name << "Audio "; |
| 127 | } else if (IsVideoSsrc(direction, ssrc)) { |
| 128 | name << "Video "; |
| 129 | } else { |
| 130 | name << "Unknown "; |
| 131 | } |
| 132 | if (IsRtxSsrc(direction, ssrc)) { |
| 133 | name << "RTX "; |
| 134 | } |
| 135 | if (direction == kIncomingPacket) |
| 136 | name << "(In) "; |
| 137 | else |
| 138 | name << "(Out) "; |
| 139 | name << "SSRC " << ssrc; |
| 140 | return name.str(); |
| 141 | } |
terelius | 0740a20 | 2016-08-08 10:21:04 -0700 | [diff] [blame] | 142 | |
Bjorn Terelius | 2eb3188 | 2017-11-30 15:15:25 +0100 | [diff] [blame] | 143 | float ToCallTime(int64_t timestamp) const; |
| 144 | |
Bjorn Terelius | c4ca1d3 | 2018-04-27 14:33:34 +0200 | [diff] [blame^] | 145 | void Alert_RtpLogTimeGap(PacketDirection direction, |
| 146 | float time_seconds, |
| 147 | int64_t duration) { |
| 148 | if (direction == kIncomingPacket) { |
| 149 | incoming_rtp_recv_time_gaps_.emplace_back(time_seconds, duration); |
| 150 | } else { |
| 151 | outgoing_rtp_send_time_gaps_.emplace_back(time_seconds, duration); |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | void Alert_RtcpLogTimeGap(PacketDirection direction, |
| 156 | float time_seconds, |
| 157 | int64_t duration) { |
| 158 | if (direction == kIncomingPacket) { |
| 159 | incoming_rtcp_recv_time_gaps_.emplace_back(time_seconds, duration); |
| 160 | } else { |
| 161 | outgoing_rtcp_send_time_gaps_.emplace_back(time_seconds, duration); |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | void Alert_SeqNumJump(PacketDirection direction, |
| 166 | float time_seconds, |
| 167 | uint32_t ssrc) { |
| 168 | if (direction == kIncomingPacket) { |
| 169 | incoming_seq_num_jumps_.emplace_back(time_seconds, ssrc); |
| 170 | } else { |
| 171 | outgoing_seq_num_jumps_.emplace_back(time_seconds, ssrc); |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | void Alert_CaptureTimeJump(PacketDirection direction, |
| 176 | float time_seconds, |
| 177 | uint32_t ssrc) { |
| 178 | if (direction == kIncomingPacket) { |
| 179 | incoming_capture_time_jumps_.emplace_back(time_seconds, ssrc); |
| 180 | } else { |
| 181 | outgoing_capture_time_jumps_.emplace_back(time_seconds, ssrc); |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | void Alert_OutgoingHighLoss(double avg_loss_fraction) { |
| 186 | outgoing_high_loss_alerts_.emplace_back(avg_loss_fraction); |
| 187 | } |
Bjorn Terelius | 2eb3188 | 2017-11-30 15:15:25 +0100 | [diff] [blame] | 188 | |
Qingsi Wang | 8eca1ff | 2018-02-02 11:49:44 -0800 | [diff] [blame] | 189 | std::string GetCandidatePairLogDescriptionFromId(uint32_t candidate_pair_id); |
| 190 | |
Bjorn Terelius | c4ca1d3 | 2018-04-27 14:33:34 +0200 | [diff] [blame^] | 191 | const ParsedRtcEventLogNew& parsed_log_; |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 192 | |
| 193 | // A list of SSRCs we are interested in analysing. |
| 194 | // If left empty, all SSRCs will be considered relevant. |
| 195 | std::vector<uint32_t> desired_ssrc_; |
| 196 | |
henrik.lundin | 3c938fc | 2017-06-14 06:09:58 -0700 | [diff] [blame] | 197 | // Stores the timestamps for all log segments, in the form of associated start |
| 198 | // and end events. |
Bjorn Terelius | c4ca1d3 | 2018-04-27 14:33:34 +0200 | [diff] [blame^] | 199 | std::vector<std::pair<int64_t, int64_t>> log_segments_; |
henrik.lundin | 3c938fc | 2017-06-14 06:09:58 -0700 | [diff] [blame] | 200 | |
Bjorn Terelius | c4ca1d3 | 2018-04-27 14:33:34 +0200 | [diff] [blame^] | 201 | std::vector<IncomingRtpReceiveTimeGap> incoming_rtp_recv_time_gaps_; |
| 202 | std::vector<IncomingRtcpReceiveTimeGap> incoming_rtcp_recv_time_gaps_; |
| 203 | std::vector<OutgoingRtpSendTimeGap> outgoing_rtp_send_time_gaps_; |
| 204 | std::vector<OutgoingRtcpSendTimeGap> outgoing_rtcp_send_time_gaps_; |
| 205 | std::vector<IncomingSeqNumJump> incoming_seq_num_jumps_; |
| 206 | std::vector<IncomingCaptureTimeJump> incoming_capture_time_jumps_; |
| 207 | std::vector<OutgoingSeqNoJump> outgoing_seq_num_jumps_; |
| 208 | std::vector<OutgoingCaptureTimeJump> outgoing_capture_time_jumps_; |
| 209 | std::vector<OutgoingHighLoss> outgoing_high_loss_alerts_; |
Qingsi Wang | 8eca1ff | 2018-02-02 11:49:44 -0800 | [diff] [blame] | 210 | |
| 211 | std::map<uint32_t, std::string> candidate_pair_desc_by_id_; |
| 212 | |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 213 | // Window and step size used for calculating moving averages, e.g. bitrate. |
| 214 | // The generated data points will be |step_| microseconds apart. |
| 215 | // Only events occuring at most |window_duration_| microseconds before the |
| 216 | // current data point will be part of the average. |
Bjorn Terelius | c4ca1d3 | 2018-04-27 14:33:34 +0200 | [diff] [blame^] | 217 | int64_t window_duration_; |
| 218 | int64_t step_; |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 219 | |
| 220 | // First and last events of the log. |
Bjorn Terelius | c4ca1d3 | 2018-04-27 14:33:34 +0200 | [diff] [blame^] | 221 | int64_t begin_time_; |
| 222 | int64_t end_time_; |
terelius | dc35dcd | 2016-08-01 12:03:27 -0700 | [diff] [blame] | 223 | |
| 224 | // Duration (in seconds) of log file. |
| 225 | float call_duration_s_; |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 226 | }; |
| 227 | |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 228 | } // namespace webrtc |
| 229 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 230 | #endif // RTC_TOOLS_EVENT_LOG_VISUALIZER_ANALYZER_H_ |