Break out parameters from EventLogAnalyzer to AnalyzerConfig struct.
This is not a functional change. I've verified that the event_log_visualizer outputs the same bytes before and after the CL.
Bug: webrtc:10102, webrtc:10312
Change-Id: I49c4c847926078cefc9b72fe57fbdaebf76423e9
Reviewed-on: https://webrtc-review.googlesource.com/c/122844
Reviewed-by: Mirta Dvornicic <mirtad@webrtc.org>
Commit-Queue: Björn Terelius <terelius@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26685}
diff --git a/rtc_tools/event_log_visualizer/analyzer.cc b/rtc_tools/event_log_visualizer/analyzer.cc
index e854a2f..5c3e006 100644
--- a/rtc_tools/event_log_visualizer/analyzer.cc
+++ b/rtc_tools/event_log_visualizer/analyzer.cc
@@ -288,19 +288,16 @@
// during the preceeding |window_duration_us| microseconds.
template <typename DataType, typename ResultType, typename IterableType>
void MovingAverage(
- rtc::FunctionView<float(int64_t)> fx,
rtc::FunctionView<absl::optional<ResultType>(const DataType&)> fy,
const IterableType& data_view,
- int64_t begin_time,
- int64_t end_time,
- int64_t window_duration_us,
- int64_t step,
+ AnalyzerConfig config,
TimeSeries* result) {
size_t window_index_begin = 0;
size_t window_index_end = 0;
ResultType sum_in_window = 0;
- for (int64_t t = begin_time; t < end_time + step; t += step) {
+ for (int64_t t = config.begin_time_; t < config.end_time_ + config.step_;
+ t += config.step_) {
while (window_index_end < data_view.size() &&
data_view[window_index_end].log_time_us() < t) {
absl::optional<ResultType> value = fy(data_view[window_index_end]);
@@ -310,15 +307,15 @@
}
while (window_index_begin < data_view.size() &&
data_view[window_index_begin].log_time_us() <
- t - window_duration_us) {
+ t - config.window_duration_) {
absl::optional<ResultType> value = fy(data_view[window_index_begin]);
if (value)
sum_in_window -= *value;
++window_index_begin;
}
float window_duration_s =
- static_cast<float>(window_duration_us) / kNumMicrosecsPerSec;
- float x = fx(t);
+ static_cast<float>(config.window_duration_) / kNumMicrosecsPerSec;
+ float x = config.GetCallTimeSec(t);
float y = sum_in_window / window_duration_s;
result->points.emplace_back(x, y);
}
@@ -448,17 +445,16 @@
EventLogAnalyzer::EventLogAnalyzer(const ParsedRtcEventLog& log,
bool normalize_time)
- : parsed_log_(log),
- window_duration_(250000),
- step_(10000),
- normalize_time_(normalize_time) {
- begin_time_ = parsed_log_.first_timestamp();
- end_time_ = parsed_log_.last_timestamp();
- if (end_time_ < begin_time_) {
+ : parsed_log_(log) {
+ config_.window_duration_ = 250000;
+ config_.step_ = 10000;
+ config_.normalize_time_ = normalize_time;
+ config_.begin_time_ = parsed_log_.first_timestamp();
+ config_.end_time_ = parsed_log_.last_timestamp();
+ if (config_.end_time_ < config_.begin_time_) {
RTC_LOG(LS_WARNING) << "No useful events in the log.";
- begin_time_ = end_time_ = 0;
+ config_.begin_time_ = config_.end_time_ = 0;
}
- call_duration_s_ = ToCallTimeSec(end_time_);
const auto& log_start_events = parsed_log_.start_log_events();
const auto& log_end_events = parsed_log_.stop_log_events();
@@ -481,7 +477,7 @@
// we're missing an end event. Assume that it occurred just before the
// next start.
log_segments_.push_back(
- std::make_pair(start, next_start.value_or(end_time_)));
+ std::make_pair(start, next_start.value_or(config_.end_time_)));
}
}
RTC_LOG(LS_INFO) << "Found " << log_segments_.size()
@@ -514,18 +510,6 @@
bool bitrate_updated_;
};
-int64_t EventLogAnalyzer::ToCallTimeUs(int64_t timestamp) const {
- int64_t begin_time = 0;
- if (normalize_time_) {
- begin_time = begin_time_;
- }
- return timestamp - begin_time;
-}
-
-float EventLogAnalyzer::ToCallTimeSec(int64_t timestamp) const {
- return static_cast<float>(ToCallTimeUs(timestamp)) / kNumMicrosecsPerSec;
-}
-
void EventLogAnalyzer::CreatePacketGraph(PacketDirection direction,
Plot* plot) {
for (const auto& stream : parsed_log_.rtp_packets_by_ssrc(direction)) {
@@ -540,15 +524,15 @@
return absl::optional<float>(packet.total_length);
};
auto ToCallTime = [this](const LoggedRtpPacket& packet) {
- return this->ToCallTimeSec(packet.log_time_us());
+ return this->config_.GetCallTimeSec(packet.log_time_us());
};
ProcessPoints<LoggedRtpPacket>(ToCallTime, GetPacketSize,
stream.packet_view, &time_series);
plot->AppendTimeSeries(std::move(time_series));
}
- plot->SetXAxis(ToCallTimeSec(begin_time_), call_duration_s_, "Time (s)",
- kLeftMargin, kRightMargin);
+ plot->SetXAxis(config_.CallBeginTimeSec(), config_.CallEndTimeSec(),
+ "Time (s)", kLeftMargin, kRightMargin);
plot->SetSuggestedYAxis(0, 1, "Packet size (bytes)", kBottomMargin,
kTopMargin);
plot->SetTitle(GetDirectionAsString(direction) + " RTP packets");
@@ -561,7 +545,7 @@
const std::string& label) {
TimeSeries time_series(label, LineStyle::kStep);
for (size_t i = 0; i < packets.size(); i++) {
- float x = ToCallTimeSec(packets[i].log_time_us());
+ float x = config_.GetCallTimeSec(packets[i].log_time_us());
time_series.points.emplace_back(x, i + 1);
}
plot->AppendTimeSeries(std::move(time_series));
@@ -586,8 +570,8 @@
plot, parsed_log_.outgoing_rtcp_packets(), label);
}
- plot->SetXAxis(ToCallTimeSec(begin_time_), call_duration_s_, "Time (s)",
- kLeftMargin, kRightMargin);
+ plot->SetXAxis(config_.CallBeginTimeSec(), config_.CallEndTimeSec(),
+ "Time (s)", kLeftMargin, kRightMargin);
plot->SetSuggestedYAxis(0, 1, "Received Packets", kBottomMargin, kTopMargin);
plot->SetTitle(std::string("Accumulated ") + GetDirectionAsString(direction) +
" RTP/RTCP packets");
@@ -602,7 +586,7 @@
absl::optional<int64_t> last_playout_ms;
TimeSeries time_series(SsrcToString(ssrc), LineStyle::kBar);
for (const auto& playout_event : playout_stream.second) {
- float x = ToCallTimeSec(playout_event.log_time_us());
+ float x = config_.GetCallTimeSec(playout_event.log_time_us());
int64_t playout_time_ms = playout_event.log_time_ms();
// If there were no previous playouts, place the point on the x-axis.
float y = playout_time_ms - last_playout_ms.value_or(playout_time_ms);
@@ -612,8 +596,8 @@
plot->AppendTimeSeries(std::move(time_series));
}
- plot->SetXAxis(ToCallTimeSec(begin_time_), call_duration_s_, "Time (s)",
- kLeftMargin, kRightMargin);
+ plot->SetXAxis(config_.CallBeginTimeSec(), config_.CallEndTimeSec(),
+ "Time (s)", kLeftMargin, kRightMargin);
plot->SetSuggestedYAxis(0, 1, "Time since last playout (ms)", kBottomMargin,
kTopMargin);
plot->SetTitle("Audio playout");
@@ -629,7 +613,7 @@
LineStyle::kLine);
for (auto& packet : stream.packet_view) {
if (packet.header.extension.hasAudioLevel) {
- float x = ToCallTimeSec(packet.log_time_us());
+ float x = config_.GetCallTimeSec(packet.log_time_us());
// The audio level is stored in -dBov (so e.g. -10 dBov is stored as 10)
// Here we convert it to dBov.
float y = static_cast<float>(-packet.header.extension.audioLevel);
@@ -639,8 +623,8 @@
plot->AppendTimeSeries(std::move(time_series));
}
- plot->SetXAxis(ToCallTimeSec(begin_time_), call_duration_s_, "Time (s)",
- kLeftMargin, kRightMargin);
+ plot->SetXAxis(config_.CallBeginTimeSec(), config_.CallEndTimeSec(),
+ "Time (s)", kLeftMargin, kRightMargin);
plot->SetYAxis(-127, 0, "Audio level (dBov)", kBottomMargin, kTopMargin);
plot->SetTitle(GetDirectionAsString(direction) + " audio level");
}
@@ -663,7 +647,7 @@
return diff;
};
auto ToCallTime = [this](const LoggedRtpPacketIncoming& packet) {
- return this->ToCallTimeSec(packet.log_time_us());
+ return this->config_.GetCallTimeSec(packet.log_time_us());
};
ProcessPairs<LoggedRtpPacketIncoming, float>(
ToCallTime, GetSequenceNumberDiff, stream.incoming_packets,
@@ -671,8 +655,8 @@
plot->AppendTimeSeries(std::move(time_series));
}
- plot->SetXAxis(ToCallTimeSec(begin_time_), call_duration_s_, "Time (s)",
- kLeftMargin, kRightMargin);
+ plot->SetXAxis(config_.CallBeginTimeSec(), config_.CallEndTimeSec(),
+ "Time (s)", kLeftMargin, kRightMargin);
plot->SetSuggestedYAxis(0, 1, "Difference since last packet", kBottomMargin,
kTopMargin);
plot->SetTitle("Sequence number");
@@ -702,7 +686,8 @@
uint64_t highest_prior_seq_number =
prior_unwrapper_.Unwrap(packets[0].rtp.header.sequenceNumber) - 1;
- for (int64_t t = begin_time_; t < end_time_ + kStep; t += kStep) {
+ for (int64_t t = config_.begin_time_; t < config_.end_time_ + kStep;
+ t += kStep) {
while (window_index_end < packets.size() &&
packets[window_index_end].rtp.log_time_us() < t) {
uint64_t sequence_number = unwrapper_.Unwrap(
@@ -718,7 +703,7 @@
std::max(highest_prior_seq_number, sequence_number);
++window_index_begin;
}
- float x = ToCallTimeSec(t);
+ float x = config_.GetCallTimeSec(t);
uint64_t expected_packets = highest_seq_number - highest_prior_seq_number;
if (expected_packets > 0) {
int64_t received_packets = window_index_end - window_index_begin;
@@ -730,8 +715,8 @@
plot->AppendTimeSeries(std::move(time_series));
}
- plot->SetXAxis(ToCallTimeSec(begin_time_), call_duration_s_, "Time (s)",
- kLeftMargin, kRightMargin);
+ plot->SetXAxis(config_.CallBeginTimeSec(), config_.CallEndTimeSec(),
+ "Time (s)", kLeftMargin, kRightMargin);
plot->SetSuggestedYAxis(0, 1, "Estimated loss rate (%)", kBottomMargin,
kTopMargin);
plot->SetTitle("Estimated incoming loss rate");
@@ -768,7 +753,7 @@
}
auto ToCallTime = [this](const LoggedRtpPacketIncoming& packet) {
- return this->ToCallTimeSec(packet.log_time_us());
+ return this->config_.GetCallTimeSec(packet.log_time_us());
};
auto ToNetworkDelay = [frequency_hz](
const LoggedRtpPacketIncoming& old_packet,
@@ -791,8 +776,8 @@
plot->AppendTimeSeriesIfNotEmpty(std::move(send_time_data));
}
- plot->SetXAxis(ToCallTimeSec(begin_time_), call_duration_s_, "Time (s)",
- kLeftMargin, kRightMargin);
+ plot->SetXAxis(config_.CallBeginTimeSec(), config_.CallEndTimeSec(),
+ "Time (s)", kLeftMargin, kRightMargin);
plot->SetSuggestedYAxis(0, 1, "Delay (ms)", kBottomMargin, kTopMargin);
plot->SetTitle("Incoming network delay (relative to first packet)");
}
@@ -802,14 +787,14 @@
TimeSeries time_series("Fraction lost", LineStyle::kLine,
PointStyle::kHighlight);
for (auto& bwe_update : parsed_log_.bwe_loss_updates()) {
- float x = ToCallTimeSec(bwe_update.log_time_us());
+ float x = config_.GetCallTimeSec(bwe_update.log_time_us());
float y = static_cast<float>(bwe_update.fraction_lost) / 255 * 100;
time_series.points.emplace_back(x, y);
}
plot->AppendTimeSeries(std::move(time_series));
- plot->SetXAxis(ToCallTimeSec(begin_time_), call_duration_s_, "Time (s)",
- kLeftMargin, kRightMargin);
+ plot->SetXAxis(config_.CallBeginTimeSec(), config_.CallEndTimeSec(),
+ "Time (s)", kLeftMargin, kRightMargin);
plot->SetSuggestedYAxis(0, 10, "Percent lost packets", kBottomMargin,
kTopMargin);
plot->SetTitle("Reported packet loss");
@@ -831,20 +816,21 @@
// Calculate a moving average of the bitrate and store in a TimeSeries.
TimeSeries bitrate_series("Bitrate", LineStyle::kLine);
- for (int64_t time = begin_time_; time < end_time_ + step_; time += step_) {
+ for (int64_t time = config_.begin_time_;
+ time < config_.end_time_ + config_.step_; time += config_.step_) {
while (window_end != packets_in_order.end() && window_end->first < time) {
bytes_in_window += window_end->second;
++window_end;
}
while (window_begin != packets_in_order.end() &&
- window_begin->first < time - window_duration_) {
+ window_begin->first < time - config_.window_duration_) {
RTC_DCHECK_LE(window_begin->second, bytes_in_window);
bytes_in_window -= window_begin->second;
++window_begin;
}
float window_duration_in_seconds =
- static_cast<float>(window_duration_) / kNumMicrosecsPerSec;
- float x = ToCallTimeSec(time);
+ static_cast<float>(config_.window_duration_) / kNumMicrosecsPerSec;
+ float x = config_.GetCallTimeSec(time);
float y = bytes_in_window * 8 / window_duration_in_seconds / 1000;
bitrate_series.points.emplace_back(x, y);
}
@@ -853,14 +839,14 @@
// Overlay the outgoing REMB over incoming bitrate.
TimeSeries remb_series("Remb", LineStyle::kStep);
for (const auto& rtcp : parsed_log_.rembs(kOutgoingPacket)) {
- float x = ToCallTimeSec(rtcp.log_time_us());
+ float x = config_.GetCallTimeSec(rtcp.log_time_us());
float y = static_cast<float>(rtcp.remb.bitrate_bps()) / 1000;
remb_series.points.emplace_back(x, y);
}
plot->AppendTimeSeriesIfNotEmpty(std::move(remb_series));
- plot->SetXAxis(ToCallTimeSec(begin_time_), call_duration_s_, "Time (s)",
- kLeftMargin, kRightMargin);
+ plot->SetXAxis(config_.CallBeginTimeSec(), config_.CallEndTimeSec(),
+ "Time (s)", kLeftMargin, kRightMargin);
plot->SetSuggestedYAxis(0, 1, "Bitrate (kbps)", kBottomMargin, kTopMargin);
plot->SetTitle("Incoming RTP bitrate");
}
@@ -883,20 +869,21 @@
// Calculate a moving average of the bitrate and store in a TimeSeries.
TimeSeries bitrate_series("Bitrate", LineStyle::kLine);
- for (int64_t time = begin_time_; time < end_time_ + step_; time += step_) {
+ for (int64_t time = config_.begin_time_;
+ time < config_.end_time_ + config_.step_; time += config_.step_) {
while (window_end != packets_in_order.end() && window_end->first < time) {
bytes_in_window += window_end->second;
++window_end;
}
while (window_begin != packets_in_order.end() &&
- window_begin->first < time - window_duration_) {
+ window_begin->first < time - config_.window_duration_) {
RTC_DCHECK_LE(window_begin->second, bytes_in_window);
bytes_in_window -= window_begin->second;
++window_begin;
}
float window_duration_in_seconds =
- static_cast<float>(window_duration_) / kNumMicrosecsPerSec;
- float x = ToCallTimeSec(time);
+ static_cast<float>(config_.window_duration_) / kNumMicrosecsPerSec;
+ float x = config_.GetCallTimeSec(time);
float y = bytes_in_window * 8 / window_duration_in_seconds / 1000;
bitrate_series.points.emplace_back(x, y);
}
@@ -905,7 +892,7 @@
// Overlay the send-side bandwidth estimate over the outgoing bitrate.
TimeSeries loss_series("Loss-based estimate", LineStyle::kStep);
for (auto& loss_update : parsed_log_.bwe_loss_updates()) {
- float x = ToCallTimeSec(loss_update.log_time_us());
+ float x = config_.GetCallTimeSec(loss_update.log_time_us());
float y = static_cast<float>(loss_update.bitrate_bps) / 1000;
loss_series.points.emplace_back(x, y);
}
@@ -923,7 +910,7 @@
BandwidthUsage last_detector_state = BandwidthUsage::kBwNormal;
for (auto& delay_update : parsed_log_.bwe_delay_updates()) {
- float x = ToCallTimeSec(delay_update.log_time_us());
+ float x = config_.GetCallTimeSec(delay_update.log_time_us());
float y = static_cast<float>(delay_update.bitrate_bps) / 1000;
if (last_detector_state != delay_update.detector_state) {
@@ -950,12 +937,12 @@
}
RTC_CHECK(last_series);
- last_series->intervals.emplace_back(last_detector_switch, end_time_);
+ last_series->intervals.emplace_back(last_detector_switch, config_.end_time_);
TimeSeries created_series("Probe cluster created.", LineStyle::kNone,
PointStyle::kHighlight);
for (auto& cluster : parsed_log_.bwe_probe_cluster_created_events()) {
- float x = ToCallTimeSec(cluster.log_time_us());
+ float x = config_.GetCallTimeSec(cluster.log_time_us());
float y = static_cast<float>(cluster.bitrate_bps) / 1000;
created_series.points.emplace_back(x, y);
}
@@ -963,7 +950,7 @@
TimeSeries result_series("Probing results.", LineStyle::kNone,
PointStyle::kHighlight);
for (auto& result : parsed_log_.bwe_probe_success_events()) {
- float x = ToCallTimeSec(result.log_time_us());
+ float x = config_.GetCallTimeSec(result.log_time_us());
float y = static_cast<float>(result.bitrate_bps) / 1000;
result_series.points.emplace_back(x, y);
}
@@ -971,7 +958,7 @@
TimeSeries probe_failures_series("Probe failed", LineStyle::kNone,
PointStyle::kHighlight);
for (auto& failure : parsed_log_.bwe_probe_failure_events()) {
- float x = ToCallTimeSec(failure.log_time_us());
+ float x = config_.GetCallTimeSec(failure.log_time_us());
probe_failures_series.points.emplace_back(x, 0);
}
@@ -979,20 +966,20 @@
bool previously_in_alr = false;
int64_t alr_start = 0;
for (auto& alr : parsed_log_.alr_state_events()) {
- float y = ToCallTimeSec(alr.log_time_us());
+ float y = config_.GetCallTimeSec(alr.log_time_us());
if (!previously_in_alr && alr.in_alr) {
alr_start = alr.log_time_us();
previously_in_alr = true;
} else if (previously_in_alr && !alr.in_alr) {
- float x = ToCallTimeSec(alr_start);
+ float x = config_.GetCallTimeSec(alr_start);
alr_state.intervals.emplace_back(x, y);
previously_in_alr = false;
}
}
if (previously_in_alr) {
- float x = ToCallTimeSec(alr_start);
- float y = ToCallTimeSec(end_time_);
+ float x = config_.GetCallTimeSec(alr_start);
+ float y = config_.GetCallTimeSec(config_.end_time_);
alr_state.intervals.emplace_back(x, y);
}
@@ -1014,14 +1001,14 @@
// Overlay the incoming REMB over the outgoing bitrate.
TimeSeries remb_series("Remb", LineStyle::kStep);
for (const auto& rtcp : parsed_log_.rembs(kIncomingPacket)) {
- float x = ToCallTimeSec(rtcp.log_time_us());
+ float x = config_.GetCallTimeSec(rtcp.log_time_us());
float y = static_cast<float>(rtcp.remb.bitrate_bps()) / 1000;
remb_series.points.emplace_back(x, y);
}
plot->AppendTimeSeriesIfNotEmpty(std::move(remb_series));
- plot->SetXAxis(ToCallTimeSec(begin_time_), call_duration_s_, "Time (s)",
- kLeftMargin, kRightMargin);
+ plot->SetXAxis(config_.CallBeginTimeSec(), config_.CallEndTimeSec(),
+ "Time (s)", kLeftMargin, kRightMargin);
plot->SetSuggestedYAxis(0, 1, "Bitrate (kbps)", kBottomMargin, kTopMargin);
plot->SetTitle("Outgoing RTP bitrate");
}
@@ -1040,17 +1027,13 @@
auto GetPacketSizeKilobits = [](const LoggedRtpPacket& packet) {
return packet.total_length * 8.0 / 1000.0;
};
- auto ToCallTime = [this](int64_t time) {
- return this->ToCallTimeSec(time);
- };
MovingAverage<LoggedRtpPacket, double>(
- ToCallTime, GetPacketSizeKilobits, stream.packet_view, begin_time_,
- end_time_, window_duration_, step_, &time_series);
+ GetPacketSizeKilobits, stream.packet_view, config_, &time_series);
plot->AppendTimeSeries(std::move(time_series));
}
- plot->SetXAxis(ToCallTimeSec(begin_time_), call_duration_s_, "Time (s)",
- kLeftMargin, kRightMargin);
+ plot->SetXAxis(config_.CallBeginTimeSec(), config_.CallEndTimeSec(),
+ "Time (s)", kLeftMargin, kRightMargin);
plot->SetSuggestedYAxis(0, 1, "Bitrate (kbps)", kBottomMargin, kTopMargin);
plot->SetTitle(GetDirectionAsString(direction) + " bitrate per stream");
}
@@ -1176,7 +1159,7 @@
}
}
- float x = ToCallTimeSec(clock.TimeInMicroseconds());
+ float x = config_.GetCallTimeSec(clock.TimeInMicroseconds());
float y = bitrate_bps.value_or(0) / 1000;
acked_time_series.points.emplace_back(x, y);
#if !(BWE_TEST_LOGGING_COMPILE_TIME_ENABLE)
@@ -1195,7 +1178,7 @@
if (observer.GetAndResetBitrateUpdated() ||
time_us - last_update_us >= 1e6) {
uint32_t y = observer.last_bitrate_bps() / 1000;
- float x = ToCallTimeSec(clock.TimeInMicroseconds());
+ float x = config_.GetCallTimeSec(clock.TimeInMicroseconds());
time_series.points.emplace_back(x, y);
last_update_us = time_us;
}
@@ -1206,8 +1189,8 @@
plot->AppendTimeSeries(std::move(acked_time_series));
plot->AppendTimeSeriesIfNotEmpty(std::move(acked_estimate_time_series));
- plot->SetXAxis(ToCallTimeSec(begin_time_), call_duration_s_, "Time (s)",
- kLeftMargin, kRightMargin);
+ plot->SetXAxis(config_.CallBeginTimeSec(), config_.CallEndTimeSec(),
+ "Time (s)", kLeftMargin, kRightMargin);
plot->SetSuggestedYAxis(0, 10, "Bitrate (kbps)", kBottomMargin, kTopMargin);
plot->SetTitle("Simulated send-side BWE behavior");
}
@@ -1270,13 +1253,13 @@
absl::optional<uint32_t> bitrate_bps = acked_bitrate.Rate(arrival_time_ms);
if (bitrate_bps) {
uint32_t y = *bitrate_bps / 1000;
- float x = ToCallTimeSec(clock.TimeInMicroseconds());
+ float x = config_.GetCallTimeSec(clock.TimeInMicroseconds());
acked_time_series.points.emplace_back(x, y);
}
if (packet_router.GetAndResetBitrateUpdated() ||
clock.TimeInMicroseconds() - last_update_us >= 1e6) {
uint32_t y = packet_router.last_bitrate_bps() / 1000;
- float x = ToCallTimeSec(clock.TimeInMicroseconds());
+ float x = config_.GetCallTimeSec(clock.TimeInMicroseconds());
time_series.points.emplace_back(x, y);
last_update_us = clock.TimeInMicroseconds();
}
@@ -1285,8 +1268,8 @@
plot->AppendTimeSeries(std::move(time_series));
plot->AppendTimeSeries(std::move(acked_time_series));
- plot->SetXAxis(ToCallTimeSec(begin_time_), call_duration_s_, "Time (s)",
- kLeftMargin, kRightMargin);
+ plot->SetXAxis(config_.CallBeginTimeSec(), config_.CallEndTimeSec(),
+ "Time (s)", kLeftMargin, kRightMargin);
plot->SetSuggestedYAxis(0, 10, "Bitrate (kbps)", kBottomMargin, kTopMargin);
plot->SetTitle("Simulated receive-side BWE behavior");
}
@@ -1303,7 +1286,7 @@
for (auto packet : GetNetworkTrace(parsed_log_)) {
if (packet.arrival_time_ms == PacketFeedback::kNotReceived)
continue;
- float x = ToCallTimeSec(1000 * packet.feedback_arrival_time_ms);
+ float x = config_.GetCallTimeSec(1000 * packet.feedback_arrival_time_ms);
if (packet.send_time_ms == PacketFeedback::kNoSendTime) {
late_feedback_series.points.emplace_back(x, prev_y);
continue;
@@ -1330,8 +1313,8 @@
plot->AppendTimeSeriesIfNotEmpty(std::move(time_series));
plot->AppendTimeSeriesIfNotEmpty(std::move(late_feedback_series));
- plot->SetXAxis(ToCallTimeSec(begin_time_), call_duration_s_, "Time (s)",
- kLeftMargin, kRightMargin);
+ plot->SetXAxis(config_.CallBeginTimeSec(), config_.CallEndTimeSec(),
+ "Time (s)", kLeftMargin, kRightMargin);
plot->SetSuggestedYAxis(0, 10, "Delay (ms)", kBottomMargin, kTopMargin);
plot->SetTitle("Outgoing network delay (based on per-packet feedback)");
}
@@ -1378,15 +1361,15 @@
double send_time_ms =
static_cast<double>(packet.rtp.log_time_us() - first_send_timestamp) /
1000;
- float x = ToCallTimeSec(packet.rtp.log_time_us());
+ float x = config_.GetCallTimeSec(packet.rtp.log_time_us());
float y = send_time_ms - capture_time_ms;
pacer_delay_series.points.emplace_back(x, y);
}
plot->AppendTimeSeries(std::move(pacer_delay_series));
}
- plot->SetXAxis(ToCallTimeSec(begin_time_), call_duration_s_, "Time (s)",
- kLeftMargin, kRightMargin);
+ plot->SetXAxis(config_.CallBeginTimeSec(), config_.CallEndTimeSec(),
+ "Time (s)", kLeftMargin, kRightMargin);
plot->SetSuggestedYAxis(0, 10, "Pacer delay (ms)", kBottomMargin, kTopMargin);
plot->SetTitle(
"Delay from capture to send time. (First packet normalized to 0.)");
@@ -1399,7 +1382,7 @@
GetStreamName(direction, stream.ssrc) + " capture-time",
LineStyle::kLine, PointStyle::kHighlight);
for (const auto& packet : stream.packet_view) {
- float x = ToCallTimeSec(packet.log_time_us());
+ float x = config_.GetCallTimeSec(packet.log_time_us());
float y = packet.header.timestamp;
rtp_timestamps.points.emplace_back(x, y);
}
@@ -1413,15 +1396,15 @@
for (const auto& rtcp : sender_reports) {
if (rtcp.sr.sender_ssrc() != stream.ssrc)
continue;
- float x = ToCallTimeSec(rtcp.log_time_us());
+ float x = config_.GetCallTimeSec(rtcp.log_time_us());
float y = rtcp.sr.rtp_timestamp();
rtcp_timestamps.points.emplace_back(x, y);
}
plot->AppendTimeSeriesIfNotEmpty(std::move(rtcp_timestamps));
}
- plot->SetXAxis(ToCallTimeSec(begin_time_), call_duration_s_, "Time (s)",
- kLeftMargin, kRightMargin);
+ plot->SetXAxis(config_.CallBeginTimeSec(), config_.CallEndTimeSec(),
+ "Time (s)", kLeftMargin, kRightMargin);
plot->SetSuggestedYAxis(0, 1, "RTP timestamp", kBottomMargin, kTopMargin);
plot->SetTitle(GetDirectionAsString(direction) + " timestamps");
}
@@ -1435,7 +1418,7 @@
std::map<uint32_t, TimeSeries> sr_reports_by_ssrc;
const auto& sender_reports = parsed_log_.sender_reports(direction);
for (const auto& rtcp : sender_reports) {
- float x = ToCallTimeSec(rtcp.log_time_us());
+ float x = config_.GetCallTimeSec(rtcp.log_time_us());
uint32_t ssrc = rtcp.sr.sender_ssrc();
for (const auto& block : rtcp.sr.report_blocks()) {
float y = fy(block);
@@ -1456,7 +1439,7 @@
std::map<uint32_t, TimeSeries> rr_reports_by_ssrc;
const auto& receiver_reports = parsed_log_.receiver_reports(direction);
for (const auto& rtcp : receiver_reports) {
- float x = ToCallTimeSec(rtcp.log_time_us());
+ float x = config_.GetCallTimeSec(rtcp.log_time_us());
uint32_t ssrc = rtcp.rr.sender_ssrc();
for (const auto& block : rtcp.rr.report_blocks()) {
float y = fy(block);
@@ -1475,8 +1458,8 @@
plot->AppendTimeSeries(std::move(kv.second));
}
- plot->SetXAxis(ToCallTimeSec(begin_time_), call_duration_s_, "Time (s)",
- kLeftMargin, kRightMargin);
+ plot->SetXAxis(config_.CallBeginTimeSec(), config_.CallEndTimeSec(),
+ "Time (s)", kLeftMargin, kRightMargin);
plot->SetSuggestedYAxis(0, 1, yaxis_label, kBottomMargin, kTopMargin);
plot->SetTitle(title);
}
@@ -1492,14 +1475,14 @@
return absl::nullopt;
};
auto ToCallTime = [this](const LoggedAudioNetworkAdaptationEvent& packet) {
- return this->ToCallTimeSec(packet.log_time_us());
+ return this->config_.GetCallTimeSec(packet.log_time_us());
};
ProcessPoints<LoggedAudioNetworkAdaptationEvent>(
ToCallTime, GetAnaBitrateBps,
parsed_log_.audio_network_adaptation_events(), &time_series);
plot->AppendTimeSeries(std::move(time_series));
- plot->SetXAxis(ToCallTimeSec(begin_time_), call_duration_s_, "Time (s)",
- kLeftMargin, kRightMargin);
+ plot->SetXAxis(config_.CallBeginTimeSec(), config_.CallEndTimeSec(),
+ "Time (s)", kLeftMargin, kRightMargin);
plot->SetSuggestedYAxis(0, 1, "Bitrate (bps)", kBottomMargin, kTopMargin);
plot->SetTitle("Reported audio encoder target bitrate");
}
@@ -1515,14 +1498,14 @@
return absl::optional<float>();
};
auto ToCallTime = [this](const LoggedAudioNetworkAdaptationEvent& packet) {
- return this->ToCallTimeSec(packet.log_time_us());
+ return this->config_.GetCallTimeSec(packet.log_time_us());
};
ProcessPoints<LoggedAudioNetworkAdaptationEvent>(
ToCallTime, GetAnaFrameLengthMs,
parsed_log_.audio_network_adaptation_events(), &time_series);
plot->AppendTimeSeries(std::move(time_series));
- plot->SetXAxis(ToCallTimeSec(begin_time_), call_duration_s_, "Time (s)",
- kLeftMargin, kRightMargin);
+ plot->SetXAxis(config_.CallBeginTimeSec(), config_.CallEndTimeSec(),
+ "Time (s)", kLeftMargin, kRightMargin);
plot->SetSuggestedYAxis(0, 1, "Frame length (ms)", kBottomMargin, kTopMargin);
plot->SetTitle("Reported audio encoder frame length");
}
@@ -1538,14 +1521,14 @@
return absl::optional<float>();
};
auto ToCallTime = [this](const LoggedAudioNetworkAdaptationEvent& packet) {
- return this->ToCallTimeSec(packet.log_time_us());
+ return this->config_.GetCallTimeSec(packet.log_time_us());
};
ProcessPoints<LoggedAudioNetworkAdaptationEvent>(
ToCallTime, GetAnaPacketLoss,
parsed_log_.audio_network_adaptation_events(), &time_series);
plot->AppendTimeSeries(std::move(time_series));
- plot->SetXAxis(ToCallTimeSec(begin_time_), call_duration_s_, "Time (s)",
- kLeftMargin, kRightMargin);
+ plot->SetXAxis(config_.CallBeginTimeSec(), config_.CallEndTimeSec(),
+ "Time (s)", kLeftMargin, kRightMargin);
plot->SetSuggestedYAxis(0, 10, "Percent lost packets", kBottomMargin,
kTopMargin);
plot->SetTitle("Reported audio encoder lost packets");
@@ -1562,14 +1545,14 @@
return absl::optional<float>();
};
auto ToCallTime = [this](const LoggedAudioNetworkAdaptationEvent& packet) {
- return this->ToCallTimeSec(packet.log_time_us());
+ return this->config_.GetCallTimeSec(packet.log_time_us());
};
ProcessPoints<LoggedAudioNetworkAdaptationEvent>(
ToCallTime, GetAnaFecEnabled,
parsed_log_.audio_network_adaptation_events(), &time_series);
plot->AppendTimeSeries(std::move(time_series));
- plot->SetXAxis(ToCallTimeSec(begin_time_), call_duration_s_, "Time (s)",
- kLeftMargin, kRightMargin);
+ plot->SetXAxis(config_.CallBeginTimeSec(), config_.CallEndTimeSec(),
+ "Time (s)", kLeftMargin, kRightMargin);
plot->SetSuggestedYAxis(0, 1, "FEC (false/true)", kBottomMargin, kTopMargin);
plot->SetTitle("Reported audio encoder FEC");
}
@@ -1585,14 +1568,14 @@
return absl::optional<float>();
};
auto ToCallTime = [this](const LoggedAudioNetworkAdaptationEvent& packet) {
- return this->ToCallTimeSec(packet.log_time_us());
+ return this->config_.GetCallTimeSec(packet.log_time_us());
};
ProcessPoints<LoggedAudioNetworkAdaptationEvent>(
ToCallTime, GetAnaDtxEnabled,
parsed_log_.audio_network_adaptation_events(), &time_series);
plot->AppendTimeSeries(std::move(time_series));
- plot->SetXAxis(ToCallTimeSec(begin_time_), call_duration_s_, "Time (s)",
- kLeftMargin, kRightMargin);
+ plot->SetXAxis(config_.CallBeginTimeSec(), config_.CallEndTimeSec(),
+ "Time (s)", kLeftMargin, kRightMargin);
plot->SetSuggestedYAxis(0, 1, "DTX (false/true)", kBottomMargin, kTopMargin);
plot->SetTitle("Reported audio encoder DTX");
}
@@ -1608,14 +1591,14 @@
return absl::optional<float>();
};
auto ToCallTime = [this](const LoggedAudioNetworkAdaptationEvent& packet) {
- return this->ToCallTimeSec(packet.log_time_us());
+ return this->config_.GetCallTimeSec(packet.log_time_us());
};
ProcessPoints<LoggedAudioNetworkAdaptationEvent>(
ToCallTime, GetAnaNumChannels,
parsed_log_.audio_network_adaptation_events(), &time_series);
plot->AppendTimeSeries(std::move(time_series));
- plot->SetXAxis(ToCallTimeSec(begin_time_), call_duration_s_, "Time (s)",
- kLeftMargin, kRightMargin);
+ plot->SetXAxis(config_.CallBeginTimeSec(), config_.CallEndTimeSec(),
+ "Time (s)", kLeftMargin, kRightMargin);
plot->SetSuggestedYAxis(0, 1, "Number of channels (1 (mono)/2 (stereo))",
kBottomMargin, kTopMargin);
plot->SetTitle("Reported audio encoder number of channels");
@@ -1844,23 +1827,23 @@
PointStyle::kHighlight);
for (const auto& data : arrival_delay_ms) {
- const float x = ToCallTimeSec(data.first * 1000); // ms to us.
+ const float x = config_.GetCallTimeSec(data.first * 1000); // ms to us.
const float y = data.second;
time_series_packet_arrival.points.emplace_back(TimeSeriesPoint(x, y));
}
for (const auto& data : corrected_arrival_delay_ms) {
- const float x = ToCallTimeSec(data.first * 1000); // ms to us.
+ const float x = config_.GetCallTimeSec(data.first * 1000); // ms to us.
const float y = data.second;
time_series_relative_packet_arrival.points.emplace_back(
TimeSeriesPoint(x, y));
}
for (const auto& data : playout_delay_ms) {
- const float x = ToCallTimeSec(data.first * 1000); // ms to us.
+ const float x = config_.GetCallTimeSec(data.first * 1000); // ms to us.
const float y = data.second;
time_series_play_time.points.emplace_back(TimeSeriesPoint(x, y));
}
for (const auto& data : target_delay_ms) {
- const float x = ToCallTimeSec(data.first * 1000); // ms to us.
+ const float x = config_.GetCallTimeSec(data.first * 1000); // ms to us.
const float y = data.second;
time_series_target_time.points.emplace_back(TimeSeriesPoint(x, y));
}
@@ -1870,8 +1853,8 @@
plot->AppendTimeSeries(std::move(time_series_play_time));
plot->AppendTimeSeries(std::move(time_series_target_time));
- plot->SetXAxis(ToCallTimeSec(begin_time_), call_duration_s_, "Time (s)",
- kLeftMargin, kRightMargin);
+ plot->SetXAxis(config_.CallBeginTimeSec(), config_.CallEndTimeSec(),
+ "Time (s)", kLeftMargin, kRightMargin);
plot->SetSuggestedYAxis(0, 1, "Relative delay (ms)", kBottomMargin,
kTopMargin);
plot->SetTitle("NetEq timing for " + GetStreamName(kIncomingPacket, ssrc));
@@ -1892,7 +1875,8 @@
const std::vector<std::pair<int64_t, NetEqStatsType>>* data_vector =
data_extractor(st.second.get());
for (const auto& data : *data_vector) {
- const float time = ToCallTimeSec(data.first * 1000); // ms to us.
+ const float time =
+ config_.GetCallTimeSec(data.first * 1000); // ms to us.
const float value = stats_extractor(data.second);
time_series[ssrc].points.emplace_back(TimeSeriesPoint(time, value));
}
@@ -1904,8 +1888,8 @@
plot->AppendTimeSeries(std::move(series.second));
}
- plot->SetXAxis(ToCallTimeSec(begin_time_), call_duration_s_, "Time (s)",
- kLeftMargin, kRightMargin);
+ plot->SetXAxis(config_.CallBeginTimeSec(), config_.CallEndTimeSec(),
+ "Time (s)", kLeftMargin, kRightMargin);
plot->SetSuggestedYAxis(0, 1, plot_name, kBottomMargin, kTopMargin);
plot->SetTitle(plot_name);
}
@@ -1950,7 +1934,7 @@
candidate_pair_desc_by_id_[config.candidate_pair_id] =
candidate_pair_desc;
}
- float x = ToCallTimeSec(config.log_time_us());
+ float x = config_.GetCallTimeSec(config.log_time_us());
float y = static_cast<float>(config.type);
configs_by_cp_id[config.candidate_pair_id].points.emplace_back(x, y);
}
@@ -1962,8 +1946,8 @@
plot->AppendTimeSeries(std::move(kv.second));
}
- plot->SetXAxis(ToCallTimeSec(begin_time_), call_duration_s_, "Time (s)",
- kLeftMargin, kRightMargin);
+ plot->SetXAxis(config_.CallBeginTimeSec(), config_.CallEndTimeSec(),
+ "Time (s)", kLeftMargin, kRightMargin);
plot->SetSuggestedYAxis(0, 3, "Numeric Config Type", kBottomMargin,
kTopMargin);
plot->SetTitle("[IceEventLog] ICE candidate pair configs");
@@ -1999,7 +1983,7 @@
GetCandidatePairLogDescriptionFromId(event.candidate_pair_id),
LineStyle::kNone, PointStyle::kHighlight);
}
- float x = ToCallTimeSec(event.log_time_us());
+ float x = config_.GetCallTimeSec(event.log_time_us());
constexpr int kIceCandidatePairEventTypeOffset =
static_cast<int>(IceCandidatePairConfigType::kNumValues);
float y = static_cast<float>(event.type) + kIceCandidatePairEventTypeOffset;
@@ -2011,8 +1995,8 @@
plot->AppendTimeSeries(std::move(kv.second));
}
- plot->SetXAxis(ToCallTimeSec(begin_time_), call_duration_s_, "Time (s)",
- kLeftMargin, kRightMargin);
+ plot->SetXAxis(config_.CallBeginTimeSec(), config_.CallEndTimeSec(),
+ "Time (s)", kLeftMargin, kRightMargin);
plot->SetSuggestedYAxis(0, 4, "Numeric Connectivity State", kBottomMargin,
kTopMargin);
plot->SetTitle("[IceEventLog] ICE connectivity checks");
@@ -2022,13 +2006,13 @@
TimeSeries states("DTLS Transport State", LineStyle::kNone,
PointStyle::kHighlight);
for (const auto& event : parsed_log_.dtls_transport_states()) {
- float x = ToCallTimeSec(event.log_time_us());
+ float x = config_.GetCallTimeSec(event.log_time_us());
float y = static_cast<float>(event.dtls_transport_state);
states.points.emplace_back(x, y);
}
plot->AppendTimeSeries(std::move(states));
- plot->SetXAxis(ToCallTimeSec(begin_time_), call_duration_s_, "Time (s)",
- kLeftMargin, kRightMargin);
+ plot->SetXAxis(config_.CallBeginTimeSec(), config_.CallEndTimeSec(),
+ "Time (s)", kLeftMargin, kRightMargin);
plot->SetSuggestedYAxis(0, static_cast<float>(DtlsTransportState::kNumValues),
"Numeric Transport State", kBottomMargin, kTopMargin);
plot->SetTitle("DTLS Transport State");
@@ -2038,13 +2022,13 @@
TimeSeries writable("DTLS Writable", LineStyle::kNone,
PointStyle::kHighlight);
for (const auto& event : parsed_log_.dtls_writable_states()) {
- float x = ToCallTimeSec(event.log_time_us());
+ float x = config_.GetCallTimeSec(event.log_time_us());
float y = static_cast<float>(event.writable);
writable.points.emplace_back(x, y);
}
plot->AppendTimeSeries(std::move(writable));
- plot->SetXAxis(ToCallTimeSec(begin_time_), call_duration_s_, "Time (s)",
- kLeftMargin, kRightMargin);
+ plot->SetXAxis(config_.CallBeginTimeSec(), config_.CallEndTimeSec(),
+ "Time (s)", kLeftMargin, kRightMargin);
plot->SetSuggestedYAxis(0, 1, "Writable", kBottomMargin, kTopMargin);
plot->SetTitle("DTLS Writable State");
}
@@ -2107,7 +2091,8 @@
int64_t seq_num = seq_num_unwrapper.Unwrap(packet.header.sequenceNumber);
if (last_seq_num.has_value() &&
std::abs(seq_num - last_seq_num.value()) > kMaxSeqNumJump) {
- Alert_SeqNumJump(direction, ToCallTimeSec(packet.log_time_us()),
+ Alert_SeqNumJump(direction,
+ config_.GetCallTimeSec(packet.log_time_us()),
packet.header.ssrc);
}
last_seq_num.emplace(seq_num);
@@ -2117,7 +2102,8 @@
if (last_capture_time.has_value() &&
std::abs(capture_time - last_capture_time.value()) >
kMaxCaptureTimeJump) {
- Alert_CaptureTimeJump(direction, ToCallTimeSec(packet.log_time_us()),
+ Alert_CaptureTimeJump(direction,
+ config_.GetCallTimeSec(packet.log_time_us()),
packet.header.ssrc);
}
last_capture_time.emplace(capture_time);
@@ -2149,7 +2135,8 @@
int64_t duration = timestamp - last_rtp_time.value_or(0);
if (last_rtp_time.has_value() && duration > kMaxRtpTransmissionGap) {
// No packet sent/received for more than 500 ms.
- Alert_RtpLogTimeGap(direction, ToCallTimeSec(timestamp), duration / 1000);
+ Alert_RtpLogTimeGap(direction, config_.GetCallTimeSec(timestamp),
+ duration / 1000);
}
last_rtp_time.emplace(timestamp);
}
@@ -2164,7 +2151,8 @@
int64_t duration = rtcp.log_time_us() - last_rtcp_time.value_or(0);
if (last_rtcp_time.has_value() && duration > kMaxRtcpTransmissionGap) {
// No feedback sent/received for more than 2000 ms.
- Alert_RtcpLogTimeGap(direction, ToCallTimeSec(rtcp.log_time_us()),
+ Alert_RtcpLogTimeGap(direction,
+ config_.GetCallTimeSec(rtcp.log_time_us()),
duration / 1000);
}
last_rtcp_time.emplace(rtcp.log_time_us());
@@ -2178,7 +2166,8 @@
int64_t duration = rtcp.log_time_us() - last_rtcp_time.value_or(0);
if (last_rtcp_time.has_value() && duration > kMaxRtcpTransmissionGap) {
// No feedback sent/received for more than 2000 ms.
- Alert_RtcpLogTimeGap(direction, ToCallTimeSec(rtcp.log_time_us()),
+ Alert_RtcpLogTimeGap(direction,
+ config_.GetCallTimeSec(rtcp.log_time_us()),
duration / 1000);
}
last_rtcp_time.emplace(rtcp.log_time_us());
diff --git a/rtc_tools/event_log_visualizer/analyzer.h b/rtc_tools/event_log_visualizer/analyzer.h
index 976598b..6064202 100644
--- a/rtc_tools/event_log_visualizer/analyzer.h
+++ b/rtc_tools/event_log_visualizer/analyzer.h
@@ -26,6 +26,30 @@
namespace webrtc {
+class AnalyzerConfig {
+ public:
+ float GetCallTimeSec(int64_t timestamp_us) const {
+ int64_t offset = normalize_time_ ? begin_time_ : 0;
+ return static_cast<float>(timestamp_us - offset) / 1000000;
+ }
+
+ float CallBeginTimeSec() const { return GetCallTimeSec(begin_time_); }
+
+ float CallEndTimeSec() const { return GetCallTimeSec(end_time_); }
+
+ // 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.
+ int64_t window_duration_;
+ int64_t step_;
+
+ // First and last events of the log.
+ int64_t begin_time_;
+ int64_t end_time_;
+ bool normalize_time_;
+};
+
class EventLogAnalyzer {
public:
// The EventLogAnalyzer keeps a reference to the ParsedRtcEventLogNew for the
@@ -174,9 +198,6 @@
return name.str();
}
- int64_t ToCallTimeUs(int64_t timestamp) const;
- float ToCallTimeSec(int64_t timestamp) const;
-
void Alert_RtpLogTimeGap(PacketDirection direction,
float time_seconds,
int64_t duration) {
@@ -245,20 +266,7 @@
std::map<uint32_t, std::string> candidate_pair_desc_by_id_;
- // 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.
- int64_t window_duration_;
- int64_t step_;
-
- // First and last events of the log.
- int64_t begin_time_;
- int64_t end_time_;
- const bool normalize_time_;
-
- // Duration (in seconds) of log file.
- float call_duration_s_;
+ AnalyzerConfig config_;
};
} // namespace webrtc