Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #ifndef WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_BWE_H_ | 11 #ifndef WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_BWE_H_ |
| 12 #define WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_BWE_H_ | 12 #define WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_BWE_H_ |
| 13 | 13 |
| 14 #include <sstream> | 14 #include <sstream> |
| 15 | 15 |
| 16 #include "webrtc/modules/remote_bitrate_estimator/test/packet.h" | 16 #include "webrtc/modules/remote_bitrate_estimator/test/packet.h" |
| 17 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" | 17 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" |
| 18 #include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.h" | |
| 18 | 19 |
| 19 namespace webrtc { | 20 namespace webrtc { |
| 20 namespace testing { | 21 namespace testing { |
| 21 namespace bwe { | 22 namespace bwe { |
| 22 | 23 |
| 23 // Holds only essential information about packets to be saved for | 24 // Holds only essential information about packets to be saved for |
| 24 // further use, e.g. for calculating packet loss and receiving rate. | 25 // further use, e.g. for calculating packet loss and receiving rate. |
| 25 struct PacketIdentifierNode { | 26 struct PacketIdentifierNode { |
| 26 PacketIdentifierNode(uint16_t sequence_number, | 27 PacketIdentifierNode(uint16_t sequence_number, |
| 27 int64_t send_time_ms, | 28 int64_t send_time_ms, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 59 PacketNodeIt begin() { return list_.begin(); } | 60 PacketNodeIt begin() { return list_.begin(); } |
| 60 PacketNodeIt end() { return list_.end(); } | 61 PacketNodeIt end() { return list_.end(); } |
| 61 bool empty() { return list_.empty(); } | 62 bool empty() { return list_.empty(); } |
| 62 size_t size() { return list_.size(); } | 63 size_t size() { return list_.size(); } |
| 63 // Gets the latest arrived sequence number. | 64 // Gets the latest arrived sequence number. |
| 64 uint16_t find_max() { return map_.rbegin()->first; } | 65 uint16_t find_max() { return map_.rbegin()->first; } |
| 65 // Gets the first arrived sequence number still saved in the LinkedSet. | 66 // Gets the first arrived sequence number still saved in the LinkedSet. |
| 66 uint16_t find_min() { return map_.begin()->first; } | 67 uint16_t find_min() { return map_.begin()->first; } |
| 67 // Gets the lowest saved sequence number that is >= than the input key. | 68 // Gets the lowest saved sequence number that is >= than the input key. |
| 68 uint16_t lower_bound(uint16_t key) { return map_.lower_bound(key)->first; } | 69 uint16_t lower_bound(uint16_t key) { return map_.lower_bound(key)->first; } |
| 69 // Gets the highest saved sequence number that is <= than the input key. | 70 // Gets the highest saved sequence number that is < than the input key. |
| 70 uint16_t upper_bound(uint16_t key) { return map_.upper_bound(key)->first; } | 71 uint16_t upper_bound(uint16_t key) { |
|
stefan-webrtc
2015/06/25 14:44:04
Isn't it very confusing to call this upper_bound n
magalhaesc
2015/07/01 12:48:40
I agree.
For a set containing values {2, 1, 0, 65
| |
| 72 return (--map_.lower_bound(key))->first; | |
| 73 } | |
| 71 size_t capacity() { return capacity_; } | 74 size_t capacity() { return capacity_; } |
| 75 void Clear() { | |
| 76 map_.clear(); | |
| 77 list_.clear(); | |
| 78 } | |
| 72 | 79 |
| 73 private: | 80 private: |
| 74 // Pop oldest element from the back of the list and remove it from the map. | 81 // Pop oldest element from the back of the list and remove it from the map. |
| 75 void RemoveTail(); | 82 void RemoveTail(); |
| 76 // Add new element to the front of the list and insert it in the map. | 83 // Add new element to the front of the list and insert it in the map. |
| 77 void UpdateHead(PacketIdentifierNode* new_head); | 84 void UpdateHead(PacketIdentifierNode* new_head); |
| 78 size_t capacity_; | 85 size_t capacity_; |
| 79 std::map<uint16_t, PacketNodeIt> map_; | 86 std::map<uint16_t, PacketNodeIt> map_; |
| 80 std::list<PacketIdentifierNode*> list_; | 87 std::list<PacketIdentifierNode*> list_; |
| 81 }; | 88 }; |
| 82 | 89 |
| 83 const int kMinBitrateKbps = 150; | 90 const int kMinBitrateKbps = 50; |
| 84 const int kMaxBitrateKbps = 3000; | 91 const int kMaxBitrateKbps = 2500; |
| 85 | 92 |
| 86 class BweSender : public Module { | 93 class BweSender : public Module { |
| 87 public: | 94 public: |
| 88 BweSender() {} | 95 BweSender() : running_(true) {} |
| 89 virtual ~BweSender() {} | 96 virtual ~BweSender() {} |
| 90 | 97 |
| 91 virtual int GetFeedbackIntervalMs() const = 0; | 98 virtual int GetFeedbackIntervalMs() const = 0; |
| 92 virtual void GiveFeedback(const FeedbackPacket& feedback) = 0; | 99 virtual void GiveFeedback(const FeedbackPacket& feedback) = 0; |
| 93 virtual void OnPacketsSent(const Packets& packets) = 0; | 100 virtual void OnPacketsSent(const Packets& packets) = 0; |
| 101 virtual void Pause(); | |
| 102 virtual void Resume(); | |
| 103 | |
| 104 protected: | |
| 105 bool running_; | |
| 106 int bitrate_kbps_; | |
| 94 | 107 |
| 95 private: | 108 private: |
| 96 DISALLOW_COPY_AND_ASSIGN(BweSender); | 109 DISALLOW_COPY_AND_ASSIGN(BweSender); |
| 97 }; | 110 }; |
| 98 | 111 |
| 99 class BweReceiver { | 112 class BweReceiver { |
| 100 public: | 113 public: |
| 101 explicit BweReceiver(int flow_id); | 114 explicit BweReceiver(int flow_id); |
| 102 virtual ~BweReceiver() {} | 115 virtual ~BweReceiver() {} |
| 103 | 116 |
| 104 virtual void ReceivePacket(int64_t arrival_time_ms, | 117 virtual void ReceivePacket(int64_t arrival_time_ms, |
| 105 const MediaPacket& media_packet) {} | 118 const MediaPacket& media_packet) {} |
| 106 virtual FeedbackPacket* GetFeedback(int64_t now_ms) { return NULL; } | 119 virtual FeedbackPacket* GetFeedback(int64_t now_ms) { return NULL; } |
| 107 | 120 |
| 108 float GlobalPacketLossRatio(); | 121 float GlobalReceiverPacketLossRatio(); |
| 122 float LinkedSetPacketLossRatio(); | |
|
stefan-webrtc
2015/06/25 14:44:03
It's not clear what this is supposed to be used fo
stefan-webrtc
2015/06/25 14:44:04
Should be private I think? Maybe other methods as
magalhaesc
2015/07/01 12:48:40
The only difference is the amount of packets consi
magalhaesc
2015/07/01 12:48:40
Yes, some methods are private now.
| |
| 109 float RecentPacketLossRatio(); | 123 float RecentPacketLossRatio(); |
| 124 size_t RecentReceivingRate(); | |
| 125 uint32_t RecentKbps() { | |
| 126 return (rate_counter_.bits_per_second() + 500) / 1000; | |
| 127 } | |
|
stefan-webrtc
2015/06/25 14:44:03
Do we need both RecentKbps and RecentReceivingRate
magalhaesc
2015/07/01 12:48:39
No, we don't.
RecentReceivingRate will be removed.
| |
| 110 size_t GetSetCapacity() { return received_packets_.capacity(); } | 128 size_t GetSetCapacity() { return received_packets_.capacity(); } |
| 129 void UpdateLossAccount(); | |
|
stefan-webrtc
2015/06/25 14:44:04
Just UpdateLoss()
magalhaesc
2015/07/01 12:48:40
Done.
| |
| 130 void ClearSet(); | |
| 111 | 131 |
| 112 static const int64_t kPacketLossTimeWindowMs = 500; | 132 static const int64_t kPacketLossTimeWindowMs = 500; |
| 133 static const int64_t kReceivingRateTimeWindowMs = 1000; | |
| 134 | |
| 135 // Used for calculating global packet loss ratio. | |
| 136 uint32_t num_previous_total_packets_; | |
| 137 uint32_t num_previous_lost_packets_; | |
| 113 | 138 |
| 114 protected: | 139 protected: |
| 115 int flow_id_; | 140 int flow_id_; |
| 116 // Deals with packets sent more than once. | 141 // Deals with packets sent more than once. |
| 117 LinkedSet received_packets_; | 142 LinkedSet received_packets_; |
| 143 // Used for calculating recent receiving rate. | |
| 144 RateCounter rate_counter_; | |
| 118 }; | 145 }; |
| 119 | 146 |
| 120 enum BandwidthEstimatorType { | 147 enum BandwidthEstimatorType { |
| 121 kNullEstimator, | 148 kNullEstimator = 0, |
| 122 kNadaEstimator, | 149 kNadaEstimator, |
| 123 kRembEstimator, | 150 kRembEstimator, |
| 124 kFullSendSideEstimator, | 151 kFullSendSideEstimator, |
| 125 kTcpEstimator | 152 kTcpEstimator |
| 126 }; | 153 }; |
| 127 | 154 |
| 155 const std::string bwe_names[] = {"Null", "NADA", "REMB", "GCC", "TCP"}; | |
| 156 | |
| 128 int64_t GetAbsSendTimeInMs(uint32_t abs_send_time); | 157 int64_t GetAbsSendTimeInMs(uint32_t abs_send_time); |
| 129 | 158 |
| 130 BweSender* CreateBweSender(BandwidthEstimatorType estimator, | 159 BweSender* CreateBweSender(BandwidthEstimatorType estimator, |
| 131 int kbps, | 160 int kbps, |
| 132 BitrateObserver* observer, | 161 BitrateObserver* observer, |
| 133 Clock* clock); | 162 Clock* clock); |
| 134 | 163 |
| 135 BweReceiver* CreateBweReceiver(BandwidthEstimatorType type, | 164 BweReceiver* CreateBweReceiver(BandwidthEstimatorType type, |
| 136 int flow_id, | 165 int flow_id, |
| 137 bool plot); | 166 bool plot); |
| 138 } // namespace bwe | 167 } // namespace bwe |
| 139 } // namespace testing | 168 } // namespace testing |
| 140 } // namespace webrtc | 169 } // namespace webrtc |
| 141 #endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_BWE_H_ | 170 #endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_BWE_H_ |
| OLD | NEW |