Chromium Code Reviews

Side by Side Diff: webrtc/video/send_statistics_proxy_unittest.cc

Issue 2564373002: Properly report number of quality downscales in stats. (Closed)
Patch Set: tests passing Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
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 10
(...skipping 13 matching lines...)
24 const uint32_t kFirstSsrc = 17; 24 const uint32_t kFirstSsrc = 17;
25 const uint32_t kSecondSsrc = 42; 25 const uint32_t kSecondSsrc = 42;
26 const uint32_t kFirstRtxSsrc = 18; 26 const uint32_t kFirstRtxSsrc = 18;
27 const uint32_t kSecondRtxSsrc = 43; 27 const uint32_t kSecondRtxSsrc = 43;
28 const uint32_t kFlexFecSsrc = 55; 28 const uint32_t kFlexFecSsrc = 55;
29 const int kFpsPeriodicIntervalMs = 2000; 29 const int kFpsPeriodicIntervalMs = 2000;
30 const int kWidth = 640; 30 const int kWidth = 640;
31 const int kHeight = 480; 31 const int kHeight = 480;
32 const int kQpIdx0 = 21; 32 const int kQpIdx0 = 21;
33 const int kQpIdx1 = 39; 33 const int kQpIdx1 = 39;
34 const CodecSpecificInfo kDefaultCodecInfo = []() {
35 CodecSpecificInfo codec_info;
36 codec_info.codecType = kVideoCodecVP8;
37 codec_info.codecSpecific.VP8.simulcastIdx = 0;
38 return codec_info;
39 }();
34 } // namespace 40 } // namespace
35 41
36 class SendStatisticsProxyTest : public ::testing::Test { 42 class SendStatisticsProxyTest : public ::testing::Test {
37 public: 43 public:
38 SendStatisticsProxyTest() 44 SendStatisticsProxyTest()
39 : fake_clock_(1234), config_(GetTestConfig()), avg_delay_ms_(0), 45 : fake_clock_(1234), config_(GetTestConfig()), avg_delay_ms_(0),
40 max_delay_ms_(0) {} 46 max_delay_ms_(0) {}
41 virtual ~SendStatisticsProxyTest() {} 47 virtual ~SendStatisticsProxyTest() {}
42 48
43 protected: 49 protected:
(...skipping 608 matching lines...)
652 EXPECT_EQ(1, metrics::NumSamples( 658 EXPECT_EQ(1, metrics::NumSamples(
653 "WebRTC.Video.BandwidthLimitedResolutionsDisabled")); 659 "WebRTC.Video.BandwidthLimitedResolutionsDisabled"));
654 EXPECT_EQ( 660 EXPECT_EQ(
655 1, metrics::NumEvents("WebRTC.Video.BandwidthLimitedResolutionsDisabled", 661 1, metrics::NumEvents("WebRTC.Video.BandwidthLimitedResolutionsDisabled",
656 kResolutionsDisabled)); 662 kResolutionsDisabled));
657 } 663 }
658 664
659 TEST_F(SendStatisticsProxyTest, 665 TEST_F(SendStatisticsProxyTest,
660 QualityLimitedHistogramsNotUpdatedWhenDisabled) { 666 QualityLimitedHistogramsNotUpdatedWhenDisabled) {
661 EncodedImage encoded_image; 667 EncodedImage encoded_image;
662 // encoded_image.adapt_reason_.quality_resolution_downscales disabled by 668 statistics_proxy_->SetResolutionRestrictionStats(false /* scaling_enabled */,
663 // default: -1 669 0, 0);
664 for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i) 670 for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i)
665 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); 671 statistics_proxy_->OnSendEncodedImage(encoded_image, &kDefaultCodecInfo);
666 672
667 // Histograms are updated when the statistics_proxy_ is deleted. 673 // Histograms are updated when the statistics_proxy_ is deleted.
668 statistics_proxy_.reset(); 674 statistics_proxy_.reset();
675 EXPECT_EQ(
676 0, metrics::NumSamples("WebRTC.Video.QualityLimitedResolutionInPercent"));
677 EXPECT_EQ(0, metrics::NumSamples(
678 "WebRTC.Video.QualityLimitedResolutionDownscales"));
679 }
680
681 TEST_F(SendStatisticsProxyTest,
682 QualityLimitedHistogramsNotUpdatedForAdditionalSimulcastStreams) {
683 EncodedImage encoded_image;
684 // Quality limited histograms are only enabled for stream 0
685 // in simulcast;
686 CodecSpecificInfo codec_info = kDefaultCodecInfo;
687 codec_info.codecSpecific.VP8.simulcastIdx = 1;
688 for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i)
689 statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info);
690
691 // Histograms are updated when the statistics_proxy_ is deleted.
692 statistics_proxy_.reset();
669 EXPECT_EQ( 693 EXPECT_EQ(
670 0, metrics::NumSamples("WebRTC.Video.QualityLimitedResolutionInPercent")); 694 0, metrics::NumSamples("WebRTC.Video.QualityLimitedResolutionInPercent"));
671 EXPECT_EQ(0, metrics::NumSamples( 695 EXPECT_EQ(0, metrics::NumSamples(
672 "WebRTC.Video.QualityLimitedResolutionDownscales")); 696 "WebRTC.Video.QualityLimitedResolutionDownscales"));
673 } 697 }
674 698
675 TEST_F(SendStatisticsProxyTest, 699 TEST_F(SendStatisticsProxyTest,
676 QualityLimitedHistogramsUpdatedWhenEnabled_NoResolutionDownscale) { 700 QualityLimitedHistogramsUpdatedWhenEnabled_NoResolutionDownscale) {
677 const int kDownscales = 0;
678 EncodedImage encoded_image; 701 EncodedImage encoded_image;
679 encoded_image.adapt_reason_.quality_resolution_downscales = kDownscales;
680 for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i) 702 for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i)
681 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); 703 statistics_proxy_->OnSendEncodedImage(encoded_image, &kDefaultCodecInfo);
682 704
683 // Histograms are updated when the statistics_proxy_ is deleted. 705 // Histograms are updated when the statistics_proxy_ is deleted.
684 statistics_proxy_.reset(); 706 statistics_proxy_.reset();
685 EXPECT_EQ( 707 EXPECT_EQ(
686 1, metrics::NumSamples("WebRTC.Video.QualityLimitedResolutionInPercent")); 708 1, metrics::NumSamples("WebRTC.Video.QualityLimitedResolutionInPercent"));
687 EXPECT_EQ(1, metrics::NumEvents( 709 EXPECT_EQ(1, metrics::NumEvents(
688 "WebRTC.Video.QualityLimitedResolutionInPercent", 0)); 710 "WebRTC.Video.QualityLimitedResolutionInPercent", 0));
689 // No resolution downscale. 711 // No resolution downscale.
690 EXPECT_EQ(0, metrics::NumSamples( 712 EXPECT_EQ(0, metrics::NumSamples(
691 "WebRTC.Video.QualityLimitedResolutionDownscales")); 713 "WebRTC.Video.QualityLimitedResolutionDownscales"));
692 } 714 }
693 715
694 TEST_F(SendStatisticsProxyTest, 716 TEST_F(SendStatisticsProxyTest,
695 QualityLimitedHistogramsUpdatedWhenEnabled_TwoResolutionDownscales) { 717 QualityLimitedHistogramsUpdatedWhenEnabled_TwoResolutionDownscales) {
696 const int kDownscales = 2; 718 const int kDownscales = 2;
697 EncodedImage encoded_image; 719 EncodedImage encoded_image;
698 encoded_image.adapt_reason_.quality_resolution_downscales = kDownscales; 720 statistics_proxy_->OnQualityRestrictedResolutionChanged(kDownscales);
699 for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i) 721 for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i)
700 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); 722 statistics_proxy_->OnSendEncodedImage(encoded_image, &kDefaultCodecInfo);
701
702 // Histograms are updated when the statistics_proxy_ is deleted. 723 // Histograms are updated when the statistics_proxy_ is deleted.
703 statistics_proxy_.reset(); 724 statistics_proxy_.reset();
704 EXPECT_EQ( 725 EXPECT_EQ(
705 1, metrics::NumSamples("WebRTC.Video.QualityLimitedResolutionInPercent")); 726 1, metrics::NumSamples("WebRTC.Video.QualityLimitedResolutionInPercent"));
706 EXPECT_EQ(1, metrics::NumEvents( 727 EXPECT_EQ(1, metrics::NumEvents(
707 "WebRTC.Video.QualityLimitedResolutionInPercent", 100)); 728 "WebRTC.Video.QualityLimitedResolutionInPercent", 100));
708 // Resolution downscales. 729 // Resolution downscales.
709 EXPECT_EQ(1, metrics::NumSamples( 730 EXPECT_EQ(1, metrics::NumSamples(
710 "WebRTC.Video.QualityLimitedResolutionDownscales")); 731 "WebRTC.Video.QualityLimitedResolutionDownscales"));
711 EXPECT_EQ( 732 EXPECT_EQ(
712 1, metrics::NumEvents("WebRTC.Video.QualityLimitedResolutionDownscales", 733 1, metrics::NumEvents("WebRTC.Video.QualityLimitedResolutionDownscales",
713 kDownscales)); 734 kDownscales));
714 } 735 }
715 736
716 TEST_F(SendStatisticsProxyTest, GetStatsReportsBandwidthLimitedResolution) { 737 TEST_F(SendStatisticsProxyTest, GetStatsReportsBandwidthLimitedResolution) {
717 // Initially false. 738 // Initially false.
718 EXPECT_FALSE(statistics_proxy_->GetStats().bw_limited_resolution); 739 EXPECT_FALSE(statistics_proxy_->GetStats().bw_limited_resolution);
719 // No resolution scale by default. 740 // No resolution scale by default.
720 EncodedImage encoded_image; 741 EncodedImage encoded_image;
721 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); 742 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr);
722 EXPECT_FALSE(statistics_proxy_->GetStats().bw_limited_resolution); 743 EXPECT_FALSE(statistics_proxy_->GetStats().bw_limited_resolution);
723 // Resolution not scaled. 744
745 // Simulcast disabled resolutions
746 encoded_image.adapt_reason_.bw_resolutions_disabled = 1;
747 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr);
748 EXPECT_TRUE(statistics_proxy_->GetStats().bw_limited_resolution);
749
724 encoded_image.adapt_reason_.bw_resolutions_disabled = 0; 750 encoded_image.adapt_reason_.bw_resolutions_disabled = 0;
725 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); 751 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr);
726 EXPECT_FALSE(statistics_proxy_->GetStats().bw_limited_resolution); 752 EXPECT_FALSE(statistics_proxy_->GetStats().bw_limited_resolution);
727 // Resolution scaled due to bandwidth. 753
728 encoded_image.adapt_reason_.bw_resolutions_disabled = 1; 754 // Resolution scaled due to quality.
755 statistics_proxy_->OnQualityRestrictedResolutionChanged(1);
729 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); 756 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr);
730 EXPECT_TRUE(statistics_proxy_->GetStats().bw_limited_resolution); 757 EXPECT_TRUE(statistics_proxy_->GetStats().bw_limited_resolution);
731 } 758 }
732 759
733 TEST_F(SendStatisticsProxyTest, NoSubstreams) { 760 TEST_F(SendStatisticsProxyTest, NoSubstreams) {
734 uint32_t excluded_ssrc = 761 uint32_t excluded_ssrc =
735 std::max( 762 std::max(
736 *std::max_element(config_.rtp.ssrcs.begin(), config_.rtp.ssrcs.end()), 763 *std::max_element(config_.rtp.ssrcs.begin(), config_.rtp.ssrcs.end()),
737 *std::max_element(config_.rtp.rtx.ssrcs.begin(), 764 *std::max_element(config_.rtp.rtx.ssrcs.begin(),
738 config_.rtp.rtx.ssrcs.end())) + 765 config_.rtp.rtx.ssrcs.end())) +
(...skipping 424 matching lines...)
1163 1190
1164 EXPECT_EQ( 1191 EXPECT_EQ(
1165 1, metrics::NumSamples("WebRTC.Video.Screenshare.FecBitrateSentInKbps")); 1192 1, metrics::NumSamples("WebRTC.Video.Screenshare.FecBitrateSentInKbps"));
1166 EXPECT_EQ(1, metrics::NumEvents( 1193 EXPECT_EQ(1, metrics::NumEvents(
1167 "WebRTC.Video.Screenshare.FecBitrateSentInKbps", 1194 "WebRTC.Video.Screenshare.FecBitrateSentInKbps",
1168 static_cast<int>((counters.fec.TotalBytes() * 2 * 8) / 1195 static_cast<int>((counters.fec.TotalBytes() * 2 * 8) /
1169 metrics::kMinRunTimeInSeconds / 1000))); 1196 metrics::kMinRunTimeInSeconds / 1000)));
1170 } 1197 }
1171 1198
1172 } // namespace webrtc 1199 } // namespace webrtc
OLDNEW

Powered by Google App Engine