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

Unified Diff: webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.h

Issue 1202253003: More Simulation Framework features (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressing trybot failures 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/bwe_test_framework.h
diff --git a/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.h b/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.h
index 9fb219d0851caa9e9aec863c11cabc6a3cbad6ab..964d4a0975b93ec27acc3ff12a8fb14c83a2dd7d 100644
--- a/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.h
+++ b/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.h
@@ -39,10 +39,34 @@ namespace testing {
namespace bwe {
class DelayCapHelper;
-class RateCounter;
+
+class RateCounter {
+ public:
+ RateCounter()
+ : kWindowSizeUs(1000 * 1000),
+ packets_per_second_(0),
+ bytes_per_second_(0),
+ last_accumulated_us_(0),
+ window_() {}
+
+ void UpdateRates(int64_t send_time_us, uint32_t payload_size);
+ uint32_t bits_per_second() const { return bytes_per_second_ * 8; }
+
+ uint32_t packets_per_second() const { return packets_per_second_; }
+
+ private:
+ typedef std::pair<int64_t, uint32_t> TimeSizePair;
+
+ const int64_t kWindowSizeUs;
+ uint32_t packets_per_second_;
+ uint32_t bytes_per_second_;
+ int64_t last_accumulated_us_;
+ std::list<TimeSizePair> window_;
+};
typedef std::set<int> FlowIds;
const FlowIds CreateFlowIds(const int *flow_ids_array, size_t num_flow_ids);
+const FlowIds CreateFlowIdRange(int initial_value, int last_value);
template <typename T>
bool DereferencingComparator(const T* const& a, const T* const& b) {
@@ -149,9 +173,15 @@ class Random {
// Return pseudo random number in the interval [0.0, 1.0].
float Rand();
+ // Return pseudo rounded random number in interval [low, high].
+ int Rand(int low, int high);
+
// Normal Distribution.
int Gaussian(int mean, int standard_deviation);
+ // Exponential Distribution.
+ int Exponential(float lambda);
+
// TODO(solenberg): Random from histogram.
// template<typename T> int Distribution(const std::vector<T> histogram) {
@@ -193,11 +223,17 @@ class PacketProcessor {
// Run simulation for |time_ms| milliseconds, consuming packets from, and
// producing packets into in_out. The outgoing packet list must be sorted on
- // |send_time_us_|. The simulation time |time_ms| is optional to use.
+ // |send_time_us_|. The simu lation time |time_ms| is optional to use.
stefan-webrtc 2015/06/25 14:44:04 simulation
magalhaesc 2015/07/01 12:48:40 Done.
virtual void RunFor(int64_t time_ms, Packets* in_out) = 0;
const FlowIds& flow_ids() const { return flow_ids_; }
+ uint32_t packets_per_second() const;
+ uint32_t bits_per_second() const;
+
+ protected:
+ rtc::scoped_ptr<RateCounter> rate_counter_;
+
private:
PacketProcessorListener* listener_;
const FlowIds flow_ids_;
@@ -213,21 +249,22 @@ class RateCounterFilter : public PacketProcessor {
RateCounterFilter(PacketProcessorListener* listener,
const FlowIds& flow_ids,
const char* name);
+ RateCounterFilter(PacketProcessorListener* listener,
+ const FlowIds& flow_ids,
+ const char* name,
+ int64_t start_plotting_ms);
stefan-webrtc 2015/06/25 14:44:04 start_plotting_time_ms_
magalhaesc 2015/07/01 12:48:40 Done.
virtual ~RateCounterFilter();
- uint32_t packets_per_second() const;
- uint32_t bits_per_second() const;
-
void LogStats();
Stats<double> GetBitrateStats() const;
virtual void Plot(int64_t timestamp_ms);
virtual void RunFor(int64_t time_ms, Packets* in_out);
private:
- rtc::scoped_ptr<RateCounter> rate_counter_;
Stats<double> packets_per_second_stats_;
Stats<double> kbps_stats_;
std::string name_;
+ int64_t start_plotting_ms_;
DISALLOW_IMPLICIT_CONSTRUCTORS(RateCounterFilter);
};
@@ -254,11 +291,11 @@ class DelayFilter : public PacketProcessor {
DelayFilter(PacketProcessorListener* listener, const FlowIds& flow_ids);
virtual ~DelayFilter() {}
- void SetDelayMs(int64_t delay_ms);
+ void SetOneWayDelayMs(int64_t one_way_delay_ms);
virtual void RunFor(int64_t time_ms, Packets* in_out);
private:
- int64_t delay_us_;
+ int64_t one_way_delay_us_;
int64_t last_send_time_us_;
DISALLOW_IMPLICIT_CONSTRUCTORS(DelayFilter);
@@ -305,16 +342,21 @@ class ChokeFilter : public PacketProcessor {
ChokeFilter(PacketProcessorListener* listener, const FlowIds& flow_ids);
virtual ~ChokeFilter();
- void SetCapacity(uint32_t kbps);
- void SetMaxDelay(int max_delay_ms);
+ void SetCapacityKbps(uint32_t kbps);
+ void SetMaxDelayMs(int64_t max_queueing_delay_ms);
+ void PauseFlow(int flow_id); // Increases available capacity per flow.
+ void ResumeFlow(int flow_id); // Decreases available capacity per flow.
stefan-webrtc 2015/06/25 14:44:04 I don't understand what this does. If this is abou
magalhaesc 2015/07/01 12:48:40 Yes, it's done on the Source. It is also done here
+
virtual void RunFor(int64_t time_ms, Packets* in_out);
Stats<double> GetDelayStats() const;
private:
- uint32_t kbps_;
+ uint32_t available_capacity_kbps_;
int64_t last_send_time_us_;
rtc::scoped_ptr<DelayCapHelper> delay_cap_helper_;
+ int64_t max_delay_us_;
+ std::set<int> running_flows_;
DISALLOW_IMPLICIT_CONSTRUCTORS(ChokeFilter);
};
@@ -336,7 +378,7 @@ class TraceBasedDeliveryFilter : public PacketProcessor {
virtual void Plot(int64_t timestamp_ms);
virtual void RunFor(int64_t time_ms, Packets* in_out);
- void SetMaxDelay(int max_delay_ms);
+ void SetMaxDelayMs(int64_t max_delay_ms);
Stats<double> GetDelayStats() const;
Stats<double> GetBitrateStats() const;
@@ -373,6 +415,11 @@ class VideoSource {
uint32_t bits_per_second() const { return bits_per_second_; }
uint32_t max_payload_size_bytes() const { return kMaxPayloadSizeBytes; }
int64_t GetTimeUntilNextFrameMs() const { return next_frame_ms_ - now_ms_; }
+ virtual void Pause();
+ virtual void Resume();
+
+ void set_alg_name(const std::string& alg_name) { alg_name_ = alg_name; }
+ void set_plot_sending_estimate(bool plot) { plot_sending_estimate_ = plot; }
protected:
virtual uint32_t NextFrameSize();
@@ -384,12 +431,16 @@ class VideoSource {
const double frame_period_ms_;
uint32_t bits_per_second_;
uint32_t frame_size_bytes_;
+ bool running_;
private:
const int flow_id_;
int64_t next_frame_ms_;
int64_t now_ms_;
RTPHeader prototype_header_;
+ int64_t start_plotting_ms_;
+ std::string alg_name_;
stefan-webrtc 2015/06/25 14:44:04 It feels odd that we have to know about an algorit
magalhaesc 2015/07/01 12:48:40 I agree, done.
+ bool plot_sending_estimate_; // False by default.
DISALLOW_IMPLICIT_CONSTRUCTORS(VideoSource);
};

Powered by Google App Engine
This is Rietveld 408576698