| Index: webrtc/video/receive_statistics_proxy_unittest.cc
|
| diff --git a/webrtc/video/receive_statistics_proxy_unittest.cc b/webrtc/video/receive_statistics_proxy_unittest.cc
|
| index 98ec7eddad24409ec3097b6c6568c3190be064a3..45d9551d60d1e965f668b8082d2cd45e168e342b 100644
|
| --- a/webrtc/video/receive_statistics_proxy_unittest.cc
|
| +++ b/webrtc/video/receive_statistics_proxy_unittest.cc
|
| @@ -70,7 +70,7 @@ TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameIncreasesFramesDecoded) {
|
| EXPECT_EQ(0u, statistics_proxy_->GetStats().frames_decoded);
|
| for (uint32_t i = 1; i <= 3; ++i) {
|
| statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(),
|
| - VideoContentType::UNSPECIFIED);
|
| + VideoContentType::Unspecified());
|
| EXPECT_EQ(i, statistics_proxy_->GetStats().frames_decoded);
|
| }
|
| }
|
| @@ -79,21 +79,21 @@ TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameWithQpResetsFramesDecoded) {
|
| EXPECT_EQ(0u, statistics_proxy_->GetStats().frames_decoded);
|
| for (uint32_t i = 1; i <= 3; ++i) {
|
| statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(),
|
| - VideoContentType::UNSPECIFIED);
|
| + VideoContentType::Unspecified());
|
| EXPECT_EQ(i, statistics_proxy_->GetStats().frames_decoded);
|
| }
|
| statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(1u),
|
| - VideoContentType::UNSPECIFIED);
|
| + VideoContentType::Unspecified());
|
| EXPECT_EQ(1u, statistics_proxy_->GetStats().frames_decoded);
|
| }
|
|
|
| TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameIncreasesQpSum) {
|
| EXPECT_EQ(rtc::Optional<uint64_t>(), statistics_proxy_->GetStats().qp_sum);
|
| statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(3u),
|
| - VideoContentType::UNSPECIFIED);
|
| + VideoContentType::Unspecified());
|
| EXPECT_EQ(rtc::Optional<uint64_t>(3u), statistics_proxy_->GetStats().qp_sum);
|
| statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(127u),
|
| - VideoContentType::UNSPECIFIED);
|
| + VideoContentType::Unspecified());
|
| EXPECT_EQ(rtc::Optional<uint64_t>(130u),
|
| statistics_proxy_->GetStats().qp_sum);
|
| }
|
| @@ -104,24 +104,24 @@ TEST_F(ReceiveStatisticsProxyTest, ReportsMaxInterframeDelay) {
|
| const int64_t kInterframeDelayMs3 = 100;
|
| EXPECT_EQ(-1, statistics_proxy_->GetStats().interframe_delay_max_ms);
|
| statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(3u),
|
| - VideoContentType::UNSPECIFIED);
|
| + VideoContentType::Unspecified());
|
| EXPECT_EQ(-1, statistics_proxy_->GetStats().interframe_delay_max_ms);
|
|
|
| fake_clock_.AdvanceTimeMilliseconds(kInterframeDelayMs1);
|
| statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(127u),
|
| - VideoContentType::UNSPECIFIED);
|
| + VideoContentType::Unspecified());
|
| EXPECT_EQ(kInterframeDelayMs1,
|
| statistics_proxy_->GetStats().interframe_delay_max_ms);
|
|
|
| fake_clock_.AdvanceTimeMilliseconds(kInterframeDelayMs2);
|
| statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(127u),
|
| - VideoContentType::UNSPECIFIED);
|
| + VideoContentType::Unspecified());
|
| EXPECT_EQ(kInterframeDelayMs2,
|
| statistics_proxy_->GetStats().interframe_delay_max_ms);
|
|
|
| fake_clock_.AdvanceTimeMilliseconds(kInterframeDelayMs3);
|
| statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(127u),
|
| - VideoContentType::UNSPECIFIED);
|
| + VideoContentType::Unspecified());
|
| // kInterframeDelayMs3 is smaller than kInterframeDelayMs2.
|
| EXPECT_EQ(kInterframeDelayMs2,
|
| statistics_proxy_->GetStats().interframe_delay_max_ms);
|
| @@ -133,25 +133,25 @@ TEST_F(ReceiveStatisticsProxyTest, ReportInterframeDelayInWindow) {
|
| const int64_t kInterframeDelayMs3 = 7000;
|
| EXPECT_EQ(-1, statistics_proxy_->GetStats().interframe_delay_max_ms);
|
| statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(3u),
|
| - VideoContentType::UNSPECIFIED);
|
| + VideoContentType::Unspecified());
|
| EXPECT_EQ(-1, statistics_proxy_->GetStats().interframe_delay_max_ms);
|
|
|
| fake_clock_.AdvanceTimeMilliseconds(kInterframeDelayMs1);
|
| statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(127u),
|
| - VideoContentType::UNSPECIFIED);
|
| + VideoContentType::Unspecified());
|
| EXPECT_EQ(kInterframeDelayMs1,
|
| statistics_proxy_->GetStats().interframe_delay_max_ms);
|
|
|
| fake_clock_.AdvanceTimeMilliseconds(kInterframeDelayMs2);
|
| statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(127u),
|
| - VideoContentType::UNSPECIFIED);
|
| + VideoContentType::Unspecified());
|
| // Still first delay is the maximum
|
| EXPECT_EQ(kInterframeDelayMs1,
|
| statistics_proxy_->GetStats().interframe_delay_max_ms);
|
|
|
| fake_clock_.AdvanceTimeMilliseconds(kInterframeDelayMs3);
|
| statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(127u),
|
| - VideoContentType::UNSPECIFIED);
|
| + VideoContentType::Unspecified());
|
| // Now the first sample is out of the window, so the second is the maximum.
|
| EXPECT_EQ(kInterframeDelayMs2,
|
| statistics_proxy_->GetStats().interframe_delay_max_ms);
|
| @@ -160,17 +160,17 @@ TEST_F(ReceiveStatisticsProxyTest, ReportInterframeDelayInWindow) {
|
| TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameWithoutQpQpSumWontExist) {
|
| EXPECT_EQ(rtc::Optional<uint64_t>(), statistics_proxy_->GetStats().qp_sum);
|
| statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(),
|
| - VideoContentType::UNSPECIFIED);
|
| + VideoContentType::Unspecified());
|
| EXPECT_EQ(rtc::Optional<uint64_t>(), statistics_proxy_->GetStats().qp_sum);
|
| }
|
|
|
| TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameWithoutQpResetsQpSum) {
|
| EXPECT_EQ(rtc::Optional<uint64_t>(), statistics_proxy_->GetStats().qp_sum);
|
| statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(3u),
|
| - VideoContentType::UNSPECIFIED);
|
| + VideoContentType::Unspecified());
|
| EXPECT_EQ(rtc::Optional<uint64_t>(3u), statistics_proxy_->GetStats().qp_sum);
|
| statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(),
|
| - VideoContentType::UNSPECIFIED);
|
| + VideoContentType::Unspecified());
|
| EXPECT_EQ(rtc::Optional<uint64_t>(), statistics_proxy_->GetStats().qp_sum);
|
| }
|
|
|
| @@ -203,7 +203,8 @@ TEST_F(ReceiveStatisticsProxyTest, GetStatsReportsDecoderImplementationName) {
|
|
|
| TEST_F(ReceiveStatisticsProxyTest, GetStatsReportsOnCompleteFrame) {
|
| const int kFrameSizeBytes = 1000;
|
| - statistics_proxy_->OnCompleteFrame(true, kFrameSizeBytes);
|
| + statistics_proxy_->OnCompleteFrame(true, kFrameSizeBytes,
|
| + VideoContentType::Unspecified());
|
| VideoReceiveStream::Stats stats = statistics_proxy_->GetStats();
|
| EXPECT_EQ(1, stats.network_frame_rate);
|
| EXPECT_EQ(1, stats.frame_counts.key_frames);
|
| @@ -352,6 +353,9 @@ TEST_F(ReceiveStatisticsProxyTest, GetTimingFrameInfoTimingFramesReportedOnce) {
|
| TEST_F(ReceiveStatisticsProxyTest, LifetimeHistogramIsUpdated) {
|
| const int64_t kTimeSec = 3;
|
| fake_clock_.AdvanceTimeMilliseconds(kTimeSec * 1000);
|
| + // Need at least one frame to report stream lifetime.
|
| + statistics_proxy_->OnCompleteFrame(true, 1000,
|
| + VideoContentType::Unspecified());
|
| // Histograms are updated when the statistics_proxy_ is deleted.
|
| statistics_proxy_.reset();
|
| EXPECT_EQ(1,
|
| @@ -360,6 +364,17 @@ TEST_F(ReceiveStatisticsProxyTest, LifetimeHistogramIsUpdated) {
|
| kTimeSec));
|
| }
|
|
|
| +TEST_F(ReceiveStatisticsProxyTest,
|
| + LifetimeHistogramNotReportedForEmptyStreams) {
|
| + const int64_t kTimeSec = 3;
|
| + fake_clock_.AdvanceTimeMilliseconds(kTimeSec * 1000);
|
| + // No frames received.
|
| + // Histograms are updated when the statistics_proxy_ is deleted.
|
| + statistics_proxy_.reset();
|
| + EXPECT_EQ(0,
|
| + metrics::NumSamples("WebRTC.Video.ReceiveStreamLifetimeInSeconds"));
|
| +}
|
| +
|
| TEST_F(ReceiveStatisticsProxyTest, BadCallHistogramsAreUpdated) {
|
| // Based on the tuning parameters this will produce 7 uncertain states,
|
| // then 10 certainly bad states. There has to be 10 certain states before
|
| @@ -533,7 +548,8 @@ TEST_F(ReceiveStatisticsProxyTest,
|
| const int kFrameSizeBytes = 1000;
|
|
|
| for (int i = 0; i < kMinRequiredSamples - 1; ++i)
|
| - statistics_proxy_->OnCompleteFrame(kIsKeyFrame, kFrameSizeBytes);
|
| + statistics_proxy_->OnCompleteFrame(kIsKeyFrame, kFrameSizeBytes,
|
| + VideoContentType::Unspecified());
|
|
|
| EXPECT_EQ(0, statistics_proxy_->GetStats().frame_counts.key_frames);
|
| EXPECT_EQ(kMinRequiredSamples - 1,
|
| @@ -549,7 +565,8 @@ TEST_F(ReceiveStatisticsProxyTest,
|
| const int kFrameSizeBytes = 1000;
|
|
|
| for (int i = 0; i < kMinRequiredSamples; ++i)
|
| - statistics_proxy_->OnCompleteFrame(kIsKeyFrame, kFrameSizeBytes);
|
| + statistics_proxy_->OnCompleteFrame(kIsKeyFrame, kFrameSizeBytes,
|
| + VideoContentType::Unspecified());
|
|
|
| EXPECT_EQ(0, statistics_proxy_->GetStats().frame_counts.key_frames);
|
| EXPECT_EQ(kMinRequiredSamples,
|
| @@ -565,10 +582,12 @@ TEST_F(ReceiveStatisticsProxyTest, KeyFrameHistogramIsUpdated) {
|
| const int kFrameSizeBytes = 1000;
|
|
|
| for (int i = 0; i < kMinRequiredSamples; ++i)
|
| - statistics_proxy_->OnCompleteFrame(true, kFrameSizeBytes);
|
| + statistics_proxy_->OnCompleteFrame(true, kFrameSizeBytes,
|
| + VideoContentType::Unspecified());
|
|
|
| for (int i = 0; i < kMinRequiredSamples; ++i)
|
| - statistics_proxy_->OnCompleteFrame(false, kFrameSizeBytes);
|
| + statistics_proxy_->OnCompleteFrame(false, kFrameSizeBytes,
|
| + VideoContentType::Unspecified());
|
|
|
| EXPECT_EQ(kMinRequiredSamples,
|
| statistics_proxy_->GetStats().frame_counts.key_frames);
|
| @@ -651,7 +670,7 @@ TEST_F(ReceiveStatisticsProxyTest, DoesNotReportStaleFramerates) {
|
| // i.e. bad
|
| frame.set_ntp_time_ms(fake_clock_.CurrentNtpInMilliseconds());
|
| statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(),
|
| - VideoContentType::UNSPECIFIED);
|
| + VideoContentType::Unspecified());
|
| statistics_proxy_->OnRenderedFrame(frame);
|
| fake_clock_.AdvanceTimeMilliseconds(1000 / kDefaultFps);
|
| }
|
| @@ -758,8 +777,8 @@ TEST_F(ReceiveStatisticsProxyTest, RtcpHistogramsAreUpdated) {
|
|
|
| INSTANTIATE_TEST_CASE_P(ContentTypes,
|
| ReceiveStatisticsProxyTest,
|
| - ::testing::Values(VideoContentType::UNSPECIFIED,
|
| - VideoContentType::SCREENSHARE));
|
| + ::testing::Values(VideoContentType::Unspecified(),
|
| + VideoContentType::Screenshare()));
|
|
|
| TEST_P(ReceiveStatisticsProxyTest, InterFrameDelaysAreReported) {
|
| const VideoContentType content_type = GetParam();
|
| @@ -777,23 +796,18 @@ TEST_P(ReceiveStatisticsProxyTest, InterFrameDelaysAreReported) {
|
| (kInterFrameDelayMs * (kMinRequiredSamples - 1) +
|
| kInterFrameDelayMs * 2) /
|
| kMinRequiredSamples;
|
| - switch (content_type) {
|
| - case VideoContentType::UNSPECIFIED:
|
| - EXPECT_EQ(kExpectedInterFrame,
|
| - metrics::MinSample("WebRTC.Video.InterframeDelayInMs"));
|
| - EXPECT_EQ(kInterFrameDelayMs * 2,
|
| - metrics::MinSample("WebRTC.Video.InterframeDelayMaxInMs"));
|
| - break;
|
| - case VideoContentType::SCREENSHARE:
|
| - EXPECT_EQ(
|
| - kExpectedInterFrame,
|
| - metrics::MinSample("WebRTC.Video.Screenshare.InterframeDelayInMs"));
|
| - EXPECT_EQ(kInterFrameDelayMs * 2,
|
| - metrics::MinSample(
|
| - "WebRTC.Video.Screenshare.InterframeDelayMaxInMs"));
|
| - break;
|
| - default:
|
| - RTC_NOTREACHED();
|
| + if (content_type.IsScreenshare()) {
|
| + EXPECT_EQ(
|
| + kExpectedInterFrame,
|
| + metrics::MinSample("WebRTC.Video.Screenshare.InterframeDelayInMs"));
|
| + EXPECT_EQ(
|
| + kInterFrameDelayMs * 2,
|
| + metrics::MinSample("WebRTC.Video.Screenshare.InterframeDelayMaxInMs"));
|
| + } else {
|
| + EXPECT_EQ(kExpectedInterFrame,
|
| + metrics::MinSample("WebRTC.Video.InterframeDelayInMs"));
|
| + EXPECT_EQ(kInterFrameDelayMs * 2,
|
| + metrics::MinSample("WebRTC.Video.InterframeDelayMaxInMs"));
|
| }
|
| }
|
|
|
| @@ -836,7 +850,7 @@ TEST_P(ReceiveStatisticsProxyTest, MaxInterFrameDelayOnlyWithPause) {
|
| statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(), content_type);
|
|
|
| statistics_proxy_.reset();
|
| - if (content_type == VideoContentType::SCREENSHARE) {
|
| + if (content_type.IsScreenshare()) {
|
| EXPECT_EQ(
|
| 1, metrics::NumSamples("WebRTC.Video.Screenshare.InterframeDelayInMs"));
|
| EXPECT_EQ(1, metrics::NumSamples(
|
| @@ -857,4 +871,84 @@ TEST_P(ReceiveStatisticsProxyTest, MaxInterFrameDelayOnlyWithPause) {
|
| }
|
| }
|
|
|
| +TEST_P(ReceiveStatisticsProxyTest, StatsAreSlicedOnSimulcastAndExperiment) {
|
| + VideoContentType content_type = GetParam();
|
| + const uint8_t experiment_id = 1;
|
| + content_type.SetExperimentId(experiment_id);
|
| + const int kInterFrameDelayMs1 = 30;
|
| + const int kInterFrameDelayMs2 = 50;
|
| +
|
| + content_type.SetSimulcastId(1);
|
| + for (int i = 0; i <= kMinRequiredSamples; ++i) {
|
| + fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs1);
|
| + statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(), content_type);
|
| + }
|
| +
|
| + content_type.SetSimulcastId(2);
|
| + for (int i = 0; i <= kMinRequiredSamples; ++i) {
|
| + fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs2);
|
| + statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(), content_type);
|
| + }
|
| + statistics_proxy_.reset();
|
| +
|
| + if (content_type.IsScreenshare()) {
|
| + EXPECT_EQ(
|
| + 1, metrics::NumSamples("WebRTC.Video.Screenshare.InterframeDelayInMs"));
|
| + EXPECT_EQ(1, metrics::NumSamples(
|
| + "WebRTC.Video.Screenshare.InterframeDelayMaxInMs"));
|
| + EXPECT_EQ(1, metrics::NumSamples(
|
| + "WebRTC.Video.Screenshare.InterframeDelayInMs.S0"));
|
| + EXPECT_EQ(1, metrics::NumSamples(
|
| + "WebRTC.Video.Screenshare.InterframeDelayMaxInMs.S0"));
|
| + EXPECT_EQ(1, metrics::NumSamples(
|
| + "WebRTC.Video.Screenshare.InterframeDelayInMs.S1"));
|
| + EXPECT_EQ(1, metrics::NumSamples(
|
| + "WebRTC.Video.Screenshare.InterframeDelayMaxInMs.S1"));
|
| + EXPECT_EQ(1,
|
| + metrics::NumSamples("WebRTC.Video.Screenshare.InterframeDelayInMs"
|
| + ".ExperimentGroup0"));
|
| + EXPECT_EQ(
|
| + 1, metrics::NumSamples("WebRTC.Video.Screenshare.InterframeDelayMaxInMs"
|
| + ".ExperimentGroup0"));
|
| + EXPECT_EQ(
|
| + kInterFrameDelayMs1,
|
| + metrics::MinSample("WebRTC.Video.Screenshare.InterframeDelayInMs.S0"));
|
| + EXPECT_EQ(
|
| + kInterFrameDelayMs2,
|
| + metrics::MinSample("WebRTC.Video.Screenshare.InterframeDelayInMs.S1"));
|
| + EXPECT_EQ(
|
| + (kInterFrameDelayMs1 + kInterFrameDelayMs2) / 2,
|
| + metrics::MinSample("WebRTC.Video.Screenshare.InterframeDelayInMs"));
|
| + EXPECT_EQ(
|
| + kInterFrameDelayMs2,
|
| + metrics::MinSample("WebRTC.Video.Screenshare.InterframeDelayMaxInMs"));
|
| + EXPECT_EQ(
|
| + (kInterFrameDelayMs1 + kInterFrameDelayMs2) / 2,
|
| + metrics::MinSample(
|
| + "WebRTC.Video.Screenshare.InterframeDelayInMs.ExperimentGroup0"));
|
| + } else {
|
| + EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.InterframeDelayInMs"));
|
| + EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.InterframeDelayMaxInMs"));
|
| + EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.InterframeDelayInMs.S0"));
|
| + EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.InterframeDelayMaxInMs.S0"));
|
| + EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.InterframeDelayInMs.S1"));
|
| + EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.InterframeDelayMaxInMs.S1"));
|
| + EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.InterframeDelayInMs"
|
| + ".ExperimentGroup0"));
|
| + EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.InterframeDelayMaxInMs"
|
| + ".ExperimentGroup0"));
|
| + EXPECT_EQ(kInterFrameDelayMs1,
|
| + metrics::MinSample("WebRTC.Video.InterframeDelayInMs.S0"));
|
| + EXPECT_EQ(kInterFrameDelayMs2,
|
| + metrics::MinSample("WebRTC.Video.InterframeDelayInMs.S1"));
|
| + EXPECT_EQ((kInterFrameDelayMs1 + kInterFrameDelayMs2) / 2,
|
| + metrics::MinSample("WebRTC.Video.InterframeDelayInMs"));
|
| + EXPECT_EQ(kInterFrameDelayMs2,
|
| + metrics::MinSample("WebRTC.Video.InterframeDelayMaxInMs"));
|
| + EXPECT_EQ((kInterFrameDelayMs1 + kInterFrameDelayMs2) / 2,
|
| + metrics::MinSample(
|
| + "WebRTC.Video.InterframeDelayInMs.ExperimentGroup0"));
|
| + }
|
| +}
|
| +
|
| } // namespace webrtc
|
|
|