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

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

Issue 3000773002: Move PacedSender ownership to RtpTransportControllerSend. (Closed)
Patch Set: Created 3 years, 4 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) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 } // namespace 56 } // namespace
57 57
58 namespace test { 58 namespace test {
59 59
60 class CongestionControllerTest : public ::testing::Test { 60 class CongestionControllerTest : public ::testing::Test {
61 protected: 61 protected:
62 CongestionControllerTest() : clock_(123456), target_bitrate_observer_(this) {} 62 CongestionControllerTest() : clock_(123456), target_bitrate_observer_(this) {}
63 ~CongestionControllerTest() override {} 63 ~CongestionControllerTest() override {}
64 64
65 void SetUp() override { 65 void SetUp() override {
66 pacer_ = new NiceMock<MockPacedSender>(); 66 controller_.reset(
67 std::unique_ptr<PacedSender> pacer(pacer_); // Passes ownership. 67 new CongestionController(&clock_, &observer_, &remote_bitrate_observer_,
68 controller_.reset(new CongestionController( 68 &event_log_, &packet_router_, &pacer_));
69 &clock_, &observer_, &remote_bitrate_observer_, &event_log_,
70 &packet_router_, std::move(pacer)));
71 bandwidth_observer_.reset( 69 bandwidth_observer_.reset(
72 controller_->GetBitrateController()->CreateRtcpBandwidthObserver()); 70 controller_->GetBitrateController()->CreateRtcpBandwidthObserver());
73 71
74 // Set the initial bitrate estimate and expect the |observer| and |pacer_| 72 // Set the initial bitrate estimate and expect the |observer| and |pacer_|
75 // to be updated. 73 // to be updated.
76 EXPECT_CALL(observer_, OnNetworkChanged(kInitialBitrateBps, _, _, _)); 74 EXPECT_CALL(observer_, OnNetworkChanged(kInitialBitrateBps, _, _, _));
77 EXPECT_CALL(*pacer_, SetEstimatedBitrate(kInitialBitrateBps)); 75 EXPECT_CALL(pacer_, SetEstimatedBitrate(kInitialBitrateBps));
78 EXPECT_CALL(*pacer_, CreateProbeCluster(kInitialBitrateBps * 3)); 76 EXPECT_CALL(pacer_, CreateProbeCluster(kInitialBitrateBps * 3));
79 EXPECT_CALL(*pacer_, CreateProbeCluster(kInitialBitrateBps * 5)); 77 EXPECT_CALL(pacer_, CreateProbeCluster(kInitialBitrateBps * 5));
80 controller_->SetBweBitrates(0, kInitialBitrateBps, 5 * kInitialBitrateBps); 78 controller_->SetBweBitrates(0, kInitialBitrateBps, 5 * kInitialBitrateBps);
81 } 79 }
82 80
83 // Custom setup - use an observer that tracks the target bitrate, without 81 // Custom setup - use an observer that tracks the target bitrate, without
84 // prescribing on which iterations it must change (like a mock would). 82 // prescribing on which iterations it must change (like a mock would).
85 void TargetBitrateTrackingSetup() { 83 void TargetBitrateTrackingSetup() {
86 std::unique_ptr<PacedSender> pacer(new NiceMock<MockPacedSender>());
87 controller_.reset(new CongestionController( 84 controller_.reset(new CongestionController(
88 &clock_, &target_bitrate_observer_, &remote_bitrate_observer_, 85 &clock_, &target_bitrate_observer_, &remote_bitrate_observer_,
89 &event_log_, &packet_router_, std::move(pacer))); 86 &event_log_, &packet_router_, &pacer_));
90 controller_->SetBweBitrates(0, kInitialBitrateBps, 5 * kInitialBitrateBps); 87 controller_->SetBweBitrates(0, kInitialBitrateBps, 5 * kInitialBitrateBps);
91 } 88 }
92 89
93 void OnSentPacket(const PacketFeedback& packet_feedback) { 90 void OnSentPacket(const PacketFeedback& packet_feedback) {
94 constexpr uint32_t ssrc = 0; 91 constexpr uint32_t ssrc = 0;
95 controller_->AddPacket(ssrc, packet_feedback.sequence_number, 92 controller_->AddPacket(ssrc, packet_feedback.sequence_number,
96 packet_feedback.payload_size, 93 packet_feedback.payload_size,
97 packet_feedback.pacing_info); 94 packet_feedback.pacing_info);
98 controller_->OnSentPacket(rtc::SentPacket(packet_feedback.sequence_number, 95 controller_->OnSentPacket(rtc::SentPacket(packet_feedback.sequence_number,
99 packet_feedback.send_time_ms)); 96 packet_feedback.send_time_ms));
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 controller_->OnTransportFeedback(*feedback.get()); 139 controller_->OnTransportFeedback(*feedback.get());
143 clock_.AdvanceTimeMilliseconds(50); 140 clock_.AdvanceTimeMilliseconds(50);
144 controller_->Process(); 141 controller_->Process();
145 ++(*seq_num); 142 ++(*seq_num);
146 } 143 }
147 } 144 }
148 145
149 SimulatedClock clock_; 146 SimulatedClock clock_;
150 StrictMock<MockCongestionObserver> observer_; 147 StrictMock<MockCongestionObserver> observer_;
151 TargetBitrateObserver target_bitrate_observer_; 148 TargetBitrateObserver target_bitrate_observer_;
152 NiceMock<MockPacedSender>* pacer_;
153 NiceMock<MockRemoteBitrateObserver> remote_bitrate_observer_; 149 NiceMock<MockRemoteBitrateObserver> remote_bitrate_observer_;
154 NiceMock<MockRtcEventLog> event_log_; 150 NiceMock<MockRtcEventLog> event_log_;
155 std::unique_ptr<RtcpBandwidthObserver> bandwidth_observer_; 151 std::unique_ptr<RtcpBandwidthObserver> bandwidth_observer_;
156 PacketRouter packet_router_; 152 PacketRouter packet_router_;
153 NiceMock<MockPacedSender> pacer_;
157 std::unique_ptr<CongestionController> controller_; 154 std::unique_ptr<CongestionController> controller_;
158 155
159 rtc::Optional<uint32_t> target_bitrate_bps_; 156 rtc::Optional<uint32_t> target_bitrate_bps_;
160 }; 157 };
161 158
162 TEST_F(CongestionControllerTest, OnNetworkChanged) { 159 TEST_F(CongestionControllerTest, OnNetworkChanged) {
163 // Test no change. 160 // Test no change.
164 clock_.AdvanceTimeMilliseconds(25); 161 clock_.AdvanceTimeMilliseconds(25);
165 controller_->Process(); 162 controller_->Process();
166 163
167 EXPECT_CALL(observer_, OnNetworkChanged(kInitialBitrateBps * 2, _, _, _)); 164 EXPECT_CALL(observer_, OnNetworkChanged(kInitialBitrateBps * 2, _, _, _));
168 EXPECT_CALL(*pacer_, SetEstimatedBitrate(kInitialBitrateBps * 2)); 165 EXPECT_CALL(pacer_, SetEstimatedBitrate(kInitialBitrateBps * 2));
169 bandwidth_observer_->OnReceivedEstimatedBitrate(kInitialBitrateBps * 2); 166 bandwidth_observer_->OnReceivedEstimatedBitrate(kInitialBitrateBps * 2);
170 clock_.AdvanceTimeMilliseconds(25); 167 clock_.AdvanceTimeMilliseconds(25);
171 controller_->Process(); 168 controller_->Process();
172 169
173 EXPECT_CALL(observer_, OnNetworkChanged(kInitialBitrateBps, _, _, _)); 170 EXPECT_CALL(observer_, OnNetworkChanged(kInitialBitrateBps, _, _, _));
174 EXPECT_CALL(*pacer_, SetEstimatedBitrate(kInitialBitrateBps)); 171 EXPECT_CALL(pacer_, SetEstimatedBitrate(kInitialBitrateBps));
175 bandwidth_observer_->OnReceivedEstimatedBitrate(kInitialBitrateBps); 172 bandwidth_observer_->OnReceivedEstimatedBitrate(kInitialBitrateBps);
176 clock_.AdvanceTimeMilliseconds(25); 173 clock_.AdvanceTimeMilliseconds(25);
177 controller_->Process(); 174 controller_->Process();
178 } 175 }
179 176
180 TEST_F(CongestionControllerTest, OnSendQueueFull) { 177 TEST_F(CongestionControllerTest, OnSendQueueFull) {
181 EXPECT_CALL(*pacer_, ExpectedQueueTimeMs()) 178 EXPECT_CALL(pacer_, ExpectedQueueTimeMs())
182 .WillOnce(Return(PacedSender::kMaxQueueLengthMs + 1)); 179 .WillOnce(Return(PacedSender::kMaxQueueLengthMs + 1));
183 180
184 EXPECT_CALL(observer_, OnNetworkChanged(0, _, _, _)); 181 EXPECT_CALL(observer_, OnNetworkChanged(0, _, _, _));
185 controller_->Process(); 182 controller_->Process();
186 183
187 // Let the pacer not be full next time the controller checks. 184 // Let the pacer not be full next time the controller checks.
188 EXPECT_CALL(*pacer_, ExpectedQueueTimeMs()) 185 EXPECT_CALL(pacer_, ExpectedQueueTimeMs())
189 .WillOnce(Return(PacedSender::kMaxQueueLengthMs - 1)); 186 .WillOnce(Return(PacedSender::kMaxQueueLengthMs - 1));
190 187
191 EXPECT_CALL(observer_, OnNetworkChanged(kInitialBitrateBps, _, _, _)); 188 EXPECT_CALL(observer_, OnNetworkChanged(kInitialBitrateBps, _, _, _));
192 controller_->Process(); 189 controller_->Process();
193 } 190 }
194 191
195 TEST_F(CongestionControllerTest, OnSendQueueFullAndEstimateChange) { 192 TEST_F(CongestionControllerTest, OnSendQueueFullAndEstimateChange) {
196 EXPECT_CALL(*pacer_, ExpectedQueueTimeMs()) 193 EXPECT_CALL(pacer_, ExpectedQueueTimeMs())
197 .WillOnce(Return(PacedSender::kMaxQueueLengthMs + 1)); 194 .WillOnce(Return(PacedSender::kMaxQueueLengthMs + 1));
198 EXPECT_CALL(observer_, OnNetworkChanged(0, _, _, _)); 195 EXPECT_CALL(observer_, OnNetworkChanged(0, _, _, _));
199 controller_->Process(); 196 controller_->Process();
200 197
201 // Receive new estimate but let the queue still be full. 198 // Receive new estimate but let the queue still be full.
202 bandwidth_observer_->OnReceivedEstimatedBitrate(kInitialBitrateBps * 2); 199 bandwidth_observer_->OnReceivedEstimatedBitrate(kInitialBitrateBps * 2);
203 EXPECT_CALL(*pacer_, ExpectedQueueTimeMs()) 200 EXPECT_CALL(pacer_, ExpectedQueueTimeMs())
204 .WillOnce(Return(PacedSender::kMaxQueueLengthMs + 1)); 201 .WillOnce(Return(PacedSender::kMaxQueueLengthMs + 1));
205 // The send pacer should get the new estimate though. 202 // The send pacer should get the new estimate though.
206 EXPECT_CALL(*pacer_, SetEstimatedBitrate(kInitialBitrateBps * 2)); 203 EXPECT_CALL(pacer_, SetEstimatedBitrate(kInitialBitrateBps * 2));
207 clock_.AdvanceTimeMilliseconds(25); 204 clock_.AdvanceTimeMilliseconds(25);
208 controller_->Process(); 205 controller_->Process();
209 206
210 // Let the pacer not be full next time the controller checks. 207 // Let the pacer not be full next time the controller checks.
211 // |OnNetworkChanged| should be called with the new estimate. 208 // |OnNetworkChanged| should be called with the new estimate.
212 EXPECT_CALL(*pacer_, ExpectedQueueTimeMs()) 209 EXPECT_CALL(pacer_, ExpectedQueueTimeMs())
213 .WillOnce(Return(PacedSender::kMaxQueueLengthMs - 1)); 210 .WillOnce(Return(PacedSender::kMaxQueueLengthMs - 1));
214 EXPECT_CALL(observer_, OnNetworkChanged(kInitialBitrateBps * 2, _, _, _)); 211 EXPECT_CALL(observer_, OnNetworkChanged(kInitialBitrateBps * 2, _, _, _));
215 clock_.AdvanceTimeMilliseconds(25); 212 clock_.AdvanceTimeMilliseconds(25);
216 controller_->Process(); 213 controller_->Process();
217 } 214 }
218 215
219 TEST_F(CongestionControllerTest, SignalNetworkState) { 216 TEST_F(CongestionControllerTest, SignalNetworkState) {
220 EXPECT_CALL(observer_, OnNetworkChanged(0, _, _, _)); 217 EXPECT_CALL(observer_, OnNetworkChanged(0, _, _, _));
221 controller_->SignalNetworkState(kNetworkDown); 218 controller_->SignalNetworkState(kNetworkDown);
222 219
223 EXPECT_CALL(observer_, OnNetworkChanged(kInitialBitrateBps, _, _, _)); 220 EXPECT_CALL(observer_, OnNetworkChanged(kInitialBitrateBps, _, _, _));
224 controller_->SignalNetworkState(kNetworkUp); 221 controller_->SignalNetworkState(kNetworkUp);
225 222
226 EXPECT_CALL(observer_, OnNetworkChanged(0, _, _, _)); 223 EXPECT_CALL(observer_, OnNetworkChanged(0, _, _, _));
227 controller_->SignalNetworkState(kNetworkDown); 224 controller_->SignalNetworkState(kNetworkDown);
228 } 225 }
229 226
230 TEST_F(CongestionControllerTest, OnNetworkRouteChanged) { 227 TEST_F(CongestionControllerTest, OnNetworkRouteChanged) {
231 int new_bitrate = 200000; 228 int new_bitrate = 200000;
232 testing::Mock::VerifyAndClearExpectations(pacer_); 229 testing::Mock::VerifyAndClearExpectations(&pacer_);
233 EXPECT_CALL(observer_, OnNetworkChanged(new_bitrate, _, _, _)); 230 EXPECT_CALL(observer_, OnNetworkChanged(new_bitrate, _, _, _));
234 EXPECT_CALL(*pacer_, SetEstimatedBitrate(new_bitrate)); 231 EXPECT_CALL(pacer_, SetEstimatedBitrate(new_bitrate));
235 rtc::NetworkRoute route; 232 rtc::NetworkRoute route;
236 route.local_network_id = 1; 233 route.local_network_id = 1;
237 controller_->OnNetworkRouteChanged(route, new_bitrate, -1, -1); 234 controller_->OnNetworkRouteChanged(route, new_bitrate, -1, -1);
238 235
239 // If the bitrate is reset to -1, the new starting bitrate will be 236 // If the bitrate is reset to -1, the new starting bitrate will be
240 // the minimum default bitrate kMinBitrateBps. 237 // the minimum default bitrate kMinBitrateBps.
241 EXPECT_CALL( 238 EXPECT_CALL(
242 observer_, 239 observer_,
243 OnNetworkChanged(congestion_controller::GetMinBitrateBps(), _, _, _)); 240 OnNetworkChanged(congestion_controller::GetMinBitrateBps(), _, _, _));
244 EXPECT_CALL(*pacer_, 241 EXPECT_CALL(pacer_,
245 SetEstimatedBitrate(congestion_controller::GetMinBitrateBps())); 242 SetEstimatedBitrate(congestion_controller::GetMinBitrateBps()));
246 route.local_network_id = 2; 243 route.local_network_id = 2;
247 controller_->OnNetworkRouteChanged(route, -1, -1, -1); 244 controller_->OnNetworkRouteChanged(route, -1, -1, -1);
248 } 245 }
249 246
250 TEST_F(CongestionControllerTest, OldFeedback) { 247 TEST_F(CongestionControllerTest, OldFeedback) {
251 int new_bitrate = 200000; 248 int new_bitrate = 200000;
252 testing::Mock::VerifyAndClearExpectations(pacer_); 249 testing::Mock::VerifyAndClearExpectations(&pacer_);
253 EXPECT_CALL(observer_, OnNetworkChanged(new_bitrate, _, _, _)); 250 EXPECT_CALL(observer_, OnNetworkChanged(new_bitrate, _, _, _));
254 EXPECT_CALL(*pacer_, SetEstimatedBitrate(new_bitrate)); 251 EXPECT_CALL(pacer_, SetEstimatedBitrate(new_bitrate));
255 252
256 // Send a few packets on the first network route. 253 // Send a few packets on the first network route.
257 std::vector<PacketFeedback> packets; 254 std::vector<PacketFeedback> packets;
258 packets.push_back(PacketFeedback(0, 0, 0, 1500, kPacingInfo0)); 255 packets.push_back(PacketFeedback(0, 0, 0, 1500, kPacingInfo0));
259 packets.push_back(PacketFeedback(10, 10, 1, 1500, kPacingInfo0)); 256 packets.push_back(PacketFeedback(10, 10, 1, 1500, kPacingInfo0));
260 packets.push_back(PacketFeedback(20, 20, 2, 1500, kPacingInfo0)); 257 packets.push_back(PacketFeedback(20, 20, 2, 1500, kPacingInfo0));
261 packets.push_back(PacketFeedback(30, 30, 3, 1500, kPacingInfo1)); 258 packets.push_back(PacketFeedback(30, 30, 3, 1500, kPacingInfo1));
262 packets.push_back(PacketFeedback(40, 40, 4, 1500, kPacingInfo1)); 259 packets.push_back(PacketFeedback(40, 40, 4, 1500, kPacingInfo1));
263 260
264 for (const PacketFeedback& packet : packets) 261 for (const PacketFeedback& packet : packets)
(...skipping 12 matching lines...) Expand all
277 packet.arrival_time_ms * 1000)); 274 packet.arrival_time_ms * 1000));
278 feedback.Build(); 275 feedback.Build();
279 controller_->OnTransportFeedback(feedback); 276 controller_->OnTransportFeedback(feedback);
280 } 277 }
281 278
282 // If the bitrate is reset to -1, the new starting bitrate will be 279 // If the bitrate is reset to -1, the new starting bitrate will be
283 // the minimum default bitrate kMinBitrateBps. 280 // the minimum default bitrate kMinBitrateBps.
284 EXPECT_CALL( 281 EXPECT_CALL(
285 observer_, 282 observer_,
286 OnNetworkChanged(congestion_controller::GetMinBitrateBps(), _, _, _)); 283 OnNetworkChanged(congestion_controller::GetMinBitrateBps(), _, _, _));
287 EXPECT_CALL(*pacer_, 284 EXPECT_CALL(pacer_,
288 SetEstimatedBitrate(congestion_controller::GetMinBitrateBps())); 285 SetEstimatedBitrate(congestion_controller::GetMinBitrateBps()));
289 route.local_network_id = 2; 286 route.local_network_id = 2;
290 controller_->OnNetworkRouteChanged(route, -1, -1, -1); 287 controller_->OnNetworkRouteChanged(route, -1, -1, -1);
291 } 288 }
292 289
293 TEST_F(CongestionControllerTest, 290 TEST_F(CongestionControllerTest,
294 SignalNetworkStateAndQueueIsFullAndEstimateChange) { 291 SignalNetworkStateAndQueueIsFullAndEstimateChange) {
295 // Send queue is full 292 // Send queue is full
296 EXPECT_CALL(*pacer_, ExpectedQueueTimeMs()) 293 EXPECT_CALL(pacer_, ExpectedQueueTimeMs())
297 .WillRepeatedly(Return(PacedSender::kMaxQueueLengthMs + 1)); 294 .WillRepeatedly(Return(PacedSender::kMaxQueueLengthMs + 1));
298 EXPECT_CALL(observer_, OnNetworkChanged(0, _, _, _)); 295 EXPECT_CALL(observer_, OnNetworkChanged(0, _, _, _));
299 controller_->Process(); 296 controller_->Process();
300 297
301 // Queue is full and network is down. Expect no bitrate change. 298 // Queue is full and network is down. Expect no bitrate change.
302 controller_->SignalNetworkState(kNetworkDown); 299 controller_->SignalNetworkState(kNetworkDown);
303 controller_->Process(); 300 controller_->Process();
304 301
305 // Queue is full but network is up. Expect no bitrate change. 302 // Queue is full but network is up. Expect no bitrate change.
306 controller_->SignalNetworkState(kNetworkUp); 303 controller_->SignalNetworkState(kNetworkUp);
307 controller_->Process(); 304 controller_->Process();
308 305
309 // Receive new estimate but let the queue still be full. 306 // Receive new estimate but let the queue still be full.
310 EXPECT_CALL(*pacer_, SetEstimatedBitrate(kInitialBitrateBps * 2)); 307 EXPECT_CALL(pacer_, SetEstimatedBitrate(kInitialBitrateBps * 2));
311 bandwidth_observer_->OnReceivedEstimatedBitrate(kInitialBitrateBps * 2); 308 bandwidth_observer_->OnReceivedEstimatedBitrate(kInitialBitrateBps * 2);
312 clock_.AdvanceTimeMilliseconds(25); 309 clock_.AdvanceTimeMilliseconds(25);
313 controller_->Process(); 310 controller_->Process();
314 311
315 // Let the pacer not be full next time the controller checks. 312 // Let the pacer not be full next time the controller checks.
316 EXPECT_CALL(*pacer_, ExpectedQueueTimeMs()) 313 EXPECT_CALL(pacer_, ExpectedQueueTimeMs())
317 .WillOnce(Return(PacedSender::kMaxQueueLengthMs - 1)); 314 .WillOnce(Return(PacedSender::kMaxQueueLengthMs - 1));
318 EXPECT_CALL(observer_, OnNetworkChanged(kInitialBitrateBps * 2, _, _, _)); 315 EXPECT_CALL(observer_, OnNetworkChanged(kInitialBitrateBps * 2, _, _, _));
319 controller_->Process(); 316 controller_->Process();
320 } 317 }
321 318
322 TEST_F(CongestionControllerTest, GetPacerQueuingDelayMs) { 319 TEST_F(CongestionControllerTest, GetPacerQueuingDelayMs) {
323 EXPECT_CALL(observer_, OnNetworkChanged(_, _, _, _)).Times(AtLeast(1)); 320 EXPECT_CALL(observer_, OnNetworkChanged(_, _, _, _)).Times(AtLeast(1));
324 321
325 const int64_t kQueueTimeMs = 123; 322 const int64_t kQueueTimeMs = 123;
326 EXPECT_CALL(*pacer_, QueueInMs()).WillRepeatedly(Return(kQueueTimeMs)); 323 EXPECT_CALL(pacer_, QueueInMs()).WillRepeatedly(Return(kQueueTimeMs));
327 EXPECT_EQ(kQueueTimeMs, controller_->GetPacerQueuingDelayMs()); 324 EXPECT_EQ(kQueueTimeMs, controller_->GetPacerQueuingDelayMs());
328 325
329 // Expect zero pacer delay when network is down. 326 // Expect zero pacer delay when network is down.
330 controller_->SignalNetworkState(kNetworkDown); 327 controller_->SignalNetworkState(kNetworkDown);
331 EXPECT_EQ(0, controller_->GetPacerQueuingDelayMs()); 328 EXPECT_EQ(0, controller_->GetPacerQueuingDelayMs());
332 329
333 // Network is up, pacer delay should be reported. 330 // Network is up, pacer delay should be reported.
334 controller_->SignalNetworkState(kNetworkUp); 331 controller_->SignalNetworkState(kNetworkUp);
335 EXPECT_EQ(kQueueTimeMs, controller_->GetPacerQueuingDelayMs()); 332 EXPECT_EQ(kQueueTimeMs, controller_->GetPacerQueuingDelayMs());
336 } 333 }
337 334
338 TEST_F(CongestionControllerTest, GetProbingInterval) { 335 TEST_F(CongestionControllerTest, GetProbingInterval) {
339 clock_.AdvanceTimeMilliseconds(25); 336 clock_.AdvanceTimeMilliseconds(25);
340 controller_->Process(); 337 controller_->Process();
341 338
342 EXPECT_CALL(observer_, OnNetworkChanged(_, _, _, testing::Ne(0))); 339 EXPECT_CALL(observer_, OnNetworkChanged(_, _, _, testing::Ne(0)));
343 EXPECT_CALL(*pacer_, SetEstimatedBitrate(_)); 340 EXPECT_CALL(pacer_, SetEstimatedBitrate(_));
344 bandwidth_observer_->OnReceivedEstimatedBitrate(kInitialBitrateBps * 2); 341 bandwidth_observer_->OnReceivedEstimatedBitrate(kInitialBitrateBps * 2);
345 clock_.AdvanceTimeMilliseconds(25); 342 clock_.AdvanceTimeMilliseconds(25);
346 controller_->Process(); 343 controller_->Process();
347 } 344 }
348 345
349 TEST(ReceiveSideCongestionControllerTest, OnReceivedPacketWithAbsSendTime) { 346 TEST(ReceiveSideCongestionControllerTest, OnReceivedPacketWithAbsSendTime) {
350 StrictMock<MockPacketRouter> packet_router; 347 StrictMock<MockPacketRouter> packet_router;
351 SimulatedClock clock_(123456); 348 SimulatedClock clock_(123456);
352 349
353 ReceiveSideCongestionController controller(&clock_, &packet_router); 350 ReceiveSideCongestionController controller(&clock_, &packet_router);
(...skipping 12 matching lines...) Expand all
366 int64_t now_ms = clock_.TimeInMilliseconds(); 363 int64_t now_ms = clock_.TimeInMilliseconds();
367 header.extension.absoluteSendTime = AbsSendTime(now_ms, 1000); 364 header.extension.absoluteSendTime = AbsSendTime(now_ms, 1000);
368 controller.OnReceivedPacket(now_ms, payload_size, header); 365 controller.OnReceivedPacket(now_ms, payload_size, header);
369 } 366 }
370 367
371 ASSERT_EQ(1u, ssrcs.size()); 368 ASSERT_EQ(1u, ssrcs.size());
372 EXPECT_EQ(header.ssrc, ssrcs[0]); 369 EXPECT_EQ(header.ssrc, ssrcs[0]);
373 } 370 }
374 371
375 TEST_F(CongestionControllerTest, ProbeOnRouteChange) { 372 TEST_F(CongestionControllerTest, ProbeOnRouteChange) {
376 testing::Mock::VerifyAndClearExpectations(pacer_); 373 testing::Mock::VerifyAndClearExpectations(&pacer_);
377 EXPECT_CALL(*pacer_, CreateProbeCluster(kInitialBitrateBps * 6)); 374 EXPECT_CALL(pacer_, CreateProbeCluster(kInitialBitrateBps * 6));
378 EXPECT_CALL(*pacer_, CreateProbeCluster(kInitialBitrateBps * 12)); 375 EXPECT_CALL(pacer_, CreateProbeCluster(kInitialBitrateBps * 12));
379 EXPECT_CALL(observer_, OnNetworkChanged(kInitialBitrateBps * 2, _, _, _)); 376 EXPECT_CALL(observer_, OnNetworkChanged(kInitialBitrateBps * 2, _, _, _));
380 rtc::NetworkRoute route; 377 rtc::NetworkRoute route;
381 route.local_network_id = 1; 378 route.local_network_id = 1;
382 controller_->OnNetworkRouteChanged(route, 2 * kInitialBitrateBps, 0, 379 controller_->OnNetworkRouteChanged(route, 2 * kInitialBitrateBps, 0,
383 20 * kInitialBitrateBps); 380 20 * kInitialBitrateBps);
384 } 381 }
385 382
386 // Estimated bitrate reduced when the feedbacks arrive with such a long delay, 383 // Estimated bitrate reduced when the feedbacks arrive with such a long delay,
387 // that the send-time-history no longer holds the feedbacked packets. 384 // that the send-time-history no longer holds the feedbacked packets.
388 TEST_F(CongestionControllerTest, LongFeedbackDelays) { 385 TEST_F(CongestionControllerTest, LongFeedbackDelays) {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 ASSERT_TRUE(target_bitrate_bps_); 486 ASSERT_TRUE(target_bitrate_bps_);
490 487
491 // Repeat, but this time with a building delay, and make sure that the 488 // Repeat, but this time with a building delay, and make sure that the
492 // estimation is adjusted downwards. 489 // estimation is adjusted downwards.
493 uint32_t bitrate_before_delay = *target_bitrate_bps_; 490 uint32_t bitrate_before_delay = *target_bitrate_bps_;
494 PacketTransmissionAndFeedbackBlock(&seq_num, kRunTimeMs, 50); 491 PacketTransmissionAndFeedbackBlock(&seq_num, kRunTimeMs, 50);
495 EXPECT_LT(*target_bitrate_bps_, bitrate_before_delay); 492 EXPECT_LT(*target_bitrate_bps_, bitrate_before_delay);
496 } 493 }
497 } // namespace test 494 } // namespace test
498 } // namespace webrtc 495 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698