| 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 #define MAYBE_LowGaussianVariance30Kbit3fps \ |
| 322 DISABLED_LowGaussianVariance30Kbit3fps |
| 323 #else |
| 324 #define MAYBE_LowGaussianVariance30Kbit3fps LowGaussianVariance30Kbit3fps |
| 325 #endif |
| 326 TEST_F(OveruseDetectorTest, MAYBE_LowGaussianVariance30Kbit3fps) { |
| 323 size_t packet_size = 1200; | 327 size_t packet_size = 1200; |
| 324 int packets_per_frame = 1; | 328 int packets_per_frame = 1; |
| 325 int frame_duration_ms = 333; | 329 int frame_duration_ms = 333; |
| 326 int drift_per_frame_ms = 1; | 330 int drift_per_frame_ms = 1; |
| 327 int sigma_ms = 3; | 331 int sigma_ms = 3; |
| 328 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 332 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, |
| 329 frame_duration_ms, sigma_ms); | 333 frame_duration_ms, sigma_ms); |
| 330 EXPECT_EQ(1, unique_overuse); | 334 EXPECT_EQ(1, unique_overuse); |
| 331 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 335 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, |
| 332 frame_duration_ms, sigma_ms, drift_per_frame_ms); | 336 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; | 372 int drift_per_frame_ms = 100; |
| 369 int sigma_ms = 10; | 373 int sigma_ms = 10; |
| 370 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 374 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, |
| 371 frame_duration_ms, sigma_ms); | 375 frame_duration_ms, sigma_ms); |
| 372 EXPECT_EQ(1, unique_overuse); | 376 EXPECT_EQ(1, unique_overuse); |
| 373 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 377 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, |
| 374 frame_duration_ms, sigma_ms, drift_per_frame_ms); | 378 frame_duration_ms, sigma_ms, drift_per_frame_ms); |
| 375 EXPECT_EQ(4, frames_until_overuse); | 379 EXPECT_EQ(4, frames_until_overuse); |
| 376 } | 380 } |
| 377 | 381 |
| 378 TEST_F(OveruseDetectorTest, | 382 #if defined(WEBRTC_ANDROID) |
| 379 DISABLED_ON_ANDROID(LowGaussianVariance100Kbit5fps)) { | 383 #define MAYBE_LowGaussianVariance100Kbit5fps \ |
| 384 DISABLED_LowGaussianVariance100Kbit5fps |
| 385 #else |
| 386 #define MAYBE_LowGaussianVariance100Kbit5fps LowGaussianVariance100Kbit5fps |
| 387 #endif |
| 388 TEST_F(OveruseDetectorTest, MAYBE_LowGaussianVariance100Kbit5fps) { |
| 380 size_t packet_size = 1200; | 389 size_t packet_size = 1200; |
| 381 int packets_per_frame = 2; | 390 int packets_per_frame = 2; |
| 382 int frame_duration_ms = 200; | 391 int frame_duration_ms = 200; |
| 383 int drift_per_frame_ms = 1; | 392 int drift_per_frame_ms = 1; |
| 384 int sigma_ms = 3; | 393 int sigma_ms = 3; |
| 385 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 394 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, |
| 386 frame_duration_ms, sigma_ms); | 395 frame_duration_ms, sigma_ms); |
| 387 EXPECT_EQ(0, unique_overuse); | 396 EXPECT_EQ(0, unique_overuse); |
| 388 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 397 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, |
| 389 frame_duration_ms, sigma_ms, drift_per_frame_ms); | 398 frame_duration_ms, sigma_ms, drift_per_frame_ms); |
| 390 EXPECT_EQ(13, frames_until_overuse); | 399 EXPECT_EQ(13, frames_until_overuse); |
| 391 } | 400 } |
| 392 | 401 |
| 393 TEST_F(OveruseDetectorTest, | 402 #if defined(WEBRTC_ANDROID) |
| 394 DISABLED_ON_ANDROID(HighGaussianVariance100Kbit5fps)) { | 403 #define MAYBE_HighGaussianVariance100Kbit5fps \ |
| 404 DISABLED_HighGaussianVariance100Kbit5fps |
| 405 #else |
| 406 #define MAYBE_HighGaussianVariance100Kbit5fps HighGaussianVariance100Kbit5fps |
| 407 #endif |
| 408 TEST_F(OveruseDetectorTest, MAYBE_HighGaussianVariance100Kbit5fps) { |
| 395 size_t packet_size = 1200; | 409 size_t packet_size = 1200; |
| 396 int packets_per_frame = 2; | 410 int packets_per_frame = 2; |
| 397 int frame_duration_ms = 200; | 411 int frame_duration_ms = 200; |
| 398 int drift_per_frame_ms = 1; | 412 int drift_per_frame_ms = 1; |
| 399 int sigma_ms = 10; | 413 int sigma_ms = 10; |
| 400 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 414 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, |
| 401 frame_duration_ms, sigma_ms); | 415 frame_duration_ms, sigma_ms); |
| 402 EXPECT_EQ(1, unique_overuse); | 416 EXPECT_EQ(1, unique_overuse); |
| 403 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 417 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, |
| 404 frame_duration_ms, sigma_ms, drift_per_frame_ms); | 418 frame_duration_ms, sigma_ms, drift_per_frame_ms); |
| 405 EXPECT_EQ(32, frames_until_overuse); | 419 EXPECT_EQ(32, frames_until_overuse); |
| 406 } | 420 } |
| 407 | 421 |
| 408 TEST_F(OveruseDetectorTest, | 422 #if defined(WEBRTC_ANDROID) |
| 409 DISABLED_ON_ANDROID(LowGaussianVariance100Kbit10fps)) { | 423 #define MAYBE_LowGaussianVariance100Kbit10fps \ |
| 424 DISABLED_LowGaussianVariance100Kbit10fps |
| 425 #else |
| 426 #define MAYBE_LowGaussianVariance100Kbit10fps LowGaussianVariance100Kbit10fps |
| 427 #endif |
| 428 TEST_F(OveruseDetectorTest, MAYBE_LowGaussianVariance100Kbit10fps) { |
| 410 size_t packet_size = 1200; | 429 size_t packet_size = 1200; |
| 411 int packets_per_frame = 1; | 430 int packets_per_frame = 1; |
| 412 int frame_duration_ms = 100; | 431 int frame_duration_ms = 100; |
| 413 int drift_per_frame_ms = 1; | 432 int drift_per_frame_ms = 1; |
| 414 int sigma_ms = 3; | 433 int sigma_ms = 3; |
| 415 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 434 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, |
| 416 frame_duration_ms, sigma_ms); | 435 frame_duration_ms, sigma_ms); |
| 417 EXPECT_EQ(1, unique_overuse); | 436 EXPECT_EQ(1, unique_overuse); |
| 418 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 437 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, |
| 419 frame_duration_ms, sigma_ms, drift_per_frame_ms); | 438 frame_duration_ms, sigma_ms, drift_per_frame_ms); |
| 420 EXPECT_EQ(13, frames_until_overuse); | 439 EXPECT_EQ(13, frames_until_overuse); |
| 421 } | 440 } |
| 422 | 441 |
| 423 TEST_F(OveruseDetectorTest, | 442 #if defined(WEBRTC_ANDROID) |
| 424 DISABLED_ON_ANDROID(HighGaussianVariance100Kbit10fps)) { | 443 #define MAYBE_HighGaussianVariance100Kbit10fps \ |
| 444 DISABLED_HighGaussianVariance100Kbit10fps |
| 445 #else |
| 446 #define MAYBE_HighGaussianVariance100Kbit10fps HighGaussianVariance100Kbit10fps |
| 447 #endif |
| 448 TEST_F(OveruseDetectorTest, MAYBE_HighGaussianVariance100Kbit10fps) { |
| 425 size_t packet_size = 1200; | 449 size_t packet_size = 1200; |
| 426 int packets_per_frame = 1; | 450 int packets_per_frame = 1; |
| 427 int frame_duration_ms = 100; | 451 int frame_duration_ms = 100; |
| 428 int drift_per_frame_ms = 1; | 452 int drift_per_frame_ms = 1; |
| 429 int sigma_ms = 10; | 453 int sigma_ms = 10; |
| 430 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 454 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, |
| 431 frame_duration_ms, sigma_ms); | 455 frame_duration_ms, sigma_ms); |
| 432 EXPECT_EQ(0, unique_overuse); | 456 EXPECT_EQ(0, unique_overuse); |
| 433 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 457 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, |
| 434 frame_duration_ms, sigma_ms, drift_per_frame_ms); | 458 frame_duration_ms, sigma_ms, drift_per_frame_ms); |
| 435 EXPECT_EQ(32, frames_until_overuse); | 459 EXPECT_EQ(32, frames_until_overuse); |
| 436 } | 460 } |
| 437 | 461 |
| 438 TEST_F(OveruseDetectorTest, | 462 #if defined(WEBRTC_ANDROID) |
| 439 DISABLED_ON_ANDROID(LowGaussianVariance300Kbit30fps)) { | 463 #define MAYBE_LowGaussianVariance300Kbit30fps \ |
| 464 DISABLED_LowGaussianVariance300Kbit30fps |
| 465 #else |
| 466 #define MAYBE_LowGaussianVariance300Kbit30fps LowGaussianVariance300Kbit30fps |
| 467 #endif |
| 468 TEST_F(OveruseDetectorTest, MAYBE_LowGaussianVariance300Kbit30fps) { |
| 440 size_t packet_size = 1200; | 469 size_t packet_size = 1200; |
| 441 int packets_per_frame = 1; | 470 int packets_per_frame = 1; |
| 442 int frame_duration_ms = 33; | 471 int frame_duration_ms = 33; |
| 443 int drift_per_frame_ms = 1; | 472 int drift_per_frame_ms = 1; |
| 444 int sigma_ms = 3; | 473 int sigma_ms = 3; |
| 445 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 474 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, |
| 446 frame_duration_ms, sigma_ms); | 475 frame_duration_ms, sigma_ms); |
| 447 EXPECT_EQ(0, unique_overuse); | 476 EXPECT_EQ(0, unique_overuse); |
| 448 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 477 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, |
| 449 frame_duration_ms, sigma_ms, drift_per_frame_ms); | 478 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; | 514 int drift_per_frame_ms = 10; |
| 486 int sigma_ms = 10; | 515 int sigma_ms = 10; |
| 487 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 516 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, |
| 488 frame_duration_ms, sigma_ms); | 517 frame_duration_ms, sigma_ms); |
| 489 EXPECT_EQ(0, unique_overuse); | 518 EXPECT_EQ(0, unique_overuse); |
| 490 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 519 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, |
| 491 frame_duration_ms, sigma_ms, drift_per_frame_ms); | 520 frame_duration_ms, sigma_ms, drift_per_frame_ms); |
| 492 EXPECT_EQ(10, frames_until_overuse); | 521 EXPECT_EQ(10, frames_until_overuse); |
| 493 } | 522 } |
| 494 | 523 |
| 495 TEST_F(OveruseDetectorTest, | 524 #if defined(WEBRTC_ANDROID) |
| 496 DISABLED_ON_ANDROID(LowGaussianVariance1000Kbit30fps)) { | 525 #define MAYBE_LowGaussianVariance1000Kbit30fps \ |
| 526 DISABLED_LowGaussianVariance1000Kbit30fps |
| 527 #else |
| 528 #define MAYBE_LowGaussianVariance1000Kbit30fps LowGaussianVariance1000Kbit30fps |
| 529 #endif |
| 530 TEST_F(OveruseDetectorTest, MAYBE_LowGaussianVariance1000Kbit30fps) { |
| 497 size_t packet_size = 1200; | 531 size_t packet_size = 1200; |
| 498 int packets_per_frame = 3; | 532 int packets_per_frame = 3; |
| 499 int frame_duration_ms = 33; | 533 int frame_duration_ms = 33; |
| 500 int drift_per_frame_ms = 1; | 534 int drift_per_frame_ms = 1; |
| 501 int sigma_ms = 3; | 535 int sigma_ms = 3; |
| 502 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 536 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, |
| 503 frame_duration_ms, sigma_ms); | 537 frame_duration_ms, sigma_ms); |
| 504 EXPECT_EQ(0, unique_overuse); | 538 EXPECT_EQ(0, unique_overuse); |
| 505 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 539 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, |
| 506 frame_duration_ms, sigma_ms, drift_per_frame_ms); | 540 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; | 576 int drift_per_frame_ms = 10; |
| 543 int sigma_ms = 10; | 577 int sigma_ms = 10; |
| 544 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 578 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, |
| 545 frame_duration_ms, sigma_ms); | 579 frame_duration_ms, sigma_ms); |
| 546 EXPECT_EQ(0, unique_overuse); | 580 EXPECT_EQ(0, unique_overuse); |
| 547 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 581 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, |
| 548 frame_duration_ms, sigma_ms, drift_per_frame_ms); | 582 frame_duration_ms, sigma_ms, drift_per_frame_ms); |
| 549 EXPECT_EQ(10, frames_until_overuse); | 583 EXPECT_EQ(10, frames_until_overuse); |
| 550 } | 584 } |
| 551 | 585 |
| 552 TEST_F(OveruseDetectorTest, | 586 #if defined(WEBRTC_ANDROID) |
| 553 DISABLED_ON_ANDROID(LowGaussianVariance2000Kbit30fps)) { | 587 #define MAYBE_LowGaussianVariance2000Kbit30fps \ |
| 588 DISABLED_LowGaussianVariance2000Kbit30fps |
| 589 #else |
| 590 #define MAYBE_LowGaussianVariance2000Kbit30fps LowGaussianVariance2000Kbit30fps |
| 591 #endif |
| 592 TEST_F(OveruseDetectorTest, MAYBE_LowGaussianVariance2000Kbit30fps) { |
| 554 size_t packet_size = 1200; | 593 size_t packet_size = 1200; |
| 555 int packets_per_frame = 6; | 594 int packets_per_frame = 6; |
| 556 int frame_duration_ms = 33; | 595 int frame_duration_ms = 33; |
| 557 int drift_per_frame_ms = 1; | 596 int drift_per_frame_ms = 1; |
| 558 int sigma_ms = 3; | 597 int sigma_ms = 3; |
| 559 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, | 598 int unique_overuse = Run100000Samples(packets_per_frame, packet_size, |
| 560 frame_duration_ms, sigma_ms); | 599 frame_duration_ms, sigma_ms); |
| 561 EXPECT_EQ(0, unique_overuse); | 600 EXPECT_EQ(0, unique_overuse); |
| 562 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, | 601 int frames_until_overuse = RunUntilOveruse(packets_per_frame, packet_size, |
| 563 frame_duration_ms, sigma_ms, drift_per_frame_ms); | 602 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) { | 774 if (overuse_state == kBwOverusing) { |
| 736 overuse_detected = true; | 775 overuse_detected = true; |
| 737 } | 776 } |
| 738 ++num_deltas; | 777 ++num_deltas; |
| 739 now_ms += 5; | 778 now_ms += 5; |
| 740 } | 779 } |
| 741 EXPECT_TRUE(overuse_detected); | 780 EXPECT_TRUE(overuse_detected); |
| 742 } | 781 } |
| 743 } // namespace testing | 782 } // namespace testing |
| 744 } // namespace webrtc | 783 } // namespace webrtc |
| OLD | NEW |