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 18 matching lines...) Expand all Loading... |
29 | 29 |
30 const double kRtpTimestampToMs = 1.0 / 90.0; | 30 const double kRtpTimestampToMs = 1.0 / 90.0; |
31 | 31 |
32 class OveruseDetectorTest : public ::testing::Test { | 32 class OveruseDetectorTest : public ::testing::Test { |
33 public: | 33 public: |
34 OveruseDetectorTest() | 34 OveruseDetectorTest() |
35 : now_ms_(0), | 35 : now_ms_(0), |
36 receive_time_ms_(0), | 36 receive_time_ms_(0), |
37 rtp_timestamp_(10 * 90), | 37 rtp_timestamp_(10 * 90), |
38 overuse_detector_(), | 38 overuse_detector_(), |
39 overuse_estimator_(new OveruseEstimator(options_)), | 39 overuse_estimator_(new OveruseEstimator()), |
40 inter_arrival_(new InterArrival(5 * 90, kRtpTimestampToMs, true)), | 40 inter_arrival_(new InterArrival(5 * 90, kRtpTimestampToMs, true)), |
41 random_(1234) {} | 41 random_(1234) {} |
42 | 42 |
43 protected: | 43 protected: |
44 void SetUp() override { | 44 void SetUp() override { overuse_detector_.reset(new OveruseDetector()); } |
45 overuse_detector_.reset(new OveruseDetector(options_)); | |
46 } | |
47 | 45 |
48 int Run100000Samples(int packets_per_frame, size_t packet_size, int mean_ms, | 46 int Run100000Samples(int packets_per_frame, |
| 47 int mean_ms, |
49 int standard_deviation_ms) { | 48 int standard_deviation_ms) { |
50 int unique_overuse = 0; | 49 int unique_overuse = 0; |
51 int last_overuse = -1; | 50 int last_overuse = -1; |
52 for (int i = 0; i < 100000; ++i) { | 51 for (int i = 0; i < 100000; ++i) { |
53 for (int j = 0; j < packets_per_frame; ++j) { | 52 for (int j = 0; j < packets_per_frame; ++j) { |
54 UpdateDetector(rtp_timestamp_, receive_time_ms_, packet_size); | 53 UpdateDetector(rtp_timestamp_, receive_time_ms_); |
55 } | 54 } |
56 rtp_timestamp_ += mean_ms * 90; | 55 rtp_timestamp_ += mean_ms * 90; |
57 now_ms_ += mean_ms; | 56 now_ms_ += mean_ms; |
58 receive_time_ms_ = | 57 receive_time_ms_ = |
59 std::max(receive_time_ms_, | 58 std::max(receive_time_ms_, |
60 now_ms_ + random_.Gaussian(0, standard_deviation_ms)); | 59 now_ms_ + random_.Gaussian(0, standard_deviation_ms)); |
61 if (kBwOverusing == overuse_detector_->State()) { | 60 if (kBwOverusing == overuse_detector_->State()) { |
62 if (last_overuse + 1 != i) { | 61 if (last_overuse + 1 != i) { |
63 unique_overuse++; | 62 unique_overuse++; |
64 } | 63 } |
65 last_overuse = i; | 64 last_overuse = i; |
66 } | 65 } |
67 } | 66 } |
68 return unique_overuse; | 67 return unique_overuse; |
69 } | 68 } |
70 | 69 |
71 int RunUntilOveruse(int packets_per_frame, size_t packet_size, int mean_ms, | 70 int RunUntilOveruse(int packets_per_frame, |
72 int standard_deviation_ms, int drift_per_frame_ms) { | 71 int mean_ms, |
| 72 int standard_deviation_ms, |
| 73 int drift_per_frame_ms) { |
73 // Simulate a higher send pace, that is too high. | 74 // Simulate a higher send pace, that is too high. |
74 for (int i = 0; i < 1000; ++i) { | 75 for (int i = 0; i < 1000; ++i) { |
75 for (int j = 0; j < packets_per_frame; ++j) { | 76 for (int j = 0; j < packets_per_frame; ++j) { |
76 UpdateDetector(rtp_timestamp_, receive_time_ms_, packet_size); | 77 UpdateDetector(rtp_timestamp_, receive_time_ms_); |
77 } | 78 } |
78 rtp_timestamp_ += mean_ms * 90; | 79 rtp_timestamp_ += mean_ms * 90; |
79 now_ms_ += mean_ms + drift_per_frame_ms; | 80 now_ms_ += mean_ms + drift_per_frame_ms; |
80 receive_time_ms_ = | 81 receive_time_ms_ = |
81 std::max(receive_time_ms_, | 82 std::max(receive_time_ms_, |
82 now_ms_ + random_.Gaussian(0, standard_deviation_ms)); | 83 now_ms_ + random_.Gaussian(0, standard_deviation_ms)); |
83 if (kBwOverusing == overuse_detector_->State()) { | 84 if (kBwOverusing == overuse_detector_->State()) { |
84 return i + 1; | 85 return i + 1; |
85 } | 86 } |
86 } | 87 } |
87 return -1; | 88 return -1; |
88 } | 89 } |
89 | 90 |
90 void UpdateDetector(uint32_t rtp_timestamp, int64_t receive_time_ms, | 91 void UpdateDetector(uint32_t rtp_timestamp, int64_t receive_time_ms) { |
91 size_t packet_size) { | |
92 uint32_t timestamp_delta; | 92 uint32_t timestamp_delta; |
93 int64_t time_delta; | 93 int64_t time_delta; |
94 int size_delta; | 94 if (inter_arrival_->ComputeDeltas(rtp_timestamp, receive_time_ms, |
95 if (inter_arrival_->ComputeDeltas(rtp_timestamp, | 95 ×tamp_delta, &time_delta)) { |
96 receive_time_ms, | |
97 packet_size, | |
98 ×tamp_delta, | |
99 &time_delta, | |
100 &size_delta)) { | |
101 double timestamp_delta_ms = timestamp_delta / 90.0; | 96 double timestamp_delta_ms = timestamp_delta / 90.0; |
102 overuse_estimator_->Update(time_delta, timestamp_delta_ms, size_delta, | 97 overuse_estimator_->Update(time_delta, timestamp_delta_ms, |
103 overuse_detector_->State()); | 98 overuse_detector_->State()); |
104 overuse_detector_->Detect( | 99 overuse_detector_->Detect( |
105 overuse_estimator_->offset(), timestamp_delta_ms, | 100 overuse_estimator_->offset(), timestamp_delta_ms, |
106 overuse_estimator_->num_of_deltas(), receive_time_ms); | 101 overuse_estimator_->num_of_deltas(), receive_time_ms); |
107 } | 102 } |
108 } | 103 } |
109 | 104 |
110 int64_t now_ms_; | 105 int64_t now_ms_; |
111 int64_t receive_time_ms_; | 106 int64_t receive_time_ms_; |
112 uint32_t rtp_timestamp_; | 107 uint32_t rtp_timestamp_; |
113 OverUseDetectorOptions options_; | |
114 rtc::scoped_ptr<OveruseDetector> overuse_detector_; | 108 rtc::scoped_ptr<OveruseDetector> overuse_detector_; |
115 rtc::scoped_ptr<OveruseEstimator> overuse_estimator_; | 109 rtc::scoped_ptr<OveruseEstimator> overuse_estimator_; |
116 rtc::scoped_ptr<InterArrival> inter_arrival_; | 110 rtc::scoped_ptr<InterArrival> inter_arrival_; |
117 test::Random random_; | 111 test::Random random_; |
118 }; | 112 }; |
119 | 113 |
120 TEST_F(OveruseDetectorTest, GaussianRandom) { | 114 TEST_F(OveruseDetectorTest, GaussianRandom) { |
121 int buckets[100]; | 115 int buckets[100]; |
122 memset(buckets, 0, sizeof(buckets)); | 116 memset(buckets, 0, sizeof(buckets)); |
123 for (int i = 0; i < 100000; ++i) { | 117 for (int i = 0; i < 100000; ++i) { |
124 int index = random_.Gaussian(49, 10); | 118 int index = random_.Gaussian(49, 10); |
125 if (index >= 0 && index < 100) | 119 if (index >= 0 && index < 100) |
126 buckets[index]++; | 120 buckets[index]++; |
127 } | 121 } |
128 for (int n = 0; n < 100; ++n) { | 122 for (int n = 0; n < 100; ++n) { |
129 printf("Bucket n:%d, %d\n", n, buckets[n]); | 123 printf("Bucket n:%d, %d\n", n, buckets[n]); |
130 } | 124 } |
131 } | 125 } |
132 | 126 |
133 TEST_F(OveruseDetectorTest, SimpleNonOveruse30fps) { | 127 TEST_F(OveruseDetectorTest, SimpleNonOveruse30fps) { |
134 size_t packet_size = 1200; | |
135 uint32_t frame_duration_ms = 33; | 128 uint32_t frame_duration_ms = 33; |
136 uint32_t rtp_timestamp = 10 * 90; | 129 uint32_t rtp_timestamp = 10 * 90; |
137 | 130 |
138 // No variance. | 131 // No variance. |
139 for (int i = 0; i < 1000; ++i) { | 132 for (int i = 0; i < 1000; ++i) { |
140 UpdateDetector(rtp_timestamp, now_ms_, packet_size); | 133 UpdateDetector(rtp_timestamp, now_ms_); |
141 now_ms_ += frame_duration_ms; | 134 now_ms_ += frame_duration_ms; |
142 rtp_timestamp += frame_duration_ms * 90; | 135 rtp_timestamp += frame_duration_ms * 90; |
143 EXPECT_EQ(kBwNormal, overuse_detector_->State()); | 136 EXPECT_EQ(kBwNormal, overuse_detector_->State()); |
144 } | 137 } |
145 } | 138 } |
146 | 139 |
147 // Roughly 1 Mbit/s | 140 // Roughly 1 Mbit/s |
148 TEST_F(OveruseDetectorTest, SimpleNonOveruseWithReceiveVariance) { | 141 TEST_F(OveruseDetectorTest, SimpleNonOveruseWithReceiveVariance) { |
149 uint32_t frame_duration_ms = 10; | 142 uint32_t frame_duration_ms = 10; |
150 uint32_t rtp_timestamp = 10 * 90; | 143 uint32_t rtp_timestamp = 10 * 90; |
151 size_t packet_size = 1200; | |
152 | 144 |
153 for (int i = 0; i < 1000; ++i) { | 145 for (int i = 0; i < 1000; ++i) { |
154 UpdateDetector(rtp_timestamp, now_ms_, packet_size); | 146 UpdateDetector(rtp_timestamp, now_ms_); |
155 rtp_timestamp += frame_duration_ms * 90; | 147 rtp_timestamp += frame_duration_ms * 90; |
156 if (i % 2) { | 148 if (i % 2) { |
157 now_ms_ += frame_duration_ms - 5; | 149 now_ms_ += frame_duration_ms - 5; |
158 } else { | 150 } else { |
159 now_ms_ += frame_duration_ms + 5; | 151 now_ms_ += frame_duration_ms + 5; |
160 } | 152 } |
161 EXPECT_EQ(kBwNormal, overuse_detector_->State()); | 153 EXPECT_EQ(kBwNormal, overuse_detector_->State()); |
162 } | 154 } |
163 } | 155 } |
164 | 156 |
165 TEST_F(OveruseDetectorTest, SimpleNonOveruseWithRtpTimestampVariance) { | 157 TEST_F(OveruseDetectorTest, SimpleNonOveruseWithRtpTimestampVariance) { |
166 // Roughly 1 Mbit/s. | 158 // Roughly 1 Mbit/s. |
167 uint32_t frame_duration_ms = 10; | 159 uint32_t frame_duration_ms = 10; |
168 uint32_t rtp_timestamp = 10 * 90; | 160 uint32_t rtp_timestamp = 10 * 90; |
169 size_t packet_size = 1200; | |
170 | |
171 for (int i = 0; i < 1000; ++i) { | 161 for (int i = 0; i < 1000; ++i) { |
172 UpdateDetector(rtp_timestamp, now_ms_, packet_size); | 162 UpdateDetector(rtp_timestamp, now_ms_); |
173 now_ms_ += frame_duration_ms; | 163 now_ms_ += frame_duration_ms; |
174 if (i % 2) { | 164 if (i % 2) { |
175 rtp_timestamp += (frame_duration_ms - 5) * 90; | 165 rtp_timestamp += (frame_duration_ms - 5) * 90; |
176 } else { | 166 } else { |
177 rtp_timestamp += (frame_duration_ms + 5) * 90; | 167 rtp_timestamp += (frame_duration_ms + 5) * 90; |
178 } | 168 } |
179 EXPECT_EQ(kBwNormal, overuse_detector_->State()); | 169 EXPECT_EQ(kBwNormal, overuse_detector_->State()); |
180 } | 170 } |
181 } | 171 } |
182 | 172 |
183 TEST_F(OveruseDetectorTest, SimpleOveruse2000Kbit30fps) { | 173 TEST_F(OveruseDetectorTest, SimpleOveruse2000Kbit30fps) { |
184 size_t packet_size = 1200; | |
185 int packets_per_frame = 6; | 174 int packets_per_frame = 6; |
186 int frame_duration_ms = 33; | 175 int frame_duration_ms = 33; |
187 int drift_per_frame_ms = 1; | 176 int drift_per_frame_ms = 1; |
188 int sigma_ms = 0; // No variance. | 177 int sigma_ms = 0; // No variance. |
189 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 178 int unique_overuse = |
190 frame_duration_ms, sigma_ms); | 179 Run100000Samples(packets_per_frame, frame_duration_ms, sigma_ms); |
191 | 180 |
192 EXPECT_EQ(0, unique_overuse); | 181 EXPECT_EQ(0, unique_overuse); |
193 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 182 int frames_until_overuse = RunUntilOveruse( |
194 frame_duration_ms, sigma_ms, drift_per_frame_ms); | 183 packets_per_frame, frame_duration_ms, sigma_ms, drift_per_frame_ms); |
195 EXPECT_EQ(8, frames_until_overuse); | 184 EXPECT_EQ(8, frames_until_overuse); |
196 } | 185 } |
197 | 186 |
198 TEST_F(OveruseDetectorTest, SimpleOveruse100kbit10fps) { | 187 TEST_F(OveruseDetectorTest, SimpleOveruse100kbit10fps) { |
199 size_t packet_size = 1200; | |
200 int packets_per_frame = 1; | 188 int packets_per_frame = 1; |
201 int frame_duration_ms = 100; | 189 int frame_duration_ms = 100; |
202 int drift_per_frame_ms = 1; | 190 int drift_per_frame_ms = 1; |
203 int sigma_ms = 0; // No variance. | 191 int sigma_ms = 0; // No variance. |
204 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 192 int unique_overuse = |
205 frame_duration_ms, sigma_ms); | 193 Run100000Samples(packets_per_frame, frame_duration_ms, sigma_ms); |
206 | 194 |
207 EXPECT_EQ(0, unique_overuse); | 195 EXPECT_EQ(0, unique_overuse); |
208 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 196 int frames_until_overuse = RunUntilOveruse( |
209 frame_duration_ms, sigma_ms, drift_per_frame_ms); | 197 packets_per_frame, frame_duration_ms, sigma_ms, drift_per_frame_ms); |
210 EXPECT_EQ(6, frames_until_overuse); | 198 EXPECT_EQ(6, frames_until_overuse); |
211 } | 199 } |
212 | 200 |
213 TEST_F(OveruseDetectorTest, DISABLED_OveruseWithHighVariance100Kbit10fps) { | 201 TEST_F(OveruseDetectorTest, DISABLED_OveruseWithHighVariance100Kbit10fps) { |
214 uint32_t frame_duration_ms = 100; | 202 uint32_t frame_duration_ms = 100; |
215 uint32_t drift_per_frame_ms = 10; | 203 uint32_t drift_per_frame_ms = 10; |
216 uint32_t rtp_timestamp = frame_duration_ms * 90; | 204 uint32_t rtp_timestamp = frame_duration_ms * 90; |
217 size_t packet_size = 1200; | |
218 int offset = 10; | 205 int offset = 10; |
219 | 206 |
220 // Run 1000 samples to reach steady state. | 207 // Run 1000 samples to reach steady state. |
221 for (int i = 0; i < 1000; ++i) { | 208 for (int i = 0; i < 1000; ++i) { |
222 UpdateDetector(rtp_timestamp, now_ms_, packet_size); | 209 UpdateDetector(rtp_timestamp, now_ms_); |
223 rtp_timestamp += frame_duration_ms * 90; | 210 rtp_timestamp += frame_duration_ms * 90; |
224 if (i % 2) { | 211 if (i % 2) { |
225 offset = rand() % 50; | 212 offset = rand() % 50; |
226 now_ms_ += frame_duration_ms - offset; | 213 now_ms_ += frame_duration_ms - offset; |
227 } else { | 214 } else { |
228 now_ms_ += frame_duration_ms + offset; | 215 now_ms_ += frame_duration_ms + offset; |
229 } | 216 } |
230 EXPECT_EQ(kBwNormal, overuse_detector_->State()); | 217 EXPECT_EQ(kBwNormal, overuse_detector_->State()); |
231 } | 218 } |
232 // Simulate a higher send pace, that is too high. | 219 // Simulate a higher send pace, that is too high. |
233 // Above noise generate a standard deviation of approximately 28 ms. | 220 // Above noise generate a standard deviation of approximately 28 ms. |
234 // Total build up of 150 ms. | 221 // Total build up of 150 ms. |
235 for (int j = 0; j < 15; ++j) { | 222 for (int j = 0; j < 15; ++j) { |
236 UpdateDetector(rtp_timestamp, now_ms_, packet_size); | 223 UpdateDetector(rtp_timestamp, now_ms_); |
237 now_ms_ += frame_duration_ms + drift_per_frame_ms; | 224 now_ms_ += frame_duration_ms + drift_per_frame_ms; |
238 rtp_timestamp += frame_duration_ms * 90; | 225 rtp_timestamp += frame_duration_ms * 90; |
239 EXPECT_EQ(kBwNormal, overuse_detector_->State()); | 226 EXPECT_EQ(kBwNormal, overuse_detector_->State()); |
240 } | 227 } |
241 UpdateDetector(rtp_timestamp, now_ms_, packet_size); | 228 UpdateDetector(rtp_timestamp, now_ms_); |
242 EXPECT_EQ(kBwOverusing, overuse_detector_->State()); | 229 EXPECT_EQ(kBwOverusing, overuse_detector_->State()); |
243 } | 230 } |
244 | 231 |
245 TEST_F(OveruseDetectorTest, DISABLED_OveruseWithLowVariance100Kbit10fps) { | 232 TEST_F(OveruseDetectorTest, DISABLED_OveruseWithLowVariance100Kbit10fps) { |
246 uint32_t frame_duration_ms = 100; | 233 uint32_t frame_duration_ms = 100; |
247 uint32_t drift_per_frame_ms = 1; | 234 uint32_t drift_per_frame_ms = 1; |
248 uint32_t rtp_timestamp = frame_duration_ms * 90; | 235 uint32_t rtp_timestamp = frame_duration_ms * 90; |
249 size_t packet_size = 1200; | |
250 int offset = 10; | 236 int offset = 10; |
251 | 237 |
252 // Run 1000 samples to reach steady state. | 238 // Run 1000 samples to reach steady state. |
253 for (int i = 0; i < 1000; ++i) { | 239 for (int i = 0; i < 1000; ++i) { |
254 UpdateDetector(rtp_timestamp, now_ms_, packet_size); | 240 UpdateDetector(rtp_timestamp, now_ms_); |
255 rtp_timestamp += frame_duration_ms * 90; | 241 rtp_timestamp += frame_duration_ms * 90; |
256 if (i % 2) { | 242 if (i % 2) { |
257 offset = rand() % 2; | 243 offset = rand() % 2; |
258 now_ms_ += frame_duration_ms - offset; | 244 now_ms_ += frame_duration_ms - offset; |
259 } else { | 245 } else { |
260 now_ms_ += frame_duration_ms + offset; | 246 now_ms_ += frame_duration_ms + offset; |
261 } | 247 } |
262 EXPECT_EQ(kBwNormal, overuse_detector_->State()); | 248 EXPECT_EQ(kBwNormal, overuse_detector_->State()); |
263 } | 249 } |
264 // Simulate a higher send pace, that is too high. | 250 // Simulate a higher send pace, that is too high. |
265 // Total build up of 6 ms. | 251 // Total build up of 6 ms. |
266 for (int j = 0; j < 6; ++j) { | 252 for (int j = 0; j < 6; ++j) { |
267 UpdateDetector(rtp_timestamp, now_ms_, packet_size); | 253 UpdateDetector(rtp_timestamp, now_ms_); |
268 now_ms_ += frame_duration_ms + drift_per_frame_ms; | 254 now_ms_ += frame_duration_ms + drift_per_frame_ms; |
269 rtp_timestamp += frame_duration_ms * 90; | 255 rtp_timestamp += frame_duration_ms * 90; |
270 EXPECT_EQ(kBwNormal, overuse_detector_->State()); | 256 EXPECT_EQ(kBwNormal, overuse_detector_->State()); |
271 } | 257 } |
272 UpdateDetector(rtp_timestamp, now_ms_, packet_size); | 258 UpdateDetector(rtp_timestamp, now_ms_); |
273 EXPECT_EQ(kBwOverusing, overuse_detector_->State()); | 259 EXPECT_EQ(kBwOverusing, overuse_detector_->State()); |
274 } | 260 } |
275 | 261 |
276 TEST_F(OveruseDetectorTest, OveruseWithLowVariance2000Kbit30fps) { | 262 TEST_F(OveruseDetectorTest, OveruseWithLowVariance2000Kbit30fps) { |
277 uint32_t frame_duration_ms = 33; | 263 uint32_t frame_duration_ms = 33; |
278 uint32_t drift_per_frame_ms = 1; | 264 uint32_t drift_per_frame_ms = 1; |
279 uint32_t rtp_timestamp = frame_duration_ms * 90; | 265 uint32_t rtp_timestamp = frame_duration_ms * 90; |
280 size_t packet_size = 1200; | |
281 int offset = 0; | 266 int offset = 0; |
282 | 267 |
283 // Run 1000 samples to reach steady state. | 268 // Run 1000 samples to reach steady state. |
284 for (int i = 0; i < 1000; ++i) { | 269 for (int i = 0; i < 1000; ++i) { |
285 UpdateDetector(rtp_timestamp, now_ms_, packet_size); | 270 UpdateDetector(rtp_timestamp, now_ms_); |
286 UpdateDetector(rtp_timestamp, now_ms_, packet_size); | 271 UpdateDetector(rtp_timestamp, now_ms_); |
287 UpdateDetector(rtp_timestamp, now_ms_, packet_size); | 272 UpdateDetector(rtp_timestamp, now_ms_); |
288 UpdateDetector(rtp_timestamp, now_ms_, packet_size); | 273 UpdateDetector(rtp_timestamp, now_ms_); |
289 UpdateDetector(rtp_timestamp, now_ms_, packet_size); | 274 UpdateDetector(rtp_timestamp, now_ms_); |
290 UpdateDetector(rtp_timestamp, now_ms_, packet_size); | 275 UpdateDetector(rtp_timestamp, now_ms_); |
291 rtp_timestamp += frame_duration_ms * 90; | 276 rtp_timestamp += frame_duration_ms * 90; |
292 if (i % 2) { | 277 if (i % 2) { |
293 offset = rand() % 2; | 278 offset = rand() % 2; |
294 now_ms_ += frame_duration_ms - offset; | 279 now_ms_ += frame_duration_ms - offset; |
295 } else { | 280 } else { |
296 now_ms_ += frame_duration_ms + offset; | 281 now_ms_ += frame_duration_ms + offset; |
297 } | 282 } |
298 EXPECT_EQ(kBwNormal, overuse_detector_->State()); | 283 EXPECT_EQ(kBwNormal, overuse_detector_->State()); |
299 } | 284 } |
300 // Simulate a higher send pace, that is too high. | 285 // Simulate a higher send pace, that is too high. |
301 // Total build up of 30 ms. | 286 // Total build up of 30 ms. |
302 for (int j = 0; j < 5; ++j) { | 287 for (int j = 0; j < 5; ++j) { |
303 UpdateDetector(rtp_timestamp, now_ms_, packet_size); | 288 UpdateDetector(rtp_timestamp, now_ms_); |
304 UpdateDetector(rtp_timestamp, now_ms_, packet_size); | 289 UpdateDetector(rtp_timestamp, now_ms_); |
305 UpdateDetector(rtp_timestamp, now_ms_, packet_size); | 290 UpdateDetector(rtp_timestamp, now_ms_); |
306 UpdateDetector(rtp_timestamp, now_ms_, packet_size); | 291 UpdateDetector(rtp_timestamp, now_ms_); |
307 UpdateDetector(rtp_timestamp, now_ms_, packet_size); | 292 UpdateDetector(rtp_timestamp, now_ms_); |
308 UpdateDetector(rtp_timestamp, now_ms_, packet_size); | 293 UpdateDetector(rtp_timestamp, now_ms_); |
309 now_ms_ += frame_duration_ms + drift_per_frame_ms * 6; | 294 now_ms_ += frame_duration_ms + drift_per_frame_ms * 6; |
310 rtp_timestamp += frame_duration_ms * 90; | 295 rtp_timestamp += frame_duration_ms * 90; |
311 EXPECT_EQ(kBwNormal, overuse_detector_->State()); | 296 EXPECT_EQ(kBwNormal, overuse_detector_->State()); |
312 } | 297 } |
313 UpdateDetector(rtp_timestamp, now_ms_, packet_size); | 298 UpdateDetector(rtp_timestamp, now_ms_); |
314 EXPECT_EQ(kBwOverusing, overuse_detector_->State()); | 299 EXPECT_EQ(kBwOverusing, overuse_detector_->State()); |
315 } | 300 } |
316 | 301 |
317 TEST_F(OveruseDetectorTest, | 302 TEST_F(OveruseDetectorTest, |
318 DISABLED_ON_ANDROID(LowGaussianVariance30Kbit3fps)) { | 303 DISABLED_ON_ANDROID(LowGaussianVariance30Kbit3fps)) { |
319 size_t packet_size = 1200; | 304 int packets_per_frame = 1; |
320 int packets_per_frame = 1; | 305 int frame_duration_ms = 333; |
321 int frame_duration_ms = 333; | 306 int drift_per_frame_ms = 1; |
322 int drift_per_frame_ms = 1; | 307 int sigma_ms = 3; |
323 int sigma_ms = 3; | 308 int unique_overuse = |
324 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 309 Run100000Samples(packets_per_frame, frame_duration_ms, sigma_ms); |
325 frame_duration_ms, sigma_ms); | |
326 EXPECT_EQ(13, unique_overuse); | 310 EXPECT_EQ(13, unique_overuse); |
327 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 311 int frames_until_overuse = RunUntilOveruse( |
328 frame_duration_ms, sigma_ms, drift_per_frame_ms); | 312 packets_per_frame, frame_duration_ms, sigma_ms, drift_per_frame_ms); |
329 EXPECT_EQ(14, frames_until_overuse); | 313 EXPECT_EQ(14, frames_until_overuse); |
330 } | 314 } |
331 | 315 |
332 TEST_F(OveruseDetectorTest, LowGaussianVarianceFastDrift30Kbit3fps) { | 316 TEST_F(OveruseDetectorTest, LowGaussianVarianceFastDrift30Kbit3fps) { |
333 size_t packet_size = 1200; | |
334 int packets_per_frame = 1; | 317 int packets_per_frame = 1; |
335 int frame_duration_ms = 333; | 318 int frame_duration_ms = 333; |
336 int drift_per_frame_ms = 100; | 319 int drift_per_frame_ms = 100; |
337 int sigma_ms = 3; | 320 int sigma_ms = 3; |
338 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 321 int unique_overuse = |
339 frame_duration_ms, sigma_ms); | 322 Run100000Samples(packets_per_frame, frame_duration_ms, sigma_ms); |
340 EXPECT_EQ(13, unique_overuse); | 323 EXPECT_EQ(13, unique_overuse); |
341 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 324 int frames_until_overuse = RunUntilOveruse( |
342 frame_duration_ms, sigma_ms, drift_per_frame_ms); | 325 packets_per_frame, frame_duration_ms, sigma_ms, drift_per_frame_ms); |
343 EXPECT_EQ(4, frames_until_overuse); | 326 EXPECT_EQ(4, frames_until_overuse); |
344 } | 327 } |
345 | 328 |
346 TEST_F(OveruseDetectorTest, HighGaussianVariance30Kbit3fps) { | 329 TEST_F(OveruseDetectorTest, HighGaussianVariance30Kbit3fps) { |
347 size_t packet_size = 1200; | 330 int packets_per_frame = 1; |
348 int packets_per_frame = 1; | 331 int frame_duration_ms = 333; |
349 int frame_duration_ms = 333; | 332 int drift_per_frame_ms = 1; |
350 int drift_per_frame_ms = 1; | 333 int sigma_ms = 10; |
351 int sigma_ms = 10; | 334 int unique_overuse = |
352 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 335 Run100000Samples(packets_per_frame, frame_duration_ms, sigma_ms); |
353 frame_duration_ms, sigma_ms); | 336 EXPECT_EQ(50, unique_overuse); |
354 EXPECT_EQ(46, unique_overuse); | 337 int frames_until_overuse = RunUntilOveruse( |
355 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 338 packets_per_frame, frame_duration_ms, sigma_ms, drift_per_frame_ms); |
356 frame_duration_ms, sigma_ms, drift_per_frame_ms); | |
357 EXPECT_EQ(42, frames_until_overuse); | 339 EXPECT_EQ(42, frames_until_overuse); |
358 } | 340 } |
359 | 341 |
360 TEST_F(OveruseDetectorTest, HighGaussianVarianceFastDrift30Kbit3fps) { | 342 TEST_F(OveruseDetectorTest, HighGaussianVarianceFastDrift30Kbit3fps) { |
361 size_t packet_size = 1200; | |
362 int packets_per_frame = 1; | 343 int packets_per_frame = 1; |
363 int frame_duration_ms = 333; | 344 int frame_duration_ms = 333; |
364 int drift_per_frame_ms = 100; | 345 int drift_per_frame_ms = 100; |
365 int sigma_ms = 10; | 346 int sigma_ms = 10; |
366 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 347 int unique_overuse = |
367 frame_duration_ms, sigma_ms); | 348 Run100000Samples(packets_per_frame, frame_duration_ms, sigma_ms); |
368 EXPECT_EQ(46, unique_overuse); | 349 EXPECT_EQ(50, unique_overuse); |
369 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 350 int frames_until_overuse = RunUntilOveruse( |
370 frame_duration_ms, sigma_ms, drift_per_frame_ms); | 351 packets_per_frame, frame_duration_ms, sigma_ms, drift_per_frame_ms); |
371 EXPECT_EQ(4, frames_until_overuse); | 352 EXPECT_EQ(4, frames_until_overuse); |
372 } | 353 } |
373 | 354 |
374 TEST_F(OveruseDetectorTest, | 355 TEST_F(OveruseDetectorTest, |
375 DISABLED_ON_ANDROID(LowGaussianVariance100Kbit5fps)) { | 356 DISABLED_ON_ANDROID(LowGaussianVariance100Kbit5fps)) { |
376 size_t packet_size = 1200; | |
377 int packets_per_frame = 2; | 357 int packets_per_frame = 2; |
378 int frame_duration_ms = 200; | 358 int frame_duration_ms = 200; |
379 int drift_per_frame_ms = 1; | 359 int drift_per_frame_ms = 1; |
380 int sigma_ms = 3; | 360 int sigma_ms = 3; |
381 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 361 int unique_overuse = |
382 frame_duration_ms, sigma_ms); | 362 Run100000Samples(packets_per_frame, frame_duration_ms, sigma_ms); |
383 EXPECT_EQ(12, unique_overuse); | 363 EXPECT_EQ(12, unique_overuse); |
384 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 364 int frames_until_overuse = RunUntilOveruse( |
385 frame_duration_ms, sigma_ms, drift_per_frame_ms); | 365 packets_per_frame, frame_duration_ms, sigma_ms, drift_per_frame_ms); |
386 EXPECT_EQ(12, frames_until_overuse); | 366 EXPECT_EQ(12, frames_until_overuse); |
387 } | 367 } |
388 | 368 |
389 TEST_F(OveruseDetectorTest, | 369 TEST_F(OveruseDetectorTest, |
390 DISABLED_ON_ANDROID(HighGaussianVariance100Kbit5fps)) { | 370 DISABLED_ON_ANDROID(HighGaussianVariance100Kbit5fps)) { |
391 size_t packet_size = 1200; | |
392 int packets_per_frame = 2; | 371 int packets_per_frame = 2; |
393 int frame_duration_ms = 200; | 372 int frame_duration_ms = 200; |
394 int drift_per_frame_ms = 1; | 373 int drift_per_frame_ms = 1; |
395 int sigma_ms = 10; | 374 int sigma_ms = 10; |
396 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 375 int unique_overuse = |
397 frame_duration_ms, sigma_ms); | 376 Run100000Samples(packets_per_frame, frame_duration_ms, sigma_ms); |
398 EXPECT_EQ(16, unique_overuse); | 377 EXPECT_EQ(16, unique_overuse); |
399 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 378 int frames_until_overuse = RunUntilOveruse( |
400 frame_duration_ms, sigma_ms, drift_per_frame_ms); | 379 packets_per_frame, frame_duration_ms, sigma_ms, drift_per_frame_ms); |
401 EXPECT_EQ(37, frames_until_overuse); | 380 EXPECT_EQ(37, frames_until_overuse); |
402 } | 381 } |
403 | 382 |
404 TEST_F(OveruseDetectorTest, | 383 TEST_F(OveruseDetectorTest, |
405 DISABLED_ON_ANDROID(LowGaussianVariance100Kbit10fps)) { | 384 DISABLED_ON_ANDROID(LowGaussianVariance100Kbit10fps)) { |
406 size_t packet_size = 1200; | |
407 int packets_per_frame = 1; | 385 int packets_per_frame = 1; |
408 int frame_duration_ms = 100; | 386 int frame_duration_ms = 100; |
409 int drift_per_frame_ms = 1; | 387 int drift_per_frame_ms = 1; |
410 int sigma_ms = 3; | 388 int sigma_ms = 3; |
411 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 389 int unique_overuse = |
412 frame_duration_ms, sigma_ms); | 390 Run100000Samples(packets_per_frame, frame_duration_ms, sigma_ms); |
413 EXPECT_EQ(12, unique_overuse); | 391 EXPECT_EQ(12, unique_overuse); |
414 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 392 int frames_until_overuse = RunUntilOveruse( |
415 frame_duration_ms, sigma_ms, drift_per_frame_ms); | 393 packets_per_frame, frame_duration_ms, sigma_ms, drift_per_frame_ms); |
416 EXPECT_EQ(12, frames_until_overuse); | 394 EXPECT_EQ(12, frames_until_overuse); |
417 } | 395 } |
418 | 396 |
419 TEST_F(OveruseDetectorTest, | 397 TEST_F(OveruseDetectorTest, |
420 DISABLED_ON_ANDROID(HighGaussianVariance100Kbit10fps)) { | 398 DISABLED_ON_ANDROID(HighGaussianVariance100Kbit10fps)) { |
421 size_t packet_size = 1200; | |
422 int packets_per_frame = 1; | 399 int packets_per_frame = 1; |
423 int frame_duration_ms = 100; | 400 int frame_duration_ms = 100; |
424 int drift_per_frame_ms = 1; | 401 int drift_per_frame_ms = 1; |
425 int sigma_ms = 10; | 402 int sigma_ms = 10; |
426 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 403 int unique_overuse = |
427 frame_duration_ms, sigma_ms); | 404 Run100000Samples(packets_per_frame, frame_duration_ms, sigma_ms); |
428 EXPECT_EQ(12, unique_overuse); | 405 EXPECT_EQ(12, unique_overuse); |
429 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 406 int frames_until_overuse = RunUntilOveruse( |
430 frame_duration_ms, sigma_ms, drift_per_frame_ms); | 407 packets_per_frame, frame_duration_ms, sigma_ms, drift_per_frame_ms); |
431 EXPECT_EQ(37, frames_until_overuse); | 408 EXPECT_EQ(37, frames_until_overuse); |
432 } | 409 } |
433 | 410 |
434 TEST_F(OveruseDetectorTest, | 411 TEST_F(OveruseDetectorTest, |
435 DISABLED_ON_ANDROID(LowGaussianVariance300Kbit30fps)) { | 412 DISABLED_ON_ANDROID(LowGaussianVariance300Kbit30fps)) { |
436 size_t packet_size = 1200; | 413 int packets_per_frame = 1; |
437 int packets_per_frame = 1; | 414 int frame_duration_ms = 33; |
438 int frame_duration_ms = 33; | 415 int drift_per_frame_ms = 1; |
439 int drift_per_frame_ms = 1; | 416 int sigma_ms = 3; |
440 int sigma_ms = 3; | 417 int unique_overuse = |
441 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 418 Run100000Samples(packets_per_frame, frame_duration_ms, sigma_ms); |
442 frame_duration_ms, sigma_ms); | 419 EXPECT_EQ(0, unique_overuse); |
443 EXPECT_EQ(0, unique_overuse); | 420 int frames_until_overuse = RunUntilOveruse( |
444 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 421 packets_per_frame, frame_duration_ms, sigma_ms, drift_per_frame_ms); |
445 frame_duration_ms, sigma_ms, drift_per_frame_ms); | |
446 EXPECT_EQ(14, frames_until_overuse); | 422 EXPECT_EQ(14, frames_until_overuse); |
447 } | 423 } |
448 | 424 |
449 TEST_F(OveruseDetectorTest, LowGaussianVarianceFastDrift300Kbit30fps) { | 425 TEST_F(OveruseDetectorTest, LowGaussianVarianceFastDrift300Kbit30fps) { |
450 size_t packet_size = 1200; | 426 int packets_per_frame = 1; |
451 int packets_per_frame = 1; | 427 int frame_duration_ms = 33; |
452 int frame_duration_ms = 33; | 428 int drift_per_frame_ms = 10; |
453 int drift_per_frame_ms = 10; | 429 int sigma_ms = 3; |
454 int sigma_ms = 3; | 430 int unique_overuse = |
455 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 431 Run100000Samples(packets_per_frame, frame_duration_ms, sigma_ms); |
456 frame_duration_ms, sigma_ms); | 432 EXPECT_EQ(0, unique_overuse); |
457 EXPECT_EQ(0, unique_overuse); | 433 int frames_until_overuse = RunUntilOveruse( |
458 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 434 packets_per_frame, frame_duration_ms, sigma_ms, drift_per_frame_ms); |
459 frame_duration_ms, sigma_ms, drift_per_frame_ms); | |
460 EXPECT_EQ(6, frames_until_overuse); | 435 EXPECT_EQ(6, frames_until_overuse); |
461 } | 436 } |
462 | 437 |
463 TEST_F(OveruseDetectorTest, HighGaussianVariance300Kbit30fps) { | 438 TEST_F(OveruseDetectorTest, HighGaussianVariance300Kbit30fps) { |
464 size_t packet_size = 1200; | 439 int packets_per_frame = 1; |
465 int packets_per_frame = 1; | 440 int frame_duration_ms = 33; |
466 int frame_duration_ms = 33; | 441 int drift_per_frame_ms = 1; |
467 int drift_per_frame_ms = 1; | 442 int sigma_ms = 10; |
468 int sigma_ms = 10; | 443 int unique_overuse = |
469 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 444 Run100000Samples(packets_per_frame, frame_duration_ms, sigma_ms); |
470 frame_duration_ms, sigma_ms); | 445 EXPECT_EQ(0, unique_overuse); |
471 EXPECT_EQ(0, unique_overuse); | 446 int frames_until_overuse = RunUntilOveruse( |
472 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 447 packets_per_frame, frame_duration_ms, sigma_ms, drift_per_frame_ms); |
473 frame_duration_ms, sigma_ms, drift_per_frame_ms); | |
474 EXPECT_EQ(49, frames_until_overuse); | 448 EXPECT_EQ(49, frames_until_overuse); |
475 } | 449 } |
476 | 450 |
477 TEST_F(OveruseDetectorTest, HighGaussianVarianceFastDrift300Kbit30fps) { | 451 TEST_F(OveruseDetectorTest, HighGaussianVarianceFastDrift300Kbit30fps) { |
478 size_t packet_size = 1200; | 452 int packets_per_frame = 1; |
479 int packets_per_frame = 1; | 453 int frame_duration_ms = 33; |
480 int frame_duration_ms = 33; | 454 int drift_per_frame_ms = 10; |
481 int drift_per_frame_ms = 10; | 455 int sigma_ms = 10; |
482 int sigma_ms = 10; | 456 int unique_overuse = |
483 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 457 Run100000Samples(packets_per_frame, frame_duration_ms, sigma_ms); |
484 frame_duration_ms, sigma_ms); | 458 EXPECT_EQ(0, unique_overuse); |
485 EXPECT_EQ(0, unique_overuse); | 459 int frames_until_overuse = RunUntilOveruse( |
486 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 460 packets_per_frame, frame_duration_ms, sigma_ms, drift_per_frame_ms); |
487 frame_duration_ms, sigma_ms, drift_per_frame_ms); | |
488 EXPECT_EQ(8, frames_until_overuse); | 461 EXPECT_EQ(8, frames_until_overuse); |
489 } | 462 } |
490 | 463 |
491 TEST_F(OveruseDetectorTest, | 464 TEST_F(OveruseDetectorTest, |
492 DISABLED_ON_ANDROID(LowGaussianVariance1000Kbit30fps)) { | 465 DISABLED_ON_ANDROID(LowGaussianVariance1000Kbit30fps)) { |
493 size_t packet_size = 1200; | 466 int packets_per_frame = 3; |
494 int packets_per_frame = 3; | 467 int frame_duration_ms = 33; |
495 int frame_duration_ms = 33; | 468 int drift_per_frame_ms = 1; |
496 int drift_per_frame_ms = 1; | 469 int sigma_ms = 3; |
497 int sigma_ms = 3; | 470 int unique_overuse = |
498 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 471 Run100000Samples(packets_per_frame, frame_duration_ms, sigma_ms); |
499 frame_duration_ms, sigma_ms); | 472 EXPECT_EQ(0, unique_overuse); |
500 EXPECT_EQ(0, unique_overuse); | 473 int frames_until_overuse = RunUntilOveruse( |
501 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 474 packets_per_frame, frame_duration_ms, sigma_ms, drift_per_frame_ms); |
502 frame_duration_ms, sigma_ms, drift_per_frame_ms); | |
503 EXPECT_EQ(14, frames_until_overuse); | 475 EXPECT_EQ(14, frames_until_overuse); |
504 } | 476 } |
505 | 477 |
506 TEST_F(OveruseDetectorTest, LowGaussianVarianceFastDrift1000Kbit30fps) { | 478 TEST_F(OveruseDetectorTest, LowGaussianVarianceFastDrift1000Kbit30fps) { |
507 size_t packet_size = 1200; | 479 int packets_per_frame = 3; |
508 int packets_per_frame = 3; | 480 int frame_duration_ms = 33; |
509 int frame_duration_ms = 33; | 481 int drift_per_frame_ms = 10; |
510 int drift_per_frame_ms = 10; | 482 int sigma_ms = 3; |
511 int sigma_ms = 3; | 483 int unique_overuse = |
512 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 484 Run100000Samples(packets_per_frame, frame_duration_ms, sigma_ms); |
513 frame_duration_ms, sigma_ms); | 485 EXPECT_EQ(0, unique_overuse); |
514 EXPECT_EQ(0, unique_overuse); | 486 int frames_until_overuse = RunUntilOveruse( |
515 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 487 packets_per_frame, frame_duration_ms, sigma_ms, drift_per_frame_ms); |
516 frame_duration_ms, sigma_ms, drift_per_frame_ms); | |
517 EXPECT_EQ(6, frames_until_overuse); | 488 EXPECT_EQ(6, frames_until_overuse); |
518 } | 489 } |
519 | 490 |
520 TEST_F(OveruseDetectorTest, HighGaussianVariance1000Kbit30fps) { | 491 TEST_F(OveruseDetectorTest, HighGaussianVariance1000Kbit30fps) { |
521 size_t packet_size = 1200; | 492 int packets_per_frame = 3; |
522 int packets_per_frame = 3; | 493 int frame_duration_ms = 33; |
523 int frame_duration_ms = 33; | 494 int drift_per_frame_ms = 1; |
524 int drift_per_frame_ms = 1; | 495 int sigma_ms = 10; |
525 int sigma_ms = 10; | 496 int unique_overuse = |
526 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 497 Run100000Samples(packets_per_frame, frame_duration_ms, sigma_ms); |
527 frame_duration_ms, sigma_ms); | 498 EXPECT_EQ(0, unique_overuse); |
528 EXPECT_EQ(0, unique_overuse); | 499 int frames_until_overuse = RunUntilOveruse( |
529 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 500 packets_per_frame, frame_duration_ms, sigma_ms, drift_per_frame_ms); |
530 frame_duration_ms, sigma_ms, drift_per_frame_ms); | |
531 EXPECT_EQ(49, frames_until_overuse); | 501 EXPECT_EQ(49, frames_until_overuse); |
532 } | 502 } |
533 | 503 |
534 TEST_F(OveruseDetectorTest, HighGaussianVarianceFastDrift1000Kbit30fps) { | 504 TEST_F(OveruseDetectorTest, HighGaussianVarianceFastDrift1000Kbit30fps) { |
535 size_t packet_size = 1200; | 505 int packets_per_frame = 3; |
536 int packets_per_frame = 3; | 506 int frame_duration_ms = 33; |
537 int frame_duration_ms = 33; | 507 int drift_per_frame_ms = 10; |
538 int drift_per_frame_ms = 10; | 508 int sigma_ms = 10; |
539 int sigma_ms = 10; | 509 int unique_overuse = |
540 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 510 Run100000Samples(packets_per_frame, frame_duration_ms, sigma_ms); |
541 frame_duration_ms, sigma_ms); | 511 EXPECT_EQ(0, unique_overuse); |
542 EXPECT_EQ(0, unique_overuse); | 512 int frames_until_overuse = RunUntilOveruse( |
543 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 513 packets_per_frame, frame_duration_ms, sigma_ms, drift_per_frame_ms); |
544 frame_duration_ms, sigma_ms, drift_per_frame_ms); | |
545 EXPECT_EQ(8, frames_until_overuse); | 514 EXPECT_EQ(8, frames_until_overuse); |
546 } | 515 } |
547 | 516 |
548 TEST_F(OveruseDetectorTest, | 517 TEST_F(OveruseDetectorTest, |
549 DISABLED_ON_ANDROID(LowGaussianVariance2000Kbit30fps)) { | 518 DISABLED_ON_ANDROID(LowGaussianVariance2000Kbit30fps)) { |
550 size_t packet_size = 1200; | 519 int packets_per_frame = 6; |
551 int packets_per_frame = 6; | 520 int frame_duration_ms = 33; |
552 int frame_duration_ms = 33; | 521 int drift_per_frame_ms = 1; |
553 int drift_per_frame_ms = 1; | 522 int sigma_ms = 3; |
554 int sigma_ms = 3; | 523 int unique_overuse = |
555 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 524 Run100000Samples(packets_per_frame, frame_duration_ms, sigma_ms); |
556 frame_duration_ms, sigma_ms); | 525 EXPECT_EQ(0, unique_overuse); |
557 EXPECT_EQ(0, unique_overuse); | 526 int frames_until_overuse = RunUntilOveruse( |
558 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 527 packets_per_frame, frame_duration_ms, sigma_ms, drift_per_frame_ms); |
559 frame_duration_ms, sigma_ms, drift_per_frame_ms); | |
560 EXPECT_EQ(14, frames_until_overuse); | 528 EXPECT_EQ(14, frames_until_overuse); |
561 } | 529 } |
562 | 530 |
563 TEST_F(OveruseDetectorTest, LowGaussianVarianceFastDrift2000Kbit30fps) { | 531 TEST_F(OveruseDetectorTest, LowGaussianVarianceFastDrift2000Kbit30fps) { |
564 size_t packet_size = 1200; | 532 int packets_per_frame = 6; |
565 int packets_per_frame = 6; | 533 int frame_duration_ms = 33; |
566 int frame_duration_ms = 33; | 534 int drift_per_frame_ms = 10; |
567 int drift_per_frame_ms = 10; | 535 int sigma_ms = 3; |
568 int sigma_ms = 3; | 536 int unique_overuse = |
569 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 537 Run100000Samples(packets_per_frame, frame_duration_ms, sigma_ms); |
570 frame_duration_ms, sigma_ms); | 538 EXPECT_EQ(0, unique_overuse); |
571 EXPECT_EQ(0, unique_overuse); | 539 int frames_until_overuse = RunUntilOveruse( |
572 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 540 packets_per_frame, frame_duration_ms, sigma_ms, drift_per_frame_ms); |
573 frame_duration_ms, sigma_ms, drift_per_frame_ms); | |
574 EXPECT_EQ(6, frames_until_overuse); | 541 EXPECT_EQ(6, frames_until_overuse); |
575 } | 542 } |
576 | 543 |
577 TEST_F(OveruseDetectorTest, HighGaussianVariance2000Kbit30fps) { | 544 TEST_F(OveruseDetectorTest, HighGaussianVariance2000Kbit30fps) { |
578 size_t packet_size = 1200; | 545 int packets_per_frame = 6; |
579 int packets_per_frame = 6; | 546 int frame_duration_ms = 33; |
580 int frame_duration_ms = 33; | 547 int drift_per_frame_ms = 1; |
581 int drift_per_frame_ms = 1; | 548 int sigma_ms = 10; |
582 int sigma_ms = 10; | 549 int unique_overuse = |
583 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 550 Run100000Samples(packets_per_frame, frame_duration_ms, sigma_ms); |
584 frame_duration_ms, sigma_ms); | 551 EXPECT_EQ(0, unique_overuse); |
585 EXPECT_EQ(0, unique_overuse); | 552 int frames_until_overuse = RunUntilOveruse( |
586 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 553 packets_per_frame, frame_duration_ms, sigma_ms, drift_per_frame_ms); |
587 frame_duration_ms, sigma_ms, drift_per_frame_ms); | |
588 EXPECT_EQ(49, frames_until_overuse); | 554 EXPECT_EQ(49, frames_until_overuse); |
589 } | 555 } |
590 | 556 |
591 TEST_F(OveruseDetectorTest, HighGaussianVarianceFastDrift2000Kbit30fps) { | 557 TEST_F(OveruseDetectorTest, HighGaussianVarianceFastDrift2000Kbit30fps) { |
592 size_t packet_size = 1200; | 558 int packets_per_frame = 6; |
593 int packets_per_frame = 6; | 559 int frame_duration_ms = 33; |
594 int frame_duration_ms = 33; | 560 int drift_per_frame_ms = 10; |
595 int drift_per_frame_ms = 10; | 561 int sigma_ms = 10; |
596 int sigma_ms = 10; | 562 int unique_overuse = |
597 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 563 Run100000Samples(packets_per_frame, frame_duration_ms, sigma_ms); |
598 frame_duration_ms, sigma_ms); | 564 EXPECT_EQ(0, unique_overuse); |
599 EXPECT_EQ(0, unique_overuse); | 565 int frames_until_overuse = RunUntilOveruse( |
600 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 566 packets_per_frame, frame_duration_ms, sigma_ms, drift_per_frame_ms); |
601 frame_duration_ms, sigma_ms, drift_per_frame_ms); | |
602 EXPECT_EQ(8, frames_until_overuse); | 567 EXPECT_EQ(8, frames_until_overuse); |
603 } | 568 } |
604 | 569 |
605 class OveruseDetectorExperimentTest : public OveruseDetectorTest { | 570 class OveruseDetectorExperimentTest : public OveruseDetectorTest { |
606 public: | 571 public: |
607 OveruseDetectorExperimentTest() | 572 OveruseDetectorExperimentTest() |
608 : override_field_trials_( | 573 : override_field_trials_( |
609 "WebRTC-AdaptiveBweThreshold/Enabled-0.01,0.00018/") {} | 574 "WebRTC-AdaptiveBweThreshold/Enabled-0.01,0.00018/") {} |
610 | 575 |
611 protected: | 576 protected: |
612 void SetUp() override { | 577 void SetUp() override { overuse_detector_.reset(new OveruseDetector()); } |
613 overuse_detector_.reset(new OveruseDetector(options_)); | |
614 } | |
615 | 578 |
616 test::ScopedFieldTrials override_field_trials_; | 579 test::ScopedFieldTrials override_field_trials_; |
617 }; | 580 }; |
618 | 581 |
619 TEST_F(OveruseDetectorExperimentTest, ThresholdAdapts) { | 582 TEST_F(OveruseDetectorExperimentTest, ThresholdAdapts) { |
620 const double kOffset = 0.21; | 583 const double kOffset = 0.21; |
621 double kTsDelta = 3000.0; | 584 double kTsDelta = 3000.0; |
622 int64_t now_ms = 0; | 585 int64_t now_ms = 0; |
623 int num_deltas = 60; | 586 int num_deltas = 60; |
624 const int kBatchLength = 10; | 587 const int kBatchLength = 10; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 if (overuse_state == kBwOverusing) { | 694 if (overuse_state == kBwOverusing) { |
732 overuse_detected = true; | 695 overuse_detected = true; |
733 } | 696 } |
734 ++num_deltas; | 697 ++num_deltas; |
735 now_ms += 5; | 698 now_ms += 5; |
736 } | 699 } |
737 EXPECT_TRUE(overuse_detected); | 700 EXPECT_TRUE(overuse_detected); |
738 } | 701 } |
739 } // namespace testing | 702 } // namespace testing |
740 } // namespace webrtc | 703 } // namespace webrtc |
OLD | NEW |