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