Event log visualizer TimeSeries is now created on the stack and then moved into the vector of series.

BUG=none

Review-Url: https://codereview.webrtc.org/2824973003
Cr-Commit-Position: refs/heads/master@{#17763}
This commit is contained in:
philipel
2017-04-19 05:58:51 -07:00
committed by Commit bot
parent 13fc18068f
commit 35ba9bd597
4 changed files with 60 additions and 66 deletions

View File

@ -582,7 +582,7 @@ void EventLogAnalyzer::CreatePacketGraph(PacketDirection desired_direction,
return rtc::Optional<float>(packet.total_length); return rtc::Optional<float>(packet.total_length);
}, },
packet_stream, begin_time_, &time_series); packet_stream, begin_time_, &time_series);
plot->series_list_.push_back(std::move(time_series)); plot->AppendTimeSeries(std::move(time_series));
} }
plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin);
@ -618,7 +618,7 @@ void EventLogAnalyzer::CreateAccumulatedPacketsTimeSeries(
time_series.points.emplace_back(x, i + 1); time_series.points.emplace_back(x, i + 1);
} }
plot->series_list_.push_back(std::move(time_series)); plot->AppendTimeSeries(std::move(time_series));
} }
} }
@ -669,7 +669,7 @@ void EventLogAnalyzer::CreatePlayoutGraph(Plot* plot) {
for (auto& kv : time_series) { for (auto& kv : time_series) {
kv.second.label = SsrcToString(kv.first); kv.second.label = SsrcToString(kv.first);
kv.second.style = BAR_GRAPH; kv.second.style = BAR_GRAPH;
plot->series_list_.push_back(std::move(kv.second)); plot->AppendTimeSeries(std::move(kv.second));
} }
plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin);
@ -702,7 +702,7 @@ void EventLogAnalyzer::CreateAudioLevelGraph(Plot* plot) {
for (auto& series : time_series) { for (auto& series : time_series) {
series.second.label = GetStreamName(series.first); series.second.label = GetStreamName(series.first);
series.second.style = LINE_GRAPH; series.second.style = LINE_GRAPH;
plot->series_list_.push_back(std::move(series.second)); plot->AppendTimeSeries(std::move(series.second));
} }
plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin);
@ -732,7 +732,7 @@ void EventLogAnalyzer::CreateSequenceNumberGraph(Plot* plot) {
return rtc::Optional<float>(diff); return rtc::Optional<float>(diff);
}, },
packet_stream, begin_time_, &time_series); packet_stream, begin_time_, &time_series);
plot->series_list_.push_back(std::move(time_series)); plot->AppendTimeSeries(std::move(time_series));
} }
plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin);
@ -789,7 +789,7 @@ void EventLogAnalyzer::CreateIncomingPacketLossGraph(Plot* plot) {
time_series.points.emplace_back(x, y); time_series.points.emplace_back(x, y);
} }
} }
plot->series_list_.push_back(std::move(time_series)); plot->AppendTimeSeries(std::move(time_series));
} }
plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin);
@ -815,14 +815,14 @@ void EventLogAnalyzer::CreateDelayChangeGraph(Plot* plot) {
ProcessPairs<LoggedRtpPacket, double>(NetworkDelayDiff_CaptureTime, ProcessPairs<LoggedRtpPacket, double>(NetworkDelayDiff_CaptureTime,
packet_stream, begin_time_, packet_stream, begin_time_,
&capture_time_data); &capture_time_data);
plot->series_list_.push_back(std::move(capture_time_data)); plot->AppendTimeSeries(std::move(capture_time_data));
TimeSeries send_time_data(GetStreamName(stream_id) + " abs-send-time", TimeSeries send_time_data(GetStreamName(stream_id) + " abs-send-time",
BAR_GRAPH); BAR_GRAPH);
ProcessPairs<LoggedRtpPacket, double>(NetworkDelayDiff_AbsSendTime, ProcessPairs<LoggedRtpPacket, double>(NetworkDelayDiff_AbsSendTime,
packet_stream, begin_time_, packet_stream, begin_time_,
&send_time_data); &send_time_data);
plot->series_list_.push_back(std::move(send_time_data)); plot->AppendTimeSeries(std::move(send_time_data));
} }
plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin);
@ -848,14 +848,14 @@ void EventLogAnalyzer::CreateAccumulatedDelayChangeGraph(Plot* plot) {
AccumulatePairs<LoggedRtpPacket, double>(NetworkDelayDiff_CaptureTime, AccumulatePairs<LoggedRtpPacket, double>(NetworkDelayDiff_CaptureTime,
packet_stream, begin_time_, packet_stream, begin_time_,
&capture_time_data); &capture_time_data);
plot->series_list_.push_back(std::move(capture_time_data)); plot->AppendTimeSeries(std::move(capture_time_data));
TimeSeries send_time_data(GetStreamName(stream_id) + " abs-send-time", TimeSeries send_time_data(GetStreamName(stream_id) + " abs-send-time",
LINE_GRAPH); LINE_GRAPH);
AccumulatePairs<LoggedRtpPacket, double>(NetworkDelayDiff_AbsSendTime, AccumulatePairs<LoggedRtpPacket, double>(NetworkDelayDiff_AbsSendTime,
packet_stream, begin_time_, packet_stream, begin_time_,
&send_time_data); &send_time_data);
plot->series_list_.push_back(std::move(send_time_data)); plot->AppendTimeSeries(std::move(send_time_data));
} }
plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin);
@ -866,18 +866,18 @@ void EventLogAnalyzer::CreateAccumulatedDelayChangeGraph(Plot* plot) {
// Plot the fraction of packets lost (as perceived by the loss-based BWE). // Plot the fraction of packets lost (as perceived by the loss-based BWE).
void EventLogAnalyzer::CreateFractionLossGraph(Plot* plot) { void EventLogAnalyzer::CreateFractionLossGraph(Plot* plot) {
TimeSeries* time_series = TimeSeries time_series("Fraction lost", LINE_DOT_GRAPH);
plot->AddTimeSeries("Fraction lost", LINE_DOT_GRAPH);
for (auto& bwe_update : bwe_loss_updates_) { for (auto& bwe_update : bwe_loss_updates_) {
float x = static_cast<float>(bwe_update.timestamp - begin_time_) / 1000000; float x = static_cast<float>(bwe_update.timestamp - begin_time_) / 1000000;
float y = static_cast<float>(bwe_update.fraction_loss) / 255 * 100; float y = static_cast<float>(bwe_update.fraction_loss) / 255 * 100;
time_series->points.emplace_back(x, y); time_series.points.emplace_back(x, y);
} }
plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin);
plot->SetSuggestedYAxis(0, 10, "Percent lost packets", kBottomMargin, plot->SetSuggestedYAxis(0, 10, "Percent lost packets", kBottomMargin,
kTopMargin); kTopMargin);
plot->SetTitle("Reported packet loss"); plot->SetTitle("Reported packet loss");
plot->AppendTimeSeries(std::move(time_series));
} }
// Plot the total bandwidth used by all RTP streams. // Plot the total bandwidth used by all RTP streams.
@ -912,7 +912,7 @@ void EventLogAnalyzer::CreateTotalBitrateGraph(
size_t bytes_in_window = 0; size_t bytes_in_window = 0;
// Calculate a moving average of the bitrate and store in a TimeSeries. // Calculate a moving average of the bitrate and store in a TimeSeries.
TimeSeries* time_series = plot->AddTimeSeries("Bitrate", LINE_GRAPH); TimeSeries bitrate_series("Bitrate", LINE_GRAPH);
for (uint64_t time = begin_time_; time < end_time_ + step_; time += step_) { for (uint64_t time = begin_time_; time < end_time_ + step_; time += step_) {
while (window_index_end < packets.size() && while (window_index_end < packets.size() &&
packets[window_index_end].timestamp < time) { packets[window_index_end].timestamp < time) {
@ -929,46 +929,47 @@ void EventLogAnalyzer::CreateTotalBitrateGraph(
static_cast<float>(window_duration_) / 1000000; static_cast<float>(window_duration_) / 1000000;
float x = static_cast<float>(time - begin_time_) / 1000000; float x = static_cast<float>(time - begin_time_) / 1000000;
float y = bytes_in_window * 8 / window_duration_in_seconds / 1000; float y = bytes_in_window * 8 / window_duration_in_seconds / 1000;
time_series->points.emplace_back(x, y); bitrate_series.points.emplace_back(x, y);
} }
plot->AppendTimeSeries(std::move(bitrate_series));
// Overlay the send-side bandwidth estimate over the outgoing bitrate. // Overlay the send-side bandwidth estimate over the outgoing bitrate.
if (desired_direction == kOutgoingPacket) { if (desired_direction == kOutgoingPacket) {
TimeSeries* loss_series = TimeSeries loss_series("Loss-based estimate", LINE_STEP_GRAPH);
plot->AddTimeSeries("Loss-based estimate", LINE_STEP_GRAPH);
for (auto& loss_update : bwe_loss_updates_) { for (auto& loss_update : bwe_loss_updates_) {
float x = float x =
static_cast<float>(loss_update.timestamp - begin_time_) / 1000000; static_cast<float>(loss_update.timestamp - begin_time_) / 1000000;
float y = static_cast<float>(loss_update.new_bitrate) / 1000; float y = static_cast<float>(loss_update.new_bitrate) / 1000;
loss_series->points.emplace_back(x, y); loss_series.points.emplace_back(x, y);
} }
TimeSeries* delay_series = TimeSeries delay_series("Delay-based estimate", LINE_STEP_GRAPH);
plot->AddTimeSeries("Delay-based estimate", LINE_STEP_GRAPH);
for (auto& delay_update : bwe_delay_updates_) { for (auto& delay_update : bwe_delay_updates_) {
float x = float x =
static_cast<float>(delay_update.timestamp - begin_time_) / 1000000; static_cast<float>(delay_update.timestamp - begin_time_) / 1000000;
float y = static_cast<float>(delay_update.bitrate_bps) / 1000; float y = static_cast<float>(delay_update.bitrate_bps) / 1000;
delay_series->points.emplace_back(x, y); delay_series.points.emplace_back(x, y);
} }
TimeSeries* created_series = TimeSeries created_series("Probe cluster created.", DOT_GRAPH);
plot->AddTimeSeries("Probe cluster created.", DOT_GRAPH);
for (auto& cluster : bwe_probe_cluster_created_events_) { for (auto& cluster : bwe_probe_cluster_created_events_) {
float x = static_cast<float>(cluster.timestamp - begin_time_) / 1000000; float x = static_cast<float>(cluster.timestamp - begin_time_) / 1000000;
float y = static_cast<float>(cluster.bitrate_bps) / 1000; float y = static_cast<float>(cluster.bitrate_bps) / 1000;
created_series->points.emplace_back(x, y); created_series.points.emplace_back(x, y);
} }
TimeSeries* result_series = TimeSeries result_series("Probing results.", DOT_GRAPH);
plot->AddTimeSeries("Probing results.", DOT_GRAPH);
for (auto& result : bwe_probe_result_events_) { for (auto& result : bwe_probe_result_events_) {
if (result.bitrate_bps) { if (result.bitrate_bps) {
float x = static_cast<float>(result.timestamp - begin_time_) / 1000000; float x = static_cast<float>(result.timestamp - begin_time_) / 1000000;
float y = static_cast<float>(*result.bitrate_bps) / 1000; float y = static_cast<float>(*result.bitrate_bps) / 1000;
result_series->points.emplace_back(x, y); result_series.points.emplace_back(x, y);
} }
} }
plot->AppendTimeSeries(std::move(loss_series));
plot->AppendTimeSeries(std::move(delay_series));
plot->AppendTimeSeries(std::move(created_series));
plot->AppendTimeSeries(std::move(result_series));
} }
plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin);
@ -1000,7 +1001,7 @@ void EventLogAnalyzer::CreateStreamBitrateGraph(
}, },
packet_stream, begin_time_, end_time_, window_duration_, step_, packet_stream, begin_time_, end_time_, window_duration_, step_,
&time_series); &time_series);
plot->series_list_.push_back(std::move(time_series)); plot->AppendTimeSeries(std::move(time_series));
} }
plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin);
@ -1126,8 +1127,8 @@ void EventLogAnalyzer::CreateBweSimulationGraph(Plot* plot) {
time_us = std::min({NextRtpTime(), NextRtcpTime(), NextProcessTime()}); time_us = std::min({NextRtpTime(), NextRtcpTime(), NextProcessTime()});
} }
// Add the data set to the plot. // Add the data set to the plot.
plot->series_list_.push_back(std::move(time_series)); plot->AppendTimeSeries(std::move(time_series));
plot->series_list_.push_back(std::move(acked_time_series)); plot->AppendTimeSeries(std::move(acked_time_series));
plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin);
plot->SetSuggestedYAxis(0, 10, "Bitrate (kbps)", kBottomMargin, kTopMargin); plot->SetSuggestedYAxis(0, 10, "Bitrate (kbps)", kBottomMargin, kTopMargin);
@ -1217,7 +1218,7 @@ void EventLogAnalyzer::CreateNetworkDelayFeedbackGraph(Plot* plot) {
for (TimeSeriesPoint& point : time_series.points) for (TimeSeriesPoint& point : time_series.points)
point.y -= estimated_base_delay_ms; point.y -= estimated_base_delay_ms;
// Add the data set to the plot. // Add the data set to the plot.
plot->series_list_.push_back(std::move(time_series)); plot->AppendTimeSeries(std::move(time_series));
plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin);
plot->SetSuggestedYAxis(0, 10, "Delay (ms)", kBottomMargin, kTopMargin); plot->SetSuggestedYAxis(0, 10, "Delay (ms)", kBottomMargin, kTopMargin);
@ -1265,7 +1266,7 @@ void EventLogAnalyzer::CreateTimestampGraph(Plot* plot) {
float y = packet.header.timestamp; float y = packet.header.timestamp;
timestamp_data.points.emplace_back(x, y); timestamp_data.points.emplace_back(x, y);
} }
plot->series_list_.push_back(std::move(timestamp_data)); plot->AppendTimeSeries(std::move(timestamp_data));
} }
{ {
@ -1283,7 +1284,7 @@ void EventLogAnalyzer::CreateTimestampGraph(Plot* plot) {
float y = sr->rtp_timestamp(); float y = sr->rtp_timestamp();
timestamp_data.points.emplace_back(x, y); timestamp_data.points.emplace_back(x, y);
} }
plot->series_list_.push_back(std::move(timestamp_data)); plot->AppendTimeSeries(std::move(timestamp_data));
} }
} }
} }
@ -1294,8 +1295,7 @@ void EventLogAnalyzer::CreateTimestampGraph(Plot* plot) {
} }
void EventLogAnalyzer::CreateAudioEncoderTargetBitrateGraph(Plot* plot) { void EventLogAnalyzer::CreateAudioEncoderTargetBitrateGraph(Plot* plot) {
TimeSeries* time_series = TimeSeries time_series("Audio encoder target bitrate", LINE_DOT_GRAPH);
plot->AddTimeSeries("Audio encoder target bitrate", LINE_DOT_GRAPH);
ProcessPoints<AudioNetworkAdaptationEvent>( ProcessPoints<AudioNetworkAdaptationEvent>(
[](const AudioNetworkAdaptationEvent& ana_event) -> rtc::Optional<float> { [](const AudioNetworkAdaptationEvent& ana_event) -> rtc::Optional<float> {
if (ana_event.config.bitrate_bps) if (ana_event.config.bitrate_bps)
@ -1303,15 +1303,15 @@ void EventLogAnalyzer::CreateAudioEncoderTargetBitrateGraph(Plot* plot) {
static_cast<float>(*ana_event.config.bitrate_bps)); static_cast<float>(*ana_event.config.bitrate_bps));
return rtc::Optional<float>(); return rtc::Optional<float>();
}, },
audio_network_adaptation_events_, begin_time_, time_series); audio_network_adaptation_events_, begin_time_, &time_series);
plot->AppendTimeSeries(std::move(time_series));
plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin);
plot->SetSuggestedYAxis(0, 1, "Bitrate (bps)", kBottomMargin, kTopMargin); plot->SetSuggestedYAxis(0, 1, "Bitrate (bps)", kBottomMargin, kTopMargin);
plot->SetTitle("Reported audio encoder target bitrate"); plot->SetTitle("Reported audio encoder target bitrate");
} }
void EventLogAnalyzer::CreateAudioEncoderFrameLengthGraph(Plot* plot) { void EventLogAnalyzer::CreateAudioEncoderFrameLengthGraph(Plot* plot) {
TimeSeries* time_series = TimeSeries time_series("Audio encoder frame length", LINE_DOT_GRAPH);
plot->AddTimeSeries("Audio encoder frame length", LINE_DOT_GRAPH);
ProcessPoints<AudioNetworkAdaptationEvent>( ProcessPoints<AudioNetworkAdaptationEvent>(
[](const AudioNetworkAdaptationEvent& ana_event) { [](const AudioNetworkAdaptationEvent& ana_event) {
if (ana_event.config.frame_length_ms) if (ana_event.config.frame_length_ms)
@ -1319,7 +1319,8 @@ void EventLogAnalyzer::CreateAudioEncoderFrameLengthGraph(Plot* plot) {
static_cast<float>(*ana_event.config.frame_length_ms)); static_cast<float>(*ana_event.config.frame_length_ms));
return rtc::Optional<float>(); return rtc::Optional<float>();
}, },
audio_network_adaptation_events_, begin_time_, time_series); audio_network_adaptation_events_, begin_time_, &time_series);
plot->AppendTimeSeries(std::move(time_series));
plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin);
plot->SetSuggestedYAxis(0, 1, "Frame length (ms)", kBottomMargin, kTopMargin); plot->SetSuggestedYAxis(0, 1, "Frame length (ms)", kBottomMargin, kTopMargin);
plot->SetTitle("Reported audio encoder frame length"); plot->SetTitle("Reported audio encoder frame length");
@ -1327,8 +1328,8 @@ void EventLogAnalyzer::CreateAudioEncoderFrameLengthGraph(Plot* plot) {
void EventLogAnalyzer::CreateAudioEncoderUplinkPacketLossFractionGraph( void EventLogAnalyzer::CreateAudioEncoderUplinkPacketLossFractionGraph(
Plot* plot) { Plot* plot) {
TimeSeries* time_series = plot->AddTimeSeries( TimeSeries time_series("Audio encoder uplink packet loss fraction",
"Audio encoder uplink packet loss fraction", LINE_DOT_GRAPH); LINE_DOT_GRAPH);
ProcessPoints<AudioNetworkAdaptationEvent>( ProcessPoints<AudioNetworkAdaptationEvent>(
[](const AudioNetworkAdaptationEvent& ana_event) { [](const AudioNetworkAdaptationEvent& ana_event) {
if (ana_event.config.uplink_packet_loss_fraction) if (ana_event.config.uplink_packet_loss_fraction)
@ -1336,7 +1337,8 @@ void EventLogAnalyzer::CreateAudioEncoderUplinkPacketLossFractionGraph(
*ana_event.config.uplink_packet_loss_fraction)); *ana_event.config.uplink_packet_loss_fraction));
return rtc::Optional<float>(); return rtc::Optional<float>();
}, },
audio_network_adaptation_events_, begin_time_, time_series); audio_network_adaptation_events_, begin_time_, &time_series);
plot->AppendTimeSeries(std::move(time_series));
plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin);
plot->SetSuggestedYAxis(0, 10, "Percent lost packets", kBottomMargin, plot->SetSuggestedYAxis(0, 10, "Percent lost packets", kBottomMargin,
kTopMargin); kTopMargin);
@ -1344,8 +1346,7 @@ void EventLogAnalyzer::CreateAudioEncoderUplinkPacketLossFractionGraph(
} }
void EventLogAnalyzer::CreateAudioEncoderEnableFecGraph(Plot* plot) { void EventLogAnalyzer::CreateAudioEncoderEnableFecGraph(Plot* plot) {
TimeSeries* time_series = TimeSeries time_series("Audio encoder FEC", LINE_DOT_GRAPH);
plot->AddTimeSeries("Audio encoder FEC", LINE_DOT_GRAPH);
ProcessPoints<AudioNetworkAdaptationEvent>( ProcessPoints<AudioNetworkAdaptationEvent>(
[](const AudioNetworkAdaptationEvent& ana_event) { [](const AudioNetworkAdaptationEvent& ana_event) {
if (ana_event.config.enable_fec) if (ana_event.config.enable_fec)
@ -1353,15 +1354,15 @@ void EventLogAnalyzer::CreateAudioEncoderEnableFecGraph(Plot* plot) {
static_cast<float>(*ana_event.config.enable_fec)); static_cast<float>(*ana_event.config.enable_fec));
return rtc::Optional<float>(); return rtc::Optional<float>();
}, },
audio_network_adaptation_events_, begin_time_, time_series); audio_network_adaptation_events_, begin_time_, &time_series);
plot->AppendTimeSeries(std::move(time_series));
plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin);
plot->SetSuggestedYAxis(0, 1, "FEC (false/true)", kBottomMargin, kTopMargin); plot->SetSuggestedYAxis(0, 1, "FEC (false/true)", kBottomMargin, kTopMargin);
plot->SetTitle("Reported audio encoder FEC"); plot->SetTitle("Reported audio encoder FEC");
} }
void EventLogAnalyzer::CreateAudioEncoderEnableDtxGraph(Plot* plot) { void EventLogAnalyzer::CreateAudioEncoderEnableDtxGraph(Plot* plot) {
TimeSeries* time_series = TimeSeries time_series("Audio encoder DTX", LINE_DOT_GRAPH);
plot->AddTimeSeries("Audio encoder DTX", LINE_DOT_GRAPH);
ProcessPoints<AudioNetworkAdaptationEvent>( ProcessPoints<AudioNetworkAdaptationEvent>(
[](const AudioNetworkAdaptationEvent& ana_event) { [](const AudioNetworkAdaptationEvent& ana_event) {
if (ana_event.config.enable_dtx) if (ana_event.config.enable_dtx)
@ -1369,15 +1370,15 @@ void EventLogAnalyzer::CreateAudioEncoderEnableDtxGraph(Plot* plot) {
static_cast<float>(*ana_event.config.enable_dtx)); static_cast<float>(*ana_event.config.enable_dtx));
return rtc::Optional<float>(); return rtc::Optional<float>();
}, },
audio_network_adaptation_events_, begin_time_, time_series); audio_network_adaptation_events_, begin_time_, &time_series);
plot->AppendTimeSeries(std::move(time_series));
plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin);
plot->SetSuggestedYAxis(0, 1, "DTX (false/true)", kBottomMargin, kTopMargin); plot->SetSuggestedYAxis(0, 1, "DTX (false/true)", kBottomMargin, kTopMargin);
plot->SetTitle("Reported audio encoder DTX"); plot->SetTitle("Reported audio encoder DTX");
} }
void EventLogAnalyzer::CreateAudioEncoderNumChannelsGraph(Plot* plot) { void EventLogAnalyzer::CreateAudioEncoderNumChannelsGraph(Plot* plot) {
TimeSeries* time_series = TimeSeries time_series("Audio encoder number of channels", LINE_DOT_GRAPH);
plot->AddTimeSeries("Audio encoder number of channels", LINE_DOT_GRAPH);
ProcessPoints<AudioNetworkAdaptationEvent>( ProcessPoints<AudioNetworkAdaptationEvent>(
[](const AudioNetworkAdaptationEvent& ana_event) { [](const AudioNetworkAdaptationEvent& ana_event) {
if (ana_event.config.num_channels) if (ana_event.config.num_channels)
@ -1385,7 +1386,8 @@ void EventLogAnalyzer::CreateAudioEncoderNumChannelsGraph(Plot* plot) {
static_cast<float>(*ana_event.config.num_channels)); static_cast<float>(*ana_event.config.num_channels));
return rtc::Optional<float>(); return rtc::Optional<float>();
}, },
audio_network_adaptation_events_, begin_time_, time_series); audio_network_adaptation_events_, begin_time_, &time_series);
plot->AppendTimeSeries(std::move(time_series));
plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin);
plot->SetSuggestedYAxis(0, 1, "Number of channels (1 (mono)/2 (stereo))", plot->SetSuggestedYAxis(0, 1, "Number of channels (1 (mono)/2 (stereo))",
kBottomMargin, kTopMargin); kBottomMargin, kTopMargin);

