Chromium Code Reviews| 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..66abf2ceb142285d7a8ba3b42cd0228c2459969b 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 { |
| @@ -56,20 +57,31 @@ class LinkedSet { |
| int64_t arrival_time_ms, |
| size_t payload_size); |
| + void Insert(PacketIdentifierNode packet_identifier); |
| + |
| PacketNodeIt begin() { return list_.begin(); } |
|
stefan-webrtc
2015/07/06 08:24:51
Many of the methods below should be const.
magalhaesc
2015/07/06 09:28:06
Done.
|
| 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(); |
| + } |
| + |
| + void Erase(PacketNodeIt node_rit); |
|
stefan-webrtc
2015/07/06 08:24:51
This doesn't delete a reverse iterator right? If i
magalhaesc
2015/07/06 09:28:06
Previously it was for reverse_iterator, I forgot t
|
| + |
| private: |
| // Pop oldest element from the back of the list and remove it from the map. |
| void RemoveTail(); |
| @@ -80,17 +92,35 @@ class LinkedSet { |
| std::list<PacketIdentifierNode*> list_; |
| }; |
| -const int kMinBitrateKbps = 150; |
| -const int kMaxBitrateKbps = 3000; |
| +// Holds information for computing global packet loss. |
| +struct LossAccount { |
| + LossAccount() : num_total(0), num_lost(0) {} |
| + LossAccount(size_t num_total, size_t num_lost) |
| + : num_total(num_total), num_lost(num_lost) {} |
| + void Add(LossAccount rhs); |
| + void Subtract(LossAccount rhs); |
| + float LossRatio(); |
| + size_t num_total; |
| + size_t num_lost; |
| +}; |
| + |
| +const int kMinBitrateKbps = 30; |
| +const int kMaxBitrateKbps = 2500; |
| 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 +135,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. |
|
stefan-webrtc
2015/07/06 08:24:51
This method should be const, right? Same with some
magalhaesc
2015/07/06 09:28:06
Done.
|
| + // 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; |
| 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 +184,7 @@ BweSender* CreateBweSender(BandwidthEstimatorType estimator, |
| BweReceiver* CreateBweReceiver(BandwidthEstimatorType type, |
| int flow_id, |
| bool plot); |
| + |
| } // namespace bwe |
| } // namespace testing |
| } // namespace webrtc |