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

Side by Side Diff: webrtc/modules/congestion_controller/transport_feedback_adapter_unittest.cc

Issue 2684353004: Reduce the BWE with 50% when feedback is received too late. (Closed)
Patch Set: Updated comment. Created 3 years, 10 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 unified diff | Download patch
OLDNEW
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
(...skipping 20 matching lines...) Expand all
31 class TransportFeedbackAdapterTest : public ::testing::Test { 31 class TransportFeedbackAdapterTest : public ::testing::Test {
32 public: 32 public:
33 TransportFeedbackAdapterTest() 33 TransportFeedbackAdapterTest()
34 : clock_(0), bitrate_controller_(this), target_bitrate_bps_(0) {} 34 : clock_(0), bitrate_controller_(this), target_bitrate_bps_(0) {}
35 35
36 virtual ~TransportFeedbackAdapterTest() {} 36 virtual ~TransportFeedbackAdapterTest() {}
37 37
38 virtual void SetUp() { 38 virtual void SetUp() {
39 adapter_.reset(new TransportFeedbackAdapter(&clock_, &bitrate_controller_)); 39 adapter_.reset(new TransportFeedbackAdapter(&clock_, &bitrate_controller_));
40 adapter_->InitBwe(); 40 adapter_->InitBwe();
41 adapter_->SetStartBitrate(300000);
41 } 42 }
42 43
43 virtual void TearDown() { adapter_.reset(); } 44 virtual void TearDown() { adapter_.reset(); }
44 45
45 protected: 46 protected:
46 // Proxy class used since TransportFeedbackAdapter will own the instance 47 // Proxy class used since TransportFeedbackAdapter will own the instance
47 // passed at construction. 48 // passed at construction.
48 class MockBitrateControllerAdapter : public MockBitrateController { 49 class MockBitrateControllerAdapter : public MockBitrateController {
49 public: 50 public:
50 explicit MockBitrateControllerAdapter(TransportFeedbackAdapterTest* owner) 51 explicit MockBitrateControllerAdapter(TransportFeedbackAdapterTest* owner)
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 EXPECT_TRUE(feedback.AddReceivedPacket(packet.sequence_number, 123 EXPECT_TRUE(feedback.AddReceivedPacket(packet.sequence_number,
123 packet.arrival_time_ms * 1000)); 124 packet.arrival_time_ms * 1000));
124 } 125 }
125 126
126 feedback.Build(); 127 feedback.Build();
127 128
128 adapter_->OnTransportFeedback(feedback); 129 adapter_->OnTransportFeedback(feedback);
129 ComparePacketVectors(packets, adapter_->GetTransportFeedbackVector()); 130 ComparePacketVectors(packets, adapter_->GetTransportFeedbackVector());
130 } 131 }
131 132
132 TEST_F(TransportFeedbackAdapterTest, Timeout) { 133 TEST_F(TransportFeedbackAdapterTest, LongFeedbackDelays) {
133 const int64_t kFeedbackTimeoutMs = 60001; 134 const int64_t kFeedbackTimeoutMs = 60001;
134 { 135 const int kMaxConsecutiveFailedLookups = 5;
136 for (int i = 0; i < kMaxConsecutiveFailedLookups; ++i) {
135 std::vector<PacketInfo> packets; 137 std::vector<PacketInfo> packets;
136 packets.push_back(PacketInfo(100, 200, 0, 1500, 0)); 138 packets.push_back(PacketInfo(i * 100, 2 * i * 100, 0, 1500, 0));
137 packets.push_back(PacketInfo(110, 210, 1, 1500, 0)); 139 packets.push_back(PacketInfo(i * 100 + 10, 2 * i * 100 + 10, 1, 1500, 0));
138 packets.push_back(PacketInfo(120, 220, 2, 1500, 0)); 140 packets.push_back(PacketInfo(i * 100 + 20, 2 * i * 100 + 20, 2, 1500, 0));
139 packets.push_back(PacketInfo(130, 230, 3, 1500, 1)); 141 packets.push_back(PacketInfo(i * 100 + 30, 2 * i * 100 + 30, 3, 1500, 1));
140 packets.push_back(PacketInfo(140, 240, 4, 1500, 1)); 142 packets.push_back(PacketInfo(i * 100 + 40, 2 * i * 100 + 40, 4, 1500, 1));
141 143
142 for (const PacketInfo& packet : packets) 144 for (const PacketInfo& packet : packets)
143 OnSentPacket(packet); 145 OnSentPacket(packet);
144 146
145 rtcp::TransportFeedback feedback; 147 rtcp::TransportFeedback feedback;
146 feedback.SetBase(packets[0].sequence_number, 148 feedback.SetBase(packets[0].sequence_number,
147 packets[0].arrival_time_ms * 1000); 149 packets[0].arrival_time_ms * 1000);
148 150
149 for (const PacketInfo& packet : packets) { 151 for (const PacketInfo& packet : packets) {
150 EXPECT_TRUE(feedback.AddReceivedPacket(packet.sequence_number, 152 EXPECT_TRUE(feedback.AddReceivedPacket(packet.sequence_number,
151 packet.arrival_time_ms * 1000)); 153 packet.arrival_time_ms * 1000));
152 } 154 }
153 155
154 feedback.Build(); 156 feedback.Build();
155 157
156 clock_.AdvanceTimeMilliseconds(kFeedbackTimeoutMs); 158 clock_.AdvanceTimeMilliseconds(kFeedbackTimeoutMs);
157 PacketInfo later_packet(kFeedbackTimeoutMs + 140, kFeedbackTimeoutMs + 240, 159 PacketInfo later_packet(kFeedbackTimeoutMs + i * 100 + 40,
158 5, 1500, 1); 160 kFeedbackTimeoutMs + i * 200 + 40, 5, 1500, 1);
159 OnSentPacket(later_packet); 161 OnSentPacket(later_packet);
160 162
161 adapter_->OnTransportFeedback(feedback); 163 adapter_->OnTransportFeedback(feedback);
162 EXPECT_EQ(0, rtc::checked_cast<int>( 164
163 adapter_->GetTransportFeedbackVector().size())); 165 // Check that packets have timed out.
166 for (PacketInfo& packet : packets) {
167 packet.send_time_ms = -1;
168 packet.payload_size = 0;
169 packet.probe_cluster_id = -1;
170 }
171 ComparePacketVectors(packets, adapter_->GetTransportFeedbackVector());
164 } 172 }
165 173
174 // Target bitrate should have halved due to feedback delays.
175 EXPECT_EQ(150000u, target_bitrate_bps_);
176
177 // Test with feedback that isn't late enough to time out.
166 { 178 {
167 std::vector<PacketInfo> packets; 179 std::vector<PacketInfo> packets;
168 packets.push_back(PacketInfo(100, 200, 0, 1500, 0)); 180 packets.push_back(PacketInfo(100, 200, 0, 1500, 0));
169 packets.push_back(PacketInfo(110, 210, 1, 1500, 0)); 181 packets.push_back(PacketInfo(110, 210, 1, 1500, 0));
170 packets.push_back(PacketInfo(120, 220, 2, 1500, 0)); 182 packets.push_back(PacketInfo(120, 220, 2, 1500, 0));
171 packets.push_back(PacketInfo(130, 230, 3, 1500, 1)); 183 packets.push_back(PacketInfo(130, 230, 3, 1500, 1));
172 packets.push_back(PacketInfo(140, 240, 4, 1500, 1)); 184 packets.push_back(PacketInfo(140, 240, 4, 1500, 1));
173 185
174 for (const PacketInfo& packet : packets) 186 for (const PacketInfo& packet : packets)
175 OnSentPacket(packet); 187 OnSentPacket(packet);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 for (const PacketInfo& packet : packets) { 230 for (const PacketInfo& packet : packets) {
219 if (packet.sequence_number <= kReceiveSideDropAfter) { 231 if (packet.sequence_number <= kReceiveSideDropAfter) {
220 EXPECT_TRUE(feedback.AddReceivedPacket(packet.sequence_number, 232 EXPECT_TRUE(feedback.AddReceivedPacket(packet.sequence_number,
221 packet.arrival_time_ms * 1000)); 233 packet.arrival_time_ms * 1000));
222 } 234 }
223 } 235 }
224 236
225 feedback.Build(); 237 feedback.Build();
226 238
227 std::vector<PacketInfo> expected_packets( 239 std::vector<PacketInfo> expected_packets(
228 packets.begin() + kSendSideDropBefore, 240 packets.begin(), packets.begin() + kReceiveSideDropAfter + 1);
229 packets.begin() + kReceiveSideDropAfter + 1); 241 // Packets that have timed out on the send-side have lost the
242 // information stored on the send-side.
243 for (size_t i = 0; i < kSendSideDropBefore; ++i) {
244 expected_packets[i].send_time_ms = -1;
245 expected_packets[i].probe_cluster_id = -1;
246 expected_packets[i].payload_size = 0;
247 }
230 248
231 adapter_->OnTransportFeedback(feedback); 249 adapter_->OnTransportFeedback(feedback);
232 ComparePacketVectors(expected_packets, 250 ComparePacketVectors(expected_packets,
233 adapter_->GetTransportFeedbackVector()); 251 adapter_->GetTransportFeedbackVector());
234 } 252 }
235 253
236 TEST_F(TransportFeedbackAdapterTest, SendTimeWrapsBothWays) { 254 TEST_F(TransportFeedbackAdapterTest, SendTimeWrapsBothWays) {
237 int64_t kHighArrivalTimeMs = rtcp::TransportFeedback::kDeltaScaleFactor * 255 int64_t kHighArrivalTimeMs = rtcp::TransportFeedback::kDeltaScaleFactor *
238 static_cast<int64_t>(1 << 8) * 256 static_cast<int64_t>(1 << 8) *
239 static_cast<int64_t>((1 << 23) - 1) / 1000; 257 static_cast<int64_t>((1 << 23) - 1) / 1000;
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 EXPECT_TRUE(feedback.get() != nullptr); 431 EXPECT_TRUE(feedback.get() != nullptr);
414 adapter_->OnTransportFeedback(*feedback.get()); 432 adapter_->OnTransportFeedback(*feedback.get());
415 clock_.AdvanceTimeMilliseconds(50); 433 clock_.AdvanceTimeMilliseconds(50);
416 ++seq_num; 434 ++seq_num;
417 } 435 }
418 EXPECT_GT(target_bitrate_bps_, 0u); 436 EXPECT_GT(target_bitrate_bps_, 0u);
419 } 437 }
420 438
421 } // namespace test 439 } // namespace test
422 } // namespace webrtc 440 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698