View File

@ -71,14 +71,8 @@ void Plot::SetTitle(std::string title) {
title_ = title; title_ = title;
} }
TimeSeries* Plot::AddTimeSeries(const char* label, PlotStyle style) { void Plot::AppendTimeSeries(TimeSeries&& time_series) {
series_list_.emplace_back(label, style); series_list_.emplace_back(std::move(time_series));
return &series_list_.back();
}
TimeSeries* Plot::AddTimeSeries(const std::string& label, PlotStyle style) {
series_list_.emplace_back(label, style);
return &series_list_.back();
} }
} // namespace plotting } // namespace plotting

View File

@ -34,10 +34,9 @@ struct TimeSeriesPoint {
struct TimeSeries { struct TimeSeries {
TimeSeries() = default; TimeSeries() = default;
TimeSeries(const char* label, PlotStyle style) TimeSeries(const char* label, PlotStyle style) : label(label), style(style) {}
: label(label), style(style), points() {}
TimeSeries(const std::string& label, PlotStyle style) TimeSeries(const std::string& label, PlotStyle style)
: label(label), style(style), points() {} : label(label), style(style) {}
TimeSeries(TimeSeries&& other) TimeSeries(TimeSeries&& other)
: label(std::move(other.label)), : label(std::move(other.label)),
style(other.style), style(other.style),
@ -108,10 +107,7 @@ class Plot {
void SetTitle(std::string title); void SetTitle(std::string title);
// Add a new TimeSeries to the plot. // Add a new TimeSeries to the plot.
TimeSeries* AddTimeSeries(const char* label, PlotStyle style); void AppendTimeSeries(TimeSeries&& time_series);
TimeSeries* AddTimeSeries(const std::string& label, PlotStyle style);
std::vector<TimeSeries> series_list_;
protected: protected:
float xaxis_min_; float xaxis_min_;
@ -121,6 +117,7 @@ class Plot {
float yaxis_max_; float yaxis_max_;
std::string yaxis_label_; std::string yaxis_label_;
std::string title_; std::string title_;
std::vector<TimeSeries> series_list_;
}; };
class PlotCollection { class PlotCollection {

View File

@ -33,6 +33,7 @@ void PythonPlot::Draw() {
printf("rgb_colors = [colorsys.hls_to_rgb(*hls) for hls in hls_colors]\n"); printf("rgb_colors = [colorsys.hls_to_rgb(*hls) for hls in hls_colors]\n");
for (size_t i = 0; i < series_list_.size(); i++) { for (size_t i = 0; i < series_list_.size(); i++) {
printf("\n# === Series: %s ===\n", series_list_[i].label.c_str());
// List x coordinates // List x coordinates
printf("x%zu = [", i); printf("x%zu = [", i);
if (series_list_[i].points.size() > 0) if (series_list_[i].points.size() > 0)