 Chromium Code Reviews
 Chromium Code Reviews Issue 1202253003:
  More Simulation Framework features  (Closed) 
  Base URL: https://chromium.googlesource.com/external/webrtc.git@master
    
  
    Issue 1202253003:
  More Simulation Framework features  (Closed) 
  Base URL: https://chromium.googlesource.com/external/webrtc.git@master| Index: webrtc/modules/remote_bitrate_estimator/test/bwe.h | 
| diff --git a/webrtc/modules/remote_bitrate_estimator/test/bwe.h b/webrtc/modules/remote_bitrate_estimator/test/bwe.h | 
| index d059871488bec092c836bf9692c34bdcc4f2c06f..32cdf1ac974039e86d816343494589122bcef26f 100644 | 
| --- a/webrtc/modules/remote_bitrate_estimator/test/bwe.h | 
| +++ b/webrtc/modules/remote_bitrate_estimator/test/bwe.h | 
| @@ -15,6 +15,7 @@ | 
| #include "webrtc/modules/remote_bitrate_estimator/test/packet.h" | 
| #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" | 
| +#include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.h" | 
| namespace webrtc { | 
| namespace testing { | 
| @@ -32,6 +33,8 @@ struct PacketIdentifierNode { | 
| arrival_time_ms(arrival_time_ms), | 
| payload_size(payload_size) {} | 
| + PacketIdentifierNode copy(); | 
| 
stefan-webrtc
2015/07/02 11:03:41
Not sure why this is needed. You can simply use th
 
magalhaesc
2015/07/02 17:06:18
Done.
 | 
| + | 
| uint16_t sequence_number; | 
| int64_t send_time_ms; | 
| int64_t arrival_time_ms; | 
| @@ -56,20 +59,28 @@ class LinkedSet { | 
| int64_t arrival_time_ms, | 
| size_t payload_size); | 
| + void Insert(PacketIdentifierNode packet_identifier); | 
| + | 
| PacketNodeIt begin() { return list_.begin(); } | 
| PacketNodeIt end() { return list_.end(); } | 
| bool empty() { return list_.empty(); } | 
| size_t size() { return list_.size(); } | 
| - // Gets the latest arrived sequence number. | 
| - uint16_t find_max() { return map_.rbegin()->first; } | 
| - // Gets the first arrived sequence number still saved in the LinkedSet. | 
| - uint16_t find_min() { return map_.begin()->first; } | 
| - // Gets the lowest saved sequence number that is >= than the input key. | 
| - uint16_t lower_bound(uint16_t key) { return map_.lower_bound(key)->first; } | 
| - // Gets the highest saved sequence number that is <= than the input key. | 
| - uint16_t upper_bound(uint16_t key) { return map_.upper_bound(key)->first; } | 
| size_t capacity() { return capacity_; } | 
| + // Gets the highest (absolute value) sequence number. | 
| + uint16_t Max() { return empty() ? 0 : map_.rbegin()->first; } | 
| + // Gets the lowest (absolute value) sequence number still saved in the | 
| + // LinkedSet. | 
| + uint16_t Min() { return empty() ? 0 : map_.begin()->first; } | 
| + | 
| + uint16_t OldestSeqNumber(); | 
| + uint16_t NewestSeqNumber(); | 
| + | 
| + void Clear() { | 
| + map_.clear(); | 
| + list_.clear(); | 
| + } | 
| + | 
| private: | 
| // Pop oldest element from the back of the list and remove it from the map. | 
| void RemoveTail(); | 
| @@ -80,17 +91,35 @@ class LinkedSet { | 
| std::list<PacketIdentifierNode*> list_; | 
| }; | 
| +// Holds information for computing global packet loss. | 
| +struct LossAccount { | 
| + LossAccount() : num_total(0), num_lost(0) {} | 
| + LossAccount(uint32_t num_total, uint32_t num_lost) | 
| + : num_total(num_total), num_lost(num_lost) {} | 
| + void Add(LossAccount addend); | 
| + void Subtract(LossAccount subtrahend); | 
| 
stefan-webrtc
2015/07/02 11:03:41
Switch addend and subtrahend to "loss" or "rhs" (r
 
magalhaesc
2015/07/02 17:06:18
Done.
 | 
| + float LossRatio(); | 
| + uint32_t num_total; | 
| + uint32_t num_lost; | 
| +}; | 
| + | 
| const int kMinBitrateKbps = 150; | 
| -const int kMaxBitrateKbps = 3000; | 
| +const int kMaxBitrateKbps = 1500; | 
| 
stefan-webrtc
2015/07/02 11:03:41
Should make these 30 / 2500, right?
 
magalhaesc
2015/07/02 17:06:18
right
 | 
| class BweSender : public Module { | 
| public: | 
| - BweSender() {} | 
| + BweSender() : running_(true) {} | 
| virtual ~BweSender() {} | 
| virtual int GetFeedbackIntervalMs() const = 0; | 
| virtual void GiveFeedback(const FeedbackPacket& feedback) = 0; | 
| virtual void OnPacketsSent(const Packets& packets) = 0; | 
| + virtual void Pause(); | 
| + virtual void Resume(); | 
| + | 
| + protected: | 
| + bool running_; | 
| + int bitrate_kbps_; | 
| private: | 
| DISALLOW_COPY_AND_ASSIGN(BweSender); | 
| @@ -105,26 +134,45 @@ class BweReceiver { | 
| const MediaPacket& media_packet) {} | 
| virtual FeedbackPacket* GetFeedback(int64_t now_ms) { return NULL; } | 
| - float GlobalPacketLossRatio(); | 
| - float RecentPacketLossRatio(); | 
| size_t GetSetCapacity() { return received_packets_.capacity(); } | 
| + uint32_t RecentKbps(); // Receiving Rate calculated over latest 1000ms. | 
| + // Packet loss only for packets arriving in the latest 500ms time window. | 
| + float RecentPacketLossRatio(); // Plot dynamics. | 
| + // Computes packet loss during an entire simulation, up to 4 billion packets. | 
| + float GlobalReceiverPacketLossRatio(); // Plot histogram. | 
| + | 
| static const int64_t kPacketLossTimeWindowMs = 500; | 
| + static const int64_t kReceivingRateTimeWindowMs = 1000; | 
| 
stefan-webrtc
2015/07/02 11:03:41
Do these constants have to be public?
 
magalhaesc
2015/07/02 17:06:18
We made them public to use on nada_unittests.cc
Do
 
stefan-webrtc
2015/07/03 09:32:10
No, this is OK.
 | 
| protected: | 
| + void RelieveSetAndUpdateLoss(); | 
| int flow_id_; | 
| // Deals with packets sent more than once. | 
| LinkedSet received_packets_; | 
| + // Used for calculating recent receiving rate. | 
| + RateCounter rate_counter_; | 
| + | 
| + private: | 
| + void UpdateLoss(); | 
| + void ClearSet(); | 
| + // Packet loss for packets stored in the LinkedSet, up to 1000 packets. | 
| + // Used to update global loss account whenever the set is filled and cleared. | 
| + LossAccount LinkedSetPacketLossRatio(); | 
| + // Used for calculating global packet loss ratio. | 
| + LossAccount loss_account; | 
| }; | 
| enum BandwidthEstimatorType { | 
| - kNullEstimator, | 
| + kNullEstimator = 0, | 
| kNadaEstimator, | 
| kRembEstimator, | 
| kFullSendSideEstimator, | 
| kTcpEstimator | 
| }; | 
| +const std::string bwe_names[] = {"Null", "NADA", "REMB", "GCC", "TCP"}; | 
| + | 
| int64_t GetAbsSendTimeInMs(uint32_t abs_send_time); | 
| BweSender* CreateBweSender(BandwidthEstimatorType estimator, | 
| @@ -135,6 +183,7 @@ BweSender* CreateBweSender(BandwidthEstimatorType estimator, | 
| BweReceiver* CreateBweReceiver(BandwidthEstimatorType type, | 
| int flow_id, | 
| bool plot); | 
| + | 
| } // namespace bwe | 
| } // namespace testing | 
| } // namespace webrtc |