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 |
11 #include <math.h> | 11 #include <math.h> |
12 | 12 |
13 #include <algorithm> | 13 #include <algorithm> |
14 #include <cmath> | 14 #include <cmath> |
15 #include <cstdlib> | 15 #include <cstdlib> |
16 | 16 |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
18 | 18 |
19 #include "webrtc/base/random.h" | 19 #include "webrtc/base/random.h" |
20 #include "webrtc/base/scoped_ptr.h" | 20 #include "webrtc/base/scoped_ptr.h" |
21 #include "webrtc/common_types.h" | 21 #include "webrtc/common_types.h" |
22 #include "webrtc/modules/remote_bitrate_estimator/inter_arrival.h" | 22 #include "webrtc/modules/remote_bitrate_estimator/inter_arrival.h" |
23 #include "webrtc/modules/remote_bitrate_estimator/overuse_detector.h" | 23 #include "webrtc/modules/remote_bitrate_estimator/overuse_detector.h" |
24 #include "webrtc/modules/remote_bitrate_estimator/overuse_estimator.h" | 24 #include "webrtc/modules/remote_bitrate_estimator/overuse_estimator.h" |
25 #include "webrtc/modules/remote_bitrate_estimator/rate_statistics.h" | 25 #include "webrtc/modules/remote_bitrate_estimator/rate_statistics.h" |
26 #include "webrtc/test/field_trial.h" | 26 #include "webrtc/test/field_trial.h" |
27 #include "webrtc/test/testsupport/gtest_disable.h" | |
28 | 27 |
29 namespace webrtc { | 28 namespace webrtc { |
30 namespace testing { | 29 namespace testing { |
31 | 30 |
32 const double kRtpTimestampToMs = 1.0 / 90.0; | 31 const double kRtpTimestampToMs = 1.0 / 90.0; |
33 | 32 |
34 class OveruseDetectorTest : public ::testing::Test { | 33 class OveruseDetectorTest : public ::testing::Test { |
35 public: | 34 public: |
36 OveruseDetectorTest() | 35 OveruseDetectorTest() |
37 : now_ms_(0), | 36 : now_ms_(0), |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 UpdateDetector(rtp_timestamp, now_ms_, packet_size); | 310 UpdateDetector(rtp_timestamp, now_ms_, packet_size); |
312 UpdateDetector(rtp_timestamp, now_ms_, packet_size); | 311 UpdateDetector(rtp_timestamp, now_ms_, packet_size); |
313 now_ms_ += frame_duration_ms + drift_per_frame_ms * 6; | 312 now_ms_ += frame_duration_ms + drift_per_frame_ms * 6; |
314 rtp_timestamp += frame_duration_ms * 90; | 313 rtp_timestamp += frame_duration_ms * 90; |
315 EXPECT_EQ(kBwNormal, overuse_detector_->State()); | 314 EXPECT_EQ(kBwNormal, overuse_detector_->State()); |
316 } | 315 } |
317 UpdateDetector(rtp_timestamp, now_ms_, packet_size); | 316 UpdateDetector(rtp_timestamp, now_ms_, packet_size); |
318 EXPECT_EQ(kBwOverusing, overuse_detector_->State()); | 317 EXPECT_EQ(kBwOverusing, overuse_detector_->State()); |
319 } | 318 } |
320 | 319 |
321 TEST_F(OveruseDetectorTest, | 320 #if defined(WEBRTC_ANDROID) |
322 DISABLED_ON_ANDROID(LowGaussianVariance30Kbit3fps)) { | 321 TEST_F(OveruseDetectorTest, DISABLED_LowGaussianVariance30Kbit3fps) { |
| 322 #else |
| 323 TEST_F(OveruseDetectorTest, LowGaussianVariance30Kbit3fps) { |
| 324 #endif |
323 size_t packet_size = 1200; | 325 size_t packet_size = 1200; |
324 int packets_per_frame = 1; | 326 int packets_per_frame = 1; |
325 int frame_duration_ms = 333; | 327 int frame_duration_ms = 333; |
326 int drift_per_frame_ms = 1; | 328 int drift_per_frame_ms = 1; |
327 int sigma_ms = 3; | 329 int sigma_ms = 3; |
328 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 330 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, |
329 frame_duration_ms, sigma_ms); | 331 frame_duration_ms, sigma_ms); |
330 EXPECT_EQ(1, unique_overuse); | 332 EXPECT_EQ(1, unique_overuse); |
331 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 333 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, |
332 frame_duration_ms, sigma_ms, drift_per_frame_ms); | 334 frame_duration_ms, sigma_ms, drift_per_frame_ms); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 int drift_per_frame_ms = 100; | 370 int drift_per_frame_ms = 100; |
369 int sigma_ms = 10; | 371 int sigma_ms = 10; |
370 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 372 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, |
371 frame_duration_ms, sigma_ms); | 373 frame_duration_ms, sigma_ms); |
372 EXPECT_EQ(1, unique_overuse); | 374 EXPECT_EQ(1, unique_overuse); |
373 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 375 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, |
374 frame_duration_ms, sigma_ms, drift_per_frame_ms); | 376 frame_duration_ms, sigma_ms, drift_per_frame_ms); |
375 EXPECT_EQ(4, frames_until_overuse); | 377 EXPECT_EQ(4, frames_until_overuse); |
376 } | 378 } |
377 | 379 |
378 TEST_F(OveruseDetectorTest, | 380 #if defined(WEBRTC_ANDROID) |
379 DISABLED_ON_ANDROID(LowGaussianVariance100Kbit5fps)) { | 381 TEST_F(OveruseDetectorTest, DISABLED_LowGaussianVariance100Kbit5fps) { |
| 382 #else |
| 383 TEST_F(OveruseDetectorTest, LowGaussianVariance100Kbit5fps) { |
| 384 #endif |
380 size_t packet_size = 1200; | 385 size_t packet_size = 1200; |
381 int packets_per_frame = 2; | 386 int packets_per_frame = 2; |
382 int frame_duration_ms = 200; | 387 int frame_duration_ms = 200; |
383 int drift_per_frame_ms = 1; | 388 int drift_per_frame_ms = 1; |
384 int sigma_ms = 3; | 389 int sigma_ms = 3; |
385 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 390 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, |
386 frame_duration_ms, sigma_ms); | 391 frame_duration_ms, sigma_ms); |
387 EXPECT_EQ(0, unique_overuse); | 392 EXPECT_EQ(0, unique_overuse); |
388 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 393 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, |
389 frame_duration_ms, sigma_ms, drift_per_frame_ms); | 394 frame_duration_ms, sigma_ms, drift_per_frame_ms); |
390 EXPECT_EQ(13, frames_until_overuse); | 395 EXPECT_EQ(13, frames_until_overuse); |
391 } | 396 } |
392 | 397 |
393 TEST_F(OveruseDetectorTest, | 398 #if defined(WEBRTC_ANDROID) |
394 DISABLED_ON_ANDROID(HighGaussianVariance100Kbit5fps)) { | 399 TEST_F(OveruseDetectorTest, DISABLED_HighGaussianVariance100Kbit5fps) { |
| 400 #else |
| 401 TEST_F(OveruseDetectorTest, HighGaussianVariance100Kbit5fps) { |
| 402 #endif |
395 size_t packet_size = 1200; | 403 size_t packet_size = 1200; |
396 int packets_per_frame = 2; | 404 int packets_per_frame = 2; |
397 int frame_duration_ms = 200; | 405 int frame_duration_ms = 200; |
398 int drift_per_frame_ms = 1; | 406 int drift_per_frame_ms = 1; |
399 int sigma_ms = 10; | 407 int sigma_ms = 10; |
400 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 408 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, |
401 frame_duration_ms, sigma_ms); | 409 frame_duration_ms, sigma_ms); |
402 EXPECT_EQ(1, unique_overuse); | 410 EXPECT_EQ(1, unique_overuse); |
403 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 411 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, |
404 frame_duration_ms, sigma_ms, drift_per_frame_ms); | 412 frame_duration_ms, sigma_ms, drift_per_frame_ms); |
405 EXPECT_EQ(32, frames_until_overuse); | 413 EXPECT_EQ(32, frames_until_overuse); |
406 } | 414 } |
407 | 415 |
408 TEST_F(OveruseDetectorTest, | 416 #if defined(WEBRTC_ANDROID) |
409 DISABLED_ON_ANDROID(LowGaussianVariance100Kbit10fps)) { | 417 TEST_F(OveruseDetectorTest, DISABLED_LowGaussianVariance100Kbit10fps) { |
| 418 #else |
| 419 TEST_F(OveruseDetectorTest, LowGaussianVariance100Kbit10fps) { |
| 420 #endif |
410 size_t packet_size = 1200; | 421 size_t packet_size = 1200; |
411 int packets_per_frame = 1; | 422 int packets_per_frame = 1; |
412 int frame_duration_ms = 100; | 423 int frame_duration_ms = 100; |
413 int drift_per_frame_ms = 1; | 424 int drift_per_frame_ms = 1; |
414 int sigma_ms = 3; | 425 int sigma_ms = 3; |
415 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 426 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, |
416 frame_duration_ms, sigma_ms); | 427 frame_duration_ms, sigma_ms); |
417 EXPECT_EQ(1, unique_overuse); | 428 EXPECT_EQ(1, unique_overuse); |
418 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 429 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, |
419 frame_duration_ms, sigma_ms, drift_per_frame_ms); | 430 frame_duration_ms, sigma_ms, drift_per_frame_ms); |
420 EXPECT_EQ(13, frames_until_overuse); | 431 EXPECT_EQ(13, frames_until_overuse); |
421 } | 432 } |
422 | 433 |
423 TEST_F(OveruseDetectorTest, | 434 #if defined(WEBRTC_ANDROID) |
424 DISABLED_ON_ANDROID(HighGaussianVariance100Kbit10fps)) { | 435 TEST_F(OveruseDetectorTest, DISABLED_HighGaussianVariance100Kbit10fps) { |
| 436 #else |
| 437 TEST_F(OveruseDetectorTest, HighGaussianVariance100Kbit10fps) { |
| 438 #endif |
425 size_t packet_size = 1200; | 439 size_t packet_size = 1200; |
426 int packets_per_frame = 1; | 440 int packets_per_frame = 1; |
427 int frame_duration_ms = 100; | 441 int frame_duration_ms = 100; |
428 int drift_per_frame_ms = 1; | 442 int drift_per_frame_ms = 1; |
429 int sigma_ms = 10; | 443 int sigma_ms = 10; |
430 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 444 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, |
431 frame_duration_ms, sigma_ms); | 445 frame_duration_ms, sigma_ms); |
432 EXPECT_EQ(0, unique_overuse); | 446 EXPECT_EQ(0, unique_overuse); |
433 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 447 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, |
434 frame_duration_ms, sigma_ms, drift_per_frame_ms); | 448 frame_duration_ms, sigma_ms, drift_per_frame_ms); |
435 EXPECT_EQ(32, frames_until_overuse); | 449 EXPECT_EQ(32, frames_until_overuse); |
436 } | 450 } |
437 | 451 |
438 TEST_F(OveruseDetectorTest, | 452 #if defined(WEBRTC_ANDROID) |
439 DISABLED_ON_ANDROID(LowGaussianVariance300Kbit30fps)) { | 453 TEST_F(OveruseDetectorTest, DISABLED_LowGaussianVariance300Kbit30fps) { |
| 454 #else |
| 455 TEST_F(OveruseDetectorTest, LowGaussianVariance300Kbit30fps) { |
| 456 #endif |
440 size_t packet_size = 1200; | 457 size_t packet_size = 1200; |
441 int packets_per_frame = 1; | 458 int packets_per_frame = 1; |
442 int frame_duration_ms = 33; | 459 int frame_duration_ms = 33; |
443 int drift_per_frame_ms = 1; | 460 int drift_per_frame_ms = 1; |
444 int sigma_ms = 3; | 461 int sigma_ms = 3; |
445 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 462 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, |
446 frame_duration_ms, sigma_ms); | 463 frame_duration_ms, sigma_ms); |
447 EXPECT_EQ(0, unique_overuse); | 464 EXPECT_EQ(0, unique_overuse); |
448 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 465 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, |
449 frame_duration_ms, sigma_ms, drift_per_frame_ms); | 466 frame_duration_ms, sigma_ms, drift_per_frame_ms); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 int drift_per_frame_ms = 10; | 502 int drift_per_frame_ms = 10; |
486 int sigma_ms = 10; | 503 int sigma_ms = 10; |
487 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 504 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, |
488 frame_duration_ms, sigma_ms); | 505 frame_duration_ms, sigma_ms); |
489 EXPECT_EQ(0, unique_overuse); | 506 EXPECT_EQ(0, unique_overuse); |
490 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 507 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, |
491 frame_duration_ms, sigma_ms, drift_per_frame_ms); | 508 frame_duration_ms, sigma_ms, drift_per_frame_ms); |
492 EXPECT_EQ(10, frames_until_overuse); | 509 EXPECT_EQ(10, frames_until_overuse); |
493 } | 510 } |
494 | 511 |
495 TEST_F(OveruseDetectorTest, | 512 #if defined(WEBRTC_ANDROID) |
496 DISABLED_ON_ANDROID(LowGaussianVariance1000Kbit30fps)) { | 513 TEST_F(OveruseDetectorTest, DISABLED_LowGaussianVariance1000Kbit30fps) { |
| 514 #else |
| 515 TEST_F(OveruseDetectorTest, LowGaussianVariance1000Kbit30fps) { |
| 516 #endif |
497 size_t packet_size = 1200; | 517 size_t packet_size = 1200; |
498 int packets_per_frame = 3; | 518 int packets_per_frame = 3; |
499 int frame_duration_ms = 33; | 519 int frame_duration_ms = 33; |
500 int drift_per_frame_ms = 1; | 520 int drift_per_frame_ms = 1; |
501 int sigma_ms = 3; | 521 int sigma_ms = 3; |
502 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 522 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, |
503 frame_duration_ms, sigma_ms); | 523 frame_duration_ms, sigma_ms); |
504 EXPECT_EQ(0, unique_overuse); | 524 EXPECT_EQ(0, unique_overuse); |
505 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 525 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, |
506 frame_duration_ms, sigma_ms, drift_per_frame_ms); | 526 frame_duration_ms, sigma_ms, drift_per_frame_ms); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 int drift_per_frame_ms = 10; | 562 int drift_per_frame_ms = 10; |
543 int sigma_ms = 10; | 563 int sigma_ms = 10; |
544 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 564 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, |
545 frame_duration_ms, sigma_ms); | 565 frame_duration_ms, sigma_ms); |
546 EXPECT_EQ(0, unique_overuse); | 566 EXPECT_EQ(0, unique_overuse); |
547 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 567 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, |
548 frame_duration_ms, sigma_ms, drift_per_frame_ms); | 568 frame_duration_ms, sigma_ms, drift_per_frame_ms); |
549 EXPECT_EQ(10, frames_until_overuse); | 569 EXPECT_EQ(10, frames_until_overuse); |
550 } | 570 } |
551 | 571 |
552 TEST_F(OveruseDetectorTest, | 572 #if defined(WEBRTC_ANDROID) |
553 DISABLED_ON_ANDROID(LowGaussianVariance2000Kbit30fps)) { | 573 TEST_F(OveruseDetectorTest, DISABLED_LowGaussianVariance2000Kbit30fps) { |
| 574 #else |
| 575 TEST_F(OveruseDetectorTest, LowGaussianVariance2000Kbit30fps) { |
| 576 #endif |
554 size_t packet_size = 1200; | 577 size_t packet_size = 1200; |
555 int packets_per_frame = 6; | 578 int packets_per_frame = 6; |
556 int frame_duration_ms = 33; | 579 int frame_duration_ms = 33; |
557 int drift_per_frame_ms = 1; | 580 int drift_per_frame_ms = 1; |
558 int sigma_ms = 3; | 581 int sigma_ms = 3; |
559 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 582 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, |
560 frame_duration_ms, sigma_ms); | 583 frame_duration_ms, sigma_ms); |
561 EXPECT_EQ(0, unique_overuse); | 584 EXPECT_EQ(0, unique_overuse); |
562 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 585 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, |
563 frame_duration_ms, sigma_ms, drift_per_frame_ms); | 586 frame_duration_ms, sigma_ms, drift_per_frame_ms); |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
735 if (overuse_state == kBwOverusing) { | 758 if (overuse_state == kBwOverusing) { |
736 overuse_detected = true; | 759 overuse_detected = true; |
737 } | 760 } |
738 ++num_deltas; | 761 ++num_deltas; |
739 now_ms += 5; | 762 now_ms += 5; |
740 } | 763 } |
741 EXPECT_TRUE(overuse_detected); | 764 EXPECT_TRUE(overuse_detected); |
742 } | 765 } |
743 } // namespace testing | 766 } // namespace testing |
744 } // namespace webrtc | 767 } // namespace webrtc |
OLD | NEW |