diff options
author | asapersson <asapersson@webrtc.org> | 2016-01-07 23:36:00 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-08 07:36:06 +0000 |
commit | 59bac1a4c557bb4ba4e5f9f2f6db6040ae4b41a7 (patch) | |
tree | bbbb2c8aa53a811e4c886a9edc95b4d7e2bbe815 /webrtc | |
parent | 95ab30ce88676dc75761c77beef8438d58a4446d (diff) | |
download | webrtc-59bac1a4c557bb4ba4e5f9f2f6db6040ae4b41a7.tar.gz |
Fix for stats updated twice when switching content type (realtime <-> screenshare). Add unittest.
BUG=
Review URL: https://codereview.webrtc.org/1543933004
Cr-Commit-Position: refs/heads/master@{#11180}
Diffstat (limited to 'webrtc')
-rw-r--r-- | webrtc/video/send_statistics_proxy.cc | 1 | ||||
-rw-r--r-- | webrtc/video/send_statistics_proxy_unittest.cc | 20 |
2 files changed, 20 insertions, 1 deletions
diff --git a/webrtc/video/send_statistics_proxy.cc b/webrtc/video/send_statistics_proxy.cc index 0a84439825..d2964b21da 100644 --- a/webrtc/video/send_statistics_proxy.cc +++ b/webrtc/video/send_statistics_proxy.cc @@ -162,7 +162,6 @@ void SendStatisticsProxy::SetContentType( VideoEncoderConfig::ContentType content_type) { rtc::CritScope lock(&crit_); if (content_type_ != content_type) { - uma_container_->UpdateHistograms(); uma_container_.reset(new UmaSamplesContainer(GetUmaPrefix(content_type))); content_type_ = content_type; } diff --git a/webrtc/video/send_statistics_proxy_unittest.cc b/webrtc/video/send_statistics_proxy_unittest.cc index f098ce2d23..fc1f3fdbde 100644 --- a/webrtc/video/send_statistics_proxy_unittest.cc +++ b/webrtc/video/send_statistics_proxy_unittest.cc @@ -16,6 +16,7 @@ #include <vector> #include "testing/gtest/include/gtest/gtest.h" +#include "webrtc/test/histogram.h" namespace webrtc { @@ -296,6 +297,25 @@ TEST_F(SendStatisticsProxyTest, OnEncodedFrame) { EXPECT_EQ(kEncodeTimeMs, stats.avg_encode_time_ms); } +TEST_F(SendStatisticsProxyTest, SwitchContentTypeUpdatesHistograms) { + test::ClearHistograms(); + const int kMinRequiredSamples = 200; + const int kWidth = 640; + const int kHeight = 480; + + for (int i = 0; i < kMinRequiredSamples; ++i) + statistics_proxy_->OnIncomingFrame(kWidth, kHeight); + + // No switch, stats not should be updated. + statistics_proxy_->SetContentType( + VideoEncoderConfig::ContentType::kRealtimeVideo); + EXPECT_EQ(0, test::NumHistogramSamples("WebRTC.Video.InputWidthInPixels")); + + // Switch to screenshare, real-time stats should be updated. + statistics_proxy_->SetContentType(VideoEncoderConfig::ContentType::kScreen); + EXPECT_EQ(1, test::NumHistogramSamples("WebRTC.Video.InputWidthInPixels")); +} + TEST_F(SendStatisticsProxyTest, NoSubstreams) { uint32_t excluded_ssrc = std::max( |