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

Side by Side Diff: webrtc/call/call_perf_tests.cc

Issue 1487893004: Replace EventWrapper in video/, test/ and call/. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years 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) 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 if (first_time_in_sync_ == -1) { 165 if (first_time_in_sync_ == -1) {
166 first_time_in_sync_ = now_ms; 166 first_time_in_sync_ = now_ms;
167 webrtc::test::PrintResult("sync_convergence_time", 167 webrtc::test::PrintResult("sync_convergence_time",
168 "", 168 "",
169 "synchronization", 169 "synchronization",
170 time_since_creation, 170 time_since_creation,
171 "ms", 171 "ms",
172 false); 172 false);
173 } 173 }
174 if (time_since_creation > kMinRunTimeMs) 174 if (time_since_creation > kMinRunTimeMs)
175 observation_complete_->Set(); 175 observation_complete_.Set();
176 } 176 }
177 } 177 }
178 178
179 bool IsTextureSupported() const override { return false; } 179 bool IsTextureSupported() const override { return false; }
180 180
181 private: 181 private:
182 Clock* const clock_; 182 Clock* const clock_;
183 const int voe_channel_; 183 const int voe_channel_;
184 VoEVideoSync* const voe_sync_; 184 VoEVideoSync* const voe_sync_;
185 SyncRtcpObserver* const audio_observer_; 185 SyncRtcpObserver* const audio_observer_;
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 304
305 CreateFrameGeneratorCapturer(); 305 CreateFrameGeneratorCapturer();
306 306
307 Start(); 307 Start();
308 308
309 fake_audio_device.Start(); 309 fake_audio_device.Start();
310 EXPECT_EQ(0, voe_base->StartPlayout(channel)); 310 EXPECT_EQ(0, voe_base->StartPlayout(channel));
311 EXPECT_EQ(0, voe_base->StartReceive(channel)); 311 EXPECT_EQ(0, voe_base->StartReceive(channel));
312 EXPECT_EQ(0, voe_base->StartSend(channel)); 312 EXPECT_EQ(0, voe_base->StartSend(channel));
313 313
314 EXPECT_EQ(kEventSignaled, observer.Wait()) 314 EXPECT_TRUE(observer.Wait())
315 << "Timed out while waiting for audio and video to be synchronized."; 315 << "Timed out while waiting for audio and video to be synchronized.";
316 316
317 EXPECT_EQ(0, voe_base->StopSend(channel)); 317 EXPECT_EQ(0, voe_base->StopSend(channel));
318 EXPECT_EQ(0, voe_base->StopReceive(channel)); 318 EXPECT_EQ(0, voe_base->StopReceive(channel));
319 EXPECT_EQ(0, voe_base->StopPlayout(channel)); 319 EXPECT_EQ(0, voe_base->StopPlayout(channel));
320 fake_audio_device.Stop(); 320 fake_audio_device.Stop();
321 321
322 Stop(); 322 Stop();
323 sync_send_transport.StopSending(); 323 sync_send_transport.StopSending();
324 sync_receive_transport.StopSending(); 324 sync_receive_transport.StopSending();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 } 381 }
382 382
383 int64_t now_ms = clock_->TimeInMilliseconds(); 383 int64_t now_ms = clock_->TimeInMilliseconds();
384 int64_t time_since_creation = now_ms - creation_time_ms_; 384 int64_t time_since_creation = now_ms - creation_time_ms_;
385 if (time_since_creation < start_time_ms_) { 385 if (time_since_creation < start_time_ms_) {
386 // Wait for |start_time_ms_| before start measuring. 386 // Wait for |start_time_ms_| before start measuring.
387 return; 387 return;
388 } 388 }
389 389
390 if (time_since_creation > run_time_ms_) { 390 if (time_since_creation > run_time_ms_) {
391 observation_complete_->Set(); 391 observation_complete_.Set();
392 } 392 }
393 393
394 FrameCaptureTimeList::iterator iter = 394 FrameCaptureTimeList::iterator iter =
395 capture_time_list_.find(video_frame.timestamp()); 395 capture_time_list_.find(video_frame.timestamp());
396 EXPECT_TRUE(iter != capture_time_list_.end()); 396 EXPECT_TRUE(iter != capture_time_list_.end());
397 397
398 // The real capture time has been wrapped to uint32_t before converted 398 // The real capture time has been wrapped to uint32_t before converted
399 // to rtp timestamp in the sender side. So here we convert the estimated 399 // to rtp timestamp in the sender side. So here we convert the estimated
400 // capture time to a uint32_t 90k timestamp also for comparing. 400 // capture time to a uint32_t 90k timestamp also for comparing.
401 uint32_t estimated_capture_timestamp = 401 uint32_t estimated_capture_timestamp =
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 441
442 void ModifyConfigs(VideoSendStream::Config* send_config, 442 void ModifyConfigs(VideoSendStream::Config* send_config,
443 std::vector<VideoReceiveStream::Config>* receive_configs, 443 std::vector<VideoReceiveStream::Config>* receive_configs,
444 VideoEncoderConfig* encoder_config) override { 444 VideoEncoderConfig* encoder_config) override {
445 (*receive_configs)[0].renderer = this; 445 (*receive_configs)[0].renderer = this;
446 // Enable the receiver side rtt calculation. 446 // Enable the receiver side rtt calculation.
447 (*receive_configs)[0].rtp.rtcp_xr.receiver_reference_time_report = true; 447 (*receive_configs)[0].rtp.rtcp_xr.receiver_reference_time_report = true;
448 } 448 }
449 449
450 void PerformTest() override { 450 void PerformTest() override {
451 EXPECT_EQ(kEventSignaled, Wait()) << "Timed out while waiting for " 451 EXPECT_TRUE(Wait()) << "Timed out while waiting for "
452 "estimated capture NTP time to be " 452 "estimated capture NTP time to be "
453 "within bounds."; 453 "within bounds.";
454 } 454 }
455 455
456 rtc::CriticalSection crit_; 456 rtc::CriticalSection crit_;
457 Clock* const clock_; 457 Clock* const clock_;
458 int threshold_ms_; 458 int threshold_ms_;
459 int start_time_ms_; 459 int start_time_ms_;
460 int run_time_ms_; 460 int run_time_ms_;
461 int64_t creation_time_ms_; 461 int64_t creation_time_ms_;
462 test::FrameGeneratorCapturer* capturer_; 462 test::FrameGeneratorCapturer* capturer_;
463 bool rtp_start_timestamp_set_; 463 bool rtp_start_timestamp_set_;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 int encode_delay_ms) { 496 int encode_delay_ms) {
497 class LoadObserver : public test::SendTest, public webrtc::LoadObserver { 497 class LoadObserver : public test::SendTest, public webrtc::LoadObserver {
498 public: 498 public:
499 LoadObserver(LoadObserver::Load tested_load, int encode_delay_ms) 499 LoadObserver(LoadObserver::Load tested_load, int encode_delay_ms)
500 : SendTest(kLongTimeoutMs), 500 : SendTest(kLongTimeoutMs),
501 tested_load_(tested_load), 501 tested_load_(tested_load),
502 encoder_(Clock::GetRealTimeClock(), encode_delay_ms) {} 502 encoder_(Clock::GetRealTimeClock(), encode_delay_ms) {}
503 503
504 void OnLoadUpdate(Load load) override { 504 void OnLoadUpdate(Load load) override {
505 if (load == tested_load_) 505 if (load == tested_load_)
506 observation_complete_->Set(); 506 observation_complete_.Set();
507 } 507 }
508 508
509 void ModifyConfigs(VideoSendStream::Config* send_config, 509 void ModifyConfigs(VideoSendStream::Config* send_config,
510 std::vector<VideoReceiveStream::Config>* receive_configs, 510 std::vector<VideoReceiveStream::Config>* receive_configs,
511 VideoEncoderConfig* encoder_config) override { 511 VideoEncoderConfig* encoder_config) override {
512 send_config->overuse_callback = this; 512 send_config->overuse_callback = this;
513 send_config->encoder_settings.encoder = &encoder_; 513 send_config->encoder_settings.encoder = &encoder_;
514 } 514 }
515 515
516 void PerformTest() override { 516 void PerformTest() override {
517 EXPECT_EQ(kEventSignaled, Wait()) 517 EXPECT_TRUE(Wait()) << "Timed out before receiving an overuse callback.";
518 << "Timed out before receiving an overuse callback.";
519 } 518 }
520 519
521 LoadObserver::Load tested_load_; 520 LoadObserver::Load tested_load_;
522 test::DelayedEncoder encoder_; 521 test::DelayedEncoder encoder_;
523 } test(tested_load, encode_delay_ms); 522 } test(tested_load, encode_delay_ms);
524 523
525 RunBaseTest(&test, FakeNetworkPipe::Config()); 524 RunBaseTest(&test, FakeNetworkPipe::Config());
526 } 525 }
527 526
528 TEST_F(CallPerfTest, ReceivesCpuUnderuse) { 527 TEST_F(CallPerfTest, ReceivesCpuUnderuse) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 // Expect bitrate stats to roughly match the max encode bitrate. 575 // Expect bitrate stats to roughly match the max encode bitrate.
577 if (bitrate_kbps > (kMaxEncodeBitrateKbps - 576 if (bitrate_kbps > (kMaxEncodeBitrateKbps -
578 kAcceptableBitrateErrorMargin / 2) && 577 kAcceptableBitrateErrorMargin / 2) &&
579 bitrate_kbps < (kMaxEncodeBitrateKbps + 578 bitrate_kbps < (kMaxEncodeBitrateKbps +
580 kAcceptableBitrateErrorMargin / 2)) { 579 kAcceptableBitrateErrorMargin / 2)) {
581 ++num_bitrate_observations_in_range_; 580 ++num_bitrate_observations_in_range_;
582 } 581 }
583 } 582 }
584 if (num_bitrate_observations_in_range_ == 583 if (num_bitrate_observations_in_range_ ==
585 kNumBitrateObservationsInRange) 584 kNumBitrateObservationsInRange)
586 observation_complete_->Set(); 585 observation_complete_.Set();
587 } 586 }
588 } 587 }
589 return SEND_PACKET; 588 return SEND_PACKET;
590 } 589 }
591 590
592 void OnStreamsCreated( 591 void OnStreamsCreated(
593 VideoSendStream* send_stream, 592 VideoSendStream* send_stream,
594 const std::vector<VideoReceiveStream*>& receive_streams) override { 593 const std::vector<VideoReceiveStream*>& receive_streams) override {
595 send_stream_ = send_stream; 594 send_stream_ = send_stream;
596 } 595 }
597 596
598 void ModifyConfigs(VideoSendStream::Config* send_config, 597 void ModifyConfigs(VideoSendStream::Config* send_config,
599 std::vector<VideoReceiveStream::Config>* receive_configs, 598 std::vector<VideoReceiveStream::Config>* receive_configs,
600 VideoEncoderConfig* encoder_config) override { 599 VideoEncoderConfig* encoder_config) override {
601 if (pad_to_min_bitrate_) { 600 if (pad_to_min_bitrate_) {
602 encoder_config->min_transmit_bitrate_bps = kMinTransmitBitrateBps; 601 encoder_config->min_transmit_bitrate_bps = kMinTransmitBitrateBps;
603 } else { 602 } else {
604 RTC_DCHECK_EQ(0, encoder_config->min_transmit_bitrate_bps); 603 RTC_DCHECK_EQ(0, encoder_config->min_transmit_bitrate_bps);
605 } 604 }
606 } 605 }
607 606
608 void PerformTest() override { 607 void PerformTest() override {
609 EXPECT_EQ(kEventSignaled, Wait()) 608 EXPECT_TRUE(Wait()) << "Timeout while waiting for send-bitrate stats.";
610 << "Timeout while waiting for send-bitrate stats.";
611 } 609 }
612 610
613 VideoSendStream* send_stream_; 611 VideoSendStream* send_stream_;
614 const bool pad_to_min_bitrate_; 612 const bool pad_to_min_bitrate_;
615 int num_bitrate_observations_in_range_; 613 int num_bitrate_observations_in_range_;
616 } test(pad_to_min_bitrate); 614 } test(pad_to_min_bitrate);
617 615
618 fake_encoder_.SetMaxBitrate(kMaxEncodeBitrateKbps); 616 fake_encoder_.SetMaxBitrate(kMaxEncodeBitrateKbps);
619 RunBaseTest(&test, FakeNetworkPipe::Config()); 617 RunBaseTest(&test, FakeNetworkPipe::Config());
620 } 618 }
621 619
622 TEST_F(CallPerfTest, PadsToMinTransmitBitrate) { TestMinTransmitBitrate(true); } 620 TEST_F(CallPerfTest, PadsToMinTransmitBitrate) { TestMinTransmitBitrate(true); }
623 621
624 TEST_F(CallPerfTest, NoPadWithoutMinTransmitBitrate) { 622 TEST_F(CallPerfTest, NoPadWithoutMinTransmitBitrate) {
625 TestMinTransmitBitrate(false); 623 TestMinTransmitBitrate(false);
626 } 624 }
627 625
628 TEST_F(CallPerfTest, KeepsHighBitrateWhenReconfiguringSender) { 626 TEST_F(CallPerfTest, KeepsHighBitrateWhenReconfiguringSender) {
629 static const uint32_t kInitialBitrateKbps = 400; 627 static const uint32_t kInitialBitrateKbps = 400;
630 static const uint32_t kReconfigureThresholdKbps = 600; 628 static const uint32_t kReconfigureThresholdKbps = 600;
631 static const uint32_t kPermittedReconfiguredBitrateDiffKbps = 100; 629 static const uint32_t kPermittedReconfiguredBitrateDiffKbps = 100;
632 630
633 class BitrateObserver : public test::EndToEndTest, public test::FakeEncoder { 631 class BitrateObserver : public test::EndToEndTest, public test::FakeEncoder {
634 public: 632 public:
635 BitrateObserver() 633 BitrateObserver()
636 : EndToEndTest(kDefaultTimeoutMs), 634 : EndToEndTest(kDefaultTimeoutMs),
637 FakeEncoder(Clock::GetRealTimeClock()), 635 FakeEncoder(Clock::GetRealTimeClock()),
638 time_to_reconfigure_(webrtc::EventWrapper::Create()), 636 time_to_reconfigure_(false, false),
639 encoder_inits_(0), 637 encoder_inits_(0),
640 last_set_bitrate_(0), 638 last_set_bitrate_(0),
641 send_stream_(nullptr) {} 639 send_stream_(nullptr) {}
642 640
643 int32_t InitEncode(const VideoCodec* config, 641 int32_t InitEncode(const VideoCodec* config,
644 int32_t number_of_cores, 642 int32_t number_of_cores,
645 size_t max_payload_size) override { 643 size_t max_payload_size) override {
646 if (encoder_inits_ == 0) { 644 if (encoder_inits_ == 0) {
647 EXPECT_EQ(kInitialBitrateKbps, config->startBitrate) 645 EXPECT_EQ(kInitialBitrateKbps, config->startBitrate)
648 << "Encoder not initialized at expected bitrate."; 646 << "Encoder not initialized at expected bitrate.";
649 } 647 }
650 ++encoder_inits_; 648 ++encoder_inits_;
651 if (encoder_inits_ == 2) { 649 if (encoder_inits_ == 2) {
652 EXPECT_GE(last_set_bitrate_, kReconfigureThresholdKbps); 650 EXPECT_GE(last_set_bitrate_, kReconfigureThresholdKbps);
653 EXPECT_NEAR(config->startBitrate, 651 EXPECT_NEAR(config->startBitrate,
654 last_set_bitrate_, 652 last_set_bitrate_,
655 kPermittedReconfiguredBitrateDiffKbps) 653 kPermittedReconfiguredBitrateDiffKbps)
656 << "Encoder reconfigured with bitrate too far away from last set."; 654 << "Encoder reconfigured with bitrate too far away from last set.";
657 observation_complete_->Set(); 655 observation_complete_.Set();
658 } 656 }
659 return FakeEncoder::InitEncode(config, number_of_cores, max_payload_size); 657 return FakeEncoder::InitEncode(config, number_of_cores, max_payload_size);
660 } 658 }
661 659
662 int32_t SetRates(uint32_t new_target_bitrate_kbps, 660 int32_t SetRates(uint32_t new_target_bitrate_kbps,
663 uint32_t framerate) override { 661 uint32_t framerate) override {
664 last_set_bitrate_ = new_target_bitrate_kbps; 662 last_set_bitrate_ = new_target_bitrate_kbps;
665 if (encoder_inits_ == 1 && 663 if (encoder_inits_ == 1 &&
666 new_target_bitrate_kbps > kReconfigureThresholdKbps) { 664 new_target_bitrate_kbps > kReconfigureThresholdKbps) {
667 time_to_reconfigure_->Set(); 665 time_to_reconfigure_.Set();
668 } 666 }
669 return FakeEncoder::SetRates(new_target_bitrate_kbps, framerate); 667 return FakeEncoder::SetRates(new_target_bitrate_kbps, framerate);
670 } 668 }
671 669
672 Call::Config GetSenderCallConfig() override { 670 Call::Config GetSenderCallConfig() override {
673 Call::Config config = EndToEndTest::GetSenderCallConfig(); 671 Call::Config config = EndToEndTest::GetSenderCallConfig();
674 config.bitrate_config.start_bitrate_bps = kInitialBitrateKbps * 1000; 672 config.bitrate_config.start_bitrate_bps = kInitialBitrateKbps * 1000;
675 return config; 673 return config;
676 } 674 }
677 675
678 void ModifyConfigs(VideoSendStream::Config* send_config, 676 void ModifyConfigs(VideoSendStream::Config* send_config,
679 std::vector<VideoReceiveStream::Config>* receive_configs, 677 std::vector<VideoReceiveStream::Config>* receive_configs,
680 VideoEncoderConfig* encoder_config) override { 678 VideoEncoderConfig* encoder_config) override {
681 send_config->encoder_settings.encoder = this; 679 send_config->encoder_settings.encoder = this;
682 encoder_config->streams[0].min_bitrate_bps = 50000; 680 encoder_config->streams[0].min_bitrate_bps = 50000;
683 encoder_config->streams[0].target_bitrate_bps = 681 encoder_config->streams[0].target_bitrate_bps =
684 encoder_config->streams[0].max_bitrate_bps = 2000000; 682 encoder_config->streams[0].max_bitrate_bps = 2000000;
685 683
686 encoder_config_ = *encoder_config; 684 encoder_config_ = *encoder_config;
687 } 685 }
688 686
689 void OnStreamsCreated( 687 void OnStreamsCreated(
690 VideoSendStream* send_stream, 688 VideoSendStream* send_stream,
691 const std::vector<VideoReceiveStream*>& receive_streams) override { 689 const std::vector<VideoReceiveStream*>& receive_streams) override {
692 send_stream_ = send_stream; 690 send_stream_ = send_stream;
693 } 691 }
694 692
695 void PerformTest() override { 693 void PerformTest() override {
696 ASSERT_EQ(kEventSignaled, time_to_reconfigure_->Wait(kDefaultTimeoutMs)) 694 ASSERT_TRUE(time_to_reconfigure_.Wait(kDefaultTimeoutMs))
697 << "Timed out before receiving an initial high bitrate."; 695 << "Timed out before receiving an initial high bitrate.";
698 encoder_config_.streams[0].width *= 2; 696 encoder_config_.streams[0].width *= 2;
699 encoder_config_.streams[0].height *= 2; 697 encoder_config_.streams[0].height *= 2;
700 EXPECT_TRUE(send_stream_->ReconfigureVideoEncoder(encoder_config_)); 698 EXPECT_TRUE(send_stream_->ReconfigureVideoEncoder(encoder_config_));
701 EXPECT_EQ(kEventSignaled, Wait()) 699 EXPECT_TRUE(Wait())
702 << "Timed out while waiting for a couple of high bitrate estimates " 700 << "Timed out while waiting for a couple of high bitrate estimates "
703 "after reconfiguring the send stream."; 701 "after reconfiguring the send stream.";
704 } 702 }
705 703
706 private: 704 private:
707 rtc::scoped_ptr<webrtc::EventWrapper> time_to_reconfigure_; 705 rtc::Event time_to_reconfigure_;
708 int encoder_inits_; 706 int encoder_inits_;
709 uint32_t last_set_bitrate_; 707 uint32_t last_set_bitrate_;
710 VideoSendStream* send_stream_; 708 VideoSendStream* send_stream_;
711 VideoEncoderConfig encoder_config_; 709 VideoEncoderConfig encoder_config_;
712 } test; 710 } test;
713 711
714 RunBaseTest(&test, FakeNetworkPipe::Config()); 712 RunBaseTest(&test, FakeNetworkPipe::Config());
715 } 713 }
716 714
717 } // namespace webrtc 715 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698