Pass label and plot style to the TimeSeries' constructor.

BUG=webrtc:7323

Review-Url: https://codereview.webrtc.org/2750583002
Cr-Commit-Position: refs/heads/master@{#17237}
This commit is contained in:
terelius
2017-03-15 01:59:12 -07:00
committed by Commit bot
parent 5d389dbde0
commit 23c595adba
3 changed files with 65 additions and 91 deletions

View File

@ -572,9 +572,7 @@ void EventLogAnalyzer::CreatePacketGraph(PacketDirection desired_direction,
continue; continue;
} }
TimeSeries time_series; TimeSeries time_series(GetStreamName(stream_id), BAR_GRAPH);
time_series.label = GetStreamName(stream_id);
time_series.style = BAR_GRAPH;
ProcessPoints<LoggedRtpPacket>( ProcessPoints<LoggedRtpPacket>(
[](const LoggedRtpPacket& packet) -> rtc::Optional<float> { [](const LoggedRtpPacket& packet) -> rtc::Optional<float> {
return rtc::Optional<float>(packet.total_length); return rtc::Optional<float>(packet.total_length);
@ -608,10 +606,8 @@ void EventLogAnalyzer::CreateAccumulatedPacketsTimeSeries(
continue; continue;
} }
TimeSeries time_series; std::string label = label_prefix + " " + GetStreamName(stream_id);
time_series.label = label_prefix + " " + GetStreamName(stream_id); TimeSeries time_series(label, LINE_STEP_GRAPH);
time_series.style = LINE_STEP_GRAPH;
for (size_t i = 0; i < packet_stream.size(); i++) { for (size_t i = 0; i < packet_stream.size(); i++) {
float x = static_cast<float>(packet_stream[i].timestamp - begin_time_) / float x = static_cast<float>(packet_stream[i].timestamp - begin_time_) /
1000000; 1000000;
@ -722,9 +718,7 @@ void EventLogAnalyzer::CreateSequenceNumberGraph(Plot* plot) {
continue; continue;
} }
TimeSeries time_series; TimeSeries time_series(GetStreamName(stream_id), BAR_GRAPH);
time_series.label = GetStreamName(stream_id);
time_series.style = BAR_GRAPH;
ProcessPairs<LoggedRtpPacket, float>( ProcessPairs<LoggedRtpPacket, float>(
[](const LoggedRtpPacket& old_packet, [](const LoggedRtpPacket& old_packet,
const LoggedRtpPacket& new_packet) { const LoggedRtpPacket& new_packet) {
@ -754,9 +748,7 @@ void EventLogAnalyzer::CreateIncomingPacketLossGraph(Plot* plot) {
continue; continue;
} }
TimeSeries time_series; TimeSeries time_series(GetStreamName(stream_id), LINE_DOT_GRAPH);
time_series.label = GetStreamName(stream_id);
time_series.style = LINE_DOT_GRAPH;
const uint64_t kWindowUs = 1000000; const uint64_t kWindowUs = 1000000;
const uint64_t kStep = 1000000; const uint64_t kStep = 1000000;
SequenceNumberUnwrapper unwrapper_; SequenceNumberUnwrapper unwrapper_;
@ -814,17 +806,15 @@ void EventLogAnalyzer::CreateDelayChangeGraph(Plot* plot) {
continue; continue;
} }
TimeSeries capture_time_data; TimeSeries capture_time_data(GetStreamName(stream_id) + " capture-time",
capture_time_data.label = GetStreamName(stream_id) + " capture-time"; BAR_GRAPH);
capture_time_data.style = BAR_GRAPH;
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->series_list_.push_back(std::move(capture_time_data));
TimeSeries send_time_data; TimeSeries send_time_data(GetStreamName(stream_id) + " abs-send-time",
send_time_data.label = GetStreamName(stream_id) + " abs-send-time"; BAR_GRAPH);
send_time_data.style = 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);
@ -849,17 +839,15 @@ void EventLogAnalyzer::CreateAccumulatedDelayChangeGraph(Plot* plot) {
continue; continue;
} }
TimeSeries capture_time_data; TimeSeries capture_time_data(GetStreamName(stream_id) + " capture-time",
capture_time_data.label = GetStreamName(stream_id) + " capture-time"; LINE_GRAPH);
capture_time_data.style = LINE_GRAPH;
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->series_list_.push_back(std::move(capture_time_data));
TimeSeries send_time_data; TimeSeries send_time_data(GetStreamName(stream_id) + " abs-send-time",
send_time_data.label = GetStreamName(stream_id) + " abs-send-time"; LINE_GRAPH);
send_time_data.style = 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);
@ -874,14 +862,13 @@ 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) {
plot->series_list_.push_back(TimeSeries()); TimeSeries* time_series =
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;
plot->series_list_.back().points.emplace_back(x, y); time_series->points.emplace_back(x, y);
} }
plot->series_list_.back().label = "Fraction lost";
plot->series_list_.back().style = LINE_DOT_GRAPH;
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,
@ -921,7 +908,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.
plot->series_list_.push_back(TimeSeries()); TimeSeries* time_series = plot->AddTimeSeries("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) {
@ -938,28 +925,19 @@ 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;
plot->series_list_.back().points.push_back(TimeSeriesPoint(x, y)); time_series->points.emplace_back(x, y);
} }
// Set labels.
if (desired_direction == webrtc::PacketDirection::kIncomingPacket) {
plot->series_list_.back().label = "Incoming bitrate";
} else if (desired_direction == webrtc::PacketDirection::kOutgoingPacket) {
plot->series_list_.back().label = "Outgoing bitrate";
}
plot->series_list_.back().style = LINE_GRAPH;
// 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) {
plot->series_list_.push_back(TimeSeries()); TimeSeries* time_series =
plot->AddTimeSeries("Loss-based estimate", LINE_STEP_GRAPH);
for (auto& bwe_update : bwe_loss_updates_) { for (auto& bwe_update : bwe_loss_updates_) {
float x = float x =
static_cast<float>(bwe_update.timestamp - begin_time_) / 1000000; static_cast<float>(bwe_update.timestamp - begin_time_) / 1000000;
float y = static_cast<float>(bwe_update.new_bitrate) / 1000; float y = static_cast<float>(bwe_update.new_bitrate) / 1000;
plot->series_list_.back().points.emplace_back(x, y); time_series->points.emplace_back(x, y);
} }
plot->series_list_.back().label = "Loss-based estimate";
plot->series_list_.back().style = LINE_STEP_GRAPH;
} }
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 (kbps)", kBottomMargin, kTopMargin); plot->SetSuggestedYAxis(0, 1, "Bitrate (kbps)", kBottomMargin, kTopMargin);
@ -983,9 +961,7 @@ void EventLogAnalyzer::CreateStreamBitrateGraph(
continue; continue;
} }
TimeSeries time_series; TimeSeries time_series(GetStreamName(stream_id), LINE_GRAPH);
time_series.label = GetStreamName(stream_id);
time_series.style = LINE_GRAPH;
MovingAverage<LoggedRtpPacket, double>( MovingAverage<LoggedRtpPacket, double>(
[](const LoggedRtpPacket& packet) { [](const LoggedRtpPacket& packet) {
return rtc::Optional<double>(packet.total_length * 8.0 / 1000.0); return rtc::Optional<double>(packet.total_length * 8.0 / 1000.0);
@ -1033,12 +1009,8 @@ void EventLogAnalyzer::CreateBweSimulationGraph(Plot* plot) {
static const uint32_t kDefaultStartBitrateBps = 300000; static const uint32_t kDefaultStartBitrateBps = 300000;
cc.SetBweBitrates(0, kDefaultStartBitrateBps, -1); cc.SetBweBitrates(0, kDefaultStartBitrateBps, -1);
TimeSeries time_series; TimeSeries time_series("Delay-based estimate", LINE_DOT_GRAPH);
time_series.label = "Delay-based estimate"; TimeSeries acked_time_series("Acked bitrate", LINE_DOT_GRAPH);
time_series.style = LINE_DOT_GRAPH;
TimeSeries acked_time_series;
acked_time_series.label = "Acked bitrate";
acked_time_series.style = LINE_DOT_GRAPH;
auto rtp_iterator = outgoing_rtp.begin(); auto rtp_iterator = outgoing_rtp.begin();
auto rtcp_iterator = incoming_rtcp.begin(); auto rtcp_iterator = incoming_rtcp.begin();
@ -1151,9 +1123,7 @@ void EventLogAnalyzer::CreateNetworkDelayFeedbackGraph(Plot* plot) {
SimulatedClock clock(0); SimulatedClock clock(0);
TransportFeedbackAdapter feedback_adapter(&clock); TransportFeedbackAdapter feedback_adapter(&clock);
TimeSeries time_series; TimeSeries time_series("Network Delay Change", LINE_DOT_GRAPH);
time_series.label = "Network Delay Change";
time_series.style = LINE_DOT_GRAPH;
int64_t estimated_base_delay_ms = std::numeric_limits<int64_t>::max(); int64_t estimated_base_delay_ms = std::numeric_limits<int64_t>::max();
auto rtp_iterator = outgoing_rtp.begin(); auto rtp_iterator = outgoing_rtp.begin();
@ -1254,9 +1224,8 @@ void EventLogAnalyzer::CreateTimestampGraph(Plot* plot) {
StreamId stream_id = kv.first; StreamId stream_id = kv.first;
{ {
TimeSeries timestamp_data; TimeSeries timestamp_data(GetStreamName(stream_id) + " capture-time",
timestamp_data.label = GetStreamName(stream_id) + " capture-time"; LINE_DOT_GRAPH);
timestamp_data.style = LINE_DOT_GRAPH;
for (LoggedRtpPacket packet : rtp_packets) { for (LoggedRtpPacket packet : rtp_packets) {
float x = static_cast<float>(packet.timestamp - begin_time_) / 1000000; float x = static_cast<float>(packet.timestamp - begin_time_) / 1000000;
float y = packet.header.timestamp; float y = packet.header.timestamp;
@ -1269,9 +1238,8 @@ void EventLogAnalyzer::CreateTimestampGraph(Plot* plot) {
auto kv = rtcp_packets_.find(stream_id); auto kv = rtcp_packets_.find(stream_id);
if (kv != rtcp_packets_.end()) { if (kv != rtcp_packets_.end()) {
const auto& packets = kv->second; const auto& packets = kv->second;
TimeSeries timestamp_data; TimeSeries timestamp_data(
timestamp_data.label = GetStreamName(stream_id) + " rtcp capture-time"; GetStreamName(stream_id) + " rtcp capture-time", LINE_DOT_GRAPH);
timestamp_data.style = LINE_DOT_GRAPH;
for (const LoggedRtcpPacket& rtcp : packets) { for (const LoggedRtcpPacket& rtcp : packets) {
if (rtcp.type != kRtcpSr) if (rtcp.type != kRtcpSr)
continue; continue;
@ -1292,9 +1260,8 @@ void EventLogAnalyzer::CreateTimestampGraph(Plot* plot) {
} }
void EventLogAnalyzer::CreateAudioEncoderTargetBitrateGraph(Plot* plot) { void EventLogAnalyzer::CreateAudioEncoderTargetBitrateGraph(Plot* plot) {
plot->series_list_.push_back(TimeSeries()); TimeSeries* time_series =
plot->series_list_.back().style = LINE_DOT_GRAPH; plot->AddTimeSeries("Audio encoder target bitrate", LINE_DOT_GRAPH);
plot->series_list_.back().label = "Audio encoder target bitrate";
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)
@ -1302,17 +1269,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_, audio_network_adaptation_events_, begin_time_, time_series);
&plot->series_list_.back());
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) {
plot->series_list_.push_back(TimeSeries()); TimeSeries* time_series =
plot->series_list_.back().style = LINE_DOT_GRAPH; plot->AddTimeSeries("Audio encoder frame length", LINE_DOT_GRAPH);
plot->series_list_.back().label = "Audio encoder frame length";
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)
@ -1320,8 +1285,7 @@ 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_, audio_network_adaptation_events_, begin_time_, time_series);
&plot->series_list_.back());
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");
@ -1329,9 +1293,8 @@ void EventLogAnalyzer::CreateAudioEncoderFrameLengthGraph(Plot* plot) {
void EventLogAnalyzer::CreateAudioEncoderUplinkPacketLossFractionGraph( void EventLogAnalyzer::CreateAudioEncoderUplinkPacketLossFractionGraph(
Plot* plot) { Plot* plot) {
plot->series_list_.push_back(TimeSeries()); TimeSeries* time_series = plot->AddTimeSeries(
plot->series_list_.back().style = LINE_DOT_GRAPH; "Audio encoder uplink packet loss fraction", LINE_DOT_GRAPH);
plot->series_list_.back().label = "Audio encoder uplink packet loss fraction";
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)
@ -1339,8 +1302,7 @@ 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_, audio_network_adaptation_events_, begin_time_, time_series);
&plot->series_list_.back());
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);
@ -1348,9 +1310,8 @@ void EventLogAnalyzer::CreateAudioEncoderUplinkPacketLossFractionGraph(
} }
void EventLogAnalyzer::CreateAudioEncoderEnableFecGraph(Plot* plot) { void EventLogAnalyzer::CreateAudioEncoderEnableFecGraph(Plot* plot) {
plot->series_list_.push_back(TimeSeries()); TimeSeries* time_series =
plot->series_list_.back().style = LINE_DOT_GRAPH; plot->AddTimeSeries("Audio encoder FEC", LINE_DOT_GRAPH);
plot->series_list_.back().label = "Audio encoder FEC";
ProcessPoints<AudioNetworkAdaptationEvent>( ProcessPoints<AudioNetworkAdaptationEvent>(
[](const AudioNetworkAdaptationEvent& ana_event) { [](const AudioNetworkAdaptationEvent& ana_event) {
if (ana_event.config.enable_fec) if (ana_event.config.enable_fec)
@ -1358,17 +1319,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_, audio_network_adaptation_events_, begin_time_, time_series);
&plot->series_list_.back());
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) {
plot->series_list_.push_back(TimeSeries()); TimeSeries* time_series =
plot->series_list_.back().style = LINE_DOT_GRAPH; plot->AddTimeSeries("Audio encoder DTX", LINE_DOT_GRAPH);
plot->series_list_.back().label = "Audio encoder DTX";
ProcessPoints<AudioNetworkAdaptationEvent>( ProcessPoints<AudioNetworkAdaptationEvent>(
[](const AudioNetworkAdaptationEvent& ana_event) { [](const AudioNetworkAdaptationEvent& ana_event) {
if (ana_event.config.enable_dtx) if (ana_event.config.enable_dtx)
@ -1376,17 +1335,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_, audio_network_adaptation_events_, begin_time_, time_series);
&plot->series_list_.back());
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) {
plot->series_list_.push_back(TimeSeries()); TimeSeries* time_series =
plot->series_list_.back().style = LINE_DOT_GRAPH; plot->AddTimeSeries("Audio encoder number of channels", LINE_DOT_GRAPH);
plot->series_list_.back().label = "Audio encoder number of channels";
ProcessPoints<AudioNetworkAdaptationEvent>( ProcessPoints<AudioNetworkAdaptationEvent>(
[](const AudioNetworkAdaptationEvent& ana_event) { [](const AudioNetworkAdaptationEvent& ana_event) {
if (ana_event.config.num_channels) if (ana_event.config.num_channels)
@ -1394,8 +1351,7 @@ 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_, audio_network_adaptation_events_, begin_time_, time_series);
&plot->series_list_.back());
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,5 +71,15 @@ void Plot::SetTitle(std::string title) {
title_ = title; title_ = title;
} }
TimeSeries* Plot::AddTimeSeries(const char* label, PlotStyle style) {
series_list_.emplace_back(label, style);
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
} // namespace webrtc } // namespace webrtc

View File

@ -28,6 +28,10 @@ struct TimeSeriesPoint {
struct TimeSeries { struct TimeSeries {
TimeSeries() = default; TimeSeries() = default;
TimeSeries(const char* label, PlotStyle style)
: label(label), style(style), points() {}
TimeSeries(const std::string& label, PlotStyle style)
: label(label), style(style), points() {}
TimeSeries(TimeSeries&& other) TimeSeries(TimeSeries&& other)
: label(std::move(other.label)), : label(std::move(other.label)),
style(other.style), style(other.style),
@ -97,6 +101,10 @@ class Plot {
// Sets the title of the plot. // Sets the title of the plot.
void SetTitle(std::string title); void SetTitle(std::string title);
// Add a new TimeSeries to the plot.
TimeSeries* AddTimeSeries(const char* label, PlotStyle style);
TimeSeries* AddTimeSeries(const std::string& label, PlotStyle style);
std::vector<TimeSeries> series_list_; std::vector<TimeSeries> series_list_;
protected: protected: