OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 #include <algorithm> | 10 #include <algorithm> |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 TestAudioVideoSync(true, false); | 377 TestAudioVideoSync(true, false); |
378 } | 378 } |
379 | 379 |
380 void CallPerfTest::TestCaptureNtpTime(const FakeNetworkPipe::Config& net_config, | 380 void CallPerfTest::TestCaptureNtpTime(const FakeNetworkPipe::Config& net_config, |
381 int threshold_ms, | 381 int threshold_ms, |
382 int start_time_ms, | 382 int start_time_ms, |
383 int run_time_ms) { | 383 int run_time_ms) { |
384 class CaptureNtpTimeObserver : public test::EndToEndTest, | 384 class CaptureNtpTimeObserver : public test::EndToEndTest, |
385 public VideoRenderer { | 385 public VideoRenderer { |
386 public: | 386 public: |
387 CaptureNtpTimeObserver(int threshold_ms, int start_time_ms, int run_time_ms) | 387 CaptureNtpTimeObserver(const FakeNetworkPipe::Config& net_config, |
| 388 int threshold_ms, |
| 389 int start_time_ms, |
| 390 int run_time_ms) |
388 : EndToEndTest(kLongTimeoutMs), | 391 : EndToEndTest(kLongTimeoutMs), |
| 392 net_config_(net_config), |
389 clock_(Clock::GetRealTimeClock()), | 393 clock_(Clock::GetRealTimeClock()), |
390 threshold_ms_(threshold_ms), | 394 threshold_ms_(threshold_ms), |
391 start_time_ms_(start_time_ms), | 395 start_time_ms_(start_time_ms), |
392 run_time_ms_(run_time_ms), | 396 run_time_ms_(run_time_ms), |
393 creation_time_ms_(clock_->TimeInMilliseconds()), | 397 creation_time_ms_(clock_->TimeInMilliseconds()), |
394 capturer_(nullptr), | 398 capturer_(nullptr), |
395 rtp_start_timestamp_set_(false), | 399 rtp_start_timestamp_set_(false), |
396 rtp_start_timestamp_(0) {} | 400 rtp_start_timestamp_(0) {} |
397 | 401 |
398 private: | 402 private: |
| 403 test::PacketTransport* CreateSendTransport(Call* sender_call) override { |
| 404 return new test::PacketTransport( |
| 405 sender_call, this, test::PacketTransport::kSender, net_config_); |
| 406 } |
| 407 |
399 void RenderFrame(const VideoFrame& video_frame, | 408 void RenderFrame(const VideoFrame& video_frame, |
400 int time_to_render_ms) override { | 409 int time_to_render_ms) override { |
401 rtc::CritScope lock(&crit_); | 410 rtc::CritScope lock(&crit_); |
402 if (video_frame.ntp_time_ms() <= 0) { | 411 if (video_frame.ntp_time_ms() <= 0) { |
403 // Haven't got enough RTCP SR in order to calculate the capture ntp | 412 // Haven't got enough RTCP SR in order to calculate the capture ntp |
404 // time. | 413 // time. |
405 return; | 414 return; |
406 } | 415 } |
407 | 416 |
408 int64_t now_ms = clock_->TimeInMilliseconds(); | 417 int64_t now_ms = clock_->TimeInMilliseconds(); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 (*receive_configs)[0].rtp.rtcp_xr.receiver_reference_time_report = true; | 482 (*receive_configs)[0].rtp.rtcp_xr.receiver_reference_time_report = true; |
474 } | 483 } |
475 | 484 |
476 void PerformTest() override { | 485 void PerformTest() override { |
477 EXPECT_TRUE(Wait()) << "Timed out while waiting for " | 486 EXPECT_TRUE(Wait()) << "Timed out while waiting for " |
478 "estimated capture NTP time to be " | 487 "estimated capture NTP time to be " |
479 "within bounds."; | 488 "within bounds."; |
480 } | 489 } |
481 | 490 |
482 rtc::CriticalSection crit_; | 491 rtc::CriticalSection crit_; |
| 492 const FakeNetworkPipe::Config net_config_; |
483 Clock* const clock_; | 493 Clock* const clock_; |
484 int threshold_ms_; | 494 int threshold_ms_; |
485 int start_time_ms_; | 495 int start_time_ms_; |
486 int run_time_ms_; | 496 int run_time_ms_; |
487 int64_t creation_time_ms_; | 497 int64_t creation_time_ms_; |
488 test::FrameGeneratorCapturer* capturer_; | 498 test::FrameGeneratorCapturer* capturer_; |
489 bool rtp_start_timestamp_set_; | 499 bool rtp_start_timestamp_set_; |
490 uint32_t rtp_start_timestamp_; | 500 uint32_t rtp_start_timestamp_; |
491 typedef std::map<uint32_t, uint32_t> FrameCaptureTimeList; | 501 typedef std::map<uint32_t, uint32_t> FrameCaptureTimeList; |
492 FrameCaptureTimeList capture_time_list_ GUARDED_BY(&crit_); | 502 FrameCaptureTimeList capture_time_list_ GUARDED_BY(&crit_); |
493 } test(threshold_ms, start_time_ms, run_time_ms); | 503 } test(net_config, threshold_ms, start_time_ms, run_time_ms); |
494 | 504 |
495 RunBaseTest(&test, net_config); | 505 RunBaseTest(&test); |
496 } | 506 } |
497 | 507 |
498 TEST_F(CallPerfTest, CaptureNtpTimeWithNetworkDelay) { | 508 TEST_F(CallPerfTest, CaptureNtpTimeWithNetworkDelay) { |
499 FakeNetworkPipe::Config net_config; | 509 FakeNetworkPipe::Config net_config; |
500 net_config.queue_delay_ms = 100; | 510 net_config.queue_delay_ms = 100; |
501 // TODO(wu): lower the threshold as the calculation/estimatation becomes more | 511 // TODO(wu): lower the threshold as the calculation/estimatation becomes more |
502 // accurate. | 512 // accurate. |
503 const int kThresholdMs = 100; | 513 const int kThresholdMs = 100; |
504 const int kStartTimeMs = 10000; | 514 const int kStartTimeMs = 10000; |
505 const int kRunTimeMs = 20000; | 515 const int kRunTimeMs = 20000; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 } | 551 } |
542 | 552 |
543 void PerformTest() override { | 553 void PerformTest() override { |
544 EXPECT_TRUE(Wait()) << "Timed out before receiving an overuse callback."; | 554 EXPECT_TRUE(Wait()) << "Timed out before receiving an overuse callback."; |
545 } | 555 } |
546 | 556 |
547 LoadObserver::Load tested_load_; | 557 LoadObserver::Load tested_load_; |
548 test::DelayedEncoder encoder_; | 558 test::DelayedEncoder encoder_; |
549 } test(tested_load, encode_delay_ms); | 559 } test(tested_load, encode_delay_ms); |
550 | 560 |
551 RunBaseTest(&test, FakeNetworkPipe::Config()); | 561 RunBaseTest(&test); |
552 } | 562 } |
553 | 563 |
554 TEST_F(CallPerfTest, ReceivesCpuUnderuse) { | 564 TEST_F(CallPerfTest, ReceivesCpuUnderuse) { |
555 const int kEncodeDelayMs = 2; | 565 const int kEncodeDelayMs = 2; |
556 TestCpuOveruse(LoadObserver::kUnderuse, kEncodeDelayMs); | 566 TestCpuOveruse(LoadObserver::kUnderuse, kEncodeDelayMs); |
557 } | 567 } |
558 | 568 |
559 TEST_F(CallPerfTest, ReceivesCpuOveruse) { | 569 TEST_F(CallPerfTest, ReceivesCpuOveruse) { |
560 const int kEncodeDelayMs = 35; | 570 const int kEncodeDelayMs = 35; |
561 TestCpuOveruse(LoadObserver::kOveruse, kEncodeDelayMs); | 571 TestCpuOveruse(LoadObserver::kOveruse, kEncodeDelayMs); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 void PerformTest() override { | 645 void PerformTest() override { |
636 EXPECT_TRUE(Wait()) << "Timeout while waiting for send-bitrate stats."; | 646 EXPECT_TRUE(Wait()) << "Timeout while waiting for send-bitrate stats."; |
637 } | 647 } |
638 | 648 |
639 VideoSendStream* send_stream_; | 649 VideoSendStream* send_stream_; |
640 const bool pad_to_min_bitrate_; | 650 const bool pad_to_min_bitrate_; |
641 int num_bitrate_observations_in_range_; | 651 int num_bitrate_observations_in_range_; |
642 } test(pad_to_min_bitrate); | 652 } test(pad_to_min_bitrate); |
643 | 653 |
644 fake_encoder_.SetMaxBitrate(kMaxEncodeBitrateKbps); | 654 fake_encoder_.SetMaxBitrate(kMaxEncodeBitrateKbps); |
645 RunBaseTest(&test, FakeNetworkPipe::Config()); | 655 RunBaseTest(&test); |
646 } | 656 } |
647 | 657 |
648 TEST_F(CallPerfTest, PadsToMinTransmitBitrate) { TestMinTransmitBitrate(true); } | 658 TEST_F(CallPerfTest, PadsToMinTransmitBitrate) { TestMinTransmitBitrate(true); } |
649 | 659 |
650 TEST_F(CallPerfTest, NoPadWithoutMinTransmitBitrate) { | 660 TEST_F(CallPerfTest, NoPadWithoutMinTransmitBitrate) { |
651 TestMinTransmitBitrate(false); | 661 TestMinTransmitBitrate(false); |
652 } | 662 } |
653 | 663 |
654 TEST_F(CallPerfTest, KeepsHighBitrateWhenReconfiguringSender) { | 664 TEST_F(CallPerfTest, KeepsHighBitrateWhenReconfiguringSender) { |
655 static const uint32_t kInitialBitrateKbps = 400; | 665 static const uint32_t kInitialBitrateKbps = 400; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 } | 741 } |
732 | 742 |
733 private: | 743 private: |
734 rtc::Event time_to_reconfigure_; | 744 rtc::Event time_to_reconfigure_; |
735 int encoder_inits_; | 745 int encoder_inits_; |
736 uint32_t last_set_bitrate_; | 746 uint32_t last_set_bitrate_; |
737 VideoSendStream* send_stream_; | 747 VideoSendStream* send_stream_; |
738 VideoEncoderConfig encoder_config_; | 748 VideoEncoderConfig encoder_config_; |
739 } test; | 749 } test; |
740 | 750 |
741 RunBaseTest(&test, FakeNetworkPipe::Config()); | 751 RunBaseTest(&test); |
742 } | 752 } |
743 | 753 |
744 } // namespace webrtc | 754 } // namespace webrtc |
OLD | NEW |