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

Side by Side Diff: webrtc/modules/remote_bitrate_estimator/overuse_detector_unittest.cc

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

Powered by Google App Engine
This is Rietveld 408576698