OLD | NEW |
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 Loading... |
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_); | |
105 } | 99 } |
106 | 100 |
107 class BitrateAllocatorTestNoEnforceMin : public ::testing::Test { | 101 class BitrateAllocatorTestNoEnforceMin : public ::testing::Test { |
108 protected: | 102 protected: |
109 BitrateAllocatorTestNoEnforceMin() : allocator_(new BitrateAllocator()) { | 103 BitrateAllocatorTestNoEnforceMin() : allocator_(new BitrateAllocator()) { |
110 allocator_->EnforceMinBitrate(false); | 104 allocator_->EnforceMinBitrate(false); |
111 allocator_->OnNetworkChanged(300000u, 0, 0); | 105 allocator_->OnNetworkChanged(300000u, 0, 0); |
112 } | 106 } |
113 ~BitrateAllocatorTestNoEnforceMin() {} | 107 ~BitrateAllocatorTestNoEnforceMin() {} |
114 | 108 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 EXPECT_EQ(200000u, bitrate_observer_2.last_bitrate_); // Min bitrate. | 164 EXPECT_EQ(200000u, bitrate_observer_2.last_bitrate_); // Min bitrate. |
171 EXPECT_EQ(200000u, bitrate_observer_3.last_bitrate_); // Remainder. | 165 EXPECT_EQ(200000u, bitrate_observer_3.last_bitrate_); // Remainder. |
172 | 166 |
173 // Low REMB. | 167 // Low REMB. |
174 allocator_->OnNetworkChanged(10000, 0, 0); | 168 allocator_->OnNetworkChanged(10000, 0, 0); |
175 // Verify that the first observer gets all the rate, and the rest get zero. | 169 // Verify that the first observer gets all the rate, and the rest get zero. |
176 EXPECT_EQ(10000u, bitrate_observer_1.last_bitrate_); | 170 EXPECT_EQ(10000u, bitrate_observer_1.last_bitrate_); |
177 EXPECT_EQ(0u, bitrate_observer_2.last_bitrate_); | 171 EXPECT_EQ(0u, bitrate_observer_2.last_bitrate_); |
178 EXPECT_EQ(0u, bitrate_observer_3.last_bitrate_); | 172 EXPECT_EQ(0u, bitrate_observer_3.last_bitrate_); |
179 | 173 |
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 | |
187 allocator_->RemoveObserver(&bitrate_observer_1); | 174 allocator_->RemoveObserver(&bitrate_observer_1); |
188 allocator_->RemoveObserver(&bitrate_observer_2); | 175 allocator_->RemoveObserver(&bitrate_observer_2); |
189 allocator_->RemoveObserver(&bitrate_observer_3); | 176 allocator_->RemoveObserver(&bitrate_observer_3); |
190 } | 177 } |
191 | 178 |
192 TEST_F(BitrateAllocatorTest, ThreeBitrateObserversLowRembEnforceMin) { | 179 TEST_F(BitrateAllocatorTest, ThreeBitrateObserversLowRembEnforceMin) { |
193 TestBitrateObserver bitrate_observer_1; | 180 TestBitrateObserver bitrate_observer_1; |
194 TestBitrateObserver bitrate_observer_2; | 181 TestBitrateObserver bitrate_observer_2; |
195 TestBitrateObserver bitrate_observer_3; | 182 TestBitrateObserver bitrate_observer_3; |
196 int start_bitrate = | 183 int start_bitrate = |
(...skipping 13 matching lines...) Expand all Loading... |
210 allocator_->OnNetworkChanged(1000, 0, 0); | 197 allocator_->OnNetworkChanged(1000, 0, 0); |
211 EXPECT_EQ(100000u, bitrate_observer_1.last_bitrate_); // Min cap. | 198 EXPECT_EQ(100000u, bitrate_observer_1.last_bitrate_); // Min cap. |
212 EXPECT_EQ(200000u, bitrate_observer_2.last_bitrate_); // Min cap. | 199 EXPECT_EQ(200000u, bitrate_observer_2.last_bitrate_); // Min cap. |
213 EXPECT_EQ(300000u, bitrate_observer_3.last_bitrate_); // Min cap. | 200 EXPECT_EQ(300000u, bitrate_observer_3.last_bitrate_); // Min cap. |
214 | 201 |
215 allocator_->RemoveObserver(&bitrate_observer_1); | 202 allocator_->RemoveObserver(&bitrate_observer_1); |
216 allocator_->RemoveObserver(&bitrate_observer_2); | 203 allocator_->RemoveObserver(&bitrate_observer_2); |
217 allocator_->RemoveObserver(&bitrate_observer_3); | 204 allocator_->RemoveObserver(&bitrate_observer_3); |
218 } | 205 } |
219 } // namespace webrtc | 206 } // namespace webrtc |
OLD | NEW |