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 | |
| 11 | #ifndef WEBRTC_TOOLS_EVENT_LOG_VISUALIZER_ANALYZER_H_ |
| 12 | #define WEBRTC_TOOLS_EVENT_LOG_VISUALIZER_ANALYZER_H_ |
| 13 | |
| 14 | #include <vector> |
terelius | 88e64e5 | 2016-07-19 01:51:06 -0700 | [diff] [blame] | 15 | #include <map> |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 16 | |
| 17 | #include "webrtc/call/rtc_event_log_parser.h" |
| 18 | #include "webrtc/tools/event_log_visualizer/plot_base.h" |
| 19 | |
| 20 | namespace webrtc { |
| 21 | namespace plotting { |
| 22 | |
| 23 | class EventLogAnalyzer { |
| 24 | public: |
| 25 | // The EventLogAnalyzer keeps a reference to the ParsedRtcEventLog for the |
| 26 | // duration of its lifetime. The ParsedRtcEventLog must not be destroyed or |
| 27 | // modified while the EventLogAnalyzer is being used. |
| 28 | explicit EventLogAnalyzer(const ParsedRtcEventLog& log); |
| 29 | |
| 30 | void CreatePacketGraph(PacketDirection desired_direction, Plot* plot); |
| 31 | |
| 32 | void CreatePlayoutGraph(Plot* plot); |
| 33 | |
| 34 | void CreateSequenceNumberGraph(Plot* plot); |
| 35 | |
| 36 | void CreateDelayChangeGraph(Plot* plot); |
| 37 | |
| 38 | void CreateAccumulatedDelayChangeGraph(Plot* plot); |
| 39 | |
| 40 | void CreateTotalBitrateGraph(PacketDirection desired_direction, Plot* plot); |
| 41 | |
| 42 | void CreateStreamBitrateGraph(PacketDirection desired_direction, Plot* plot); |
| 43 | |
| 44 | private: |
terelius | 88e64e5 | 2016-07-19 01:51:06 -0700 | [diff] [blame] | 45 | class StreamId { |
| 46 | public: |
| 47 | StreamId(uint32_t ssrc, |
| 48 | webrtc::PacketDirection direction, |
| 49 | webrtc::MediaType media_type) |
| 50 | : ssrc_(ssrc), direction_(direction), media_type_(media_type) {} |
| 51 | bool operator<(const StreamId& other) const; |
| 52 | bool operator==(const StreamId& other) const; |
| 53 | uint32_t GetSsrc() const { return ssrc_; } |
| 54 | webrtc::PacketDirection GetDirection() const { return direction_; } |
| 55 | webrtc::MediaType GetMediaType() const { return media_type_; } |
| 56 | |
| 57 | private: |
| 58 | uint32_t ssrc_; |
| 59 | webrtc::PacketDirection direction_; |
| 60 | webrtc::MediaType media_type_; |
| 61 | }; |
| 62 | |
| 63 | struct LoggedRtpPacket { |
| 64 | LoggedRtpPacket(uint64_t timestamp, RTPHeader header) |
| 65 | : timestamp(timestamp), header(header) {} |
| 66 | uint64_t timestamp; |
| 67 | RTPHeader header; |
| 68 | }; |
| 69 | |
terelius | 8058e58 | 2016-07-25 01:32:41 -0700 | [diff] [blame^] | 70 | struct BwePacketLossEvent { |
| 71 | uint64_t timestamp; |
| 72 | int32_t new_bitrate; |
| 73 | uint8_t fraction_loss; |
| 74 | int32_t expected_packets; |
| 75 | }; |
| 76 | |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 77 | const ParsedRtcEventLog& parsed_log_; |
| 78 | |
| 79 | // A list of SSRCs we are interested in analysing. |
| 80 | // If left empty, all SSRCs will be considered relevant. |
| 81 | std::vector<uint32_t> desired_ssrc_; |
| 82 | |
terelius | 88e64e5 | 2016-07-19 01:51:06 -0700 | [diff] [blame] | 83 | // Maps a stream identifier consisting of ssrc, direction and MediaType |
| 84 | // to the parsed RTP headers in that stream. Header extensions are parsed |
| 85 | // if the stream has been configured. |
| 86 | std::map<StreamId, std::vector<LoggedRtpPacket>> rtp_packets_; |
| 87 | |
terelius | 8058e58 | 2016-07-25 01:32:41 -0700 | [diff] [blame^] | 88 | // A list of all updates from the send-side loss-based bandwidth estimator. |
| 89 | std::vector<BwePacketLossEvent> bwe_loss_updates_; |
| 90 | |
terelius | 54ce680 | 2016-07-13 06:44:41 -0700 | [diff] [blame] | 91 | // Window and step size used for calculating moving averages, e.g. bitrate. |
| 92 | // The generated data points will be |step_| microseconds apart. |
| 93 | // Only events occuring at most |window_duration_| microseconds before the |
| 94 | // current data point will be part of the average. |
| 95 | uint64_t window_duration_; |
| 96 | uint64_t step_; |
| 97 | |
| 98 | // First and last events of the log. |
| 99 | uint64_t begin_time_; |
| 100 | uint64_t end_time_; |
| 101 | }; |
| 102 | |
| 103 | } // namespace plotting |
| 104 | } // namespace webrtc |
| 105 | |
| 106 | #endif // WEBRTC_TOOLS_EVENT_LOG_VISUALIZER_ANALYZER_H_ |