| 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 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 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 }(); | |
| 40 } // namespace | 34 } // namespace |
| 41 | 35 |
| 42 class SendStatisticsProxyTest : public ::testing::Test { | 36 class SendStatisticsProxyTest : public ::testing::Test { |
| 43 public: | 37 public: |
| 44 SendStatisticsProxyTest() | 38 SendStatisticsProxyTest() |
| 45 : fake_clock_(1234), config_(GetTestConfig()), avg_delay_ms_(0), | 39 : fake_clock_(1234), config_(GetTestConfig()), avg_delay_ms_(0), |
| 46 max_delay_ms_(0) {} | 40 max_delay_ms_(0) {} |
| 47 virtual ~SendStatisticsProxyTest() {} | 41 virtual ~SendStatisticsProxyTest() {} |
| 48 | 42 |
| 49 protected: | 43 protected: |
| (...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 EXPECT_EQ(1, metrics::NumSamples( | 652 EXPECT_EQ(1, metrics::NumSamples( |
| 659 "WebRTC.Video.BandwidthLimitedResolutionsDisabled")); | 653 "WebRTC.Video.BandwidthLimitedResolutionsDisabled")); |
| 660 EXPECT_EQ( | 654 EXPECT_EQ( |
| 661 1, metrics::NumEvents("WebRTC.Video.BandwidthLimitedResolutionsDisabled", | 655 1, metrics::NumEvents("WebRTC.Video.BandwidthLimitedResolutionsDisabled", |
| 662 kResolutionsDisabled)); | 656 kResolutionsDisabled)); |
| 663 } | 657 } |
| 664 | 658 |
| 665 TEST_F(SendStatisticsProxyTest, | 659 TEST_F(SendStatisticsProxyTest, |
| 666 QualityLimitedHistogramsNotUpdatedWhenDisabled) { | 660 QualityLimitedHistogramsNotUpdatedWhenDisabled) { |
| 667 EncodedImage encoded_image; | 661 EncodedImage encoded_image; |
| 668 statistics_proxy_->SetResolutionRestrictionStats(false /* scaling_enabled */, | 662 // encoded_image.adapt_reason_.quality_resolution_downscales disabled by |
| 669 0, 0); | 663 // default: -1 |
| 670 for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i) | 664 for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i) |
| 671 statistics_proxy_->OnSendEncodedImage(encoded_image, &kDefaultCodecInfo); | 665 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); |
| 672 | 666 |
| 673 // Histograms are updated when the statistics_proxy_ is deleted. | 667 // Histograms are updated when the statistics_proxy_ is deleted. |
| 674 statistics_proxy_.reset(); | 668 statistics_proxy_.reset(); |
| 675 EXPECT_EQ( | 669 EXPECT_EQ( |
| 676 0, metrics::NumSamples("WebRTC.Video.QualityLimitedResolutionInPercent")); | 670 0, metrics::NumSamples("WebRTC.Video.QualityLimitedResolutionInPercent")); |
| 677 EXPECT_EQ(0, metrics::NumSamples( | 671 EXPECT_EQ(0, metrics::NumSamples( |
| 678 "WebRTC.Video.QualityLimitedResolutionDownscales")); | 672 "WebRTC.Video.QualityLimitedResolutionDownscales")); |
| 679 } | 673 } |
| 680 | 674 |
| 681 TEST_F(SendStatisticsProxyTest, | 675 TEST_F(SendStatisticsProxyTest, |
| 682 QualityLimitedHistogramsUpdatedWhenEnabled_NoResolutionDownscale) { | 676 QualityLimitedHistogramsUpdatedWhenEnabled_NoResolutionDownscale) { |
| 677 const int kDownscales = 0; |
| 683 EncodedImage encoded_image; | 678 EncodedImage encoded_image; |
| 679 encoded_image.adapt_reason_.quality_resolution_downscales = kDownscales; |
| 684 for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i) | 680 for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i) |
| 685 statistics_proxy_->OnSendEncodedImage(encoded_image, &kDefaultCodecInfo); | 681 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); |
| 686 | 682 |
| 687 // Histograms are updated when the statistics_proxy_ is deleted. | 683 // Histograms are updated when the statistics_proxy_ is deleted. |
| 688 statistics_proxy_.reset(); | 684 statistics_proxy_.reset(); |
| 689 EXPECT_EQ( | 685 EXPECT_EQ( |
| 690 1, metrics::NumSamples("WebRTC.Video.QualityLimitedResolutionInPercent")); | 686 1, metrics::NumSamples("WebRTC.Video.QualityLimitedResolutionInPercent")); |
| 691 EXPECT_EQ(1, metrics::NumEvents( | 687 EXPECT_EQ(1, metrics::NumEvents( |
| 692 "WebRTC.Video.QualityLimitedResolutionInPercent", 0)); | 688 "WebRTC.Video.QualityLimitedResolutionInPercent", 0)); |
| 693 // No resolution downscale. | 689 // No resolution downscale. |
| 694 EXPECT_EQ(0, metrics::NumSamples( | 690 EXPECT_EQ(0, metrics::NumSamples( |
| 695 "WebRTC.Video.QualityLimitedResolutionDownscales")); | 691 "WebRTC.Video.QualityLimitedResolutionDownscales")); |
| 696 } | 692 } |
| 697 | 693 |
| 698 TEST_F(SendStatisticsProxyTest, | 694 TEST_F(SendStatisticsProxyTest, |
| 699 QualityLimitedHistogramsUpdatedWhenEnabled_TwoResolutionDownscales) { | 695 QualityLimitedHistogramsUpdatedWhenEnabled_TwoResolutionDownscales) { |
| 700 const int kDownscales = 2; | 696 const int kDownscales = 2; |
| 701 EncodedImage encoded_image; | 697 EncodedImage encoded_image; |
| 702 statistics_proxy_->OnQualityRestrictedResolutionChanged(kDownscales); | 698 encoded_image.adapt_reason_.quality_resolution_downscales = kDownscales; |
| 703 for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i) | 699 for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i) |
| 704 statistics_proxy_->OnSendEncodedImage(encoded_image, &kDefaultCodecInfo); | 700 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); |
| 701 |
| 705 // Histograms are updated when the statistics_proxy_ is deleted. | 702 // Histograms are updated when the statistics_proxy_ is deleted. |
| 706 statistics_proxy_.reset(); | 703 statistics_proxy_.reset(); |
| 707 EXPECT_EQ( | 704 EXPECT_EQ( |
| 708 1, metrics::NumSamples("WebRTC.Video.QualityLimitedResolutionInPercent")); | 705 1, metrics::NumSamples("WebRTC.Video.QualityLimitedResolutionInPercent")); |
| 709 EXPECT_EQ(1, metrics::NumEvents( | 706 EXPECT_EQ(1, metrics::NumEvents( |
| 710 "WebRTC.Video.QualityLimitedResolutionInPercent", 100)); | 707 "WebRTC.Video.QualityLimitedResolutionInPercent", 100)); |
| 711 // Resolution downscales. | 708 // Resolution downscales. |
| 712 EXPECT_EQ(1, metrics::NumSamples( | 709 EXPECT_EQ(1, metrics::NumSamples( |
| 713 "WebRTC.Video.QualityLimitedResolutionDownscales")); | 710 "WebRTC.Video.QualityLimitedResolutionDownscales")); |
| 714 EXPECT_EQ( | 711 EXPECT_EQ( |
| 715 1, metrics::NumEvents("WebRTC.Video.QualityLimitedResolutionDownscales", | 712 1, metrics::NumEvents("WebRTC.Video.QualityLimitedResolutionDownscales", |
| 716 kDownscales)); | 713 kDownscales)); |
| 717 } | 714 } |
| 718 | 715 |
| 719 TEST_F(SendStatisticsProxyTest, GetStatsReportsBandwidthLimitedResolution) { | 716 TEST_F(SendStatisticsProxyTest, GetStatsReportsBandwidthLimitedResolution) { |
| 720 // Initially false. | 717 // Initially false. |
| 721 EXPECT_FALSE(statistics_proxy_->GetStats().bw_limited_resolution); | 718 EXPECT_FALSE(statistics_proxy_->GetStats().bw_limited_resolution); |
| 722 // No resolution scale by default. | 719 // No resolution scale by default. |
| 723 EncodedImage encoded_image; | 720 EncodedImage encoded_image; |
| 724 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); | 721 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); |
| 725 EXPECT_FALSE(statistics_proxy_->GetStats().bw_limited_resolution); | 722 EXPECT_FALSE(statistics_proxy_->GetStats().bw_limited_resolution); |
| 726 | 723 // Resolution not scaled. |
| 727 // Simulcast disabled resolutions | 724 encoded_image.adapt_reason_.bw_resolutions_disabled = 0; |
| 725 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); |
| 726 EXPECT_FALSE(statistics_proxy_->GetStats().bw_limited_resolution); |
| 727 // Resolution scaled due to bandwidth. |
| 728 encoded_image.adapt_reason_.bw_resolutions_disabled = 1; | 728 encoded_image.adapt_reason_.bw_resolutions_disabled = 1; |
| 729 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); | 729 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); |
| 730 EXPECT_TRUE(statistics_proxy_->GetStats().bw_limited_resolution); | 730 EXPECT_TRUE(statistics_proxy_->GetStats().bw_limited_resolution); |
| 731 | |
| 732 encoded_image.adapt_reason_.bw_resolutions_disabled = 0; | |
| 733 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); | |
| 734 EXPECT_FALSE(statistics_proxy_->GetStats().bw_limited_resolution); | |
| 735 | |
| 736 // Resolution scaled due to quality. | |
| 737 statistics_proxy_->OnQualityRestrictedResolutionChanged(1); | |
| 738 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); | |
| 739 EXPECT_TRUE(statistics_proxy_->GetStats().bw_limited_resolution); | |
| 740 } | 731 } |
| 741 | 732 |
| 742 TEST_F(SendStatisticsProxyTest, NoSubstreams) { | 733 TEST_F(SendStatisticsProxyTest, NoSubstreams) { |
| 743 uint32_t excluded_ssrc = | 734 uint32_t excluded_ssrc = |
| 744 std::max( | 735 std::max( |
| 745 *std::max_element(config_.rtp.ssrcs.begin(), config_.rtp.ssrcs.end()), | 736 *std::max_element(config_.rtp.ssrcs.begin(), config_.rtp.ssrcs.end()), |
| 746 *std::max_element(config_.rtp.rtx.ssrcs.begin(), | 737 *std::max_element(config_.rtp.rtx.ssrcs.begin(), |
| 747 config_.rtp.rtx.ssrcs.end())) + | 738 config_.rtp.rtx.ssrcs.end())) + |
| 748 1; | 739 1; |
| 749 // From RtcpStatisticsCallback. | 740 // From RtcpStatisticsCallback. |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1172 | 1163 |
| 1173 EXPECT_EQ( | 1164 EXPECT_EQ( |
| 1174 1, metrics::NumSamples("WebRTC.Video.Screenshare.FecBitrateSentInKbps")); | 1165 1, metrics::NumSamples("WebRTC.Video.Screenshare.FecBitrateSentInKbps")); |
| 1175 EXPECT_EQ(1, metrics::NumEvents( | 1166 EXPECT_EQ(1, metrics::NumEvents( |
| 1176 "WebRTC.Video.Screenshare.FecBitrateSentInKbps", | 1167 "WebRTC.Video.Screenshare.FecBitrateSentInKbps", |
| 1177 static_cast<int>((counters.fec.TotalBytes() * 2 * 8) / | 1168 static_cast<int>((counters.fec.TotalBytes() * 2 * 8) / |
| 1178 metrics::kMinRunTimeInSeconds / 1000))); | 1169 metrics::kMinRunTimeInSeconds / 1000))); |
| 1179 } | 1170 } |
| 1180 | 1171 |
| 1181 } // namespace webrtc | 1172 } // namespace webrtc |
| OLD | NEW |