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

Side by Side Diff: webrtc/call/bitrate_allocator_unittest.cc

Issue 2703393002: Revert of Fixes a bug where a video stream can get stuck in the suspended state. (Closed)
Patch Set: 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
« no previous file with comments | « webrtc/call/bitrate_allocator.cc ('k') | webrtc/call/rampup_tests.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 allocator_->OnNetworkChanged(4000000, 0, 0, kDefaultProbingIntervalMs); 91 allocator_->OnNetworkChanged(4000000, 0, 0, kDefaultProbingIntervalMs);
92 EXPECT_EQ(3000000, allocator_->GetStartBitrate(&bitrate_observer)); 92 EXPECT_EQ(3000000, allocator_->GetStartBitrate(&bitrate_observer));
93 93
94 // Expect |max_padding_bitrate_bps| to change to 0 if the observer is updated. 94 // Expect |max_padding_bitrate_bps| to change to 0 if the observer is updated.
95 EXPECT_CALL(limit_observer_, 95 EXPECT_CALL(limit_observer_,
96 OnAllocationLimitsChanged(kMinSendBitrateBps, 0)); 96 OnAllocationLimitsChanged(kMinSendBitrateBps, 0));
97 allocator_->AddObserver(&bitrate_observer, kMinSendBitrateBps, 4000000, 0, 97 allocator_->AddObserver(&bitrate_observer, kMinSendBitrateBps, 4000000, 0,
98 true); 98 true);
99 EXPECT_EQ(4000000, allocator_->GetStartBitrate(&bitrate_observer)); 99 EXPECT_EQ(4000000, allocator_->GetStartBitrate(&bitrate_observer));
100 100
101 EXPECT_CALL(limit_observer_,
102 OnAllocationLimitsChanged(kMinSendBitrateBps, 0));
101 allocator_->AddObserver(&bitrate_observer, kMinSendBitrateBps, 1500000, 0, 103 allocator_->AddObserver(&bitrate_observer, kMinSendBitrateBps, 1500000, 0,
102 true); 104 true);
103 EXPECT_EQ(3000000, allocator_->GetStartBitrate(&bitrate_observer)); 105 EXPECT_EQ(3000000, allocator_->GetStartBitrate(&bitrate_observer));
104 EXPECT_EQ(3000000u, bitrate_observer.last_bitrate_bps_); 106 EXPECT_EQ(3000000u, bitrate_observer.last_bitrate_bps_);
105 allocator_->OnNetworkChanged(1500000, 0, 0, kDefaultProbingIntervalMs); 107 allocator_->OnNetworkChanged(1500000, 0, 0, kDefaultProbingIntervalMs);
106 EXPECT_EQ(1500000u, bitrate_observer.last_bitrate_bps_); 108 EXPECT_EQ(1500000u, bitrate_observer.last_bitrate_bps_);
107 } 109 }
108 110
109 TEST_F(BitrateAllocatorTest, TwoBitrateObserversOneRtcpObserver) { 111 TEST_F(BitrateAllocatorTest, TwoBitrateObserversOneRtcpObserver) {
110 TestBitrateObserver bitrate_observer_1; 112 TestBitrateObserver bitrate_observer_1;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 NiceMock<MockLimitObserver> limit_observer_; 176 NiceMock<MockLimitObserver> limit_observer_;
175 std::unique_ptr<BitrateAllocator> allocator_; 177 std::unique_ptr<BitrateAllocator> allocator_;
176 }; 178 };
177 179
178 // The following three tests verify enforcing a minimum bitrate works as 180 // The following three tests verify enforcing a minimum bitrate works as
179 // intended. 181 // intended.
180 TEST_F(BitrateAllocatorTestNoEnforceMin, OneBitrateObserver) { 182 TEST_F(BitrateAllocatorTestNoEnforceMin, OneBitrateObserver) {
181 TestBitrateObserver bitrate_observer_1; 183 TestBitrateObserver bitrate_observer_1;
182 // Expect OnAllocationLimitsChanged with |min_send_bitrate_bps| = 0 since 184 // Expect OnAllocationLimitsChanged with |min_send_bitrate_bps| = 0 since
183 // AddObserver is called with |enforce_min_bitrate| = false. 185 // AddObserver is called with |enforce_min_bitrate| = false.
184 EXPECT_CALL(limit_observer_, OnAllocationLimitsChanged(0, 120000)); 186 EXPECT_CALL(limit_observer_, OnAllocationLimitsChanged(0, 0));
185 allocator_->AddObserver(&bitrate_observer_1, 100000, 400000, 0, false); 187 allocator_->AddObserver(&bitrate_observer_1, 100000, 400000, 0, false);
186 EXPECT_EQ(300000, allocator_->GetStartBitrate(&bitrate_observer_1)); 188 EXPECT_EQ(300000, allocator_->GetStartBitrate(&bitrate_observer_1));
187 189
188 // High BWE. 190 // High BWE.
189 allocator_->OnNetworkChanged(150000, 0, 0, kDefaultProbingIntervalMs); 191 allocator_->OnNetworkChanged(150000, 0, 0, kDefaultProbingIntervalMs);
190 EXPECT_EQ(150000u, bitrate_observer_1.last_bitrate_bps_); 192 EXPECT_EQ(150000u, bitrate_observer_1.last_bitrate_bps_);
191 193
192 // Low BWE. 194 // Low BWE.
193 allocator_->OnNetworkChanged(10000, 0, 0, kDefaultProbingIntervalMs); 195 allocator_->OnNetworkChanged(10000, 0, 0, kDefaultProbingIntervalMs);
194 EXPECT_EQ(0u, bitrate_observer_1.last_bitrate_bps_); 196 EXPECT_EQ(0u, bitrate_observer_1.last_bitrate_bps_);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 257
256 allocator_->RemoveObserver(&bitrate_observer_1); 258 allocator_->RemoveObserver(&bitrate_observer_1);
257 allocator_->RemoveObserver(&bitrate_observer_2); 259 allocator_->RemoveObserver(&bitrate_observer_2);
258 allocator_->RemoveObserver(&bitrate_observer_3); 260 allocator_->RemoveObserver(&bitrate_observer_3);
259 } 261 }
260 262
261 TEST_F(BitrateAllocatorTestNoEnforceMin, OneBitrateObserverWithPacketLoss) { 263 TEST_F(BitrateAllocatorTestNoEnforceMin, OneBitrateObserverWithPacketLoss) {
262 TestBitrateObserver bitrate_observer; 264 TestBitrateObserver bitrate_observer;
263 // Expect OnAllocationLimitsChanged with |min_send_bitrate_bps| = 0 since 265 // Expect OnAllocationLimitsChanged with |min_send_bitrate_bps| = 0 since
264 // AddObserver is called with |enforce_min_bitrate| = false. 266 // AddObserver is called with |enforce_min_bitrate| = false.
265 EXPECT_CALL(limit_observer_, OnAllocationLimitsChanged(0, 168000)); 267 EXPECT_CALL(limit_observer_, OnAllocationLimitsChanged(0, 0));
266 allocator_->AddObserver( 268 allocator_->AddObserver(
267 &bitrate_observer, 100000, 400000, 0, false); 269 &bitrate_observer, 100000, 400000, 0, false);
268 EXPECT_EQ(300000, allocator_->GetStartBitrate(&bitrate_observer)); 270 EXPECT_EQ(300000, allocator_->GetStartBitrate(&bitrate_observer));
269 271
270 // High BWE. 272 // High BWE.
271 allocator_->OnNetworkChanged(150000, 0, 0, kDefaultProbingIntervalMs); 273 allocator_->OnNetworkChanged(150000, 0, 0, kDefaultProbingIntervalMs);
272 EXPECT_EQ(150000u, bitrate_observer.last_bitrate_bps_); 274 EXPECT_EQ(150000u, bitrate_observer.last_bitrate_bps_);
273 275
274 // Add loss and use a part of the bitrate for protection. 276 // Add loss and use a part of the bitrate for protection.
275 double protection_ratio = 0.4; 277 double protection_ratio = 0.4;
276 uint8_t fraction_loss = protection_ratio * 256; 278 uint8_t fraction_loss = protection_ratio * 256;
277 bitrate_observer.SetBitrateProtectionRatio(protection_ratio); 279 bitrate_observer.SetBitrateProtectionRatio(protection_ratio);
278 allocator_->OnNetworkChanged(200000, 0, fraction_loss, 280 allocator_->OnNetworkChanged(200000, 0, fraction_loss,
279 kDefaultProbingIntervalMs); 281 kDefaultProbingIntervalMs);
280 EXPECT_EQ(200000u, bitrate_observer.last_bitrate_bps_); 282 EXPECT_EQ(200000u, bitrate_observer.last_bitrate_bps_);
281 283
282 // Above the min threshold, but not enough given the protection used. 284 // Above the min threshold, but not enough given the protection used.
283 allocator_->OnNetworkChanged(139000, 0, fraction_loss, 285 allocator_->OnNetworkChanged(139000, 0, fraction_loss,
284 kDefaultProbingIntervalMs); 286 kDefaultProbingIntervalMs);
285 EXPECT_EQ(0u, bitrate_observer.last_bitrate_bps_); 287 EXPECT_EQ(0u, bitrate_observer.last_bitrate_bps_);
286 288
287 // Verify the hysteresis is added for the protection. 289 // Verify the hysteresis is added for the protection.
288 allocator_->OnNetworkChanged(150000, 0, fraction_loss, 290 allocator_->OnNetworkChanged(150000, 0, fraction_loss,
289 kDefaultProbingIntervalMs); 291 kDefaultProbingIntervalMs);
290 EXPECT_EQ(0u, bitrate_observer.last_bitrate_bps_); 292 EXPECT_EQ(0u, bitrate_observer.last_bitrate_bps_);
291 293
292 // Just enough to enable video again. 294 // Just enough to enable video again.
293 EXPECT_CALL(limit_observer_, OnAllocationLimitsChanged(0, 0));
294 allocator_->OnNetworkChanged(168000, 0, fraction_loss, 295 allocator_->OnNetworkChanged(168000, 0, fraction_loss,
295 kDefaultProbingIntervalMs); 296 kDefaultProbingIntervalMs);
296 EXPECT_EQ(168000u, bitrate_observer.last_bitrate_bps_); 297 EXPECT_EQ(168000u, bitrate_observer.last_bitrate_bps_);
297 298
298 // Remove all protection and make sure video is not paused as earlier. 299 // Remove all protection and make sure video is not paused as earlier.
299 bitrate_observer.SetBitrateProtectionRatio(0.0); 300 bitrate_observer.SetBitrateProtectionRatio(0.0);
300 allocator_->OnNetworkChanged(140000, 0, 0, kDefaultProbingIntervalMs); 301 allocator_->OnNetworkChanged(140000, 0, 0, kDefaultProbingIntervalMs);
301 EXPECT_EQ(140000u, bitrate_observer.last_bitrate_bps_); 302 EXPECT_EQ(140000u, bitrate_observer.last_bitrate_bps_);
302 303
303 allocator_->OnNetworkChanged(139000, 0, 0, kDefaultProbingIntervalMs); 304 allocator_->OnNetworkChanged(139000, 0, 0, kDefaultProbingIntervalMs);
304 EXPECT_EQ(139000u, bitrate_observer.last_bitrate_bps_); 305 EXPECT_EQ(139000u, bitrate_observer.last_bitrate_bps_);
305 306
307 EXPECT_CALL(limit_observer_, OnAllocationLimitsChanged(0, 0));
306 allocator_->RemoveObserver(&bitrate_observer); 308 allocator_->RemoveObserver(&bitrate_observer);
307 } 309 }
308 310
309 TEST_F(BitrateAllocatorTestNoEnforceMin, TwoBitrateObserverWithPacketLoss) { 311 TEST_F(BitrateAllocatorTestNoEnforceMin, TwoBitrateObserverWithPacketLoss) {
310 TestBitrateObserver bitrate_observer_1; 312 TestBitrateObserver bitrate_observer_1;
311 TestBitrateObserver bitrate_observer_2; 313 TestBitrateObserver bitrate_observer_2;
312 314
313 allocator_->AddObserver(&bitrate_observer_1, 100000, 400000, 0, false); 315 allocator_->AddObserver(&bitrate_observer_1, 100000, 400000, 0, false);
314 EXPECT_EQ(300000, allocator_->GetStartBitrate(&bitrate_observer_1)); 316 EXPECT_EQ(300000, allocator_->GetStartBitrate(&bitrate_observer_1));
315 allocator_->AddObserver(&bitrate_observer_2, 200000, 400000, 0, false); 317 allocator_->AddObserver(&bitrate_observer_2, 200000, 400000, 0, false);
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 allocator_->AddObserver(&observer, 300000, 600000, 0, false); 515 allocator_->AddObserver(&observer, 300000, 600000, 0, false);
514 EXPECT_EQ(300000, allocator_->GetStartBitrate(&observer)); 516 EXPECT_EQ(300000, allocator_->GetStartBitrate(&observer));
515 517
516 allocator_->OnNetworkChanged(300000, 0, 50, 5000); 518 allocator_->OnNetworkChanged(300000, 0, 50, 5000);
517 EXPECT_EQ(5000, observer.last_probing_interval_ms_); 519 EXPECT_EQ(5000, observer.last_probing_interval_ms_);
518 520
519 allocator_->RemoveObserver(&observer); 521 allocator_->RemoveObserver(&observer);
520 } 522 }
521 523
522 } // namespace webrtc 524 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/call/bitrate_allocator.cc ('k') | webrtc/call/rampup_tests.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698