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 #include <limits> | 11 #include <limits> |
12 #include <memory> | 12 #include <memory> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "webrtc/base/checks.h" | 15 #include "webrtc/base/checks.h" |
16 #include "webrtc/base/safe_conversions.h" | 16 #include "webrtc/base/safe_conversions.h" |
17 #include "webrtc/modules/bitrate_controller/include/mock/mock_bitrate_controller
.h" | 17 #include "webrtc/modules/bitrate_controller/include/mock/mock_bitrate_controller
.h" |
18 #include "webrtc/modules/congestion_controller/transport_feedback_adapter.h" | 18 #include "webrtc/modules/congestion_controller/transport_feedback_adapter.h" |
19 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 19 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
20 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" | 20 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" |
21 #include "webrtc/system_wrappers/include/clock.h" | 21 #include "webrtc/system_wrappers/include/clock.h" |
22 #include "webrtc/test/gmock.h" | 22 #include "webrtc/test/gmock.h" |
23 #include "webrtc/test/gtest.h" | 23 #include "webrtc/test/gtest.h" |
24 | 24 |
25 using ::testing::_; | 25 using ::testing::_; |
26 using ::testing::Invoke; | 26 using ::testing::Invoke; |
27 | 27 |
28 namespace webrtc { | 28 namespace webrtc { |
| 29 |
| 30 namespace { |
| 31 const PacedPacketInfo kPacingInfo0(0, 5, 2000); |
| 32 const PacedPacketInfo kPacingInfo1(1, 8, 4000); |
| 33 const PacedPacketInfo kPacingInfo2(2, 14, 7000); |
| 34 const PacedPacketInfo kPacingInfo3(3, 20, 10000); |
| 35 const PacedPacketInfo kPacingInfo4(4, 22, 10000); |
| 36 } |
| 37 |
29 namespace test { | 38 namespace test { |
30 | 39 |
31 class TransportFeedbackAdapterTest : public ::testing::Test { | 40 class TransportFeedbackAdapterTest : public ::testing::Test { |
32 public: | 41 public: |
33 TransportFeedbackAdapterTest() | 42 TransportFeedbackAdapterTest() |
34 : clock_(0), bitrate_controller_(this), target_bitrate_bps_(0) {} | 43 : clock_(0), bitrate_controller_(this), target_bitrate_bps_(0) {} |
35 | 44 |
36 virtual ~TransportFeedbackAdapterTest() {} | 45 virtual ~TransportFeedbackAdapterTest() {} |
37 | 46 |
38 virtual void SetUp() { | 47 virtual void SetUp() { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 // packet, the truth[x].arrival_time and input[x].arrival_time may not be | 88 // packet, the truth[x].arrival_time and input[x].arrival_time may not be |
80 // equal. However, the difference must be the same for all x. | 89 // equal. However, the difference must be the same for all x. |
81 int64_t arrival_time_delta = | 90 int64_t arrival_time_delta = |
82 truth[0].arrival_time_ms - input[0].arrival_time_ms; | 91 truth[0].arrival_time_ms - input[0].arrival_time_ms; |
83 for (size_t i = 0; i < len; ++i) { | 92 for (size_t i = 0; i < len; ++i) { |
84 EXPECT_EQ(truth[i].arrival_time_ms, | 93 EXPECT_EQ(truth[i].arrival_time_ms, |
85 input[i].arrival_time_ms + arrival_time_delta); | 94 input[i].arrival_time_ms + arrival_time_delta); |
86 EXPECT_EQ(truth[i].send_time_ms, input[i].send_time_ms); | 95 EXPECT_EQ(truth[i].send_time_ms, input[i].send_time_ms); |
87 EXPECT_EQ(truth[i].sequence_number, input[i].sequence_number); | 96 EXPECT_EQ(truth[i].sequence_number, input[i].sequence_number); |
88 EXPECT_EQ(truth[i].payload_size, input[i].payload_size); | 97 EXPECT_EQ(truth[i].payload_size, input[i].payload_size); |
89 EXPECT_EQ(truth[i].probe_cluster_id, input[i].probe_cluster_id); | 98 EXPECT_EQ(truth[i].pacing_info, input[i].pacing_info); |
90 } | 99 } |
91 } | 100 } |
92 | 101 |
93 // Utility method, to reset arrival_time_ms before adding send time. | 102 // Utility method, to reset arrival_time_ms before adding send time. |
94 void OnSentPacket(PacketInfo info) { | 103 void OnSentPacket(PacketInfo info) { |
95 info.arrival_time_ms = 0; | 104 info.arrival_time_ms = 0; |
| 105 // TODO(philipel): Change -1, -1 to some values. |
96 adapter_->AddPacket(info.sequence_number, info.payload_size, | 106 adapter_->AddPacket(info.sequence_number, info.payload_size, |
97 info.probe_cluster_id); | 107 info.pacing_info); |
98 adapter_->OnSentPacket(info.sequence_number, info.send_time_ms); | 108 adapter_->OnSentPacket(info.sequence_number, info.send_time_ms); |
99 } | 109 } |
100 | 110 |
101 SimulatedClock clock_; | 111 SimulatedClock clock_; |
102 MockBitrateControllerAdapter bitrate_controller_; | 112 MockBitrateControllerAdapter bitrate_controller_; |
103 std::unique_ptr<TransportFeedbackAdapter> adapter_; | 113 std::unique_ptr<TransportFeedbackAdapter> adapter_; |
104 | 114 |
105 uint32_t target_bitrate_bps_; | 115 uint32_t target_bitrate_bps_; |
106 }; | 116 }; |
107 | 117 |
108 TEST_F(TransportFeedbackAdapterTest, AdaptsFeedbackAndPopulatesSendTimes) { | 118 TEST_F(TransportFeedbackAdapterTest, AdaptsFeedbackAndPopulatesSendTimes) { |
109 std::vector<PacketInfo> packets; | 119 std::vector<PacketInfo> packets; |
110 packets.push_back(PacketInfo(100, 200, 0, 1500, 0)); | 120 packets.push_back(PacketInfo(100, 200, 0, 1500, kPacingInfo0)); |
111 packets.push_back(PacketInfo(110, 210, 1, 1500, 0)); | 121 packets.push_back(PacketInfo(110, 210, 1, 1500, kPacingInfo0)); |
112 packets.push_back(PacketInfo(120, 220, 2, 1500, 0)); | 122 packets.push_back(PacketInfo(120, 220, 2, 1500, kPacingInfo0)); |
113 packets.push_back(PacketInfo(130, 230, 3, 1500, 1)); | 123 packets.push_back(PacketInfo(130, 230, 3, 1500, kPacingInfo1)); |
114 packets.push_back(PacketInfo(140, 240, 4, 1500, 1)); | 124 packets.push_back(PacketInfo(140, 240, 4, 1500, kPacingInfo1)); |
115 | 125 |
116 for (const PacketInfo& packet : packets) | 126 for (const PacketInfo& packet : packets) |
117 OnSentPacket(packet); | 127 OnSentPacket(packet); |
118 | 128 |
119 rtcp::TransportFeedback feedback; | 129 rtcp::TransportFeedback feedback; |
120 feedback.SetBase(packets[0].sequence_number, | 130 feedback.SetBase(packets[0].sequence_number, |
121 packets[0].arrival_time_ms * 1000); | 131 packets[0].arrival_time_ms * 1000); |
122 | 132 |
123 for (const PacketInfo& packet : packets) { | 133 for (const PacketInfo& packet : packets) { |
124 EXPECT_TRUE(feedback.AddReceivedPacket(packet.sequence_number, | 134 EXPECT_TRUE(feedback.AddReceivedPacket(packet.sequence_number, |
125 packet.arrival_time_ms * 1000)); | 135 packet.arrival_time_ms * 1000)); |
126 } | 136 } |
127 | 137 |
128 feedback.Build(); | 138 feedback.Build(); |
129 | 139 |
130 adapter_->OnTransportFeedback(feedback); | 140 adapter_->OnTransportFeedback(feedback); |
131 ComparePacketVectors(packets, adapter_->GetTransportFeedbackVector()); | 141 ComparePacketVectors(packets, adapter_->GetTransportFeedbackVector()); |
132 } | 142 } |
133 | 143 |
134 TEST_F(TransportFeedbackAdapterTest, LongFeedbackDelays) { | 144 TEST_F(TransportFeedbackAdapterTest, LongFeedbackDelays) { |
135 const int64_t kFeedbackTimeoutMs = 60001; | 145 const int64_t kFeedbackTimeoutMs = 60001; |
136 const int kMaxConsecutiveFailedLookups = 5; | 146 const int kMaxConsecutiveFailedLookups = 5; |
137 for (int i = 0; i < kMaxConsecutiveFailedLookups; ++i) { | 147 for (int i = 0; i < kMaxConsecutiveFailedLookups; ++i) { |
138 std::vector<PacketInfo> packets; | 148 std::vector<PacketInfo> packets; |
139 packets.push_back(PacketInfo(i * 100, 2 * i * 100, 0, 1500, 0)); | 149 packets.push_back(PacketInfo(i * 100, 2 * i * 100, 0, 1500, kPacingInfo0)); |
140 packets.push_back(PacketInfo(i * 100 + 10, 2 * i * 100 + 10, 1, 1500, 0)); | 150 packets.push_back( |
141 packets.push_back(PacketInfo(i * 100 + 20, 2 * i * 100 + 20, 2, 1500, 0)); | 151 PacketInfo(i * 100 + 10, 2 * i * 100 + 10, 1, 1500, kPacingInfo0)); |
142 packets.push_back(PacketInfo(i * 100 + 30, 2 * i * 100 + 30, 3, 1500, 1)); | 152 packets.push_back( |
143 packets.push_back(PacketInfo(i * 100 + 40, 2 * i * 100 + 40, 4, 1500, 1)); | 153 PacketInfo(i * 100 + 20, 2 * i * 100 + 20, 2, 1500, kPacingInfo0)); |
| 154 packets.push_back( |
| 155 PacketInfo(i * 100 + 30, 2 * i * 100 + 30, 3, 1500, kPacingInfo1)); |
| 156 packets.push_back( |
| 157 PacketInfo(i * 100 + 40, 2 * i * 100 + 40, 4, 1500, kPacingInfo1)); |
144 | 158 |
145 for (const PacketInfo& packet : packets) | 159 for (const PacketInfo& packet : packets) |
146 OnSentPacket(packet); | 160 OnSentPacket(packet); |
147 | 161 |
148 rtcp::TransportFeedback feedback; | 162 rtcp::TransportFeedback feedback; |
149 feedback.SetBase(packets[0].sequence_number, | 163 feedback.SetBase(packets[0].sequence_number, |
150 packets[0].arrival_time_ms * 1000); | 164 packets[0].arrival_time_ms * 1000); |
151 | 165 |
152 for (const PacketInfo& packet : packets) { | 166 for (const PacketInfo& packet : packets) { |
153 EXPECT_TRUE(feedback.AddReceivedPacket(packet.sequence_number, | 167 EXPECT_TRUE(feedback.AddReceivedPacket(packet.sequence_number, |
154 packet.arrival_time_ms * 1000)); | 168 packet.arrival_time_ms * 1000)); |
155 } | 169 } |
156 | 170 |
157 feedback.Build(); | 171 feedback.Build(); |
158 | 172 |
159 clock_.AdvanceTimeMilliseconds(kFeedbackTimeoutMs); | 173 clock_.AdvanceTimeMilliseconds(kFeedbackTimeoutMs); |
160 PacketInfo later_packet(kFeedbackTimeoutMs + i * 100 + 40, | 174 PacketInfo later_packet(kFeedbackTimeoutMs + i * 100 + 40, |
161 kFeedbackTimeoutMs + i * 200 + 40, 5, 1500, 1); | 175 kFeedbackTimeoutMs + i * 200 + 40, 5, 1500, |
| 176 kPacingInfo1); |
162 OnSentPacket(later_packet); | 177 OnSentPacket(later_packet); |
163 | 178 |
164 adapter_->OnTransportFeedback(feedback); | 179 adapter_->OnTransportFeedback(feedback); |
165 | 180 |
166 // Check that packets have timed out. | 181 // Check that packets have timed out. |
167 for (PacketInfo& packet : packets) { | 182 for (PacketInfo& packet : packets) { |
168 packet.send_time_ms = -1; | 183 packet.send_time_ms = -1; |
169 packet.payload_size = 0; | 184 packet.payload_size = 0; |
170 packet.probe_cluster_id = -1; | |
171 } | 185 } |
172 ComparePacketVectors(packets, adapter_->GetTransportFeedbackVector()); | 186 ComparePacketVectors(packets, adapter_->GetTransportFeedbackVector()); |
173 } | 187 } |
174 | 188 |
175 // Target bitrate should have halved due to feedback delays. | 189 // Target bitrate should have halved due to feedback delays. |
176 EXPECT_EQ(150000u, target_bitrate_bps_); | 190 EXPECT_EQ(150000u, target_bitrate_bps_); |
177 | 191 |
178 // Test with feedback that isn't late enough to time out. | 192 // Test with feedback that isn't late enough to time out. |
179 { | 193 { |
180 std::vector<PacketInfo> packets; | 194 std::vector<PacketInfo> packets; |
181 packets.push_back(PacketInfo(100, 200, 0, 1500, 0)); | 195 packets.push_back(PacketInfo(100, 200, 0, 1500, kPacingInfo0)); |
182 packets.push_back(PacketInfo(110, 210, 1, 1500, 0)); | 196 packets.push_back(PacketInfo(110, 210, 1, 1500, kPacingInfo0)); |
183 packets.push_back(PacketInfo(120, 220, 2, 1500, 0)); | 197 packets.push_back(PacketInfo(120, 220, 2, 1500, kPacingInfo0)); |
184 packets.push_back(PacketInfo(130, 230, 3, 1500, 1)); | 198 packets.push_back(PacketInfo(130, 230, 3, 1500, kPacingInfo1)); |
185 packets.push_back(PacketInfo(140, 240, 4, 1500, 1)); | 199 packets.push_back(PacketInfo(140, 240, 4, 1500, kPacingInfo1)); |
186 | 200 |
187 for (const PacketInfo& packet : packets) | 201 for (const PacketInfo& packet : packets) |
188 OnSentPacket(packet); | 202 OnSentPacket(packet); |
189 | 203 |
190 rtcp::TransportFeedback feedback; | 204 rtcp::TransportFeedback feedback; |
191 feedback.SetBase(packets[0].sequence_number, | 205 feedback.SetBase(packets[0].sequence_number, |
192 packets[0].arrival_time_ms * 1000); | 206 packets[0].arrival_time_ms * 1000); |
193 | 207 |
194 for (const PacketInfo& packet : packets) { | 208 for (const PacketInfo& packet : packets) { |
195 EXPECT_TRUE(feedback.AddReceivedPacket(packet.sequence_number, | 209 EXPECT_TRUE(feedback.AddReceivedPacket(packet.sequence_number, |
196 packet.arrival_time_ms * 1000)); | 210 packet.arrival_time_ms * 1000)); |
197 } | 211 } |
198 | 212 |
199 feedback.Build(); | 213 feedback.Build(); |
200 | 214 |
201 clock_.AdvanceTimeMilliseconds(kFeedbackTimeoutMs - 1); | 215 clock_.AdvanceTimeMilliseconds(kFeedbackTimeoutMs - 1); |
202 PacketInfo later_packet(kFeedbackTimeoutMs + 140, kFeedbackTimeoutMs + 240, | 216 PacketInfo later_packet(kFeedbackTimeoutMs + 140, kFeedbackTimeoutMs + 240, |
203 5, 1500, 1); | 217 5, 1500, kPacingInfo1); |
204 OnSentPacket(later_packet); | 218 OnSentPacket(later_packet); |
205 | 219 |
206 adapter_->OnTransportFeedback(feedback); | 220 adapter_->OnTransportFeedback(feedback); |
207 ComparePacketVectors(packets, adapter_->GetTransportFeedbackVector()); | 221 ComparePacketVectors(packets, adapter_->GetTransportFeedbackVector()); |
208 } | 222 } |
209 } | 223 } |
210 | 224 |
211 TEST_F(TransportFeedbackAdapterTest, HandlesDroppedPackets) { | 225 TEST_F(TransportFeedbackAdapterTest, HandlesDroppedPackets) { |
212 std::vector<PacketInfo> packets; | 226 std::vector<PacketInfo> packets; |
213 packets.push_back(PacketInfo(100, 200, 0, 1500, 1)); | 227 packets.push_back(PacketInfo(100, 200, 0, 1500, kPacingInfo0)); |
214 packets.push_back(PacketInfo(110, 210, 1, 1500, 2)); | 228 packets.push_back(PacketInfo(110, 210, 1, 1500, kPacingInfo1)); |
215 packets.push_back(PacketInfo(120, 220, 2, 1500, 3)); | 229 packets.push_back(PacketInfo(120, 220, 2, 1500, kPacingInfo2)); |
216 packets.push_back(PacketInfo(130, 230, 3, 1500, 4)); | 230 packets.push_back(PacketInfo(130, 230, 3, 1500, kPacingInfo3)); |
217 packets.push_back(PacketInfo(140, 240, 4, 1500, 5)); | 231 packets.push_back(PacketInfo(140, 240, 4, 1500, kPacingInfo4)); |
218 | 232 |
219 const uint16_t kSendSideDropBefore = 1; | 233 const uint16_t kSendSideDropBefore = 1; |
220 const uint16_t kReceiveSideDropAfter = 3; | 234 const uint16_t kReceiveSideDropAfter = 3; |
221 | 235 |
222 for (const PacketInfo& packet : packets) { | 236 for (const PacketInfo& packet : packets) { |
223 if (packet.sequence_number >= kSendSideDropBefore) | 237 if (packet.sequence_number >= kSendSideDropBefore) |
224 OnSentPacket(packet); | 238 OnSentPacket(packet); |
225 } | 239 } |
226 | 240 |
227 rtcp::TransportFeedback feedback; | 241 rtcp::TransportFeedback feedback; |
228 feedback.SetBase(packets[0].sequence_number, | 242 feedback.SetBase(packets[0].sequence_number, |
229 packets[0].arrival_time_ms * 1000); | 243 packets[0].arrival_time_ms * 1000); |
230 | 244 |
231 for (const PacketInfo& packet : packets) { | 245 for (const PacketInfo& packet : packets) { |
232 if (packet.sequence_number <= kReceiveSideDropAfter) { | 246 if (packet.sequence_number <= kReceiveSideDropAfter) { |
233 EXPECT_TRUE(feedback.AddReceivedPacket(packet.sequence_number, | 247 EXPECT_TRUE(feedback.AddReceivedPacket(packet.sequence_number, |
234 packet.arrival_time_ms * 1000)); | 248 packet.arrival_time_ms * 1000)); |
235 } | 249 } |
236 } | 250 } |
237 | 251 |
238 feedback.Build(); | 252 feedback.Build(); |
239 | 253 |
240 std::vector<PacketInfo> expected_packets( | 254 std::vector<PacketInfo> expected_packets( |
241 packets.begin(), packets.begin() + kReceiveSideDropAfter + 1); | 255 packets.begin(), packets.begin() + kReceiveSideDropAfter + 1); |
242 // Packets that have timed out on the send-side have lost the | 256 // Packets that have timed out on the send-side have lost the |
243 // information stored on the send-side. | 257 // information stored on the send-side. |
244 for (size_t i = 0; i < kSendSideDropBefore; ++i) { | 258 for (size_t i = 0; i < kSendSideDropBefore; ++i) { |
245 expected_packets[i].send_time_ms = -1; | 259 expected_packets[i].send_time_ms = -1; |
246 expected_packets[i].probe_cluster_id = -1; | |
247 expected_packets[i].payload_size = 0; | 260 expected_packets[i].payload_size = 0; |
248 } | 261 } |
249 | 262 |
250 adapter_->OnTransportFeedback(feedback); | 263 adapter_->OnTransportFeedback(feedback); |
251 ComparePacketVectors(expected_packets, | 264 ComparePacketVectors(expected_packets, |
252 adapter_->GetTransportFeedbackVector()); | 265 adapter_->GetTransportFeedbackVector()); |
253 } | 266 } |
254 | 267 |
255 TEST_F(TransportFeedbackAdapterTest, SendTimeWrapsBothWays) { | 268 TEST_F(TransportFeedbackAdapterTest, SendTimeWrapsBothWays) { |
256 int64_t kHighArrivalTimeMs = rtcp::TransportFeedback::kDeltaScaleFactor * | 269 int64_t kHighArrivalTimeMs = rtcp::TransportFeedback::kDeltaScaleFactor * |
257 static_cast<int64_t>(1 << 8) * | 270 static_cast<int64_t>(1 << 8) * |
258 static_cast<int64_t>((1 << 23) - 1) / 1000; | 271 static_cast<int64_t>((1 << 23) - 1) / 1000; |
259 std::vector<PacketInfo> packets; | 272 std::vector<PacketInfo> packets; |
260 packets.push_back(PacketInfo(kHighArrivalTimeMs - 64, 200, 0, 1500, | 273 packets.push_back( |
261 PacedPacketInfo::kNotAProbe)); | 274 PacketInfo(kHighArrivalTimeMs - 64, 200, 0, 1500, PacedPacketInfo())); |
262 packets.push_back(PacketInfo(kHighArrivalTimeMs + 64, 210, 1, 1500, | 275 packets.push_back( |
263 PacedPacketInfo::kNotAProbe)); | 276 PacketInfo(kHighArrivalTimeMs + 64, 210, 1, 1500, PacedPacketInfo())); |
264 packets.push_back(PacketInfo(kHighArrivalTimeMs, 220, 2, 1500, | 277 packets.push_back( |
265 PacedPacketInfo::kNotAProbe)); | 278 PacketInfo(kHighArrivalTimeMs, 220, 2, 1500, PacedPacketInfo())); |
266 | 279 |
267 for (const PacketInfo& packet : packets) | 280 for (const PacketInfo& packet : packets) |
268 OnSentPacket(packet); | 281 OnSentPacket(packet); |
269 | 282 |
270 for (size_t i = 0; i < packets.size(); ++i) { | 283 for (size_t i = 0; i < packets.size(); ++i) { |
271 std::unique_ptr<rtcp::TransportFeedback> feedback( | 284 std::unique_ptr<rtcp::TransportFeedback> feedback( |
272 new rtcp::TransportFeedback()); | 285 new rtcp::TransportFeedback()); |
273 feedback->SetBase(packets[i].sequence_number, | 286 feedback->SetBase(packets[i].sequence_number, |
274 packets[i].arrival_time_ms * 1000); | 287 packets[i].arrival_time_ms * 1000); |
275 | 288 |
276 EXPECT_TRUE(feedback->AddReceivedPacket(packets[i].sequence_number, | 289 EXPECT_TRUE(feedback->AddReceivedPacket(packets[i].sequence_number, |
277 packets[i].arrival_time_ms * 1000)); | 290 packets[i].arrival_time_ms * 1000)); |
278 | 291 |
279 rtc::Buffer raw_packet = feedback->Build(); | 292 rtc::Buffer raw_packet = feedback->Build(); |
280 feedback = rtcp::TransportFeedback::ParseFrom(raw_packet.data(), | 293 feedback = rtcp::TransportFeedback::ParseFrom(raw_packet.data(), |
281 raw_packet.size()); | 294 raw_packet.size()); |
282 | 295 |
283 std::vector<PacketInfo> expected_packets; | 296 std::vector<PacketInfo> expected_packets; |
284 expected_packets.push_back(packets[i]); | 297 expected_packets.push_back(packets[i]); |
285 | 298 |
286 adapter_->OnTransportFeedback(*feedback.get()); | 299 adapter_->OnTransportFeedback(*feedback.get()); |
287 ComparePacketVectors(expected_packets, | 300 ComparePacketVectors(expected_packets, |
288 adapter_->GetTransportFeedbackVector()); | 301 adapter_->GetTransportFeedbackVector()); |
289 } | 302 } |
290 } | 303 } |
291 | 304 |
292 TEST_F(TransportFeedbackAdapterTest, HandlesReordering) { | 305 TEST_F(TransportFeedbackAdapterTest, HandlesReordering) { |
293 std::vector<PacketInfo> packets; | 306 std::vector<PacketInfo> packets; |
294 packets.push_back(PacketInfo(120, 200, 0, 1500, 0)); | 307 packets.push_back(PacketInfo(120, 200, 0, 1500, kPacingInfo0)); |
295 packets.push_back(PacketInfo(110, 210, 1, 1500, 0)); | 308 packets.push_back(PacketInfo(110, 210, 1, 1500, kPacingInfo0)); |
296 packets.push_back(PacketInfo(100, 220, 2, 1500, 0)); | 309 packets.push_back(PacketInfo(100, 220, 2, 1500, kPacingInfo0)); |
297 std::vector<PacketInfo> expected_packets; | 310 std::vector<PacketInfo> expected_packets; |
298 expected_packets.push_back(packets[2]); | 311 expected_packets.push_back(packets[2]); |
299 expected_packets.push_back(packets[1]); | 312 expected_packets.push_back(packets[1]); |
300 expected_packets.push_back(packets[0]); | 313 expected_packets.push_back(packets[0]); |
301 | 314 |
302 for (const PacketInfo& packet : packets) | 315 for (const PacketInfo& packet : packets) |
303 OnSentPacket(packet); | 316 OnSentPacket(packet); |
304 | 317 |
305 rtcp::TransportFeedback feedback; | 318 rtcp::TransportFeedback feedback; |
306 feedback.SetBase(packets[0].sequence_number, | 319 feedback.SetBase(packets[0].sequence_number, |
(...skipping 15 matching lines...) Expand all Loading... |
322 std::vector<PacketInfo> sent_packets; | 335 std::vector<PacketInfo> sent_packets; |
323 const int64_t kSmallDeltaUs = | 336 const int64_t kSmallDeltaUs = |
324 rtcp::TransportFeedback::kDeltaScaleFactor * ((1 << 8) - 1); | 337 rtcp::TransportFeedback::kDeltaScaleFactor * ((1 << 8) - 1); |
325 const int64_t kLargePositiveDeltaUs = | 338 const int64_t kLargePositiveDeltaUs = |
326 rtcp::TransportFeedback::kDeltaScaleFactor * | 339 rtcp::TransportFeedback::kDeltaScaleFactor * |
327 std::numeric_limits<int16_t>::max(); | 340 std::numeric_limits<int16_t>::max(); |
328 const int64_t kLargeNegativeDeltaUs = | 341 const int64_t kLargeNegativeDeltaUs = |
329 rtcp::TransportFeedback::kDeltaScaleFactor * | 342 rtcp::TransportFeedback::kDeltaScaleFactor * |
330 std::numeric_limits<int16_t>::min(); | 343 std::numeric_limits<int16_t>::min(); |
331 | 344 |
332 PacketInfo info(100, 200, 0, 1500, true, PacedPacketInfo::kNotAProbe); | 345 PacketInfo info(100, 200, 0, 1500, true, PacedPacketInfo()); |
333 sent_packets.push_back(info); | 346 sent_packets.push_back(info); |
334 | 347 |
335 info.send_time_ms += kSmallDeltaUs / 1000; | 348 info.send_time_ms += kSmallDeltaUs / 1000; |
336 info.arrival_time_ms += kSmallDeltaUs / 1000; | 349 info.arrival_time_ms += kSmallDeltaUs / 1000; |
337 ++info.sequence_number; | 350 ++info.sequence_number; |
338 sent_packets.push_back(info); | 351 sent_packets.push_back(info); |
339 | 352 |
340 info.send_time_ms += kLargePositiveDeltaUs / 1000; | 353 info.send_time_ms += kLargePositiveDeltaUs / 1000; |
341 info.arrival_time_ms += kLargePositiveDeltaUs / 1000; | 354 info.arrival_time_ms += kLargePositiveDeltaUs / 1000; |
342 ++info.sequence_number; | 355 ++info.sequence_number; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 | 424 |
412 TEST_F(TransportFeedbackAdapterTest, UpdatesDelayBasedEstimate) { | 425 TEST_F(TransportFeedbackAdapterTest, UpdatesDelayBasedEstimate) { |
413 uint16_t seq_num = 0; | 426 uint16_t seq_num = 0; |
414 size_t kPayloadSize = 1000; | 427 size_t kPayloadSize = 1000; |
415 // The test must run and insert packets/feedback long enough that the | 428 // The test must run and insert packets/feedback long enough that the |
416 // BWE computes a valid estimate. | 429 // BWE computes a valid estimate. |
417 const int64_t kRunTimeMs = 6000; | 430 const int64_t kRunTimeMs = 6000; |
418 int64_t start_time_ms = clock_.TimeInMilliseconds(); | 431 int64_t start_time_ms = clock_.TimeInMilliseconds(); |
419 while (clock_.TimeInMilliseconds() - start_time_ms < kRunTimeMs) { | 432 while (clock_.TimeInMilliseconds() - start_time_ms < kRunTimeMs) { |
420 PacketInfo packet(clock_.TimeInMilliseconds(), clock_.TimeInMilliseconds(), | 433 PacketInfo packet(clock_.TimeInMilliseconds(), clock_.TimeInMilliseconds(), |
421 seq_num, kPayloadSize, PacedPacketInfo::kNotAProbe); | 434 seq_num, kPayloadSize, PacedPacketInfo()); |
422 OnSentPacket(packet); | 435 OnSentPacket(packet); |
423 // Create expected feedback and send into adapter. | 436 // Create expected feedback and send into adapter. |
424 std::unique_ptr<rtcp::TransportFeedback> feedback( | 437 std::unique_ptr<rtcp::TransportFeedback> feedback( |
425 new rtcp::TransportFeedback()); | 438 new rtcp::TransportFeedback()); |
426 feedback->SetBase(packet.sequence_number, packet.arrival_time_ms * 1000); | 439 feedback->SetBase(packet.sequence_number, packet.arrival_time_ms * 1000); |
427 EXPECT_TRUE(feedback->AddReceivedPacket(packet.sequence_number, | 440 EXPECT_TRUE(feedback->AddReceivedPacket(packet.sequence_number, |
428 packet.arrival_time_ms * 1000)); | 441 packet.arrival_time_ms * 1000)); |
429 rtc::Buffer raw_packet = feedback->Build(); | 442 rtc::Buffer raw_packet = feedback->Build(); |
430 feedback = rtcp::TransportFeedback::ParseFrom(raw_packet.data(), | 443 feedback = rtcp::TransportFeedback::ParseFrom(raw_packet.data(), |
431 raw_packet.size()); | 444 raw_packet.size()); |
432 EXPECT_TRUE(feedback.get() != nullptr); | 445 EXPECT_TRUE(feedback.get() != nullptr); |
433 adapter_->OnTransportFeedback(*feedback.get()); | 446 adapter_->OnTransportFeedback(*feedback.get()); |
434 clock_.AdvanceTimeMilliseconds(50); | 447 clock_.AdvanceTimeMilliseconds(50); |
435 ++seq_num; | 448 ++seq_num; |
436 } | 449 } |
437 EXPECT_GT(target_bitrate_bps_, 0u); | 450 EXPECT_GT(target_bitrate_bps_, 0u); |
438 } | 451 } |
439 | 452 |
440 } // namespace test | 453 } // namespace test |
441 } // namespace webrtc | 454 } // namespace webrtc |
OLD | NEW |