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 // Quality limited histograms are only enabled for stream 0 |
663 // default: -1 | 669 // in simulcast; |
670 CodecSpecificInfo codec_info = kDefaultCodecInfo; | |
671 codec_info.codecSpecific.VP8.simulcastIdx = 1; | |
664 for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i) | 672 for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i) |
665 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); | 673 statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info); |
666 | 674 |
667 // Histograms are updated when the statistics_proxy_ is deleted. | 675 // Histograms are updated when the statistics_proxy_ is deleted. |
668 statistics_proxy_.reset(); | 676 statistics_proxy_.reset(); |
669 EXPECT_EQ( | 677 EXPECT_EQ( |
670 0, metrics::NumSamples("WebRTC.Video.QualityLimitedResolutionInPercent")); | 678 0, metrics::NumSamples("WebRTC.Video.QualityLimitedResolutionInPercent")); |
671 EXPECT_EQ(0, metrics::NumSamples( | 679 EXPECT_EQ(0, metrics::NumSamples( |
672 "WebRTC.Video.QualityLimitedResolutionDownscales")); | 680 "WebRTC.Video.QualityLimitedResolutionDownscales")); |
673 } | 681 } |
674 | 682 |
675 TEST_F(SendStatisticsProxyTest, | 683 TEST_F(SendStatisticsProxyTest, |
676 QualityLimitedHistogramsUpdatedWhenEnabled_NoResolutionDownscale) { | 684 QualityLimitedHistogramsUpdatedWhenEnabled_NoResolutionDownscale) { |
åsapersson
2016/12/14 09:25:13
Seems like the stats can also be reported if scali
kthelgason
2016/12/15 10:33:54
Right. I fixed this and added a test for that case
| |
677 const int kDownscales = 0; | |
678 EncodedImage encoded_image; | 685 EncodedImage encoded_image; |
679 encoded_image.adapt_reason_.quality_resolution_downscales = kDownscales; | |
680 for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i) | 686 for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i) |
681 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); | 687 statistics_proxy_->OnSendEncodedImage(encoded_image, &kDefaultCodecInfo); |
682 | 688 |
683 // Histograms are updated when the statistics_proxy_ is deleted. | 689 // Histograms are updated when the statistics_proxy_ is deleted. |
684 statistics_proxy_.reset(); | 690 statistics_proxy_.reset(); |
685 EXPECT_EQ( | 691 EXPECT_EQ( |
686 1, metrics::NumSamples("WebRTC.Video.QualityLimitedResolutionInPercent")); | 692 1, metrics::NumSamples("WebRTC.Video.QualityLimitedResolutionInPercent")); |
687 EXPECT_EQ(1, metrics::NumEvents( | 693 EXPECT_EQ(1, metrics::NumEvents( |
688 "WebRTC.Video.QualityLimitedResolutionInPercent", 0)); | 694 "WebRTC.Video.QualityLimitedResolutionInPercent", 0)); |
689 // No resolution downscale. | 695 // No resolution downscale. |
690 EXPECT_EQ(0, metrics::NumSamples( | 696 EXPECT_EQ(0, metrics::NumSamples( |
691 "WebRTC.Video.QualityLimitedResolutionDownscales")); | 697 "WebRTC.Video.QualityLimitedResolutionDownscales")); |
692 } | 698 } |
693 | 699 |
694 TEST_F(SendStatisticsProxyTest, | 700 TEST_F(SendStatisticsProxyTest, |
695 QualityLimitedHistogramsUpdatedWhenEnabled_TwoResolutionDownscales) { | 701 QualityLimitedHistogramsUpdatedWhenEnabled_TwoResolutionDownscales) { |
696 const int kDownscales = 2; | 702 const int kDownscales = 2; |
697 EncodedImage encoded_image; | 703 EncodedImage encoded_image; |
698 encoded_image.adapt_reason_.quality_resolution_downscales = kDownscales; | 704 statistics_proxy_->OnQualityRestrictedResolutionChanged(kDownscales); |
699 for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i) | 705 for (int i = 0; i < SendStatisticsProxy::kMinRequiredMetricsSamples; ++i) |
700 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); | 706 statistics_proxy_->OnSendEncodedImage(encoded_image, &kDefaultCodecInfo); |
701 | |
702 // Histograms are updated when the statistics_proxy_ is deleted. | 707 // Histograms are updated when the statistics_proxy_ is deleted. |
703 statistics_proxy_.reset(); | 708 statistics_proxy_.reset(); |
704 EXPECT_EQ( | 709 EXPECT_EQ( |
705 1, metrics::NumSamples("WebRTC.Video.QualityLimitedResolutionInPercent")); | 710 1, metrics::NumSamples("WebRTC.Video.QualityLimitedResolutionInPercent")); |
706 EXPECT_EQ(1, metrics::NumEvents( | 711 EXPECT_EQ(1, metrics::NumEvents( |
707 "WebRTC.Video.QualityLimitedResolutionInPercent", 100)); | 712 "WebRTC.Video.QualityLimitedResolutionInPercent", 100)); |
708 // Resolution downscales. | 713 // Resolution downscales. |
709 EXPECT_EQ(1, metrics::NumSamples( | 714 EXPECT_EQ(1, metrics::NumSamples( |
710 "WebRTC.Video.QualityLimitedResolutionDownscales")); | 715 "WebRTC.Video.QualityLimitedResolutionDownscales")); |
711 EXPECT_EQ( | 716 EXPECT_EQ( |
712 1, metrics::NumEvents("WebRTC.Video.QualityLimitedResolutionDownscales", | 717 1, metrics::NumEvents("WebRTC.Video.QualityLimitedResolutionDownscales", |
713 kDownscales)); | 718 kDownscales)); |
714 } | 719 } |
715 | 720 |
716 TEST_F(SendStatisticsProxyTest, GetStatsReportsBandwidthLimitedResolution) { | 721 TEST_F(SendStatisticsProxyTest, GetStatsReportsBandwidthLimitedResolution) { |
717 // Initially false. | 722 // Initially false. |
718 EXPECT_FALSE(statistics_proxy_->GetStats().bw_limited_resolution); | 723 EXPECT_FALSE(statistics_proxy_->GetStats().bw_limited_resolution); |
719 // No resolution scale by default. | 724 // No resolution scale by default. |
720 EncodedImage encoded_image; | 725 EncodedImage encoded_image; |
721 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); | 726 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); |
722 EXPECT_FALSE(statistics_proxy_->GetStats().bw_limited_resolution); | 727 EXPECT_FALSE(statistics_proxy_->GetStats().bw_limited_resolution); |
723 // Resolution not scaled. | 728 |
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); | |
åsapersson
2016/12/14 09:25:13
I think this should still be tested and not remove
kthelgason
2016/12/15 10:33:54
Acknowledged.
| |
727 // Resolution scaled due to bandwidth. | 729 // Resolution scaled due to bandwidth. |
728 encoded_image.adapt_reason_.bw_resolutions_disabled = 1; | 730 statistics_proxy_->OnQualityRestrictedResolutionChanged(1); |
åsapersson
2016/12/14 09:25:13
ditto
kthelgason
2016/12/15 10:33:54
Acknowledged.
| |
729 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); | 731 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); |
730 EXPECT_TRUE(statistics_proxy_->GetStats().bw_limited_resolution); | 732 EXPECT_TRUE(statistics_proxy_->GetStats().bw_limited_resolution); |
731 } | 733 } |
732 | 734 |
733 TEST_F(SendStatisticsProxyTest, NoSubstreams) { | 735 TEST_F(SendStatisticsProxyTest, NoSubstreams) { |
734 uint32_t excluded_ssrc = | 736 uint32_t excluded_ssrc = |
735 std::max( | 737 std::max( |
736 *std::max_element(config_.rtp.ssrcs.begin(), config_.rtp.ssrcs.end()), | 738 *std::max_element(config_.rtp.ssrcs.begin(), config_.rtp.ssrcs.end()), |
737 *std::max_element(config_.rtp.rtx.ssrcs.begin(), | 739 *std::max_element(config_.rtp.rtx.ssrcs.begin(), |
738 config_.rtp.rtx.ssrcs.end())) + | 740 config_.rtp.rtx.ssrcs.end())) + |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1163 | 1165 |
1164 EXPECT_EQ( | 1166 EXPECT_EQ( |
1165 1, metrics::NumSamples("WebRTC.Video.Screenshare.FecBitrateSentInKbps")); | 1167 1, metrics::NumSamples("WebRTC.Video.Screenshare.FecBitrateSentInKbps")); |
1166 EXPECT_EQ(1, metrics::NumEvents( | 1168 EXPECT_EQ(1, metrics::NumEvents( |
1167 "WebRTC.Video.Screenshare.FecBitrateSentInKbps", | 1169 "WebRTC.Video.Screenshare.FecBitrateSentInKbps", |
1168 static_cast<int>((counters.fec.TotalBytes() * 2 * 8) / | 1170 static_cast<int>((counters.fec.TotalBytes() * 2 * 8) / |
1169 metrics::kMinRunTimeInSeconds / 1000))); | 1171 metrics::kMinRunTimeInSeconds / 1000))); |
1170 } | 1172 } |
1171 | 1173 |
1172 } // namespace webrtc | 1174 } // namespace webrtc |
OLD | NEW |