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 |
(...skipping 19 matching lines...) Expand all Loading... |
30 class TransportFeedbackAdapterTest : public ::testing::Test { | 30 class TransportFeedbackAdapterTest : public ::testing::Test { |
31 public: | 31 public: |
32 TransportFeedbackAdapterTest() | 32 TransportFeedbackAdapterTest() |
33 : clock_(0), bitrate_controller_(this), target_bitrate_bps_(0) {} | 33 : clock_(0), bitrate_controller_(this), target_bitrate_bps_(0) {} |
34 | 34 |
35 virtual ~TransportFeedbackAdapterTest() {} | 35 virtual ~TransportFeedbackAdapterTest() {} |
36 | 36 |
37 virtual void SetUp() { | 37 virtual void SetUp() { |
38 adapter_.reset(new TransportFeedbackAdapter(&clock_, &bitrate_controller_)); | 38 adapter_.reset(new TransportFeedbackAdapter(&clock_, &bitrate_controller_)); |
39 adapter_->InitBwe(); | 39 adapter_->InitBwe(); |
| 40 adapter_->SetStartBitrate(300000); |
40 } | 41 } |
41 | 42 |
42 virtual void TearDown() { adapter_.reset(); } | 43 virtual void TearDown() { adapter_.reset(); } |
43 | 44 |
44 protected: | 45 protected: |
45 // Proxy class used since TransportFeedbackAdapter will own the instance | 46 // Proxy class used since TransportFeedbackAdapter will own the instance |
46 // passed at construction. | 47 // passed at construction. |
47 class MockBitrateControllerAdapter : public MockBitrateController { | 48 class MockBitrateControllerAdapter : public MockBitrateController { |
48 public: | 49 public: |
49 explicit MockBitrateControllerAdapter(TransportFeedbackAdapterTest* owner) | 50 explicit MockBitrateControllerAdapter(TransportFeedbackAdapterTest* owner) |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 EXPECT_TRUE(feedback.AddReceivedPacket(packet.sequence_number, | 122 EXPECT_TRUE(feedback.AddReceivedPacket(packet.sequence_number, |
122 packet.arrival_time_ms * 1000)); | 123 packet.arrival_time_ms * 1000)); |
123 } | 124 } |
124 | 125 |
125 feedback.Build(); | 126 feedback.Build(); |
126 | 127 |
127 adapter_->OnTransportFeedback(feedback); | 128 adapter_->OnTransportFeedback(feedback); |
128 ComparePacketVectors(packets, adapter_->GetTransportFeedbackVector()); | 129 ComparePacketVectors(packets, adapter_->GetTransportFeedbackVector()); |
129 } | 130 } |
130 | 131 |
| 132 TEST_F(TransportFeedbackAdapterTest, LongFeedbackDelays) { |
| 133 const int64_t kFeedbackTimeoutMs = 60001; |
| 134 const int kMaxConsecutiveFailedLookups = 5; |
| 135 for (int i = 0; i < kMaxConsecutiveFailedLookups; ++i) { |
| 136 std::vector<PacketInfo> packets; |
| 137 packets.push_back(PacketInfo(i * 100, 2 * i * 100, 0, 1500, 0)); |
| 138 packets.push_back(PacketInfo(i * 100 + 10, 2 * i * 100 + 10, 1, 1500, 0)); |
| 139 packets.push_back(PacketInfo(i * 100 + 20, 2 * i * 100 + 20, 2, 1500, 0)); |
| 140 packets.push_back(PacketInfo(i * 100 + 30, 2 * i * 100 + 30, 3, 1500, 1)); |
| 141 packets.push_back(PacketInfo(i * 100 + 40, 2 * i * 100 + 40, 4, 1500, 1)); |
| 142 |
| 143 for (const PacketInfo& packet : packets) |
| 144 OnSentPacket(packet); |
| 145 |
| 146 rtcp::TransportFeedback feedback; |
| 147 feedback.SetBase(packets[0].sequence_number, |
| 148 packets[0].arrival_time_ms * 1000); |
| 149 |
| 150 for (const PacketInfo& packet : packets) { |
| 151 EXPECT_TRUE(feedback.AddReceivedPacket(packet.sequence_number, |
| 152 packet.arrival_time_ms * 1000)); |
| 153 } |
| 154 |
| 155 feedback.Build(); |
| 156 |
| 157 clock_.AdvanceTimeMilliseconds(kFeedbackTimeoutMs); |
| 158 PacketInfo later_packet(kFeedbackTimeoutMs + i * 100 + 40, |
| 159 kFeedbackTimeoutMs + i * 200 + 40, 5, 1500, 1); |
| 160 OnSentPacket(later_packet); |
| 161 |
| 162 adapter_->OnTransportFeedback(feedback); |
| 163 |
| 164 // Check that packets have timed out. |
| 165 for (PacketInfo& packet : packets) { |
| 166 packet.send_time_ms = -1; |
| 167 packet.payload_size = 0; |
| 168 packet.probe_cluster_id = -1; |
| 169 } |
| 170 ComparePacketVectors(packets, adapter_->GetTransportFeedbackVector()); |
| 171 } |
| 172 |
| 173 // Target bitate should have halved due to feedback delays. |
| 174 EXPECT_EQ(150000u, target_bitrate_bps_); |
| 175 |
| 176 // Test with feedback that isn't late enough to time out. |
| 177 { |
| 178 std::vector<PacketInfo> packets; |
| 179 packets.push_back(PacketInfo(100, 200, 0, 1500, 0)); |
| 180 packets.push_back(PacketInfo(110, 210, 1, 1500, 0)); |
| 181 packets.push_back(PacketInfo(120, 220, 2, 1500, 0)); |
| 182 packets.push_back(PacketInfo(130, 230, 3, 1500, 1)); |
| 183 packets.push_back(PacketInfo(140, 240, 4, 1500, 1)); |
| 184 |
| 185 for (const PacketInfo& packet : packets) |
| 186 OnSentPacket(packet); |
| 187 |
| 188 rtcp::TransportFeedback feedback; |
| 189 feedback.SetBase(packets[0].sequence_number, |
| 190 packets[0].arrival_time_ms * 1000); |
| 191 |
| 192 for (const PacketInfo& packet : packets) { |
| 193 EXPECT_TRUE(feedback.AddReceivedPacket(packet.sequence_number, |
| 194 packet.arrival_time_ms * 1000)); |
| 195 } |
| 196 |
| 197 feedback.Build(); |
| 198 |
| 199 clock_.AdvanceTimeMilliseconds(kFeedbackTimeoutMs - 1); |
| 200 PacketInfo later_packet(kFeedbackTimeoutMs + 140, kFeedbackTimeoutMs + 240, |
| 201 5, 1500, 1); |
| 202 OnSentPacket(later_packet); |
| 203 |
| 204 adapter_->OnTransportFeedback(feedback); |
| 205 ComparePacketVectors(packets, adapter_->GetTransportFeedbackVector()); |
| 206 } |
| 207 } |
| 208 |
131 TEST_F(TransportFeedbackAdapterTest, HandlesDroppedPackets) { | 209 TEST_F(TransportFeedbackAdapterTest, HandlesDroppedPackets) { |
132 std::vector<PacketInfo> packets; | 210 std::vector<PacketInfo> packets; |
133 packets.push_back(PacketInfo(100, 200, 0, 1500, 1)); | 211 packets.push_back(PacketInfo(100, 200, 0, 1500, 1)); |
134 packets.push_back(PacketInfo(110, 210, 1, 1500, 2)); | 212 packets.push_back(PacketInfo(110, 210, 1, 1500, 2)); |
135 packets.push_back(PacketInfo(120, 220, 2, 1500, 3)); | 213 packets.push_back(PacketInfo(120, 220, 2, 1500, 3)); |
136 packets.push_back(PacketInfo(130, 230, 3, 1500, 4)); | 214 packets.push_back(PacketInfo(130, 230, 3, 1500, 4)); |
137 packets.push_back(PacketInfo(140, 240, 4, 1500, 5)); | 215 packets.push_back(PacketInfo(140, 240, 4, 1500, 5)); |
138 | 216 |
139 const uint16_t kSendSideDropBefore = 1; | 217 const uint16_t kSendSideDropBefore = 1; |
140 const uint16_t kReceiveSideDropAfter = 3; | 218 const uint16_t kReceiveSideDropAfter = 3; |
(...skipping 10 matching lines...) Expand all Loading... |
151 for (const PacketInfo& packet : packets) { | 229 for (const PacketInfo& packet : packets) { |
152 if (packet.sequence_number <= kReceiveSideDropAfter) { | 230 if (packet.sequence_number <= kReceiveSideDropAfter) { |
153 EXPECT_TRUE(feedback.AddReceivedPacket(packet.sequence_number, | 231 EXPECT_TRUE(feedback.AddReceivedPacket(packet.sequence_number, |
154 packet.arrival_time_ms * 1000)); | 232 packet.arrival_time_ms * 1000)); |
155 } | 233 } |
156 } | 234 } |
157 | 235 |
158 feedback.Build(); | 236 feedback.Build(); |
159 | 237 |
160 std::vector<PacketInfo> expected_packets( | 238 std::vector<PacketInfo> expected_packets( |
161 packets.begin() + kSendSideDropBefore, | 239 packets.begin(), packets.begin() + kReceiveSideDropAfter + 1); |
162 packets.begin() + kReceiveSideDropAfter + 1); | 240 // Packets that have timed out on the send-side have lost the |
| 241 // information stored on the send-side. |
| 242 for (size_t i = 0; i < kSendSideDropBefore; ++i) { |
| 243 expected_packets[i].send_time_ms = -1; |
| 244 expected_packets[i].probe_cluster_id = -1; |
| 245 expected_packets[i].payload_size = 0; |
| 246 } |
163 | 247 |
164 adapter_->OnTransportFeedback(feedback); | 248 adapter_->OnTransportFeedback(feedback); |
165 ComparePacketVectors(expected_packets, | 249 ComparePacketVectors(expected_packets, |
166 adapter_->GetTransportFeedbackVector()); | 250 adapter_->GetTransportFeedbackVector()); |
167 } | 251 } |
168 | 252 |
169 TEST_F(TransportFeedbackAdapterTest, SendTimeWrapsBothWays) { | 253 TEST_F(TransportFeedbackAdapterTest, SendTimeWrapsBothWays) { |
170 int64_t kHighArrivalTimeMs = rtcp::TransportFeedback::kDeltaScaleFactor * | 254 int64_t kHighArrivalTimeMs = rtcp::TransportFeedback::kDeltaScaleFactor * |
171 static_cast<int64_t>(1 << 8) * | 255 static_cast<int64_t>(1 << 8) * |
172 static_cast<int64_t>((1 << 23) - 1) / 1000; | 256 static_cast<int64_t>((1 << 23) - 1) / 1000; |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 EXPECT_TRUE(feedback.get() != nullptr); | 430 EXPECT_TRUE(feedback.get() != nullptr); |
347 adapter_->OnTransportFeedback(*feedback.get()); | 431 adapter_->OnTransportFeedback(*feedback.get()); |
348 clock_.AdvanceTimeMilliseconds(50); | 432 clock_.AdvanceTimeMilliseconds(50); |
349 ++seq_num; | 433 ++seq_num; |
350 } | 434 } |
351 EXPECT_GT(target_bitrate_bps_, 0u); | 435 EXPECT_GT(target_bitrate_bps_, 0u); |
352 } | 436 } |
353 | 437 |
354 } // namespace test | 438 } // namespace test |
355 } // namespace webrtc | 439 } // namespace webrtc |
OLD | NEW |