Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(125)

Unified Diff: webrtc/video/send_statistics_proxy_unittest.cc

Issue 2530393003: Move histogram for number of pause events to per stream. (Closed)
Patch Set: fix comment Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/video/send_statistics_proxy.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/video/send_statistics_proxy_unittest.cc
diff --git a/webrtc/video/send_statistics_proxy_unittest.cc b/webrtc/video/send_statistics_proxy_unittest.cc
index 4cee1046ddb0509980a9e6a46673adeb19c30057..599fb7a359164ba1b7686c6e623b3041f472ae5c 100644
--- a/webrtc/video/send_statistics_proxy_unittest.cc
+++ b/webrtc/video/send_statistics_proxy_unittest.cc
@@ -82,6 +82,13 @@ class SendStatisticsProxyTest : public ::testing::Test {
return it->second;
}
+ void UpdateDataCounters(uint32_t ssrc) {
+ StreamDataCountersCallback* proxy =
+ static_cast<StreamDataCountersCallback*>(statistics_proxy_.get());
+ StreamDataCounters counters;
+ proxy->DataCountersUpdated(counters, ssrc);
+ }
+
void ExpectEqual(VideoSendStream::Stats one, VideoSendStream::Stats other) {
EXPECT_EQ(one.input_frame_rate, other.input_frame_rate);
EXPECT_EQ(one.encode_frame_rate, other.encode_frame_rate);
@@ -504,6 +511,114 @@ TEST_F(SendStatisticsProxyTest, CodecTypeHistogramIsUpdated) {
EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.Encoder.CodecType"));
}
+TEST_F(SendStatisticsProxyTest, PauseEventHistogramIsUpdated) {
+ // First RTP packet sent.
+ UpdateDataCounters(kFirstSsrc);
+
+ // Min runtime has passed.
+ fake_clock_.AdvanceTimeMilliseconds(metrics::kMinRunTimeInSeconds * 1000);
+ statistics_proxy_.reset();
+ EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.NumberOfPauseEvents"));
+ EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.NumberOfPauseEvents", 0));
+}
+
+TEST_F(SendStatisticsProxyTest,
+ PauseEventHistogramIsNotUpdatedIfMinRuntimeHasNotPassed) {
+ // First RTP packet sent.
+ UpdateDataCounters(kFirstSsrc);
+
+ // Min runtime has not passed.
+ fake_clock_.AdvanceTimeMilliseconds(metrics::kMinRunTimeInSeconds * 1000 - 1);
+ statistics_proxy_.reset();
+ EXPECT_EQ(0, metrics::NumSamples("WebRTC.Video.NumberOfPauseEvents"));
+ EXPECT_EQ(0, metrics::NumSamples("WebRTC.Video.PausedTimeInPercent"));
+}
+
+TEST_F(SendStatisticsProxyTest,
+ PauseEventHistogramIsNotUpdatedIfNoMediaIsSent) {
+ // First RTP packet not sent.
+ fake_clock_.AdvanceTimeMilliseconds(metrics::kMinRunTimeInSeconds * 1000);
+ statistics_proxy_.reset();
+ EXPECT_EQ(0, metrics::NumSamples("WebRTC.Video.NumberOfPauseEvents"));
+}
+
+TEST_F(SendStatisticsProxyTest, NoPauseEvent) {
+ // First RTP packet sent and min runtime passed.
+ UpdateDataCounters(kFirstSsrc);
+
+ // No change. Video: 10000 ms, paused: 0 ms (0%).
+ statistics_proxy_->OnSetEncoderTargetRate(50000);
+ fake_clock_.AdvanceTimeMilliseconds(metrics::kMinRunTimeInSeconds * 1000);
+ statistics_proxy_->OnSetEncoderTargetRate(0); // VideoSendStream::Stop
+
+ statistics_proxy_.reset();
+ EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.NumberOfPauseEvents"));
+ EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.NumberOfPauseEvents", 0));
+ EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.PausedTimeInPercent"));
+ EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.PausedTimeInPercent", 0));
+}
+
+TEST_F(SendStatisticsProxyTest, OnePauseEvent) {
+ // First RTP packet sent and min runtime passed.
+ UpdateDataCounters(kFirstSsrc);
+
+ // One change. Video: 7000 ms, paused: 3000 ms (30%).
+ statistics_proxy_->OnSetEncoderTargetRate(50000);
+ fake_clock_.AdvanceTimeMilliseconds(7000);
+ statistics_proxy_->OnSetEncoderTargetRate(0);
+ fake_clock_.AdvanceTimeMilliseconds(3000);
+ statistics_proxy_->OnSetEncoderTargetRate(0); // VideoSendStream::Stop
+
+ statistics_proxy_.reset();
+ EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.NumberOfPauseEvents"));
+ EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.NumberOfPauseEvents", 1));
+ EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.PausedTimeInPercent"));
+ EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.PausedTimeInPercent", 30));
+}
+
+TEST_F(SendStatisticsProxyTest, TwoPauseEvents) {
+ // First RTP packet sent.
+ UpdateDataCounters(kFirstSsrc);
+
+ // Two changes. Video: 19000 ms, paused: 1000 ms (5%).
+ statistics_proxy_->OnSetEncoderTargetRate(0);
+ fake_clock_.AdvanceTimeMilliseconds(1000);
+ statistics_proxy_->OnSetEncoderTargetRate(50000); // Starts on bitrate > 0.
+ fake_clock_.AdvanceTimeMilliseconds(7000);
+ statistics_proxy_->OnSetEncoderTargetRate(60000);
+ fake_clock_.AdvanceTimeMilliseconds(3000);
+ statistics_proxy_->OnSetEncoderTargetRate(0);
+ fake_clock_.AdvanceTimeMilliseconds(250);
+ statistics_proxy_->OnSetEncoderTargetRate(0);
+ fake_clock_.AdvanceTimeMilliseconds(750);
+ statistics_proxy_->OnSetEncoderTargetRate(60000);
+ fake_clock_.AdvanceTimeMilliseconds(5000);
+ statistics_proxy_->OnSetEncoderTargetRate(50000);
+ fake_clock_.AdvanceTimeMilliseconds(4000);
+ statistics_proxy_->OnSetEncoderTargetRate(0); // VideoSendStream::Stop
+
+ statistics_proxy_.reset();
+ EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.NumberOfPauseEvents"));
+ EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.NumberOfPauseEvents", 2));
+ EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.PausedTimeInPercent"));
+ EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.PausedTimeInPercent", 5));
+}
+
+TEST_F(SendStatisticsProxyTest,
+ PausedTimeHistogramIsNotUpdatedIfMinRuntimeHasNotPassed) {
+ // First RTP packet sent.
+ UpdateDataCounters(kFirstSsrc);
+ fake_clock_.AdvanceTimeMilliseconds(metrics::kMinRunTimeInSeconds * 1000);
+
+ // Min runtime has not passed.
+ statistics_proxy_->OnSetEncoderTargetRate(50000);
+ fake_clock_.AdvanceTimeMilliseconds(metrics::kMinRunTimeInSeconds * 1000 - 1);
+ statistics_proxy_->OnSetEncoderTargetRate(0); // VideoSendStream::Stop
+
+ statistics_proxy_.reset();
+ EXPECT_EQ(0, metrics::NumSamples("WebRTC.Video.PausedTimeInPercent"));
+}
+
TEST_F(SendStatisticsProxyTest, VerifyQpHistogramStats_Vp8) {
EncodedImage encoded_image;
CodecSpecificInfo codec_info;
@@ -730,6 +845,18 @@ TEST_F(SendStatisticsProxyTest, GetStatsReportsBandwidthLimitedResolution) {
EXPECT_TRUE(statistics_proxy_->GetStats().bw_limited_resolution);
}
+TEST_F(SendStatisticsProxyTest, GetStatsReportsTargetMediaBitrate) {
+ // Initially zero.
+ EXPECT_EQ(0, statistics_proxy_->GetStats().target_media_bitrate_bps);
+
+ const int kBitrate = 100000;
+ statistics_proxy_->OnSetEncoderTargetRate(kBitrate);
+ EXPECT_EQ(kBitrate, statistics_proxy_->GetStats().target_media_bitrate_bps);
+
+ statistics_proxy_->OnSetEncoderTargetRate(0);
+ EXPECT_EQ(0, statistics_proxy_->GetStats().target_media_bitrate_bps);
+}
+
TEST_F(SendStatisticsProxyTest, NoSubstreams) {
uint32_t excluded_ssrc =
std::max(
« no previous file with comments | « webrtc/video/send_statistics_proxy.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698