Renamed and restructured the protobuf definitions for the rtc_event_log graphs.

BUG=

Review-Url: https://codereview.webrtc.org/2310403002
Cr-Commit-Position: refs/heads/master@{#14112}
This commit is contained in:
skvlad 2016-09-07 11:15:37 -07:00 committed by Commit bot
parent a4d40cb502
commit f581eb76f4
6 changed files with 65 additions and 59 deletions

View File

@ -136,9 +136,9 @@ rtc_executable("force_mic_volume_max") {
}
if (rtc_enable_protobuf) {
proto_library("graph_proto") {
proto_library("chart_proto") {
sources = [
"event_log_visualizer/graph.proto",
"event_log_visualizer/chart.proto",
]
proto_out_dir = "webrtc/tools/event_log_visualizer"
}
@ -169,7 +169,7 @@ if (rtc_enable_protobuf) {
"//build/config/sanitizers:deps",
]
public_deps = [
":graph_proto",
":chart_proto",
"../:rtc_event_log_parser",
]
}

View File

@ -0,0 +1,36 @@
// Describes a chart generated from WebRTC event log data.
syntax = "proto3";
option optimize_for = LITE_RUNTIME;
package webrtc.analytics;
message ChartStyle {
enum Type {
UNDEFINED = 0;
LINE_CHART = 1;
BAR_CHART = 2;
}
}
message DataSet {
repeated float x_values = 1;
repeated float y_values = 2;
string label = 3;
ChartStyle.Type style = 4;
bool highlight_points = 5;
}
message Chart {
repeated DataSet data_sets = 1;
float xaxis_min = 2;
float xaxis_max = 3;
string xaxis_label = 4;
float yaxis_min = 5;
float yaxis_max = 6;
string yaxis_label = 7;
string title = 8;
}
message ChartCollection {
repeated Chart charts = 1;
}

View File

@ -1,32 +0,0 @@
syntax = "proto2";
option optimize_for = LITE_RUNTIME;
package webrtc.protobuf_plot;
enum PlotStyle {
UNDEFINED = 0;
LINE_GRAPH = 1;
LINE_DOT_GRAPH = 2;
BAR_GRAPH = 3;
};
message DataSet {
repeated float xvalues = 1;
repeated float yvalues = 2;
optional string label = 3;
optional PlotStyle style = 4;
}
message Plot {
repeated DataSet data_sets = 1;
optional float xaxis_min = 2;
optional float xaxis_max = 3;
optional string xaxis_label = 4;
optional float yaxis_min = 5;
optional float yaxis_max = 6;
optional string yaxis_label = 7;
optional string title = 8;
}
message PlotCollection {
repeated Plot plots = 1;
}

View File

@ -21,36 +21,37 @@ ProtobufPlot::~ProtobufPlot() {}
void ProtobufPlot::Draw() {}
void ProtobufPlot::ExportProtobuf(protobuf_plot::Plot* plot) {
void ProtobufPlot::ExportProtobuf(webrtc::analytics::Chart* chart) {
for (size_t i = 0; i < series_list_.size(); i++) {
protobuf_plot::DataSet* data_set = plot->add_data_sets();
webrtc::analytics::DataSet* data_set = chart->add_data_sets();
for (const auto& point : series_list_[i].points) {
data_set->add_xvalues(point.x);
data_set->add_x_values(point.x);
}
for (const auto& point : series_list_[i].points) {
data_set->add_yvalues(point.y);
data_set->add_y_values(point.y);
}
if (series_list_[i].style == BAR_GRAPH) {
data_set->set_style(protobuf_plot::BAR_GRAPH);
data_set->set_style(webrtc::analytics::ChartStyle::BAR_CHART);
} else if (series_list_[i].style == LINE_GRAPH) {
data_set->set_style(protobuf_plot::LINE_GRAPH);
data_set->set_style(webrtc::analytics::ChartStyle::LINE_CHART);
} else if (series_list_[i].style == LINE_DOT_GRAPH) {
data_set->set_style(protobuf_plot::LINE_DOT_GRAPH);
data_set->set_style(webrtc::analytics::ChartStyle::LINE_CHART);
data_set->set_highlight_points(true);
} else {
data_set->set_style(protobuf_plot::UNDEFINED);
data_set->set_style(webrtc::analytics::ChartStyle::UNDEFINED);
}
data_set->set_label(series_list_[i].label);
}
plot->set_xaxis_min(xaxis_min_);
plot->set_xaxis_max(xaxis_max_);
plot->set_yaxis_min(yaxis_min_);
plot->set_yaxis_max(yaxis_max_);
plot->set_xaxis_label(xaxis_label_);
plot->set_yaxis_label(yaxis_label_);
plot->set_title(title_);
chart->set_xaxis_min(xaxis_min_);
chart->set_xaxis_max(xaxis_max_);
chart->set_yaxis_min(yaxis_min_);
chart->set_yaxis_max(yaxis_max_);
chart->set_xaxis_label(xaxis_label_);
chart->set_yaxis_label(yaxis_label_);
chart->set_title(title_);
}
ProtobufPlotCollection::ProtobufPlotCollection() {}
@ -60,12 +61,13 @@ ProtobufPlotCollection::~ProtobufPlotCollection() {}
void ProtobufPlotCollection::Draw() {}
void ProtobufPlotCollection::ExportProtobuf(
protobuf_plot::PlotCollection* collection) {
webrtc::analytics::ChartCollection* collection) {
for (const auto& plot : plots_) {
// TODO(terelius): Ensure that there is no way to insert plots other than
// ProtobufPlots in a ProtobufPlotCollection. Needed to safely static_cast
// here.
protobuf_plot::Plot* protobuf_representation = collection->add_plots();
webrtc::analytics::Chart* protobuf_representation
= collection->add_charts();
static_cast<ProtobufPlot*>(plot.get())
->ExportProtobuf(protobuf_representation);
}

View File

@ -10,7 +10,7 @@
#ifndef WEBRTC_TOOLS_EVENT_LOG_VISUALIZER_PLOT_PROTOBUF_H_
#define WEBRTC_TOOLS_EVENT_LOG_VISUALIZER_PLOT_PROTOBUF_H_
#include "webrtc/tools/event_log_visualizer/graph.pb.h"
#include "webrtc/tools/event_log_visualizer/chart.pb.h"
#include "webrtc/tools/event_log_visualizer/plot_base.h"
namespace webrtc {
@ -21,7 +21,7 @@ class ProtobufPlot final : public Plot {
ProtobufPlot();
~ProtobufPlot() override;
void Draw() override;
void ExportProtobuf(protobuf_plot::Plot* plot);
void ExportProtobuf(webrtc::analytics::Chart* chart);
};
class ProtobufPlotCollection final : public PlotCollection {
@ -30,7 +30,7 @@ class ProtobufPlotCollection final : public PlotCollection {
~ProtobufPlotCollection() override;
void Draw() override;
Plot* AppendNewPlot() override;
void ExportProtobuf(protobuf_plot::PlotCollection* collection);
void ExportProtobuf(webrtc::analytics::ChartCollection* collection);
};
} // namespace plotting

View File

@ -102,10 +102,10 @@
['enable_protobuf==1', {
'targets': [
{
'target_name': 'graph_proto',
'target_name': 'chart_proto',
'type': 'static_library',
'sources': [
'event_log_visualizer/graph.proto',
'event_log_visualizer/chart.proto',
],
'variables': {
'proto_in_dir': 'event_log_visualizer',
@ -123,7 +123,7 @@
'<(webrtc_root)/modules/modules.gyp:congestion_controller',
'<(webrtc_root)/modules/modules.gyp:rtp_rtcp',
'<(webrtc_root)/system_wrappers/system_wrappers.gyp:metrics_default',
':graph_proto',
':chart_proto',
],
'sources': [
'event_log_visualizer/analyzer.cc',
@ -137,7 +137,7 @@
],
'export_dependent_settings': [
'<(webrtc_root)/webrtc.gyp:rtc_event_log_parser',
':graph_proto',
':chart_proto',
],
},
],