| 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 }(); |
| 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...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(); |
| 669 EXPECT_EQ( | 675 EXPECT_EQ( |
| 670 0, metrics::NumSamples("WebRTC.Video.QualityLimitedResolutionInPercent")); | 676 0, metrics::NumSamples("WebRTC.Video.QualityLimitedResolutionInPercent")); |
| 671 EXPECT_EQ(0, metrics::NumSamples( | 677 EXPECT_EQ(0, metrics::NumSamples( |
| 672 "WebRTC.Video.QualityLimitedResolutionDownscales")); | 678 "WebRTC.Video.QualityLimitedResolutionDownscales")); |
| 673 } | 679 } |
| 674 | 680 |
| 675 TEST_F(SendStatisticsProxyTest, | 681 TEST_F(SendStatisticsProxyTest, |
| 676 QualityLimitedHistogramsUpdatedWhenEnabled_NoResolutionDownscale) { | 682 QualityLimitedHistogramsUpdatedWhenEnabled_NoResolutionDownscale) { |
| 677 const int kDownscales = 0; | |
| 678 EncodedImage encoded_image; | 683 EncodedImage encoded_image; |
| 679 encoded_image.adapt_reason_.quality_resolution_downscales = kDownscales; | |
| 680 for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i) | 684 for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i) |
| 681 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); | 685 statistics_proxy_->OnSendEncodedImage(encoded_image, &kDefaultCodecInfo); |
| 682 | 686 |
| 683 // Histograms are updated when the statistics_proxy_ is deleted. | 687 // Histograms are updated when the statistics_proxy_ is deleted. |
| 684 statistics_proxy_.reset(); | 688 statistics_proxy_.reset(); |
| 685 EXPECT_EQ( | 689 EXPECT_EQ( |
| 686 1, metrics::NumSamples("WebRTC.Video.QualityLimitedResolutionInPercent")); | 690 1, metrics::NumSamples("WebRTC.Video.QualityLimitedResolutionInPercent")); |
| 687 EXPECT_EQ(1, metrics::NumEvents( | 691 EXPECT_EQ(1, metrics::NumEvents( |
| 688 "WebRTC.Video.QualityLimitedResolutionInPercent", 0)); | 692 "WebRTC.Video.QualityLimitedResolutionInPercent", 0)); |
| 689 // No resolution downscale. | 693 // No resolution downscale. |
| 690 EXPECT_EQ(0, metrics::NumSamples( | 694 EXPECT_EQ(0, metrics::NumSamples( |
| 691 "WebRTC.Video.QualityLimitedResolutionDownscales")); | 695 "WebRTC.Video.QualityLimitedResolutionDownscales")); |
| 692 } | 696 } |
| 693 | 697 |
| 694 TEST_F(SendStatisticsProxyTest, | 698 TEST_F(SendStatisticsProxyTest, |
| 695 QualityLimitedHistogramsUpdatedWhenEnabled_TwoResolutionDownscales) { | 699 QualityLimitedHistogramsUpdatedWhenEnabled_TwoResolutionDownscales) { |
| 696 const int kDownscales = 2; | 700 const int kDownscales = 2; |
| 697 EncodedImage encoded_image; | 701 EncodedImage encoded_image; |
| 698 encoded_image.adapt_reason_.quality_resolution_downscales = kDownscales; | 702 statistics_proxy_->OnQualityRestrictedResolutionChanged(kDownscales); |
| 699 for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i) | 703 for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i) |
| 700 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); | 704 statistics_proxy_->OnSendEncodedImage(encoded_image, &kDefaultCodecInfo); |
| 701 | |
| 702 // Histograms are updated when the statistics_proxy_ is deleted. | 705 // Histograms are updated when the statistics_proxy_ is deleted. |
| 703 statistics_proxy_.reset(); | 706 statistics_proxy_.reset(); |
| 704 EXPECT_EQ( | 707 EXPECT_EQ( |
| 705 1, metrics::NumSamples("WebRTC.Video.QualityLimitedResolutionInPercent")); | 708 1, metrics::NumSamples("WebRTC.Video.QualityLimitedResolutionInPercent")); |
| 706 EXPECT_EQ(1, metrics::NumEvents( | 709 EXPECT_EQ(1, metrics::NumEvents( |
| 707 "WebRTC.Video.QualityLimitedResolutionInPercent", 100)); | 710 "WebRTC.Video.QualityLimitedResolutionInPercent", 100)); |
| 708 // Resolution downscales. | 711 // Resolution downscales. |
| 709 EXPECT_EQ(1, metrics::NumSamples( | 712 EXPECT_EQ(1, metrics::NumSamples( |
| 710 "WebRTC.Video.QualityLimitedResolutionDownscales")); | 713 "WebRTC.Video.QualityLimitedResolutionDownscales")); |
| 711 EXPECT_EQ( | 714 EXPECT_EQ( |
| 712 1, metrics::NumEvents("WebRTC.Video.QualityLimitedResolutionDownscales", | 715 1, metrics::NumEvents("WebRTC.Video.QualityLimitedResolutionDownscales", |
| 713 kDownscales)); | 716 kDownscales)); |
| 714 } | 717 } |
| 715 | 718 |
| 716 TEST_F(SendStatisticsProxyTest, GetStatsReportsBandwidthLimitedResolution) { | 719 TEST_F(SendStatisticsProxyTest, GetStatsReportsBandwidthLimitedResolution) { |
| 717 // Initially false. | 720 // Initially false. |
| 718 EXPECT_FALSE(statistics_proxy_->GetStats().bw_limited_resolution); | 721 EXPECT_FALSE(statistics_proxy_->GetStats().bw_limited_resolution); |
| 719 // No resolution scale by default. | 722 // No resolution scale by default. |
| 720 EncodedImage encoded_image; | 723 EncodedImage encoded_image; |
| 721 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); | 724 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); |
| 722 EXPECT_FALSE(statistics_proxy_->GetStats().bw_limited_resolution); | 725 EXPECT_FALSE(statistics_proxy_->GetStats().bw_limited_resolution); |
| 723 // Resolution not scaled. | 726 |
| 727 // Simulcast disabled resolutions |
| 728 encoded_image.adapt_reason_.bw_resolutions_disabled = 1; |
| 729 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); |
| 730 EXPECT_TRUE(statistics_proxy_->GetStats().bw_limited_resolution); |
| 731 |
| 724 encoded_image.adapt_reason_.bw_resolutions_disabled = 0; | 732 encoded_image.adapt_reason_.bw_resolutions_disabled = 0; |
| 725 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); | 733 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); |
| 726 EXPECT_FALSE(statistics_proxy_->GetStats().bw_limited_resolution); | 734 EXPECT_FALSE(statistics_proxy_->GetStats().bw_limited_resolution); |
| 727 // Resolution scaled due to bandwidth. | 735 |
| 728 encoded_image.adapt_reason_.bw_resolutions_disabled = 1; | 736 // Resolution scaled due to quality. |
| 737 statistics_proxy_->OnQualityRestrictedResolutionChanged(1); |
| 729 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); | 738 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); |
| 730 EXPECT_TRUE(statistics_proxy_->GetStats().bw_limited_resolution); | 739 EXPECT_TRUE(statistics_proxy_->GetStats().bw_limited_resolution); |
| 731 } | 740 } |
| 732 | 741 |
| 733 TEST_F(SendStatisticsProxyTest, NoSubstreams) { | 742 TEST_F(SendStatisticsProxyTest, NoSubstreams) { |
| 734 uint32_t excluded_ssrc = | 743 uint32_t excluded_ssrc = |
| 735 std::max( | 744 std::max( |
| 736 *std::max_element(config_.rtp.ssrcs.begin(), config_.rtp.ssrcs.end()), | 745 *std::max_element(config_.rtp.ssrcs.begin(), config_.rtp.ssrcs.end()), |
| 737 *std::max_element(config_.rtp.rtx.ssrcs.begin(), | 746 *std::max_element(config_.rtp.rtx.ssrcs.begin(), |
| 738 config_.rtp.rtx.ssrcs.end())) + | 747 config_.rtp.rtx.ssrcs.end())) + |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1163 | 1172 |
| 1164 EXPECT_EQ( | 1173 EXPECT_EQ( |
| 1165 1, metrics::NumSamples("WebRTC.Video.Screenshare.FecBitrateSentInKbps")); | 1174 1, metrics::NumSamples("WebRTC.Video.Screenshare.FecBitrateSentInKbps")); |
| 1166 EXPECT_EQ(1, metrics::NumEvents( | 1175 EXPECT_EQ(1, metrics::NumEvents( |
| 1167 "WebRTC.Video.Screenshare.FecBitrateSentInKbps", | 1176 "WebRTC.Video.Screenshare.FecBitrateSentInKbps", |
| 1168 static_cast<int>((counters.fec.TotalBytes() * 2 * 8) / | 1177 static_cast<int>((counters.fec.TotalBytes() * 2 * 8) / |
| 1169 metrics::kMinRunTimeInSeconds / 1000))); | 1178 metrics::kMinRunTimeInSeconds / 1000))); |
| 1170 } | 1179 } |
| 1171 | 1180 |
| 1172 } // namespace webrtc | 1181 } // namespace webrtc |
| OLD | NEW |