2016-07-13 06:44:41 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef RTC_TOOLS_EVENT_LOG_VISUALIZER_ANALYZER_H_
|
|
|
|
|
#define RTC_TOOLS_EVENT_LOG_VISUALIZER_ANALYZER_H_
|
2016-07-13 06:44:41 -07:00
|
|
|
|
2016-07-19 01:51:06 -07:00
|
|
|
#include <map>
|
2016-07-29 14:48:54 +02:00
|
|
|
#include <memory>
|
2016-08-08 10:21:04 -07:00
|
|
|
#include <set>
|
2016-09-05 02:46:25 -07:00
|
|
|
#include <string>
|
2016-07-29 14:48:54 +02:00
|
|
|
#include <utility>
|
2016-09-05 02:46:25 -07:00
|
|
|
#include <vector>
|
2016-07-13 06:44:41 -07:00
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "logging/rtc_event_log/rtc_event_log_parser.h"
|
|
|
|
|
#include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor.h"
|
|
|
|
|
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
|
|
|
|
#include "modules/rtp_rtcp/source/rtcp_packet.h"
|
|
|
|
|
#include "rtc_base/function_view.h"
|
|
|
|
|
#include "rtc_tools/event_log_visualizer/plot_base.h"
|
2017-11-30 15:15:25 +01:00
|
|
|
#include "rtc_tools/event_log_visualizer/triage_notifications.h"
|
2016-07-13 06:44:41 -07:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
namespace plotting {
|
|
|
|
|
|
2016-08-10 07:34:28 -07:00
|
|
|
struct LoggedRtpPacket {
|
2018-04-19 13:52:36 +02:00
|
|
|
LoggedRtpPacket(uint64_t timestamp,
|
|
|
|
|
RTPHeader header,
|
|
|
|
|
size_t header_length,
|
|
|
|
|
size_t total_length)
|
|
|
|
|
: timestamp(timestamp),
|
|
|
|
|
header(header),
|
|
|
|
|
header_length(header_length),
|
|
|
|
|
total_length(total_length) {}
|
2016-08-10 07:34:28 -07:00
|
|
|
uint64_t timestamp;
|
2016-08-23 17:34:07 -07:00
|
|
|
// TODO(terelius): This allocates space for 15 CSRCs even if none are used.
|
2016-08-10 07:34:28 -07:00
|
|
|
RTPHeader header;
|
2018-04-19 13:52:36 +02:00
|
|
|
size_t header_length;
|
2016-08-10 07:34:28 -07:00
|
|
|
size_t total_length;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct LoggedRtcpPacket {
|
|
|
|
|
LoggedRtcpPacket(uint64_t timestamp,
|
|
|
|
|
RTCPPacketType rtcp_type,
|
|
|
|
|
std::unique_ptr<rtcp::RtcpPacket> rtcp_packet)
|
|
|
|
|
: timestamp(timestamp), type(rtcp_type), packet(std::move(rtcp_packet)) {}
|
|
|
|
|
uint64_t timestamp;
|
|
|
|
|
RTCPPacketType type;
|
|
|
|
|
std::unique_ptr<rtcp::RtcpPacket> packet;
|
|
|
|
|
};
|
|
|
|
|
|
2017-02-20 05:14:41 -08:00
|
|
|
struct LossBasedBweUpdate {
|
2016-08-10 07:34:28 -07:00
|
|
|
uint64_t timestamp;
|
|
|
|
|
int32_t new_bitrate;
|
|
|
|
|
uint8_t fraction_loss;
|
|
|
|
|
int32_t expected_packets;
|
|
|
|
|
};
|
|
|
|
|
|
2017-02-22 07:33:27 -08:00
|
|
|
struct AudioNetworkAdaptationEvent {
|
|
|
|
|
uint64_t timestamp;
|
2017-04-06 05:59:10 -07:00
|
|
|
AudioEncoderRuntimeConfig config;
|
2017-02-22 07:33:27 -08:00
|
|
|
};
|
|
|
|
|
|
2016-07-13 06:44:41 -07:00
|
|
|
class EventLogAnalyzer {
|
|
|
|
|
public:
|
|
|
|
|
// The EventLogAnalyzer keeps a reference to the ParsedRtcEventLog for the
|
|
|
|
|
// duration of its lifetime. The ParsedRtcEventLog must not be destroyed or
|
|
|
|
|
// modified while the EventLogAnalyzer is being used.
|
|
|
|
|
explicit EventLogAnalyzer(const ParsedRtcEventLog& log);
|
|
|
|
|
|
|
|
|
|
void CreatePacketGraph(PacketDirection desired_direction, Plot* plot);
|
|
|
|
|
|
2016-09-05 02:46:25 -07:00
|
|
|
void CreateAccumulatedPacketsGraph(PacketDirection desired_direction,
|
|
|
|
|
Plot* plot);
|
|
|
|
|
|
2016-07-13 06:44:41 -07:00
|
|
|
void CreatePlayoutGraph(Plot* plot);
|
|
|
|
|
|
2016-09-22 07:01:47 -07:00
|
|
|
void CreateAudioLevelGraph(Plot* plot);
|
|
|
|
|
|
2016-07-13 06:44:41 -07:00
|
|
|
void CreateSequenceNumberGraph(Plot* plot);
|
|
|
|
|
|
2016-09-09 13:37:50 +02:00
|
|
|
void CreateIncomingPacketLossGraph(Plot* plot);
|
|
|
|
|
|
2017-08-15 02:04:02 -07:00
|
|
|
void CreateIncomingDelayDeltaGraph(Plot* plot);
|
|
|
|
|
void CreateIncomingDelayGraph(Plot* plot);
|
2016-07-13 06:44:41 -07:00
|
|
|
|
2016-08-04 10:00:11 -07:00
|
|
|
void CreateFractionLossGraph(Plot* plot);
|
|
|
|
|
|
2017-07-14 06:30:03 -07:00
|
|
|
void CreateTotalBitrateGraph(PacketDirection desired_direction,
|
|
|
|
|
Plot* plot,
|
2017-12-05 13:19:45 +01:00
|
|
|
bool show_detector_state = false,
|
|
|
|
|
bool show_alr_state = false);
|
2016-07-13 06:44:41 -07:00
|
|
|
|
|
|
|
|
void CreateStreamBitrateGraph(PacketDirection desired_direction, Plot* plot);
|
|
|
|
|
|
2017-10-04 14:22:43 +02:00
|
|
|
void CreateSendSideBweSimulationGraph(Plot* plot);
|
|
|
|
|
void CreateReceiveSideBweSimulationGraph(Plot* plot);
|
2016-07-29 14:48:54 +02:00
|
|
|
|
2016-08-15 08:47:14 -07:00
|
|
|
void CreateNetworkDelayFeedbackGraph(Plot* plot);
|
2017-10-25 17:42:41 +02:00
|
|
|
void CreatePacerDelayGraph(Plot* plot);
|
2017-02-02 08:04:18 -08:00
|
|
|
void CreateTimestampGraph(Plot* plot);
|
2016-08-02 07:22:17 -07:00
|
|
|
|
2017-02-22 07:33:27 -08:00
|
|
|
void CreateAudioEncoderTargetBitrateGraph(Plot* plot);
|
|
|
|
|
void CreateAudioEncoderFrameLengthGraph(Plot* plot);
|
2017-08-15 02:04:02 -07:00
|
|
|
void CreateAudioEncoderPacketLossGraph(Plot* plot);
|
2017-02-22 07:33:27 -08:00
|
|
|
void CreateAudioEncoderEnableFecGraph(Plot* plot);
|
|
|
|
|
void CreateAudioEncoderEnableDtxGraph(Plot* plot);
|
|
|
|
|
void CreateAudioEncoderNumChannelsGraph(Plot* plot);
|
2017-06-14 06:09:58 -07:00
|
|
|
void CreateAudioJitterBufferGraph(const std::string& replacement_file_name,
|
|
|
|
|
int file_sample_rate_hz,
|
|
|
|
|
Plot* plot);
|
2017-02-22 07:33:27 -08:00
|
|
|
|
2018-02-02 11:49:44 -08:00
|
|
|
void CreateIceCandidatePairConfigGraph(Plot* plot);
|
|
|
|
|
void CreateIceConnectivityCheckGraph(Plot* plot);
|
|
|
|
|
|
2016-12-20 08:51:52 -08:00
|
|
|
// Returns a vector of capture and arrival timestamps for the video frames
|
|
|
|
|
// of the stream with the most number of frames.
|
|
|
|
|
std::vector<std::pair<int64_t, int64_t>> GetFrameTimestamps() const;
|
|
|
|
|
|
2017-11-30 15:15:25 +01:00
|
|
|
void CreateTriageNotifications();
|
|
|
|
|
void PrintNotifications(FILE* file);
|
|
|
|
|
|
2016-07-13 06:44:41 -07:00
|
|
|
private:
|
2016-07-19 01:51:06 -07:00
|
|
|
class StreamId {
|
|
|
|
|
public:
|
2016-07-29 14:48:54 +02:00
|
|
|
StreamId(uint32_t ssrc, webrtc::PacketDirection direction)
|
|
|
|
|
: ssrc_(ssrc), direction_(direction) {}
|
2016-08-08 10:21:04 -07:00
|
|
|
bool operator<(const StreamId& other) const {
|
|
|
|
|
return std::tie(ssrc_, direction_) <
|
|
|
|
|
std::tie(other.ssrc_, other.direction_);
|
|
|
|
|
}
|
|
|
|
|
bool operator==(const StreamId& other) const {
|
|
|
|
|
return std::tie(ssrc_, direction_) ==
|
|
|
|
|
std::tie(other.ssrc_, other.direction_);
|
|
|
|
|
}
|
2016-07-19 01:51:06 -07:00
|
|
|
uint32_t GetSsrc() const { return ssrc_; }
|
|
|
|
|
webrtc::PacketDirection GetDirection() const { return direction_; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
uint32_t ssrc_;
|
|
|
|
|
webrtc::PacketDirection direction_;
|
|
|
|
|
};
|
|
|
|
|
|
2016-09-05 02:46:25 -07:00
|
|
|
template <typename T>
|
|
|
|
|
void CreateAccumulatedPacketsTimeSeries(
|
|
|
|
|
PacketDirection desired_direction,
|
|
|
|
|
Plot* plot,
|
|
|
|
|
const std::map<StreamId, std::vector<T>>& packets,
|
|
|
|
|
const std::string& label_prefix);
|
|
|
|
|
|
2016-09-09 13:37:50 +02:00
|
|
|
bool IsRtxSsrc(StreamId stream_id) const;
|
|
|
|
|
|
|
|
|
|
bool IsVideoSsrc(StreamId stream_id) const;
|
2016-08-08 10:21:04 -07:00
|
|
|
|
2016-09-09 13:37:50 +02:00
|
|
|
bool IsAudioSsrc(StreamId stream_id) const;
|
2016-08-08 10:21:04 -07:00
|
|
|
|
2017-10-25 17:42:41 +02:00
|
|
|
std::string GetStreamName(StreamId stream_id) const;
|
|
|
|
|
|
|
|
|
|
rtc::Optional<uint32_t> EstimateRtpClockFrequency(
|
|
|
|
|
const std::vector<LoggedRtpPacket>& packets) const;
|
2016-08-08 10:21:04 -07:00
|
|
|
|
2017-11-30 15:15:25 +01:00
|
|
|
float ToCallTime(int64_t timestamp) const;
|
|
|
|
|
|
|
|
|
|
void Notification(std::unique_ptr<TriageNotification> notification);
|
|
|
|
|
|
2018-02-02 11:49:44 -08:00
|
|
|
std::string GetCandidatePairLogDescriptionFromId(uint32_t candidate_pair_id);
|
|
|
|
|
|
2016-07-13 06:44:41 -07:00
|
|
|
const ParsedRtcEventLog& parsed_log_;
|
|
|
|
|
|
|
|
|
|
// A list of SSRCs we are interested in analysing.
|
|
|
|
|
// If left empty, all SSRCs will be considered relevant.
|
|
|
|
|
std::vector<uint32_t> desired_ssrc_;
|
|
|
|
|
|
2016-08-08 10:21:04 -07:00
|
|
|
// Tracks what each stream is configured for. Note that a single SSRC can be
|
|
|
|
|
// in several sets. For example, the SSRC used for sending video over RTX
|
|
|
|
|
// will appear in both video_ssrcs_ and rtx_ssrcs_. In the unlikely case that
|
|
|
|
|
// an SSRC is reconfigured to a different media type mid-call, it will also
|
|
|
|
|
// appear in multiple sets.
|
|
|
|
|
std::set<StreamId> rtx_ssrcs_;
|
|
|
|
|
std::set<StreamId> video_ssrcs_;
|
|
|
|
|
std::set<StreamId> audio_ssrcs_;
|
|
|
|
|
|
|
|
|
|
// Maps a stream identifier consisting of ssrc and direction to the parsed
|
|
|
|
|
// RTP headers in that stream. Header extensions are parsed if the stream
|
|
|
|
|
// has been configured.
|
2016-07-19 01:51:06 -07:00
|
|
|
std::map<StreamId, std::vector<LoggedRtpPacket>> rtp_packets_;
|
|
|
|
|
|
2016-07-29 14:48:54 +02:00
|
|
|
std::map<StreamId, std::vector<LoggedRtcpPacket>> rtcp_packets_;
|
|
|
|
|
|
2017-06-14 06:09:58 -07:00
|
|
|
// Maps an SSRC to the timestamps of parsed audio playout events.
|
|
|
|
|
std::map<uint32_t, std::vector<uint64_t>> audio_playout_events_;
|
|
|
|
|
|
|
|
|
|
// Stores the timestamps for all log segments, in the form of associated start
|
|
|
|
|
// and end events.
|
|
|
|
|
std::vector<std::pair<uint64_t, uint64_t>> log_segments_;
|
|
|
|
|
|
2016-07-25 01:32:41 -07:00
|
|
|
// A list of all updates from the send-side loss-based bandwidth estimator.
|
2017-02-20 05:14:41 -08:00
|
|
|
std::vector<LossBasedBweUpdate> bwe_loss_updates_;
|
2016-07-25 01:32:41 -07:00
|
|
|
|
2017-02-22 07:33:27 -08:00
|
|
|
std::vector<AudioNetworkAdaptationEvent> audio_network_adaptation_events_;
|
|
|
|
|
|
2017-03-29 16:28:53 +02:00
|
|
|
std::vector<ParsedRtcEventLog::BweProbeClusterCreatedEvent>
|
|
|
|
|
bwe_probe_cluster_created_events_;
|
|
|
|
|
|
|
|
|
|
std::vector<ParsedRtcEventLog::BweProbeResultEvent> bwe_probe_result_events_;
|
|
|
|
|
|
2017-04-11 01:50:23 -07:00
|
|
|
std::vector<ParsedRtcEventLog::BweDelayBasedUpdate> bwe_delay_updates_;
|
|
|
|
|
|
2017-11-30 15:15:25 +01:00
|
|
|
std::vector<std::unique_ptr<TriageNotification>> notifications_;
|
|
|
|
|
|
2017-12-05 13:19:45 +01:00
|
|
|
std::vector<ParsedRtcEventLog::AlrStateEvent> alr_state_events_;
|
|
|
|
|
|
2018-02-02 11:49:44 -08:00
|
|
|
std::vector<ParsedRtcEventLog::IceCandidatePairConfig>
|
|
|
|
|
ice_candidate_pair_configs_;
|
|
|
|
|
|
|
|
|
|
std::vector<ParsedRtcEventLog::IceCandidatePairEvent>
|
|
|
|
|
ice_candidate_pair_events_;
|
|
|
|
|
|
|
|
|
|
std::map<uint32_t, std::string> candidate_pair_desc_by_id_;
|
|
|
|
|
|
2016-07-13 06:44:41 -07:00
|
|
|
// Window and step size used for calculating moving averages, e.g. bitrate.
|
|
|
|
|
// The generated data points will be |step_| microseconds apart.
|
|
|
|
|
// Only events occuring at most |window_duration_| microseconds before the
|
|
|
|
|
// current data point will be part of the average.
|
|
|
|
|
uint64_t window_duration_;
|
|
|
|
|
uint64_t step_;
|
|
|
|
|
|
|
|
|
|
// First and last events of the log.
|
|
|
|
|
uint64_t begin_time_;
|
|
|
|
|
uint64_t end_time_;
|
2016-08-01 12:03:27 -07:00
|
|
|
|
|
|
|
|
// Duration (in seconds) of log file.
|
|
|
|
|
float call_duration_s_;
|
2016-07-13 06:44:41 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace plotting
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // RTC_TOOLS_EVENT_LOG_VISUALIZER_ANALYZER_H_
|