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

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

Issue 1917793002: Remove SendPacer from ViEEncoder (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Renamed SenderDelegate to PacketSender. Created 4 years, 7 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/call.cc » ('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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 // Test a bitrate which should be distributed equally. 89 // Test a bitrate which should be distributed equally.
90 allocator_->OnNetworkChanged(500000, 0, 50); 90 allocator_->OnNetworkChanged(500000, 0, 50);
91 const uint32_t kBitrateToShare = 500000 - 200000 - 100000; 91 const uint32_t kBitrateToShare = 500000 - 200000 - 100000;
92 EXPECT_EQ(100000u + kBitrateToShare / 2, bitrate_observer_1.last_bitrate_); 92 EXPECT_EQ(100000u + kBitrateToShare / 2, bitrate_observer_1.last_bitrate_);
93 EXPECT_EQ(200000u + kBitrateToShare / 2, bitrate_observer_2.last_bitrate_); 93 EXPECT_EQ(200000u + kBitrateToShare / 2, bitrate_observer_2.last_bitrate_);
94 94
95 // Limited by 2x max bitrates since we leave room for FEC and retransmissions. 95 // Limited by 2x max bitrates since we leave room for FEC and retransmissions.
96 allocator_->OnNetworkChanged(1500000, 0, 50); 96 allocator_->OnNetworkChanged(1500000, 0, 50);
97 EXPECT_EQ(600000u, bitrate_observer_1.last_bitrate_); 97 EXPECT_EQ(600000u, bitrate_observer_1.last_bitrate_);
98 EXPECT_EQ(600000u, bitrate_observer_2.last_bitrate_); 98 EXPECT_EQ(600000u, bitrate_observer_2.last_bitrate_);
99
100 // Verify that if the bandwidth estimate is set to zero, the allocated rate is
101 // zero.
102 allocator_->OnNetworkChanged(0, 0, 50);
103 EXPECT_EQ(0u, bitrate_observer_1.last_bitrate_);
104 EXPECT_EQ(0u, bitrate_observer_2.last_bitrate_);
99 } 105 }
100 106
101 class BitrateAllocatorTestNoEnforceMin : public ::testing::Test { 107 class BitrateAllocatorTestNoEnforceMin : public ::testing::Test {
102 protected: 108 protected:
103 BitrateAllocatorTestNoEnforceMin() : allocator_(new BitrateAllocator()) { 109 BitrateAllocatorTestNoEnforceMin() : allocator_(new BitrateAllocator()) {
104 allocator_->EnforceMinBitrate(false); 110 allocator_->EnforceMinBitrate(false);
105 allocator_->OnNetworkChanged(300000u, 0, 0); 111 allocator_->OnNetworkChanged(300000u, 0, 0);
106 } 112 }
107 ~BitrateAllocatorTestNoEnforceMin() {} 113 ~BitrateAllocatorTestNoEnforceMin() {}
108 114
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 EXPECT_EQ(200000u, bitrate_observer_2.last_bitrate_); // Min bitrate. 170 EXPECT_EQ(200000u, bitrate_observer_2.last_bitrate_); // Min bitrate.
165 EXPECT_EQ(200000u, bitrate_observer_3.last_bitrate_); // Remainder. 171 EXPECT_EQ(200000u, bitrate_observer_3.last_bitrate_); // Remainder.
166 172
167 // Low REMB. 173 // Low REMB.
168 allocator_->OnNetworkChanged(10000, 0, 0); 174 allocator_->OnNetworkChanged(10000, 0, 0);
169 // Verify that the first observer gets all the rate, and the rest get zero. 175 // Verify that the first observer gets all the rate, and the rest get zero.
170 EXPECT_EQ(10000u, bitrate_observer_1.last_bitrate_); 176 EXPECT_EQ(10000u, bitrate_observer_1.last_bitrate_);
171 EXPECT_EQ(0u, bitrate_observer_2.last_bitrate_); 177 EXPECT_EQ(0u, bitrate_observer_2.last_bitrate_);
172 EXPECT_EQ(0u, bitrate_observer_3.last_bitrate_); 178 EXPECT_EQ(0u, bitrate_observer_3.last_bitrate_);
173 179
180 allocator_->OnNetworkChanged(0, 0, 0);
181 // Verify that zero estimated bandwidth, means that that all gets zero,
182 // regardless of set min bitrate.
183 EXPECT_EQ(0u, bitrate_observer_1.last_bitrate_);
184 EXPECT_EQ(0u, bitrate_observer_2.last_bitrate_);
185 EXPECT_EQ(0u, bitrate_observer_3.last_bitrate_);
186
174 allocator_->RemoveObserver(&bitrate_observer_1); 187 allocator_->RemoveObserver(&bitrate_observer_1);
175 allocator_->RemoveObserver(&bitrate_observer_2); 188 allocator_->RemoveObserver(&bitrate_observer_2);
176 allocator_->RemoveObserver(&bitrate_observer_3); 189 allocator_->RemoveObserver(&bitrate_observer_3);
177 } 190 }
178 191
179 TEST_F(BitrateAllocatorTest, ThreeBitrateObserversLowRembEnforceMin) { 192 TEST_F(BitrateAllocatorTest, ThreeBitrateObserversLowRembEnforceMin) {
180 TestBitrateObserver bitrate_observer_1; 193 TestBitrateObserver bitrate_observer_1;
181 TestBitrateObserver bitrate_observer_2; 194 TestBitrateObserver bitrate_observer_2;
182 TestBitrateObserver bitrate_observer_3; 195 TestBitrateObserver bitrate_observer_3;
183 int start_bitrate = 196 int start_bitrate =
(...skipping 13 matching lines...) Expand all
197 allocator_->OnNetworkChanged(1000, 0, 0); 210 allocator_->OnNetworkChanged(1000, 0, 0);
198 EXPECT_EQ(100000u, bitrate_observer_1.last_bitrate_); // Min cap. 211 EXPECT_EQ(100000u, bitrate_observer_1.last_bitrate_); // Min cap.
199 EXPECT_EQ(200000u, bitrate_observer_2.last_bitrate_); // Min cap. 212 EXPECT_EQ(200000u, bitrate_observer_2.last_bitrate_); // Min cap.
200 EXPECT_EQ(300000u, bitrate_observer_3.last_bitrate_); // Min cap. 213 EXPECT_EQ(300000u, bitrate_observer_3.last_bitrate_); // Min cap.
201 214
202 allocator_->RemoveObserver(&bitrate_observer_1); 215 allocator_->RemoveObserver(&bitrate_observer_1);
203 allocator_->RemoveObserver(&bitrate_observer_2); 216 allocator_->RemoveObserver(&bitrate_observer_2);
204 allocator_->RemoveObserver(&bitrate_observer_3); 217 allocator_->RemoveObserver(&bitrate_observer_3);
205 } 218 }
206 } // namespace webrtc 219 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/call/bitrate_allocator.cc ('k') | webrtc/call/call.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698