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

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

Issue 2378103005: Reland: Fix race / crash in OnNetworkRouteChanged(). (Closed)
Patch Set: . Created 4 years, 2 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
11 #include <limits> 11 #include <limits>
12 #include <memory> 12 #include <memory>
13 #include <vector> 13 #include <vector>
14 14
15 #include "webrtc/test/gmock.h" 15 #include "webrtc/test/gmock.h"
16 #include "webrtc/test/gtest.h" 16 #include "webrtc/test/gtest.h"
17 17
18 #include "webrtc/base/checks.h" 18 #include "webrtc/base/checks.h"
19 #include "webrtc/modules/bitrate_controller/include/mock/mock_bitrate_controller .h" 19 #include "webrtc/modules/bitrate_controller/include/mock/mock_bitrate_controller .h"
20 #include "webrtc/modules/remote_bitrate_estimator/include/mock/mock_remote_bitra te_estimator.h" 20 #include "webrtc/modules/congestion_controller/transport_feedback_adapter.h"
21 #include "webrtc/modules/remote_bitrate_estimator/transport_feedback_adapter.h"
22 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" 21 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
23 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" 22 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h"
24 #include "webrtc/system_wrappers/include/clock.h" 23 #include "webrtc/system_wrappers/include/clock.h"
25 24
26 using ::testing::_; 25 using ::testing::_;
27 using ::testing::Invoke; 26 using ::testing::Invoke;
28 27
29 namespace webrtc { 28 namespace webrtc {
30 namespace test { 29 namespace test {
31 30
32 class TransportFeedbackAdapterTest : public ::testing::Test { 31 class TransportFeedbackAdapterTest : public ::testing::Test {
33 public: 32 public:
34 TransportFeedbackAdapterTest() 33 TransportFeedbackAdapterTest()
35 : clock_(0), 34 : clock_(0), bitrate_controller_(this), target_bitrate_bps_(0) {}
36 bitrate_estimator_(nullptr),
37 bitrate_controller_(this),
38 receiver_estimated_bitrate_(0) {}
39 35
40 virtual ~TransportFeedbackAdapterTest() {} 36 virtual ~TransportFeedbackAdapterTest() {}
41 37
42 virtual void SetUp() { 38 virtual void SetUp() {
43 adapter_.reset(new TransportFeedbackAdapter(&clock_)); 39 adapter_.reset(new TransportFeedbackAdapter(&clock_, &bitrate_controller_));
44 40 adapter_->InitBwe();
45 bitrate_estimator_ = new MockRemoteBitrateEstimator();
46 adapter_->SetBitrateEstimator(bitrate_estimator_);
47 } 41 }
48 42
49 virtual void TearDown() { 43 virtual void TearDown() { adapter_.reset(); }
50 adapter_.reset();
51 }
52 44
53 protected: 45 protected:
54 // Proxy class used since TransportFeedbackAdapter will own the instance 46 // Proxy class used since TransportFeedbackAdapter will own the instance
55 // passed at construction. 47 // passed at construction.
56 class MockBitrateControllerAdapter : public MockBitrateController { 48 class MockBitrateControllerAdapter : public MockBitrateController {
57 public: 49 public:
58 explicit MockBitrateControllerAdapter(TransportFeedbackAdapterTest* owner) 50 explicit MockBitrateControllerAdapter(TransportFeedbackAdapterTest* owner)
59 : MockBitrateController(), owner_(owner) {} 51 : MockBitrateController(), owner_(owner) {}
60 52
61 ~MockBitrateControllerAdapter() override {} 53 ~MockBitrateControllerAdapter() override {}
62 54
63 void OnReceiveBitrateChanged(const std::vector<uint32_t>& ssrcs, 55 void OnDelayBasedBweResult(const DelayBasedBwe::Result& result) override {
64 uint32_t bitrate_bps) override { 56 owner_->target_bitrate_bps_ = result.target_bitrate_bps;
65 owner_->receiver_estimated_bitrate_ = bitrate_bps;
66 } 57 }
67 58
68 TransportFeedbackAdapterTest* const owner_; 59 TransportFeedbackAdapterTest* const owner_;
69 }; 60 };
70 61
71 void OnReceivedEstimatedBitrate(uint32_t bitrate) {} 62 void OnReceivedEstimatedBitrate(uint32_t bitrate) {}
72 63
73 void OnReceivedRtcpReceiverReport(const ReportBlockList& report_blocks, 64 void OnReceivedRtcpReceiverReport(const ReportBlockList& report_blocks,
74 int64_t rtt, 65 int64_t rtt,
75 int64_t now_ms) {} 66 int64_t now_ms) {}
(...skipping 23 matching lines...) Expand all
99 90
100 // Utility method, to reset arrival_time_ms before adding send time. 91 // Utility method, to reset arrival_time_ms before adding send time.
101 void OnSentPacket(PacketInfo info) { 92 void OnSentPacket(PacketInfo info) {
102 info.arrival_time_ms = 0; 93 info.arrival_time_ms = 0;
103 adapter_->AddPacket(info.sequence_number, info.payload_size, 94 adapter_->AddPacket(info.sequence_number, info.payload_size,
104 info.probe_cluster_id); 95 info.probe_cluster_id);
105 adapter_->OnSentPacket(info.sequence_number, info.send_time_ms); 96 adapter_->OnSentPacket(info.sequence_number, info.send_time_ms);
106 } 97 }
107 98
108 SimulatedClock clock_; 99 SimulatedClock clock_;
109 MockRemoteBitrateEstimator* bitrate_estimator_;
110 MockBitrateControllerAdapter bitrate_controller_; 100 MockBitrateControllerAdapter bitrate_controller_;
111 std::unique_ptr<TransportFeedbackAdapter> adapter_; 101 std::unique_ptr<TransportFeedbackAdapter> adapter_;
112 102
113 uint32_t receiver_estimated_bitrate_; 103 uint32_t target_bitrate_bps_;
114 }; 104 };
115 105
116 TEST_F(TransportFeedbackAdapterTest, AdaptsFeedbackAndPopulatesSendTimes) { 106 TEST_F(TransportFeedbackAdapterTest, AdaptsFeedbackAndPopulatesSendTimes) {
117 std::vector<PacketInfo> packets; 107 std::vector<PacketInfo> packets;
118 packets.push_back(PacketInfo(100, 200, 0, 1500, 0)); 108 packets.push_back(PacketInfo(100, 200, 0, 1500, 0));
119 packets.push_back(PacketInfo(110, 210, 1, 1500, 0)); 109 packets.push_back(PacketInfo(110, 210, 1, 1500, 0));
120 packets.push_back(PacketInfo(120, 220, 2, 1500, 0)); 110 packets.push_back(PacketInfo(120, 220, 2, 1500, 0));
121 packets.push_back(PacketInfo(130, 230, 3, 1500, 1)); 111 packets.push_back(PacketInfo(130, 230, 3, 1500, 1));
122 packets.push_back(PacketInfo(140, 240, 4, 1500, 1)); 112 packets.push_back(PacketInfo(140, 240, 4, 1500, 1));
123 113
124 for (const PacketInfo& packet : packets) 114 for (const PacketInfo& packet : packets)
125 OnSentPacket(packet); 115 OnSentPacket(packet);
126 116
127 rtcp::TransportFeedback feedback; 117 rtcp::TransportFeedback feedback;
128 feedback.SetBase(packets[0].sequence_number, 118 feedback.SetBase(packets[0].sequence_number,
129 packets[0].arrival_time_ms * 1000); 119 packets[0].arrival_time_ms * 1000);
130 120
131 for (const PacketInfo& packet : packets) { 121 for (const PacketInfo& packet : packets) {
132 EXPECT_TRUE(feedback.AddReceivedPacket(packet.sequence_number, 122 EXPECT_TRUE(feedback.AddReceivedPacket(packet.sequence_number,
133 packet.arrival_time_ms * 1000)); 123 packet.arrival_time_ms * 1000));
134 } 124 }
135 125
136 feedback.Build(); 126 feedback.Build();
137 127
138 EXPECT_CALL(*bitrate_estimator_, IncomingPacketFeedbackVector(_))
139 .Times(1)
140 .WillOnce(Invoke(
141 [packets, this](const std::vector<PacketInfo>& feedback_vector) {
142 ComparePacketVectors(packets, feedback_vector);
143 }));
144 adapter_->OnTransportFeedback(feedback); 128 adapter_->OnTransportFeedback(feedback);
129 ComparePacketVectors(packets, adapter_->GetTransportFeedbackVector());
145 } 130 }
146 131
147 TEST_F(TransportFeedbackAdapterTest, HandlesDroppedPackets) { 132 TEST_F(TransportFeedbackAdapterTest, HandlesDroppedPackets) {
148 std::vector<PacketInfo> packets; 133 std::vector<PacketInfo> packets;
149 packets.push_back(PacketInfo(100, 200, 0, 1500, 1)); 134 packets.push_back(PacketInfo(100, 200, 0, 1500, 1));
150 packets.push_back(PacketInfo(110, 210, 1, 1500, 2)); 135 packets.push_back(PacketInfo(110, 210, 1, 1500, 2));
151 packets.push_back(PacketInfo(120, 220, 2, 1500, 3)); 136 packets.push_back(PacketInfo(120, 220, 2, 1500, 3));
152 packets.push_back(PacketInfo(130, 230, 3, 1500, 4)); 137 packets.push_back(PacketInfo(130, 230, 3, 1500, 4));
153 packets.push_back(PacketInfo(140, 240, 4, 1500, 5)); 138 packets.push_back(PacketInfo(140, 240, 4, 1500, 5));
154 139
(...skipping 15 matching lines...) Expand all
170 packet.arrival_time_ms * 1000)); 155 packet.arrival_time_ms * 1000));
171 } 156 }
172 } 157 }
173 158
174 feedback.Build(); 159 feedback.Build();
175 160
176 std::vector<PacketInfo> expected_packets( 161 std::vector<PacketInfo> expected_packets(
177 packets.begin() + kSendSideDropBefore, 162 packets.begin() + kSendSideDropBefore,
178 packets.begin() + kReceiveSideDropAfter + 1); 163 packets.begin() + kReceiveSideDropAfter + 1);
179 164
180 EXPECT_CALL(*bitrate_estimator_, IncomingPacketFeedbackVector(_))
181 .Times(1)
182 .WillOnce(Invoke([expected_packets,
183 this](const std::vector<PacketInfo>& feedback_vector) {
184 ComparePacketVectors(expected_packets, feedback_vector);
185 }));
186 adapter_->OnTransportFeedback(feedback); 165 adapter_->OnTransportFeedback(feedback);
166 ComparePacketVectors(expected_packets,
167 adapter_->GetTransportFeedbackVector());
187 } 168 }
188 169
189 TEST_F(TransportFeedbackAdapterTest, SendTimeWrapsBothWays) { 170 TEST_F(TransportFeedbackAdapterTest, SendTimeWrapsBothWays) {
190 int64_t kHighArrivalTimeMs = rtcp::TransportFeedback::kDeltaScaleFactor * 171 int64_t kHighArrivalTimeMs = rtcp::TransportFeedback::kDeltaScaleFactor *
191 static_cast<int64_t>(1 << 8) * 172 static_cast<int64_t>(1 << 8) *
192 static_cast<int64_t>((1 << 23) - 1) / 1000; 173 static_cast<int64_t>((1 << 23) - 1) / 1000;
193 std::vector<PacketInfo> packets; 174 std::vector<PacketInfo> packets;
194 packets.push_back(PacketInfo(kHighArrivalTimeMs - 64, 200, 0, 1500, 175 packets.push_back(PacketInfo(kHighArrivalTimeMs - 64, 200, 0, 1500,
195 PacketInfo::kNotAProbe)); 176 PacketInfo::kNotAProbe));
196 packets.push_back(PacketInfo(kHighArrivalTimeMs + 64, 210, 1, 1500, 177 packets.push_back(PacketInfo(kHighArrivalTimeMs + 64, 210, 1, 1500,
(...skipping 13 matching lines...) Expand all
210 EXPECT_TRUE(feedback->AddReceivedPacket(packets[i].sequence_number, 191 EXPECT_TRUE(feedback->AddReceivedPacket(packets[i].sequence_number,
211 packets[i].arrival_time_ms * 1000)); 192 packets[i].arrival_time_ms * 1000));
212 193
213 rtc::Buffer raw_packet = feedback->Build(); 194 rtc::Buffer raw_packet = feedback->Build();
214 feedback = rtcp::TransportFeedback::ParseFrom(raw_packet.data(), 195 feedback = rtcp::TransportFeedback::ParseFrom(raw_packet.data(),
215 raw_packet.size()); 196 raw_packet.size());
216 197
217 std::vector<PacketInfo> expected_packets; 198 std::vector<PacketInfo> expected_packets;
218 expected_packets.push_back(packets[i]); 199 expected_packets.push_back(packets[i]);
219 200
220 EXPECT_CALL(*bitrate_estimator_, IncomingPacketFeedbackVector(_))
221 .Times(1)
222 .WillOnce(Invoke([expected_packets, this](
223 const std::vector<PacketInfo>& feedback_vector) {
224 ComparePacketVectors(expected_packets, feedback_vector);
225 }));
226 adapter_->OnTransportFeedback(*feedback.get()); 201 adapter_->OnTransportFeedback(*feedback.get());
202 ComparePacketVectors(expected_packets,
203 adapter_->GetTransportFeedbackVector());
227 } 204 }
228 } 205 }
229 206
230 TEST_F(TransportFeedbackAdapterTest, HandlesReordering) { 207 TEST_F(TransportFeedbackAdapterTest, HandlesReordering) {
231 std::vector<PacketInfo> packets; 208 std::vector<PacketInfo> packets;
232 packets.push_back(PacketInfo(120, 200, 0, 1500, 0)); 209 packets.push_back(PacketInfo(120, 200, 0, 1500, 0));
233 packets.push_back(PacketInfo(110, 210, 1, 1500, 0)); 210 packets.push_back(PacketInfo(110, 210, 1, 1500, 0));
234 packets.push_back(PacketInfo(100, 220, 2, 1500, 0)); 211 packets.push_back(PacketInfo(100, 220, 2, 1500, 0));
235 std::vector<PacketInfo> expected_packets; 212 std::vector<PacketInfo> expected_packets;
236 expected_packets.push_back(packets[2]); 213 expected_packets.push_back(packets[2]);
237 expected_packets.push_back(packets[1]); 214 expected_packets.push_back(packets[1]);
238 expected_packets.push_back(packets[0]); 215 expected_packets.push_back(packets[0]);
239 216
240 for (const PacketInfo& packet : packets) 217 for (const PacketInfo& packet : packets)
241 OnSentPacket(packet); 218 OnSentPacket(packet);
242 219
243 rtcp::TransportFeedback feedback; 220 rtcp::TransportFeedback feedback;
244 feedback.SetBase(packets[0].sequence_number, 221 feedback.SetBase(packets[0].sequence_number,
245 packets[0].arrival_time_ms * 1000); 222 packets[0].arrival_time_ms * 1000);
246 223
247 for (const PacketInfo& packet : packets) { 224 for (const PacketInfo& packet : packets) {
248 EXPECT_TRUE(feedback.AddReceivedPacket(packet.sequence_number, 225 EXPECT_TRUE(feedback.AddReceivedPacket(packet.sequence_number,
249 packet.arrival_time_ms * 1000)); 226 packet.arrival_time_ms * 1000));
250 } 227 }
251 228
252 feedback.Build(); 229 feedback.Build();
253 230
254 EXPECT_CALL(*bitrate_estimator_, IncomingPacketFeedbackVector(_))
255 .Times(1)
256 .WillOnce(Invoke([expected_packets,
257 this](const std::vector<PacketInfo>& feedback_vector) {
258 ComparePacketVectors(expected_packets, feedback_vector);
259 }));
260 adapter_->OnTransportFeedback(feedback); 231 adapter_->OnTransportFeedback(feedback);
232 ComparePacketVectors(expected_packets,
233 adapter_->GetTransportFeedbackVector());
261 } 234 }
262 235
263 TEST_F(TransportFeedbackAdapterTest, TimestampDeltas) { 236 TEST_F(TransportFeedbackAdapterTest, TimestampDeltas) {
264 std::vector<PacketInfo> sent_packets; 237 std::vector<PacketInfo> sent_packets;
265 const int64_t kSmallDeltaUs = 238 const int64_t kSmallDeltaUs =
266 rtcp::TransportFeedback::kDeltaScaleFactor * ((1 << 8) - 1); 239 rtcp::TransportFeedback::kDeltaScaleFactor * ((1 << 8) - 1);
267 const int64_t kLargePositiveDeltaUs = 240 const int64_t kLargePositiveDeltaUs =
268 rtcp::TransportFeedback::kDeltaScaleFactor * 241 rtcp::TransportFeedback::kDeltaScaleFactor *
269 std::numeric_limits<int16_t>::max(); 242 std::numeric_limits<int16_t>::max();
270 const int64_t kLargeNegativeDeltaUs = 243 const int64_t kLargeNegativeDeltaUs =
(...skipping 16 matching lines...) Expand all
287 info.send_time_ms += kLargeNegativeDeltaUs / 1000; 260 info.send_time_ms += kLargeNegativeDeltaUs / 1000;
288 info.arrival_time_ms += kLargeNegativeDeltaUs / 1000; 261 info.arrival_time_ms += kLargeNegativeDeltaUs / 1000;
289 ++info.sequence_number; 262 ++info.sequence_number;
290 sent_packets.push_back(info); 263 sent_packets.push_back(info);
291 264
292 // Too large, delta - will need two feedback messages. 265 // Too large, delta - will need two feedback messages.
293 info.send_time_ms += (kLargePositiveDeltaUs + 1000) / 1000; 266 info.send_time_ms += (kLargePositiveDeltaUs + 1000) / 1000;
294 info.arrival_time_ms += (kLargePositiveDeltaUs + 1000) / 1000; 267 info.arrival_time_ms += (kLargePositiveDeltaUs + 1000) / 1000;
295 ++info.sequence_number; 268 ++info.sequence_number;
296 269
297 // Expected to be ordered on arrival time when the feedback message has been
298 // parsed.
299 std::vector<PacketInfo> expected_packets;
300 expected_packets.push_back(sent_packets[0]);
301 expected_packets.push_back(sent_packets[3]);
302 expected_packets.push_back(sent_packets[1]);
303 expected_packets.push_back(sent_packets[2]);
304
305 // Packets will be added to send history. 270 // Packets will be added to send history.
306 for (const PacketInfo& packet : sent_packets) 271 for (const PacketInfo& packet : sent_packets)
307 OnSentPacket(packet); 272 OnSentPacket(packet);
308 OnSentPacket(info); 273 OnSentPacket(info);
309 274
310 // Create expected feedback and send into adapter. 275 // Create expected feedback and send into adapter.
311 std::unique_ptr<rtcp::TransportFeedback> feedback( 276 std::unique_ptr<rtcp::TransportFeedback> feedback(
312 new rtcp::TransportFeedback()); 277 new rtcp::TransportFeedback());
313 feedback->SetBase(sent_packets[0].sequence_number, 278 feedback->SetBase(sent_packets[0].sequence_number,
314 sent_packets[0].arrival_time_ms * 1000); 279 sent_packets[0].arrival_time_ms * 1000);
315 280
316 for (const PacketInfo& packet : sent_packets) { 281 for (const PacketInfo& packet : sent_packets) {
317 EXPECT_TRUE(feedback->AddReceivedPacket(packet.sequence_number, 282 EXPECT_TRUE(feedback->AddReceivedPacket(packet.sequence_number,
318 packet.arrival_time_ms * 1000)); 283 packet.arrival_time_ms * 1000));
319 } 284 }
320 EXPECT_FALSE(feedback->AddReceivedPacket(info.sequence_number, 285 EXPECT_FALSE(feedback->AddReceivedPacket(info.sequence_number,
321 info.arrival_time_ms * 1000)); 286 info.arrival_time_ms * 1000));
322 287
323 rtc::Buffer raw_packet = feedback->Build(); 288 rtc::Buffer raw_packet = feedback->Build();
324 feedback = 289 feedback =
325 rtcp::TransportFeedback::ParseFrom(raw_packet.data(), raw_packet.size()); 290 rtcp::TransportFeedback::ParseFrom(raw_packet.data(), raw_packet.size());
326 291
327 std::vector<PacketInfo> received_feedback; 292 std::vector<PacketInfo> received_feedback;
328 293
329 EXPECT_TRUE(feedback.get() != nullptr); 294 EXPECT_TRUE(feedback.get() != nullptr);
330 EXPECT_CALL(*bitrate_estimator_, IncomingPacketFeedbackVector(_))
331 .Times(1)
332 .WillOnce(Invoke([expected_packets, &received_feedback](
333 const std::vector<PacketInfo>& feedback_vector) {
334 EXPECT_EQ(expected_packets.size(), feedback_vector.size());
335 received_feedback = feedback_vector;
336 }));
337 adapter_->OnTransportFeedback(*feedback.get()); 295 adapter_->OnTransportFeedback(*feedback.get());
296 {
297 // Expected to be ordered on arrival time when the feedback message has been
298 // parsed.
299 std::vector<PacketInfo> expected_packets;
300 expected_packets.push_back(sent_packets[0]);
301 expected_packets.push_back(sent_packets[3]);
302 expected_packets.push_back(sent_packets[1]);
303 expected_packets.push_back(sent_packets[2]);
304 ComparePacketVectors(expected_packets,
305 adapter_->GetTransportFeedbackVector());
306 }
338 307
339 // Create a new feedback message and add the trailing item. 308 // Create a new feedback message and add the trailing item.
340 feedback.reset(new rtcp::TransportFeedback()); 309 feedback.reset(new rtcp::TransportFeedback());
341 feedback->SetBase(info.sequence_number, info.arrival_time_ms * 1000); 310 feedback->SetBase(info.sequence_number, info.arrival_time_ms * 1000);
342 EXPECT_TRUE(feedback->AddReceivedPacket(info.sequence_number, 311 EXPECT_TRUE(feedback->AddReceivedPacket(info.sequence_number,
343 info.arrival_time_ms * 1000)); 312 info.arrival_time_ms * 1000));
344 raw_packet = feedback->Build(); 313 raw_packet = feedback->Build();
345 feedback = 314 feedback =
346 rtcp::TransportFeedback::ParseFrom(raw_packet.data(), raw_packet.size()); 315 rtcp::TransportFeedback::ParseFrom(raw_packet.data(), raw_packet.size());
347 316
348 EXPECT_TRUE(feedback.get() != nullptr); 317 EXPECT_TRUE(feedback.get() != nullptr);
349 EXPECT_CALL(*bitrate_estimator_, IncomingPacketFeedbackVector(_))
350 .Times(1)
351 .WillOnce(Invoke(
352 [&received_feedback](const std::vector<PacketInfo>& feedback_vector) {
353 EXPECT_EQ(1u, feedback_vector.size());
354 received_feedback.push_back(feedback_vector[0]);
355 }));
356 adapter_->OnTransportFeedback(*feedback.get()); 318 adapter_->OnTransportFeedback(*feedback.get());
319 {
320 std::vector<PacketInfo> expected_packets;
321 expected_packets.push_back(info);
322 ComparePacketVectors(expected_packets,
323 adapter_->GetTransportFeedbackVector());
324 }
325 }
357 326
358 expected_packets.push_back(info); 327 TEST_F(TransportFeedbackAdapterTest, UpdatesDelayBasedEstimate) {
359 328 uint16_t seq_num = 0;
360 ComparePacketVectors(expected_packets, received_feedback); 329 size_t kPayloadSize = 1000;
330 // The test must run and insert packets/feedback long enough that the
331 // BWE computes a valid estimate.
332 const int64_t kRunTimeMs = 6000;
333 int64_t start_time_ms = clock_.TimeInMilliseconds();
334 while (clock_.TimeInMilliseconds() - start_time_ms < kRunTimeMs) {
335 PacketInfo packet(clock_.TimeInMilliseconds(), clock_.TimeInMilliseconds(),
336 seq_num, kPayloadSize, PacketInfo::kNotAProbe);
337 OnSentPacket(packet);
338 // Create expected feedback and send into adapter.
339 std::unique_ptr<rtcp::TransportFeedback> feedback(
340 new rtcp::TransportFeedback());
341 feedback->SetBase(packet.sequence_number, packet.arrival_time_ms * 1000);
342 EXPECT_TRUE(feedback->AddReceivedPacket(packet.sequence_number,
343 packet.arrival_time_ms * 1000));
344 rtc::Buffer raw_packet = feedback->Build();
345 feedback = rtcp::TransportFeedback::ParseFrom(raw_packet.data(),
346 raw_packet.size());
347 EXPECT_TRUE(feedback.get() != nullptr);
348 adapter_->OnTransportFeedback(*feedback.get());
349 clock_.AdvanceTimeMilliseconds(50);
350 ++seq_num;
351 }
352 EXPECT_GT(target_bitrate_bps_, 0u);
361 } 353 }
362 354
363 } // namespace test 355 } // namespace test
364 } // namespace webrtc 356 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/congestion_controller/transport_feedback_adapter.cc ('k') | webrtc/modules/remote_bitrate_estimator/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698