Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Unified Diff: webrtc/modules/remote_bitrate_estimator/test/packet_receiver.cc

Issue 1202253003: More Simulation Framework features (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Comments addressed Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/remote_bitrate_estimator/test/packet_receiver.cc
diff --git a/webrtc/modules/remote_bitrate_estimator/test/packet_receiver.cc b/webrtc/modules/remote_bitrate_estimator/test/packet_receiver.cc
index c13f14437a5239be926acfeb7d6b7a772d35f239..b7439a35910d2f7b0c548748358973e2544629db 100644
--- a/webrtc/modules/remote_bitrate_estimator/test/packet_receiver.cc
+++ b/webrtc/modules/remote_bitrate_estimator/test/packet_receiver.cc
@@ -10,7 +10,6 @@
#include "webrtc/modules/remote_bitrate_estimator/test/packet_receiver.h"
-#include <math.h>
#include <vector>
#include "testing/gtest/include/gtest/gtest.h"
@@ -34,21 +33,13 @@ PacketReceiver::PacketReceiver(PacketProcessorListener* listener,
delay_log_prefix_(),
metric_log_prefix_(),
packet_loss_log_prefix_(),
- last_delay_plot_ms_(0),
- last_metric_plot_ms_(0),
- last_packet_loss_plot_ms_(0),
- plot_delay_(plot_delay),
- // TODO(magalhaesc) Add separated plot_objective_function and
- // plot_packet_loss parameters to the constructor.
- plot_objective_function_(plot_delay),
- plot_packet_loss_(plot_delay),
+ available_capacity_log_prefix_(),
+ throughput_log_prefix_(),
bwe_receiver_(CreateBweReceiver(bwe_type, flow_id, plot_bwe)),
- total_delay_ms_(0),
- total_throughput_(0),
- number_packets_(0) {
+ metric_recorder_(NULL) {
// Setup the prefix ststd::rings used when logging.
std::stringstream ss1;
- ss1 << "Delay_" << flow_id << "#2";
+ ss1 << "Delay_ms_" << flow_id << "#2";
delay_log_prefix_ = ss1.str();
std::stringstream ss2;
@@ -58,6 +49,25 @@ PacketReceiver::PacketReceiver(PacketProcessorListener* listener,
std::stringstream ss3;
ss3 << "Packet_Loss_" << flow_id << "#2";
packet_loss_log_prefix_ = ss3.str();
+
+ // Plot Available capacity together with throughputs.
+ std::stringstream ss4;
+ ss4 << "Throughput_kbps" << flow_id << "#1";
+ available_capacity_log_prefix_ = ss4.str();
+
+ std::stringstream ss5;
+ ss5 << "Throughput_kbps_" << flow_id << "#2";
+ throughput_log_prefix_ = ss5.str();
+}
+
+PacketReceiver::PacketReceiver(PacketProcessorListener* listener,
+ int flow_id,
+ BandwidthEstimatorType bwe_type,
+ bool plot_delay,
+ bool plot_bwe,
+ MetricRecorder* metric_recorder)
+ : PacketReceiver(listener, flow_id, bwe_type, plot_delay, plot_bwe) {
+ metric_recorder_ = metric_recorder;
stefan-webrtc 2015/07/02 11:03:42 Set this in the initializer list.
magalhaesc 2015/07/02 17:06:19 Done.
}
PacketReceiver::~PacketReceiver() {
@@ -80,13 +90,21 @@ void PacketReceiver::RunFor(int64_t time_ms, Packets* in_out) {
int64_t arrival_time_ms = (media_packet->send_time_us() + 500) / 1000;
int64_t send_time_ms = (media_packet->creation_time_us() + 500) / 1000;
delay_stats_.Push(arrival_time_ms - send_time_ms);
- PlotDelay(arrival_time_ms, send_time_ms);
- PlotObjectiveFunction(arrival_time_ms);
- PlotPacketLoss(arrival_time_ms);
- total_delay_ms_ += arrival_time_ms - send_time_ms;
- total_throughput_ += media_packet->payload_size();
- ++number_packets_;
+ if (metric_recorder_ != NULL) {
stefan-webrtc 2015/07/02 11:03:41 nullptr
magalhaesc 2015/07/02 17:06:19 Done.
+ PlotDelay(arrival_time_ms, send_time_ms);
+ PlotThroughput(arrival_time_ms);
+ PlotTotalAvailableCapacity(arrival_time_ms);
+ PlotAvailableCapacityPerFlow(arrival_time_ms);
+ PlotObjectiveFunction(arrival_time_ms);
+ PlotPacketLoss(arrival_time_ms);
stefan-webrtc 2015/07/02 11:03:42 Just replace these with a single function called P
magalhaesc 2015/07/02 17:06:19 Done.
+
+ metric_recorder_->PushDelayMs(arrival_time_ms - send_time_ms,
+ arrival_time_ms);
+ metric_recorder_->PushThroughputBytes(media_packet->payload_size(),
+ arrival_time_ms);
stefan-webrtc 2015/07/02 11:03:42 Should we plot prior to adding new data? Maybe swi
magalhaesc 2015/07/02 17:06:19 The plots above are dynamics while the added date
+ metric_recorder_->Update(arrival_time_ms);
+ }
bwe_receiver_->ReceivePacket(arrival_time_ms, *media_packet);
FeedbackPacket* fb = bwe_receiver_->GetFeedback(arrival_time_ms);
@@ -103,45 +121,33 @@ void PacketReceiver::RunFor(int64_t time_ms, Packets* in_out) {
}
void PacketReceiver::PlotDelay(int64_t arrival_time_ms, int64_t send_time_ms) {
- static const int kDelayPlotIntervalMs = 100;
- if (!plot_delay_)
- return;
- if (arrival_time_ms - last_delay_plot_ms_ > kDelayPlotIntervalMs) {
- BWE_TEST_LOGGING_PLOT(0, delay_log_prefix_, arrival_time_ms,
- arrival_time_ms - send_time_ms);
- last_delay_plot_ms_ = arrival_time_ms;
- }
+ metric_recorder_->PlotDelay(delay_log_prefix_, arrival_time_ms,
+ arrival_time_ms - send_time_ms);
}
-double PacketReceiver::ObjectiveFunction() {
- const double kDelta = 1.0; // Delay penalty factor.
- double throughput_metric = log(static_cast<double>(total_throughput_));
- double delay_penalty = kDelta * log(static_cast<double>(total_delay_ms_));
- return throughput_metric - delay_penalty;
+void PacketReceiver::PlotThroughput(int64_t arrival_time_ms) {
+ metric_recorder_->PlotThroughput(throughput_log_prefix_, arrival_time_ms,
+ bwe_receiver_->RecentKbps());
+}
+
+void PacketReceiver::PlotTotalAvailableCapacity(int64_t arrival_time_ms) {
+ metric_recorder_->PlotTotalAvailableCapacity(available_capacity_log_prefix_,
+ arrival_time_ms);
+}
+
+void PacketReceiver::PlotAvailableCapacityPerFlow(int64_t arrival_time_ms) {
+ metric_recorder_->PlotAvailableCapacityPerFlow(available_capacity_log_prefix_,
+ arrival_time_ms);
}
void PacketReceiver::PlotObjectiveFunction(int64_t arrival_time_ms) {
- static const int kMetricPlotIntervalMs = 1000;
- if (!plot_objective_function_) {
- return;
- }
- if (arrival_time_ms - last_metric_plot_ms_ > kMetricPlotIntervalMs) {
- BWE_TEST_LOGGING_PLOT(1, metric_log_prefix_, arrival_time_ms,
- ObjectiveFunction());
- last_metric_plot_ms_ = arrival_time_ms;
- }
+ metric_recorder_->PlotObjective(metric_log_prefix_, arrival_time_ms);
}
void PacketReceiver::PlotPacketLoss(int64_t arrival_time_ms) {
- static const int kPacketLossPlotIntervalMs = 500;
- if (!plot_packet_loss_) {
- return;
- }
- if (arrival_time_ms - last_packet_loss_plot_ms_ > kPacketLossPlotIntervalMs) {
- BWE_TEST_LOGGING_PLOT(2, packet_loss_log_prefix_, arrival_time_ms,
- bwe_receiver_->RecentPacketLossRatio());
- last_packet_loss_plot_ms_ = arrival_time_ms;
- }
+ metric_recorder_->PlotLoss("Recent_" + packet_loss_log_prefix_,
+ arrival_time_ms,
+ bwe_receiver_->RecentPacketLossRatio());
}
Stats<double> PacketReceiver::GetDelayStats() const {

Powered by Google App Engine
This is Rietveld 408576698