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