Move network trace calculation from analyzer to rtc_event_log_parser.

Bug: b/116768521
Change-Id: Ibc5643c9c03caa00cc84a5efc628115d414b35f7
Reviewed-on: https://webrtc-review.googlesource.com/102301
Reviewed-by: Björn Terelius <terelius@webrtc.org>
Commit-Queue: Christoffer Rodbro <crodbro@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24879}
This commit is contained in:
Christoffer Rodbro
2018-09-27 14:29:35 +02:00
committed by Commit Bot
parent 17f4878419
commit 89f64d305e
5 changed files with 117 additions and 68 deletions

View File

@ -1276,83 +1276,27 @@ void EventLogAnalyzer::CreateReceiveSideBweSimulationGraph(Plot* plot) {
}
void EventLogAnalyzer::CreateNetworkDelayFeedbackGraph(Plot* plot) {
using RtpPacketType = LoggedRtpPacketOutgoing;
using TransportFeedbackType = LoggedRtcpPacketTransportFeedback;
// TODO(terelius): This could be provided by the parser.
std::multimap<int64_t, const RtpPacketType*> outgoing_rtp;
for (const auto& stream : parsed_log_.outgoing_rtp_packets_by_ssrc()) {
for (const RtpPacketType& rtp_packet : stream.outgoing_packets)
outgoing_rtp.insert(
std::make_pair(rtp_packet.rtp.log_time_us(), &rtp_packet));
}
const std::vector<TransportFeedbackType>& incoming_rtcp =
parsed_log_.transport_feedbacks(kIncomingPacket);
SimulatedClock clock(0);
TransportFeedbackAdapter feedback_adapter(&clock);
TimeSeries late_feedback_series("Late feedback results.", LineStyle::kNone,
PointStyle::kHighlight);
TimeSeries time_series("Network Delay Change", LineStyle::kLine,
PointStyle::kHighlight);
int64_t estimated_base_delay_ms = std::numeric_limits<int64_t>::max();
auto rtp_iterator = outgoing_rtp.begin();
auto rtcp_iterator = incoming_rtcp.begin();
auto NextRtpTime = [&]() {
if (rtp_iterator != outgoing_rtp.end())
return static_cast<int64_t>(rtp_iterator->first);
return std::numeric_limits<int64_t>::max();
};
auto NextRtcpTime = [&]() {
if (rtcp_iterator != incoming_rtcp.end())
return static_cast<int64_t>(rtcp_iterator->log_time_us());
return std::numeric_limits<int64_t>::max();
};
int64_t time_us = std::min(NextRtpTime(), NextRtcpTime());
int64_t prev_y = 0;
while (time_us != std::numeric_limits<int64_t>::max()) {
clock.AdvanceTimeMicroseconds(time_us - clock.TimeInMicroseconds());
if (clock.TimeInMicroseconds() >= NextRtcpTime()) {
RTC_DCHECK_EQ(clock.TimeInMicroseconds(), NextRtcpTime());
feedback_adapter.OnTransportFeedback(rtcp_iterator->transport_feedback);
std::vector<PacketFeedback> feedback =
feedback_adapter.GetTransportFeedbackVector();
SortPacketFeedbackVector(&feedback);
for (const PacketFeedback& packet : feedback) {
float x = ToCallTimeSec(clock.TimeInMicroseconds());
if (packet.send_time_ms == PacketFeedback::kNoSendTime) {
late_feedback_series.points.emplace_back(x, prev_y);
continue;
}
int64_t y = packet.arrival_time_ms - packet.send_time_ms;
prev_y = y;
estimated_base_delay_ms = std::min(y, estimated_base_delay_ms);
time_series.points.emplace_back(x, y);
}
++rtcp_iterator;
for (auto packet : GetNetworkTrace(parsed_log_)) {
if (packet.arrival_time_ms == PacketFeedback::kNotReceived)
continue;
float x = ToCallTimeSec(1000 * packet.feedback_arrival_time_ms);
if (packet.send_time_ms == PacketFeedback::kNoSendTime) {
late_feedback_series.points.emplace_back(x, prev_y);
continue;
}
if (clock.TimeInMicroseconds() >= NextRtpTime()) {
RTC_DCHECK_EQ(clock.TimeInMicroseconds(), NextRtpTime());
const RtpPacketType& rtp_packet = *rtp_iterator->second;
if (rtp_packet.rtp.header.extension.hasTransportSequenceNumber) {
feedback_adapter.AddPacket(
rtp_packet.rtp.header.ssrc,
rtp_packet.rtp.header.extension.transportSequenceNumber,
rtp_packet.rtp.total_length, PacedPacketInfo());
feedback_adapter.OnSentPacket(
rtp_packet.rtp.header.extension.transportSequenceNumber,
rtp_packet.rtp.log_time_us() / 1000);
}
++rtp_iterator;
}
time_us = std::min(NextRtpTime(), NextRtcpTime());
int64_t y = packet.arrival_time_ms - packet.send_time_ms;
prev_y = y;
estimated_base_delay_ms = std::min(y, estimated_base_delay_ms);
time_series.points.emplace_back(x, y);
}
// We assume that the base network delay (w/o queues) is the min delay
// observed during the call.
for (TimeSeriesPoint& point : time_series.points)