sakal | e5ba44e | 2016-10-26 07:09:24 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #include "video/receive_statistics_proxy.h" |
sakal | e5ba44e | 2016-10-26 07:09:24 -0700 | [diff] [blame] | 12 | |
asapersson | 2077f2f | 2017-05-11 05:37:35 -0700 | [diff] [blame] | 13 | #include <limits> |
sakal | e5ba44e | 2016-10-26 07:09:24 -0700 | [diff] [blame] | 14 | #include <memory> |
Ilya Nikolaevskiy | daa4f7a | 2017-10-06 12:29:47 +0200 | [diff] [blame] | 15 | #include <utility> |
sakal | e5ba44e | 2016-10-26 07:09:24 -0700 | [diff] [blame] | 16 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 17 | #include "api/video/i420_buffer.h" |
| 18 | #include "api/video/video_frame.h" |
| 19 | #include "api/video/video_rotation.h" |
| 20 | #include "modules/video_coding/include/video_codec_interface.h" |
| 21 | #include "system_wrappers/include/metrics.h" |
| 22 | #include "system_wrappers/include/metrics_default.h" |
| 23 | #include "test/gtest.h" |
sakal | e5ba44e | 2016-10-26 07:09:24 -0700 | [diff] [blame] | 24 | |
| 25 | namespace webrtc { |
asapersson | de9e5ff | 2016-11-02 07:14:03 -0700 | [diff] [blame] | 26 | namespace { |
| 27 | const int64_t kFreqOffsetProcessIntervalInMs = 40000; |
asapersson | 46c4e3c | 2016-11-03 06:48:19 -0700 | [diff] [blame] | 28 | const uint32_t kLocalSsrc = 123; |
| 29 | const uint32_t kRemoteSsrc = 456; |
| 30 | const int kMinRequiredSamples = 200; |
Ilya Nikolaevskiy | 94150ee | 2018-05-23 11:53:19 +0200 | [diff] [blame^] | 31 | |
| 32 | const int kWidth = 1280; |
| 33 | const int kHeight = 720; |
| 34 | |
asapersson | de9e5ff | 2016-11-02 07:14:03 -0700 | [diff] [blame] | 35 | } // namespace |
sakal | e5ba44e | 2016-10-26 07:09:24 -0700 | [diff] [blame] | 36 | |
| 37 | // TODO(sakal): ReceiveStatisticsProxy is lacking unittesting. |
sprang | 892dab5 | 2017-08-15 05:00:33 -0700 | [diff] [blame] | 38 | class ReceiveStatisticsProxyTest |
| 39 | : public ::testing::TestWithParam<webrtc::VideoContentType> { |
sakal | e5ba44e | 2016-10-26 07:09:24 -0700 | [diff] [blame] | 40 | public: |
| 41 | ReceiveStatisticsProxyTest() : fake_clock_(1234), config_(GetTestConfig()) {} |
| 42 | virtual ~ReceiveStatisticsProxyTest() {} |
| 43 | |
| 44 | protected: |
| 45 | virtual void SetUp() { |
asapersson | de9e5ff | 2016-11-02 07:14:03 -0700 | [diff] [blame] | 46 | metrics::Reset(); |
sakal | e5ba44e | 2016-10-26 07:09:24 -0700 | [diff] [blame] | 47 | statistics_proxy_.reset(new ReceiveStatisticsProxy(&config_, &fake_clock_)); |
| 48 | } |
| 49 | |
| 50 | VideoReceiveStream::Config GetTestConfig() { |
| 51 | VideoReceiveStream::Config config(nullptr); |
asapersson | 46c4e3c | 2016-11-03 06:48:19 -0700 | [diff] [blame] | 52 | config.rtp.local_ssrc = kLocalSsrc; |
| 53 | config.rtp.remote_ssrc = kRemoteSsrc; |
sakal | e5ba44e | 2016-10-26 07:09:24 -0700 | [diff] [blame] | 54 | return config; |
| 55 | } |
| 56 | |
asapersson | 2077f2f | 2017-05-11 05:37:35 -0700 | [diff] [blame] | 57 | void InsertFirstRtpPacket(uint32_t ssrc) { |
| 58 | StreamDataCounters counters; |
| 59 | counters.first_packet_time_ms = fake_clock_.TimeInMilliseconds(); |
| 60 | statistics_proxy_->DataCountersUpdated(counters, ssrc); |
| 61 | } |
| 62 | |
| 63 | VideoFrame CreateFrame(int width, int height) { |
| 64 | VideoFrame frame(I420Buffer::Create(width, height), 0, 0, kVideoRotation_0); |
| 65 | frame.set_ntp_time_ms(fake_clock_.CurrentNtpInMilliseconds()); |
| 66 | return frame; |
| 67 | } |
| 68 | |
sakal | e5ba44e | 2016-10-26 07:09:24 -0700 | [diff] [blame] | 69 | SimulatedClock fake_clock_; |
asapersson | de9e5ff | 2016-11-02 07:14:03 -0700 | [diff] [blame] | 70 | const VideoReceiveStream::Config config_; |
sakal | e5ba44e | 2016-10-26 07:09:24 -0700 | [diff] [blame] | 71 | std::unique_ptr<ReceiveStatisticsProxy> statistics_proxy_; |
sakal | e5ba44e | 2016-10-26 07:09:24 -0700 | [diff] [blame] | 72 | }; |
| 73 | |
| 74 | TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameIncreasesFramesDecoded) { |
| 75 | EXPECT_EQ(0u, statistics_proxy_->GetStats().frames_decoded); |
| 76 | for (uint32_t i = 1; i <= 3; ++i) { |
Ilya Nikolaevskiy | 94150ee | 2018-05-23 11:53:19 +0200 | [diff] [blame^] | 77 | statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, |
ilnik | 00d802b | 2017-04-11 10:34:31 -0700 | [diff] [blame] | 78 | VideoContentType::UNSPECIFIED); |
sakal | e5ba44e | 2016-10-26 07:09:24 -0700 | [diff] [blame] | 79 | EXPECT_EQ(i, statistics_proxy_->GetStats().frames_decoded); |
| 80 | } |
| 81 | } |
| 82 | |
Åsa Persson | b9b07ea | 2018-01-24 17:04:07 +0100 | [diff] [blame] | 83 | TEST_F(ReceiveStatisticsProxyTest, DecodedFpsIsReported) { |
| 84 | const int kFps = 20; |
| 85 | const int kRequiredSamples = metrics::kMinRunTimeInSeconds * kFps; |
| 86 | for (int i = 0; i < kRequiredSamples; ++i) { |
Ilya Nikolaevskiy | 94150ee | 2018-05-23 11:53:19 +0200 | [diff] [blame^] | 87 | statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(), kWidth, kHeight, |
Åsa Persson | b9b07ea | 2018-01-24 17:04:07 +0100 | [diff] [blame] | 88 | VideoContentType::UNSPECIFIED); |
| 89 | fake_clock_.AdvanceTimeMilliseconds(1000 / kFps); |
| 90 | } |
| 91 | statistics_proxy_.reset(); |
| 92 | EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.DecodedFramesPerSecond")); |
| 93 | EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.DecodedFramesPerSecond", kFps)); |
| 94 | } |
| 95 | |
| 96 | TEST_F(ReceiveStatisticsProxyTest, DecodedFpsIsNotReportedForTooFewSamples) { |
| 97 | const int kFps = 20; |
| 98 | const int kRequiredSamples = metrics::kMinRunTimeInSeconds * kFps; |
| 99 | for (int i = 0; i < kRequiredSamples - 1; ++i) { |
Ilya Nikolaevskiy | 94150ee | 2018-05-23 11:53:19 +0200 | [diff] [blame^] | 100 | statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(), kWidth, kHeight, |
Åsa Persson | b9b07ea | 2018-01-24 17:04:07 +0100 | [diff] [blame] | 101 | VideoContentType::UNSPECIFIED); |
| 102 | fake_clock_.AdvanceTimeMilliseconds(1000 / kFps); |
| 103 | } |
| 104 | statistics_proxy_.reset(); |
| 105 | EXPECT_EQ(0, metrics::NumSamples("WebRTC.Video.DecodedFramesPerSecond")); |
| 106 | } |
| 107 | |
| 108 | TEST_F(ReceiveStatisticsProxyTest, DecodedFpsIsReportedWithQpReset) { |
| 109 | const int kFps1 = 10; |
| 110 | for (int i = 0; i < metrics::kMinRunTimeInSeconds * kFps1; ++i) { |
Ilya Nikolaevskiy | 94150ee | 2018-05-23 11:53:19 +0200 | [diff] [blame^] | 111 | statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(), kWidth, kHeight, |
Åsa Persson | b9b07ea | 2018-01-24 17:04:07 +0100 | [diff] [blame] | 112 | VideoContentType::UNSPECIFIED); |
| 113 | fake_clock_.AdvanceTimeMilliseconds(1000 / kFps1); |
| 114 | } |
| 115 | // First QP value received, resets frames decoded. |
| 116 | const int kFps2 = 20; |
| 117 | for (int i = 0; i < metrics::kMinRunTimeInSeconds * kFps2; ++i) { |
Ilya Nikolaevskiy | 94150ee | 2018-05-23 11:53:19 +0200 | [diff] [blame^] | 118 | statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(1u), kWidth, |
| 119 | kHeight, VideoContentType::UNSPECIFIED); |
Åsa Persson | b9b07ea | 2018-01-24 17:04:07 +0100 | [diff] [blame] | 120 | fake_clock_.AdvanceTimeMilliseconds(1000 / kFps2); |
| 121 | } |
| 122 | statistics_proxy_.reset(); |
| 123 | EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.DecodedFramesPerSecond")); |
| 124 | EXPECT_EQ(1, |
| 125 | metrics::NumEvents("WebRTC.Video.DecodedFramesPerSecond", kFps2)); |
| 126 | } |
| 127 | |
sakal | cc452e1 | 2017-02-09 04:53:45 -0800 | [diff] [blame] | 128 | TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameWithQpResetsFramesDecoded) { |
| 129 | EXPECT_EQ(0u, statistics_proxy_->GetStats().frames_decoded); |
| 130 | for (uint32_t i = 1; i <= 3; ++i) { |
Ilya Nikolaevskiy | 94150ee | 2018-05-23 11:53:19 +0200 | [diff] [blame^] | 131 | statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, |
ilnik | 00d802b | 2017-04-11 10:34:31 -0700 | [diff] [blame] | 132 | VideoContentType::UNSPECIFIED); |
sakal | cc452e1 | 2017-02-09 04:53:45 -0800 | [diff] [blame] | 133 | EXPECT_EQ(i, statistics_proxy_->GetStats().frames_decoded); |
| 134 | } |
Ilya Nikolaevskiy | 94150ee | 2018-05-23 11:53:19 +0200 | [diff] [blame^] | 135 | statistics_proxy_->OnDecodedFrame(1u, kWidth, kHeight, |
| 136 | VideoContentType::UNSPECIFIED); |
sakal | cc452e1 | 2017-02-09 04:53:45 -0800 | [diff] [blame] | 137 | EXPECT_EQ(1u, statistics_proxy_->GetStats().frames_decoded); |
| 138 | } |
| 139 | |
| 140 | TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameIncreasesQpSum) { |
Oskar Sundbom | 8e07c13 | 2018-01-08 16:45:42 +0100 | [diff] [blame] | 141 | EXPECT_EQ(rtc::nullopt, statistics_proxy_->GetStats().qp_sum); |
Ilya Nikolaevskiy | 94150ee | 2018-05-23 11:53:19 +0200 | [diff] [blame^] | 142 | statistics_proxy_->OnDecodedFrame(3u, kWidth, kHeight, |
| 143 | VideoContentType::UNSPECIFIED); |
Oskar Sundbom | 8e07c13 | 2018-01-08 16:45:42 +0100 | [diff] [blame] | 144 | EXPECT_EQ(3u, statistics_proxy_->GetStats().qp_sum); |
Ilya Nikolaevskiy | 94150ee | 2018-05-23 11:53:19 +0200 | [diff] [blame^] | 145 | statistics_proxy_->OnDecodedFrame(127u, kWidth, kHeight, |
| 146 | VideoContentType::UNSPECIFIED); |
Oskar Sundbom | 8e07c13 | 2018-01-08 16:45:42 +0100 | [diff] [blame] | 147 | EXPECT_EQ(130u, statistics_proxy_->GetStats().qp_sum); |
sakal | cc452e1 | 2017-02-09 04:53:45 -0800 | [diff] [blame] | 148 | } |
| 149 | |
ilnik | 2e1b40b | 2017-09-04 07:57:17 -0700 | [diff] [blame] | 150 | TEST_F(ReceiveStatisticsProxyTest, ReportsContentType) { |
| 151 | const std::string kRealtimeString("realtime"); |
| 152 | const std::string kScreenshareString("screen"); |
| 153 | EXPECT_EQ(kRealtimeString, videocontenttypehelpers::ToString( |
| 154 | statistics_proxy_->GetStats().content_type)); |
Ilya Nikolaevskiy | 94150ee | 2018-05-23 11:53:19 +0200 | [diff] [blame^] | 155 | statistics_proxy_->OnDecodedFrame(3u, kWidth, kHeight, |
| 156 | VideoContentType::SCREENSHARE); |
ilnik | 2e1b40b | 2017-09-04 07:57:17 -0700 | [diff] [blame] | 157 | EXPECT_EQ(kScreenshareString, videocontenttypehelpers::ToString( |
| 158 | statistics_proxy_->GetStats().content_type)); |
Ilya Nikolaevskiy | 94150ee | 2018-05-23 11:53:19 +0200 | [diff] [blame^] | 159 | statistics_proxy_->OnDecodedFrame(3u, kWidth, kHeight, |
| 160 | VideoContentType::UNSPECIFIED); |
ilnik | 2e1b40b | 2017-09-04 07:57:17 -0700 | [diff] [blame] | 161 | EXPECT_EQ(kRealtimeString, videocontenttypehelpers::ToString( |
| 162 | statistics_proxy_->GetStats().content_type)); |
| 163 | } |
| 164 | |
ilnik | a79cc28 | 2017-08-23 05:24:10 -0700 | [diff] [blame] | 165 | TEST_F(ReceiveStatisticsProxyTest, ReportsMaxInterframeDelay) { |
| 166 | const int64_t kInterframeDelayMs1 = 100; |
| 167 | const int64_t kInterframeDelayMs2 = 200; |
| 168 | const int64_t kInterframeDelayMs3 = 100; |
| 169 | EXPECT_EQ(-1, statistics_proxy_->GetStats().interframe_delay_max_ms); |
Ilya Nikolaevskiy | 94150ee | 2018-05-23 11:53:19 +0200 | [diff] [blame^] | 170 | statistics_proxy_->OnDecodedFrame(3u, kWidth, kHeight, |
| 171 | VideoContentType::UNSPECIFIED); |
ilnik | a79cc28 | 2017-08-23 05:24:10 -0700 | [diff] [blame] | 172 | EXPECT_EQ(-1, statistics_proxy_->GetStats().interframe_delay_max_ms); |
ilnik | f04afde | 2017-07-07 01:26:24 -0700 | [diff] [blame] | 173 | |
| 174 | fake_clock_.AdvanceTimeMilliseconds(kInterframeDelayMs1); |
Ilya Nikolaevskiy | 94150ee | 2018-05-23 11:53:19 +0200 | [diff] [blame^] | 175 | statistics_proxy_->OnDecodedFrame(127u, kWidth, kHeight, |
| 176 | VideoContentType::UNSPECIFIED); |
ilnik | f04afde | 2017-07-07 01:26:24 -0700 | [diff] [blame] | 177 | EXPECT_EQ(kInterframeDelayMs1, |
ilnik | a79cc28 | 2017-08-23 05:24:10 -0700 | [diff] [blame] | 178 | statistics_proxy_->GetStats().interframe_delay_max_ms); |
ilnik | f04afde | 2017-07-07 01:26:24 -0700 | [diff] [blame] | 179 | |
| 180 | fake_clock_.AdvanceTimeMilliseconds(kInterframeDelayMs2); |
Ilya Nikolaevskiy | 94150ee | 2018-05-23 11:53:19 +0200 | [diff] [blame^] | 181 | statistics_proxy_->OnDecodedFrame(127u, kWidth, kHeight, |
| 182 | VideoContentType::UNSPECIFIED); |
ilnik | a79cc28 | 2017-08-23 05:24:10 -0700 | [diff] [blame] | 183 | EXPECT_EQ(kInterframeDelayMs2, |
| 184 | statistics_proxy_->GetStats().interframe_delay_max_ms); |
| 185 | |
| 186 | fake_clock_.AdvanceTimeMilliseconds(kInterframeDelayMs3); |
Ilya Nikolaevskiy | 94150ee | 2018-05-23 11:53:19 +0200 | [diff] [blame^] | 187 | statistics_proxy_->OnDecodedFrame(127u, kWidth, kHeight, |
| 188 | VideoContentType::UNSPECIFIED); |
ilnik | a79cc28 | 2017-08-23 05:24:10 -0700 | [diff] [blame] | 189 | // kInterframeDelayMs3 is smaller than kInterframeDelayMs2. |
| 190 | EXPECT_EQ(kInterframeDelayMs2, |
| 191 | statistics_proxy_->GetStats().interframe_delay_max_ms); |
| 192 | } |
| 193 | |
| 194 | TEST_F(ReceiveStatisticsProxyTest, ReportInterframeDelayInWindow) { |
Ilya Nikolaevskiy | b06b358 | 2017-10-16 17:59:12 +0200 | [diff] [blame] | 195 | const int64_t kInterframeDelayMs1 = 900; |
| 196 | const int64_t kInterframeDelayMs2 = 750; |
| 197 | const int64_t kInterframeDelayMs3 = 700; |
ilnik | a79cc28 | 2017-08-23 05:24:10 -0700 | [diff] [blame] | 198 | EXPECT_EQ(-1, statistics_proxy_->GetStats().interframe_delay_max_ms); |
Ilya Nikolaevskiy | 94150ee | 2018-05-23 11:53:19 +0200 | [diff] [blame^] | 199 | statistics_proxy_->OnDecodedFrame(3u, kWidth, kHeight, |
| 200 | VideoContentType::UNSPECIFIED); |
ilnik | a79cc28 | 2017-08-23 05:24:10 -0700 | [diff] [blame] | 201 | EXPECT_EQ(-1, statistics_proxy_->GetStats().interframe_delay_max_ms); |
| 202 | |
| 203 | fake_clock_.AdvanceTimeMilliseconds(kInterframeDelayMs1); |
Ilya Nikolaevskiy | 94150ee | 2018-05-23 11:53:19 +0200 | [diff] [blame^] | 204 | statistics_proxy_->OnDecodedFrame(127u, kWidth, kHeight, |
| 205 | VideoContentType::UNSPECIFIED); |
ilnik | a79cc28 | 2017-08-23 05:24:10 -0700 | [diff] [blame] | 206 | EXPECT_EQ(kInterframeDelayMs1, |
| 207 | statistics_proxy_->GetStats().interframe_delay_max_ms); |
| 208 | |
| 209 | fake_clock_.AdvanceTimeMilliseconds(kInterframeDelayMs2); |
Ilya Nikolaevskiy | 94150ee | 2018-05-23 11:53:19 +0200 | [diff] [blame^] | 210 | statistics_proxy_->OnDecodedFrame(127u, kWidth, kHeight, |
| 211 | VideoContentType::UNSPECIFIED); |
ilnik | a79cc28 | 2017-08-23 05:24:10 -0700 | [diff] [blame] | 212 | // Still first delay is the maximum |
| 213 | EXPECT_EQ(kInterframeDelayMs1, |
| 214 | statistics_proxy_->GetStats().interframe_delay_max_ms); |
| 215 | |
| 216 | fake_clock_.AdvanceTimeMilliseconds(kInterframeDelayMs3); |
Ilya Nikolaevskiy | 94150ee | 2018-05-23 11:53:19 +0200 | [diff] [blame^] | 217 | statistics_proxy_->OnDecodedFrame(127u, kWidth, kHeight, |
| 218 | VideoContentType::UNSPECIFIED); |
ilnik | a79cc28 | 2017-08-23 05:24:10 -0700 | [diff] [blame] | 219 | // Now the first sample is out of the window, so the second is the maximum. |
| 220 | EXPECT_EQ(kInterframeDelayMs2, |
| 221 | statistics_proxy_->GetStats().interframe_delay_max_ms); |
ilnik | f04afde | 2017-07-07 01:26:24 -0700 | [diff] [blame] | 222 | } |
| 223 | |
sakal | cc452e1 | 2017-02-09 04:53:45 -0800 | [diff] [blame] | 224 | TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameWithoutQpQpSumWontExist) { |
Oskar Sundbom | 8e07c13 | 2018-01-08 16:45:42 +0100 | [diff] [blame] | 225 | EXPECT_EQ(rtc::nullopt, statistics_proxy_->GetStats().qp_sum); |
Ilya Nikolaevskiy | 94150ee | 2018-05-23 11:53:19 +0200 | [diff] [blame^] | 226 | statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, |
ilnik | 00d802b | 2017-04-11 10:34:31 -0700 | [diff] [blame] | 227 | VideoContentType::UNSPECIFIED); |
Oskar Sundbom | 8e07c13 | 2018-01-08 16:45:42 +0100 | [diff] [blame] | 228 | EXPECT_EQ(rtc::nullopt, statistics_proxy_->GetStats().qp_sum); |
sakal | cc452e1 | 2017-02-09 04:53:45 -0800 | [diff] [blame] | 229 | } |
| 230 | |
| 231 | TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameWithoutQpResetsQpSum) { |
Oskar Sundbom | 8e07c13 | 2018-01-08 16:45:42 +0100 | [diff] [blame] | 232 | EXPECT_EQ(rtc::nullopt, statistics_proxy_->GetStats().qp_sum); |
Ilya Nikolaevskiy | 94150ee | 2018-05-23 11:53:19 +0200 | [diff] [blame^] | 233 | statistics_proxy_->OnDecodedFrame(3u, kWidth, kHeight, |
| 234 | VideoContentType::UNSPECIFIED); |
Oskar Sundbom | 8e07c13 | 2018-01-08 16:45:42 +0100 | [diff] [blame] | 235 | EXPECT_EQ(3u, statistics_proxy_->GetStats().qp_sum); |
Ilya Nikolaevskiy | 94150ee | 2018-05-23 11:53:19 +0200 | [diff] [blame^] | 236 | statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, |
ilnik | 00d802b | 2017-04-11 10:34:31 -0700 | [diff] [blame] | 237 | VideoContentType::UNSPECIFIED); |
Oskar Sundbom | 8e07c13 | 2018-01-08 16:45:42 +0100 | [diff] [blame] | 238 | EXPECT_EQ(rtc::nullopt, statistics_proxy_->GetStats().qp_sum); |
sakal | cc452e1 | 2017-02-09 04:53:45 -0800 | [diff] [blame] | 239 | } |
| 240 | |
hbos | 50cfe1f | 2017-01-23 07:21:55 -0800 | [diff] [blame] | 241 | TEST_F(ReceiveStatisticsProxyTest, OnRenderedFrameIncreasesFramesRendered) { |
| 242 | EXPECT_EQ(0u, statistics_proxy_->GetStats().frames_rendered); |
ilnik | 00d802b | 2017-04-11 10:34:31 -0700 | [diff] [blame] | 243 | webrtc::VideoFrame frame(webrtc::I420Buffer::Create(1, 1), 0, 0, |
| 244 | webrtc::kVideoRotation_0); |
hbos | 50cfe1f | 2017-01-23 07:21:55 -0800 | [diff] [blame] | 245 | for (uint32_t i = 1; i <= 3; ++i) { |
| 246 | statistics_proxy_->OnRenderedFrame(frame); |
| 247 | EXPECT_EQ(i, statistics_proxy_->GetStats().frames_rendered); |
| 248 | } |
| 249 | } |
| 250 | |
asapersson | 46c4e3c | 2016-11-03 06:48:19 -0700 | [diff] [blame] | 251 | TEST_F(ReceiveStatisticsProxyTest, GetStatsReportsSsrc) { |
| 252 | EXPECT_EQ(kRemoteSsrc, statistics_proxy_->GetStats().ssrc); |
| 253 | } |
| 254 | |
| 255 | TEST_F(ReceiveStatisticsProxyTest, GetStatsReportsIncomingPayloadType) { |
| 256 | const int kPayloadType = 111; |
| 257 | statistics_proxy_->OnIncomingPayloadType(kPayloadType); |
| 258 | EXPECT_EQ(kPayloadType, statistics_proxy_->GetStats().current_payload_type); |
| 259 | } |
| 260 | |
asapersson | 6966bd5 | 2017-01-03 00:44:06 -0800 | [diff] [blame] | 261 | TEST_F(ReceiveStatisticsProxyTest, GetStatsReportsDecoderImplementationName) { |
| 262 | const char* kName = "decoderName"; |
| 263 | statistics_proxy_->OnDecoderImplementationName(kName); |
| 264 | EXPECT_STREQ( |
| 265 | kName, statistics_proxy_->GetStats().decoder_implementation_name.c_str()); |
| 266 | } |
| 267 | |
philipel | a45102f | 2017-02-22 05:30:39 -0800 | [diff] [blame] | 268 | TEST_F(ReceiveStatisticsProxyTest, GetStatsReportsOnCompleteFrame) { |
| 269 | const int kFrameSizeBytes = 1000; |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 270 | statistics_proxy_->OnCompleteFrame(true, kFrameSizeBytes, |
| 271 | VideoContentType::UNSPECIFIED); |
philipel | a45102f | 2017-02-22 05:30:39 -0800 | [diff] [blame] | 272 | VideoReceiveStream::Stats stats = statistics_proxy_->GetStats(); |
| 273 | EXPECT_EQ(1, stats.network_frame_rate); |
philipel | a45102f | 2017-02-22 05:30:39 -0800 | [diff] [blame] | 274 | EXPECT_EQ(1, stats.frame_counts.key_frames); |
| 275 | EXPECT_EQ(0, stats.frame_counts.delta_frames); |
asapersson | 46c4e3c | 2016-11-03 06:48:19 -0700 | [diff] [blame] | 276 | } |
| 277 | |
| 278 | TEST_F(ReceiveStatisticsProxyTest, GetStatsReportsDecodeTimingStats) { |
| 279 | const int kDecodeMs = 1; |
| 280 | const int kMaxDecodeMs = 2; |
| 281 | const int kCurrentDelayMs = 3; |
| 282 | const int kTargetDelayMs = 4; |
| 283 | const int kJitterBufferMs = 5; |
| 284 | const int kMinPlayoutDelayMs = 6; |
| 285 | const int kRenderDelayMs = 7; |
| 286 | const int64_t kRttMs = 8; |
philipel | a45102f | 2017-02-22 05:30:39 -0800 | [diff] [blame] | 287 | statistics_proxy_->OnRttUpdate(kRttMs, 0); |
| 288 | statistics_proxy_->OnFrameBufferTimingsUpdated( |
asapersson | 46c4e3c | 2016-11-03 06:48:19 -0700 | [diff] [blame] | 289 | kDecodeMs, kMaxDecodeMs, kCurrentDelayMs, kTargetDelayMs, kJitterBufferMs, |
philipel | a45102f | 2017-02-22 05:30:39 -0800 | [diff] [blame] | 290 | kMinPlayoutDelayMs, kRenderDelayMs); |
asapersson | 46c4e3c | 2016-11-03 06:48:19 -0700 | [diff] [blame] | 291 | VideoReceiveStream::Stats stats = statistics_proxy_->GetStats(); |
| 292 | EXPECT_EQ(kDecodeMs, stats.decode_ms); |
| 293 | EXPECT_EQ(kMaxDecodeMs, stats.max_decode_ms); |
| 294 | EXPECT_EQ(kCurrentDelayMs, stats.current_delay_ms); |
| 295 | EXPECT_EQ(kTargetDelayMs, stats.target_delay_ms); |
| 296 | EXPECT_EQ(kJitterBufferMs, stats.jitter_buffer_ms); |
| 297 | EXPECT_EQ(kMinPlayoutDelayMs, stats.min_playout_delay_ms); |
| 298 | EXPECT_EQ(kRenderDelayMs, stats.render_delay_ms); |
| 299 | } |
| 300 | |
asapersson | 6966bd5 | 2017-01-03 00:44:06 -0800 | [diff] [blame] | 301 | TEST_F(ReceiveStatisticsProxyTest, GetStatsReportsRtcpPacketTypeCounts) { |
| 302 | const uint32_t kFirPackets = 33; |
| 303 | const uint32_t kPliPackets = 44; |
| 304 | const uint32_t kNackPackets = 55; |
| 305 | RtcpPacketTypeCounter counter; |
| 306 | counter.fir_packets = kFirPackets; |
| 307 | counter.pli_packets = kPliPackets; |
| 308 | counter.nack_packets = kNackPackets; |
| 309 | statistics_proxy_->RtcpPacketTypesCounterUpdated(kRemoteSsrc, counter); |
| 310 | VideoReceiveStream::Stats stats = statistics_proxy_->GetStats(); |
| 311 | EXPECT_EQ(kFirPackets, stats.rtcp_packet_type_counts.fir_packets); |
| 312 | EXPECT_EQ(kPliPackets, stats.rtcp_packet_type_counts.pli_packets); |
| 313 | EXPECT_EQ(kNackPackets, stats.rtcp_packet_type_counts.nack_packets); |
| 314 | } |
| 315 | |
| 316 | TEST_F(ReceiveStatisticsProxyTest, |
| 317 | GetStatsReportsNoRtcpPacketTypeCountsForUnknownSsrc) { |
| 318 | RtcpPacketTypeCounter counter; |
| 319 | counter.fir_packets = 33; |
| 320 | statistics_proxy_->RtcpPacketTypesCounterUpdated(kRemoteSsrc + 1, counter); |
| 321 | EXPECT_EQ(0u, |
| 322 | statistics_proxy_->GetStats().rtcp_packet_type_counts.fir_packets); |
| 323 | } |
| 324 | |
| 325 | TEST_F(ReceiveStatisticsProxyTest, GetStatsReportsFrameCounts) { |
| 326 | const int kKeyFrames = 3; |
| 327 | const int kDeltaFrames = 22; |
| 328 | FrameCounts frame_counts; |
| 329 | frame_counts.key_frames = kKeyFrames; |
| 330 | frame_counts.delta_frames = kDeltaFrames; |
| 331 | statistics_proxy_->OnFrameCountsUpdated(frame_counts); |
| 332 | VideoReceiveStream::Stats stats = statistics_proxy_->GetStats(); |
| 333 | EXPECT_EQ(kKeyFrames, stats.frame_counts.key_frames); |
| 334 | EXPECT_EQ(kDeltaFrames, stats.frame_counts.delta_frames); |
| 335 | } |
| 336 | |
asapersson | 46c4e3c | 2016-11-03 06:48:19 -0700 | [diff] [blame] | 337 | TEST_F(ReceiveStatisticsProxyTest, GetStatsReportsDiscardedPackets) { |
| 338 | const int kDiscardedPackets = 12; |
| 339 | statistics_proxy_->OnDiscardedPacketsUpdated(kDiscardedPackets); |
| 340 | EXPECT_EQ(kDiscardedPackets, statistics_proxy_->GetStats().discarded_packets); |
| 341 | } |
| 342 | |
asapersson | 6966bd5 | 2017-01-03 00:44:06 -0800 | [diff] [blame] | 343 | TEST_F(ReceiveStatisticsProxyTest, GetStatsReportsRtcpStats) { |
| 344 | const uint8_t kFracLost = 0; |
Harald Alvestrand | c7c4191 | 2017-12-08 09:59:34 +0100 | [diff] [blame] | 345 | const int32_t kCumLost = 1; |
asapersson | 6966bd5 | 2017-01-03 00:44:06 -0800 | [diff] [blame] | 346 | const uint32_t kExtSeqNum = 10; |
| 347 | const uint32_t kJitter = 4; |
| 348 | |
| 349 | RtcpStatistics rtcp_stats; |
| 350 | rtcp_stats.fraction_lost = kFracLost; |
srte | 186d9c3 | 2017-08-04 05:03:53 -0700 | [diff] [blame] | 351 | rtcp_stats.packets_lost = kCumLost; |
| 352 | rtcp_stats.extended_highest_sequence_number = kExtSeqNum; |
asapersson | 6966bd5 | 2017-01-03 00:44:06 -0800 | [diff] [blame] | 353 | rtcp_stats.jitter = kJitter; |
| 354 | statistics_proxy_->StatisticsUpdated(rtcp_stats, kRemoteSsrc); |
| 355 | |
| 356 | VideoReceiveStream::Stats stats = statistics_proxy_->GetStats(); |
| 357 | EXPECT_EQ(kFracLost, stats.rtcp_stats.fraction_lost); |
srte | 186d9c3 | 2017-08-04 05:03:53 -0700 | [diff] [blame] | 358 | EXPECT_EQ(kCumLost, stats.rtcp_stats.packets_lost); |
| 359 | EXPECT_EQ(kExtSeqNum, stats.rtcp_stats.extended_highest_sequence_number); |
asapersson | 6966bd5 | 2017-01-03 00:44:06 -0800 | [diff] [blame] | 360 | EXPECT_EQ(kJitter, stats.rtcp_stats.jitter); |
| 361 | } |
| 362 | |
| 363 | TEST_F(ReceiveStatisticsProxyTest, GetStatsReportsCName) { |
| 364 | const char* kName = "cName"; |
| 365 | statistics_proxy_->CNameChanged(kName, kRemoteSsrc); |
| 366 | EXPECT_STREQ(kName, statistics_proxy_->GetStats().c_name.c_str()); |
| 367 | } |
| 368 | |
| 369 | TEST_F(ReceiveStatisticsProxyTest, GetStatsReportsNoCNameForUnknownSsrc) { |
| 370 | const char* kName = "cName"; |
| 371 | statistics_proxy_->CNameChanged(kName, kRemoteSsrc + 1); |
| 372 | EXPECT_STREQ("", statistics_proxy_->GetStats().c_name.c_str()); |
| 373 | } |
| 374 | |
ilnik | 2edc684 | 2017-07-06 03:06:50 -0700 | [diff] [blame] | 375 | TEST_F(ReceiveStatisticsProxyTest, |
ilnik | 75204c5 | 2017-09-04 03:35:40 -0700 | [diff] [blame] | 376 | ReportsLongestTimingFrameInfo) { |
ilnik | 2edc684 | 2017-07-06 03:06:50 -0700 | [diff] [blame] | 377 | const int64_t kShortEndToEndDelay = 10; |
| 378 | const int64_t kMedEndToEndDelay = 20; |
| 379 | const int64_t kLongEndToEndDelay = 100; |
| 380 | const uint32_t kExpectedRtpTimestamp = 2; |
| 381 | TimingFrameInfo info; |
| 382 | rtc::Optional<TimingFrameInfo> result; |
| 383 | info.rtp_timestamp = kExpectedRtpTimestamp - 1; |
| 384 | info.capture_time_ms = 0; |
| 385 | info.decode_finish_ms = kShortEndToEndDelay; |
| 386 | statistics_proxy_->OnTimingFrameInfoUpdated(info); |
| 387 | info.rtp_timestamp = |
| 388 | kExpectedRtpTimestamp; // this frame should be reported in the end. |
| 389 | info.capture_time_ms = 0; |
| 390 | info.decode_finish_ms = kLongEndToEndDelay; |
| 391 | statistics_proxy_->OnTimingFrameInfoUpdated(info); |
| 392 | info.rtp_timestamp = kExpectedRtpTimestamp + 1; |
| 393 | info.capture_time_ms = 0; |
| 394 | info.decode_finish_ms = kMedEndToEndDelay; |
| 395 | statistics_proxy_->OnTimingFrameInfoUpdated(info); |
ilnik | 75204c5 | 2017-09-04 03:35:40 -0700 | [diff] [blame] | 396 | result = statistics_proxy_->GetStats().timing_frame_info; |
ilnik | 2edc684 | 2017-07-06 03:06:50 -0700 | [diff] [blame] | 397 | EXPECT_TRUE(result); |
| 398 | EXPECT_EQ(kExpectedRtpTimestamp, result->rtp_timestamp); |
| 399 | } |
| 400 | |
ilnik | 75204c5 | 2017-09-04 03:35:40 -0700 | [diff] [blame] | 401 | TEST_F(ReceiveStatisticsProxyTest, RespectsReportingIntervalForTimingFrames) { |
| 402 | TimingFrameInfo info; |
ilnik | 2edc684 | 2017-07-06 03:06:50 -0700 | [diff] [blame] | 403 | const int64_t kShortEndToEndDelay = 10; |
| 404 | const uint32_t kExpectedRtpTimestamp = 2; |
ilnik | 75204c5 | 2017-09-04 03:35:40 -0700 | [diff] [blame] | 405 | const int64_t kShortDelayMs = 1000; |
| 406 | const int64_t kLongDelayMs = 10000; |
ilnik | 2edc684 | 2017-07-06 03:06:50 -0700 | [diff] [blame] | 407 | rtc::Optional<TimingFrameInfo> result; |
| 408 | info.rtp_timestamp = kExpectedRtpTimestamp; |
| 409 | info.capture_time_ms = 0; |
| 410 | info.decode_finish_ms = kShortEndToEndDelay; |
| 411 | statistics_proxy_->OnTimingFrameInfoUpdated(info); |
ilnik | 75204c5 | 2017-09-04 03:35:40 -0700 | [diff] [blame] | 412 | fake_clock_.AdvanceTimeMilliseconds(kShortDelayMs); |
| 413 | result = statistics_proxy_->GetStats().timing_frame_info; |
ilnik | 2edc684 | 2017-07-06 03:06:50 -0700 | [diff] [blame] | 414 | EXPECT_TRUE(result); |
| 415 | EXPECT_EQ(kExpectedRtpTimestamp, result->rtp_timestamp); |
ilnik | 75204c5 | 2017-09-04 03:35:40 -0700 | [diff] [blame] | 416 | fake_clock_.AdvanceTimeMilliseconds(kLongDelayMs); |
| 417 | result = statistics_proxy_->GetStats().timing_frame_info; |
ilnik | 2edc684 | 2017-07-06 03:06:50 -0700 | [diff] [blame] | 418 | EXPECT_FALSE(result); |
| 419 | } |
| 420 | |
asapersson | 46c4e3c | 2016-11-03 06:48:19 -0700 | [diff] [blame] | 421 | TEST_F(ReceiveStatisticsProxyTest, LifetimeHistogramIsUpdated) { |
| 422 | const int64_t kTimeSec = 3; |
| 423 | fake_clock_.AdvanceTimeMilliseconds(kTimeSec * 1000); |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 424 | // Need at least one frame to report stream lifetime. |
| 425 | statistics_proxy_->OnCompleteFrame(true, 1000, VideoContentType::UNSPECIFIED); |
asapersson | 46c4e3c | 2016-11-03 06:48:19 -0700 | [diff] [blame] | 426 | // Histograms are updated when the statistics_proxy_ is deleted. |
| 427 | statistics_proxy_.reset(); |
| 428 | EXPECT_EQ(1, |
| 429 | metrics::NumSamples("WebRTC.Video.ReceiveStreamLifetimeInSeconds")); |
| 430 | EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.ReceiveStreamLifetimeInSeconds", |
| 431 | kTimeSec)); |
| 432 | } |
| 433 | |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 434 | TEST_F(ReceiveStatisticsProxyTest, |
| 435 | LifetimeHistogramNotReportedForEmptyStreams) { |
| 436 | const int64_t kTimeSec = 3; |
| 437 | fake_clock_.AdvanceTimeMilliseconds(kTimeSec * 1000); |
| 438 | // No frames received. |
| 439 | // Histograms are updated when the statistics_proxy_ is deleted. |
| 440 | statistics_proxy_.reset(); |
| 441 | EXPECT_EQ(0, |
| 442 | metrics::NumSamples("WebRTC.Video.ReceiveStreamLifetimeInSeconds")); |
| 443 | } |
| 444 | |
palmkvist | a40672a | 2017-01-13 05:58:34 -0800 | [diff] [blame] | 445 | TEST_F(ReceiveStatisticsProxyTest, BadCallHistogramsAreUpdated) { |
| 446 | // Based on the tuning parameters this will produce 7 uncertain states, |
| 447 | // then 10 certainly bad states. There has to be 10 certain states before |
| 448 | // any histograms are recorded. |
| 449 | const int kNumBadSamples = 17; |
| 450 | |
| 451 | StreamDataCounters counters; |
| 452 | counters.first_packet_time_ms = fake_clock_.TimeInMilliseconds(); |
| 453 | statistics_proxy_->DataCountersUpdated(counters, config_.rtp.remote_ssrc); |
| 454 | |
| 455 | for (int i = 0; i < kNumBadSamples; ++i) { |
| 456 | // Since OnRenderedFrame is never called the fps in each sample will be 0, |
| 457 | // i.e. bad |
| 458 | fake_clock_.AdvanceTimeMilliseconds(1000); |
| 459 | statistics_proxy_->OnIncomingRate(0, 0); |
| 460 | } |
| 461 | // Histograms are updated when the statistics_proxy_ is deleted. |
| 462 | statistics_proxy_.reset(); |
| 463 | EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.BadCall.Any")); |
| 464 | EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.BadCall.Any", 100)); |
| 465 | |
| 466 | EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.BadCall.FrameRate")); |
| 467 | EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.BadCall.FrameRate", 100)); |
| 468 | |
| 469 | EXPECT_EQ(0, metrics::NumSamples("WebRTC.Video.BadCall.FrameRateVariance")); |
| 470 | |
| 471 | EXPECT_EQ(0, metrics::NumSamples("WebRTC.Video.BadCall.Qp")); |
| 472 | } |
| 473 | |
asapersson | 0c43f77 | 2016-11-30 01:42:26 -0800 | [diff] [blame] | 474 | TEST_F(ReceiveStatisticsProxyTest, PacketLossHistogramIsUpdated) { |
| 475 | const uint32_t kCumLost1 = 1; |
| 476 | const uint32_t kExtSeqNum1 = 10; |
| 477 | const uint32_t kCumLost2 = 2; |
| 478 | const uint32_t kExtSeqNum2 = 20; |
| 479 | |
| 480 | // One report block received. |
| 481 | RtcpStatistics rtcp_stats1; |
srte | 186d9c3 | 2017-08-04 05:03:53 -0700 | [diff] [blame] | 482 | rtcp_stats1.packets_lost = kCumLost1; |
| 483 | rtcp_stats1.extended_highest_sequence_number = kExtSeqNum1; |
asapersson | 0c43f77 | 2016-11-30 01:42:26 -0800 | [diff] [blame] | 484 | statistics_proxy_->StatisticsUpdated(rtcp_stats1, kRemoteSsrc); |
| 485 | |
| 486 | // Two report blocks received. |
| 487 | RtcpStatistics rtcp_stats2; |
srte | 186d9c3 | 2017-08-04 05:03:53 -0700 | [diff] [blame] | 488 | rtcp_stats2.packets_lost = kCumLost2; |
| 489 | rtcp_stats2.extended_highest_sequence_number = kExtSeqNum2; |
asapersson | 0c43f77 | 2016-11-30 01:42:26 -0800 | [diff] [blame] | 490 | statistics_proxy_->StatisticsUpdated(rtcp_stats2, kRemoteSsrc); |
| 491 | |
| 492 | // Two received report blocks but min run time has not passed. |
| 493 | fake_clock_.AdvanceTimeMilliseconds(metrics::kMinRunTimeInSeconds * 1000 - 1); |
| 494 | SetUp(); // Reset stat proxy causes histograms to be updated. |
| 495 | EXPECT_EQ(0, |
| 496 | metrics::NumSamples("WebRTC.Video.ReceivedPacketsLostInPercent")); |
| 497 | |
| 498 | // Two report blocks received. |
| 499 | statistics_proxy_->StatisticsUpdated(rtcp_stats1, kRemoteSsrc); |
| 500 | statistics_proxy_->StatisticsUpdated(rtcp_stats2, kRemoteSsrc); |
| 501 | |
| 502 | // Two received report blocks and min run time has passed. |
| 503 | fake_clock_.AdvanceTimeMilliseconds(metrics::kMinRunTimeInSeconds * 1000); |
| 504 | SetUp(); |
| 505 | EXPECT_EQ(1, |
| 506 | metrics::NumSamples("WebRTC.Video.ReceivedPacketsLostInPercent")); |
| 507 | EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.ReceivedPacketsLostInPercent", |
| 508 | (kCumLost2 - kCumLost1) * 100 / |
| 509 | (kExtSeqNum2 - kExtSeqNum1))); |
| 510 | } |
| 511 | |
| 512 | TEST_F(ReceiveStatisticsProxyTest, |
| 513 | PacketLossHistogramIsNotUpdatedIfLessThanTwoReportBlocksAreReceived) { |
| 514 | RtcpStatistics rtcp_stats1; |
srte | 186d9c3 | 2017-08-04 05:03:53 -0700 | [diff] [blame] | 515 | rtcp_stats1.packets_lost = 1; |
| 516 | rtcp_stats1.extended_highest_sequence_number = 10; |
asapersson | 0c43f77 | 2016-11-30 01:42:26 -0800 | [diff] [blame] | 517 | |
| 518 | // Min run time has passed but no received report block. |
| 519 | fake_clock_.AdvanceTimeMilliseconds(metrics::kMinRunTimeInSeconds * 1000); |
| 520 | SetUp(); // Reset stat proxy causes histograms to be updated. |
| 521 | EXPECT_EQ(0, |
| 522 | metrics::NumSamples("WebRTC.Video.ReceivedPacketsLostInPercent")); |
| 523 | |
| 524 | // Min run time has passed but only one received report block. |
| 525 | statistics_proxy_->StatisticsUpdated(rtcp_stats1, kRemoteSsrc); |
| 526 | fake_clock_.AdvanceTimeMilliseconds(metrics::kMinRunTimeInSeconds * 1000); |
| 527 | SetUp(); |
| 528 | EXPECT_EQ(0, |
| 529 | metrics::NumSamples("WebRTC.Video.ReceivedPacketsLostInPercent")); |
| 530 | } |
| 531 | |
asapersson | 2077f2f | 2017-05-11 05:37:35 -0700 | [diff] [blame] | 532 | TEST_F(ReceiveStatisticsProxyTest, GetStatsReportsAvSyncOffset) { |
| 533 | const int64_t kSyncOffsetMs = 22; |
| 534 | const double kFreqKhz = 90.0; |
| 535 | EXPECT_EQ(std::numeric_limits<int>::max(), |
| 536 | statistics_proxy_->GetStats().sync_offset_ms); |
| 537 | statistics_proxy_->OnSyncOffsetUpdated(kSyncOffsetMs, kFreqKhz); |
| 538 | EXPECT_EQ(kSyncOffsetMs, statistics_proxy_->GetStats().sync_offset_ms); |
| 539 | } |
| 540 | |
asapersson | 46c4e3c | 2016-11-03 06:48:19 -0700 | [diff] [blame] | 541 | TEST_F(ReceiveStatisticsProxyTest, AvSyncOffsetHistogramIsUpdated) { |
| 542 | const int64_t kSyncOffsetMs = 22; |
| 543 | const double kFreqKhz = 90.0; |
| 544 | for (int i = 0; i < kMinRequiredSamples; ++i) |
| 545 | statistics_proxy_->OnSyncOffsetUpdated(kSyncOffsetMs, kFreqKhz); |
| 546 | // Histograms are updated when the statistics_proxy_ is deleted. |
| 547 | statistics_proxy_.reset(); |
| 548 | EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.AVSyncOffsetInMs")); |
| 549 | EXPECT_EQ(1, |
| 550 | metrics::NumEvents("WebRTC.Video.AVSyncOffsetInMs", kSyncOffsetMs)); |
| 551 | } |
| 552 | |
asapersson | de9e5ff | 2016-11-02 07:14:03 -0700 | [diff] [blame] | 553 | TEST_F(ReceiveStatisticsProxyTest, RtpToNtpFrequencyOffsetHistogramIsUpdated) { |
| 554 | const int64_t kSyncOffsetMs = 22; |
| 555 | const double kFreqKhz = 90.0; |
| 556 | statistics_proxy_->OnSyncOffsetUpdated(kSyncOffsetMs, kFreqKhz); |
| 557 | statistics_proxy_->OnSyncOffsetUpdated(kSyncOffsetMs, kFreqKhz + 2.2); |
| 558 | fake_clock_.AdvanceTimeMilliseconds(kFreqOffsetProcessIntervalInMs); |
| 559 | // Process interval passed, max diff: 2. |
| 560 | statistics_proxy_->OnSyncOffsetUpdated(kSyncOffsetMs, kFreqKhz + 1.1); |
| 561 | statistics_proxy_->OnSyncOffsetUpdated(kSyncOffsetMs, kFreqKhz - 4.2); |
| 562 | statistics_proxy_->OnSyncOffsetUpdated(kSyncOffsetMs, kFreqKhz - 0.9); |
| 563 | fake_clock_.AdvanceTimeMilliseconds(kFreqOffsetProcessIntervalInMs); |
| 564 | // Process interval passed, max diff: 4. |
| 565 | statistics_proxy_->OnSyncOffsetUpdated(kSyncOffsetMs, kFreqKhz); |
| 566 | statistics_proxy_.reset(); |
| 567 | // Average reported: (2 + 4) / 2 = 3. |
| 568 | EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.RtpToNtpFreqOffsetInKhz")); |
| 569 | EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.RtpToNtpFreqOffsetInKhz", 3)); |
| 570 | } |
| 571 | |
asapersson | 6966bd5 | 2017-01-03 00:44:06 -0800 | [diff] [blame] | 572 | TEST_F(ReceiveStatisticsProxyTest, Vp8QpHistogramIsUpdated) { |
| 573 | const int kQp = 22; |
| 574 | EncodedImage encoded_image; |
| 575 | encoded_image.qp_ = kQp; |
| 576 | CodecSpecificInfo codec_info; |
| 577 | codec_info.codecType = kVideoCodecVP8; |
| 578 | |
| 579 | for (int i = 0; i < kMinRequiredSamples; ++i) |
| 580 | statistics_proxy_->OnPreDecode(encoded_image, &codec_info); |
| 581 | |
| 582 | statistics_proxy_.reset(); |
| 583 | EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.Decoded.Vp8.Qp")); |
| 584 | EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.Decoded.Vp8.Qp", kQp)); |
| 585 | } |
| 586 | |
| 587 | TEST_F(ReceiveStatisticsProxyTest, Vp8QpHistogramIsNotUpdatedForTooFewSamples) { |
| 588 | EncodedImage encoded_image; |
| 589 | encoded_image.qp_ = 22; |
| 590 | CodecSpecificInfo codec_info; |
| 591 | codec_info.codecType = kVideoCodecVP8; |
| 592 | |
| 593 | for (int i = 0; i < kMinRequiredSamples - 1; ++i) |
| 594 | statistics_proxy_->OnPreDecode(encoded_image, &codec_info); |
| 595 | |
| 596 | statistics_proxy_.reset(); |
| 597 | EXPECT_EQ(0, metrics::NumSamples("WebRTC.Video.Decoded.Vp8.Qp")); |
| 598 | } |
| 599 | |
| 600 | TEST_F(ReceiveStatisticsProxyTest, Vp8QpHistogramIsNotUpdatedIfNoQpValue) { |
| 601 | EncodedImage encoded_image; |
| 602 | CodecSpecificInfo codec_info; |
| 603 | codec_info.codecType = kVideoCodecVP8; |
| 604 | |
| 605 | for (int i = 0; i < kMinRequiredSamples; ++i) |
| 606 | statistics_proxy_->OnPreDecode(encoded_image, &codec_info); |
| 607 | |
| 608 | statistics_proxy_.reset(); |
| 609 | EXPECT_EQ(0, metrics::NumSamples("WebRTC.Video.Decoded.Vp8.Qp")); |
| 610 | } |
| 611 | |
asapersson | b99baf8 | 2017-04-20 04:05:43 -0700 | [diff] [blame] | 612 | TEST_F(ReceiveStatisticsProxyTest, |
| 613 | KeyFrameHistogramNotUpdatedForTooFewSamples) { |
| 614 | const bool kIsKeyFrame = false; |
| 615 | const int kFrameSizeBytes = 1000; |
| 616 | |
| 617 | for (int i = 0; i < kMinRequiredSamples - 1; ++i) |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 618 | statistics_proxy_->OnCompleteFrame(kIsKeyFrame, kFrameSizeBytes, |
| 619 | VideoContentType::UNSPECIFIED); |
asapersson | b99baf8 | 2017-04-20 04:05:43 -0700 | [diff] [blame] | 620 | |
| 621 | EXPECT_EQ(0, statistics_proxy_->GetStats().frame_counts.key_frames); |
| 622 | EXPECT_EQ(kMinRequiredSamples - 1, |
| 623 | statistics_proxy_->GetStats().frame_counts.delta_frames); |
| 624 | |
| 625 | statistics_proxy_.reset(); |
| 626 | EXPECT_EQ(0, metrics::NumSamples("WebRTC.Video.KeyFramesReceivedInPermille")); |
| 627 | } |
| 628 | |
| 629 | TEST_F(ReceiveStatisticsProxyTest, |
| 630 | KeyFrameHistogramUpdatedForMinRequiredSamples) { |
| 631 | const bool kIsKeyFrame = false; |
| 632 | const int kFrameSizeBytes = 1000; |
| 633 | |
| 634 | for (int i = 0; i < kMinRequiredSamples; ++i) |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 635 | statistics_proxy_->OnCompleteFrame(kIsKeyFrame, kFrameSizeBytes, |
| 636 | VideoContentType::UNSPECIFIED); |
asapersson | b99baf8 | 2017-04-20 04:05:43 -0700 | [diff] [blame] | 637 | |
| 638 | EXPECT_EQ(0, statistics_proxy_->GetStats().frame_counts.key_frames); |
| 639 | EXPECT_EQ(kMinRequiredSamples, |
| 640 | statistics_proxy_->GetStats().frame_counts.delta_frames); |
| 641 | |
| 642 | statistics_proxy_.reset(); |
| 643 | EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.KeyFramesReceivedInPermille")); |
| 644 | EXPECT_EQ(1, |
| 645 | metrics::NumEvents("WebRTC.Video.KeyFramesReceivedInPermille", 0)); |
| 646 | } |
| 647 | |
| 648 | TEST_F(ReceiveStatisticsProxyTest, KeyFrameHistogramIsUpdated) { |
| 649 | const int kFrameSizeBytes = 1000; |
| 650 | |
| 651 | for (int i = 0; i < kMinRequiredSamples; ++i) |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 652 | statistics_proxy_->OnCompleteFrame(true, kFrameSizeBytes, |
| 653 | VideoContentType::UNSPECIFIED); |
asapersson | b99baf8 | 2017-04-20 04:05:43 -0700 | [diff] [blame] | 654 | |
| 655 | for (int i = 0; i < kMinRequiredSamples; ++i) |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 656 | statistics_proxy_->OnCompleteFrame(false, kFrameSizeBytes, |
| 657 | VideoContentType::UNSPECIFIED); |
asapersson | b99baf8 | 2017-04-20 04:05:43 -0700 | [diff] [blame] | 658 | |
| 659 | EXPECT_EQ(kMinRequiredSamples, |
| 660 | statistics_proxy_->GetStats().frame_counts.key_frames); |
| 661 | EXPECT_EQ(kMinRequiredSamples, |
| 662 | statistics_proxy_->GetStats().frame_counts.delta_frames); |
| 663 | |
| 664 | statistics_proxy_.reset(); |
| 665 | EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.KeyFramesReceivedInPermille")); |
| 666 | EXPECT_EQ( |
| 667 | 1, metrics::NumEvents("WebRTC.Video.KeyFramesReceivedInPermille", 500)); |
| 668 | } |
| 669 | |
| 670 | TEST_F(ReceiveStatisticsProxyTest, TimingHistogramsNotUpdatedForTooFewSamples) { |
| 671 | const int kDecodeMs = 1; |
| 672 | const int kMaxDecodeMs = 2; |
| 673 | const int kCurrentDelayMs = 3; |
| 674 | const int kTargetDelayMs = 4; |
| 675 | const int kJitterBufferMs = 5; |
| 676 | const int kMinPlayoutDelayMs = 6; |
| 677 | const int kRenderDelayMs = 7; |
| 678 | |
| 679 | for (int i = 0; i < kMinRequiredSamples - 1; ++i) { |
| 680 | statistics_proxy_->OnFrameBufferTimingsUpdated( |
| 681 | kDecodeMs, kMaxDecodeMs, kCurrentDelayMs, kTargetDelayMs, |
| 682 | kJitterBufferMs, kMinPlayoutDelayMs, kRenderDelayMs); |
| 683 | } |
| 684 | |
| 685 | statistics_proxy_.reset(); |
| 686 | EXPECT_EQ(0, metrics::NumSamples("WebRTC.Video.DecodeTimeInMs")); |
| 687 | EXPECT_EQ(0, metrics::NumSamples("WebRTC.Video.JitterBufferDelayInMs")); |
| 688 | EXPECT_EQ(0, metrics::NumSamples("WebRTC.Video.TargetDelayInMs")); |
| 689 | EXPECT_EQ(0, metrics::NumSamples("WebRTC.Video.CurrentDelayInMs")); |
| 690 | EXPECT_EQ(0, metrics::NumSamples("WebRTC.Video.OnewayDelayInMs")); |
| 691 | } |
| 692 | |
| 693 | TEST_F(ReceiveStatisticsProxyTest, TimingHistogramsAreUpdated) { |
| 694 | const int kDecodeMs = 1; |
| 695 | const int kMaxDecodeMs = 2; |
| 696 | const int kCurrentDelayMs = 3; |
| 697 | const int kTargetDelayMs = 4; |
| 698 | const int kJitterBufferMs = 5; |
| 699 | const int kMinPlayoutDelayMs = 6; |
| 700 | const int kRenderDelayMs = 7; |
| 701 | |
| 702 | for (int i = 0; i < kMinRequiredSamples; ++i) { |
| 703 | statistics_proxy_->OnFrameBufferTimingsUpdated( |
| 704 | kDecodeMs, kMaxDecodeMs, kCurrentDelayMs, kTargetDelayMs, |
| 705 | kJitterBufferMs, kMinPlayoutDelayMs, kRenderDelayMs); |
| 706 | } |
| 707 | |
| 708 | statistics_proxy_.reset(); |
| 709 | EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.DecodeTimeInMs")); |
| 710 | EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.JitterBufferDelayInMs")); |
| 711 | EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.TargetDelayInMs")); |
| 712 | EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.CurrentDelayInMs")); |
| 713 | EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.OnewayDelayInMs")); |
| 714 | |
| 715 | EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.DecodeTimeInMs", kDecodeMs)); |
| 716 | EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.JitterBufferDelayInMs", |
| 717 | kJitterBufferMs)); |
| 718 | EXPECT_EQ(1, |
| 719 | metrics::NumEvents("WebRTC.Video.TargetDelayInMs", kTargetDelayMs)); |
| 720 | EXPECT_EQ( |
| 721 | 1, metrics::NumEvents("WebRTC.Video.CurrentDelayInMs", kCurrentDelayMs)); |
| 722 | EXPECT_EQ(1, |
| 723 | metrics::NumEvents("WebRTC.Video.OnewayDelayInMs", kTargetDelayMs)); |
| 724 | } |
| 725 | |
sprang | 948b275 | 2017-05-04 02:47:13 -0700 | [diff] [blame] | 726 | TEST_F(ReceiveStatisticsProxyTest, DoesNotReportStaleFramerates) { |
| 727 | const int kDefaultFps = 30; |
| 728 | const int kWidth = 320; |
| 729 | const int kHeight = 240; |
| 730 | |
| 731 | rtc::scoped_refptr<VideoFrameBuffer> video_frame_buffer( |
| 732 | I420Buffer::Create(kWidth, kHeight)); |
| 733 | VideoFrame frame(video_frame_buffer, kVideoRotation_0, 0); |
| 734 | |
| 735 | for (int i = 0; i < kDefaultFps; ++i) { |
| 736 | // Since OnRenderedFrame is never called the fps in each sample will be 0, |
| 737 | // i.e. bad |
| 738 | frame.set_ntp_time_ms(fake_clock_.CurrentNtpInMilliseconds()); |
Ilya Nikolaevskiy | 94150ee | 2018-05-23 11:53:19 +0200 | [diff] [blame^] | 739 | statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, |
sprang | 948b275 | 2017-05-04 02:47:13 -0700 | [diff] [blame] | 740 | VideoContentType::UNSPECIFIED); |
| 741 | statistics_proxy_->OnRenderedFrame(frame); |
| 742 | fake_clock_.AdvanceTimeMilliseconds(1000 / kDefaultFps); |
| 743 | } |
| 744 | |
| 745 | EXPECT_EQ(kDefaultFps, statistics_proxy_->GetStats().decode_frame_rate); |
| 746 | EXPECT_EQ(kDefaultFps, statistics_proxy_->GetStats().render_frame_rate); |
| 747 | |
| 748 | // FPS trackers in stats proxy have a 1000ms sliding window. |
| 749 | fake_clock_.AdvanceTimeMilliseconds(1000); |
| 750 | EXPECT_EQ(0, statistics_proxy_->GetStats().decode_frame_rate); |
| 751 | EXPECT_EQ(0, statistics_proxy_->GetStats().render_frame_rate); |
| 752 | } |
| 753 | |
asapersson | 2077f2f | 2017-05-11 05:37:35 -0700 | [diff] [blame] | 754 | TEST_F(ReceiveStatisticsProxyTest, GetStatsReportsReceivedFrameStats) { |
| 755 | const int kWidth = 160; |
| 756 | const int kHeight = 120; |
| 757 | EXPECT_EQ(0, statistics_proxy_->GetStats().width); |
| 758 | EXPECT_EQ(0, statistics_proxy_->GetStats().height); |
| 759 | EXPECT_EQ(0u, statistics_proxy_->GetStats().frames_rendered); |
| 760 | |
| 761 | statistics_proxy_->OnRenderedFrame(CreateFrame(kWidth, kHeight)); |
| 762 | |
| 763 | EXPECT_EQ(kWidth, statistics_proxy_->GetStats().width); |
| 764 | EXPECT_EQ(kHeight, statistics_proxy_->GetStats().height); |
| 765 | EXPECT_EQ(1u, statistics_proxy_->GetStats().frames_rendered); |
| 766 | } |
| 767 | |
| 768 | TEST_F(ReceiveStatisticsProxyTest, |
| 769 | ReceivedFrameHistogramsAreNotUpdatedForTooFewSamples) { |
| 770 | const int kWidth = 160; |
| 771 | const int kHeight = 120; |
| 772 | |
| 773 | for (int i = 0; i < kMinRequiredSamples - 1; ++i) |
| 774 | statistics_proxy_->OnRenderedFrame(CreateFrame(kWidth, kHeight)); |
| 775 | |
| 776 | statistics_proxy_.reset(); |
| 777 | EXPECT_EQ(0, metrics::NumSamples("WebRTC.Video.ReceivedWidthInPixels")); |
| 778 | EXPECT_EQ(0, metrics::NumSamples("WebRTC.Video.ReceivedHeightInPixels")); |
| 779 | EXPECT_EQ(0, metrics::NumSamples("WebRTC.Video.RenderFramesPerSecond")); |
| 780 | EXPECT_EQ(0, metrics::NumSamples("WebRTC.Video.RenderSqrtPixelsPerSecond")); |
| 781 | } |
| 782 | |
| 783 | TEST_F(ReceiveStatisticsProxyTest, ReceivedFrameHistogramsAreUpdated) { |
| 784 | const int kWidth = 160; |
| 785 | const int kHeight = 120; |
| 786 | |
| 787 | for (int i = 0; i < kMinRequiredSamples; ++i) |
| 788 | statistics_proxy_->OnRenderedFrame(CreateFrame(kWidth, kHeight)); |
| 789 | |
| 790 | statistics_proxy_.reset(); |
| 791 | EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.ReceivedWidthInPixels")); |
| 792 | EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.ReceivedHeightInPixels")); |
| 793 | EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.RenderFramesPerSecond")); |
| 794 | EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.RenderSqrtPixelsPerSecond")); |
| 795 | EXPECT_EQ(1, |
| 796 | metrics::NumEvents("WebRTC.Video.ReceivedWidthInPixels", kWidth)); |
| 797 | EXPECT_EQ(1, |
| 798 | metrics::NumEvents("WebRTC.Video.ReceivedHeightInPixels", kHeight)); |
| 799 | } |
| 800 | |
| 801 | TEST_F(ReceiveStatisticsProxyTest, |
| 802 | RtcpHistogramsNotUpdatedIfMinRuntimeHasNotPassed) { |
| 803 | InsertFirstRtpPacket(kRemoteSsrc); |
| 804 | fake_clock_.AdvanceTimeMilliseconds((metrics::kMinRunTimeInSeconds * 1000) - |
| 805 | 1); |
| 806 | |
| 807 | RtcpPacketTypeCounter counter; |
| 808 | statistics_proxy_->RtcpPacketTypesCounterUpdated(kRemoteSsrc, counter); |
| 809 | |
| 810 | statistics_proxy_.reset(); |
| 811 | EXPECT_EQ(0, metrics::NumSamples("WebRTC.Video.FirPacketsSentPerMinute")); |
| 812 | EXPECT_EQ(0, metrics::NumSamples("WebRTC.Video.PliPacketsSentPerMinute")); |
| 813 | EXPECT_EQ(0, metrics::NumSamples("WebRTC.Video.NackPacketsSentPerMinute")); |
| 814 | } |
| 815 | |
| 816 | TEST_F(ReceiveStatisticsProxyTest, RtcpHistogramsAreUpdated) { |
| 817 | InsertFirstRtpPacket(kRemoteSsrc); |
| 818 | fake_clock_.AdvanceTimeMilliseconds(metrics::kMinRunTimeInSeconds * 1000); |
| 819 | |
| 820 | const uint32_t kFirPackets = 100; |
| 821 | const uint32_t kPliPackets = 200; |
| 822 | const uint32_t kNackPackets = 300; |
| 823 | |
| 824 | RtcpPacketTypeCounter counter; |
| 825 | counter.fir_packets = kFirPackets; |
| 826 | counter.pli_packets = kPliPackets; |
| 827 | counter.nack_packets = kNackPackets; |
| 828 | statistics_proxy_->RtcpPacketTypesCounterUpdated(kRemoteSsrc, counter); |
| 829 | |
| 830 | statistics_proxy_.reset(); |
| 831 | EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.FirPacketsSentPerMinute")); |
| 832 | EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.PliPacketsSentPerMinute")); |
| 833 | EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.NackPacketsSentPerMinute")); |
| 834 | EXPECT_EQ( |
| 835 | 1, metrics::NumEvents("WebRTC.Video.FirPacketsSentPerMinute", |
| 836 | kFirPackets * 60 / metrics::kMinRunTimeInSeconds)); |
| 837 | EXPECT_EQ( |
| 838 | 1, metrics::NumEvents("WebRTC.Video.PliPacketsSentPerMinute", |
| 839 | kPliPackets * 60 / metrics::kMinRunTimeInSeconds)); |
| 840 | EXPECT_EQ( |
| 841 | 1, metrics::NumEvents("WebRTC.Video.NackPacketsSentPerMinute", |
| 842 | kNackPackets * 60 / metrics::kMinRunTimeInSeconds)); |
| 843 | } |
| 844 | |
sprang | 892dab5 | 2017-08-15 05:00:33 -0700 | [diff] [blame] | 845 | INSTANTIATE_TEST_CASE_P(ContentTypes, |
| 846 | ReceiveStatisticsProxyTest, |
| 847 | ::testing::Values(VideoContentType::UNSPECIFIED, |
| 848 | VideoContentType::SCREENSHARE)); |
| 849 | |
| 850 | TEST_P(ReceiveStatisticsProxyTest, InterFrameDelaysAreReported) { |
| 851 | const VideoContentType content_type = GetParam(); |
| 852 | const int kInterFrameDelayMs = 33; |
| 853 | for (int i = 0; i < kMinRequiredSamples; ++i) { |
Ilya Nikolaevskiy | 94150ee | 2018-05-23 11:53:19 +0200 | [diff] [blame^] | 854 | statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, |
| 855 | content_type); |
sprang | 892dab5 | 2017-08-15 05:00:33 -0700 | [diff] [blame] | 856 | fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs); |
| 857 | } |
Ilya Nikolaevskiy | daa4f7a | 2017-10-06 12:29:47 +0200 | [diff] [blame] | 858 | // One extra with double the interval. |
sprang | 892dab5 | 2017-08-15 05:00:33 -0700 | [diff] [blame] | 859 | fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs); |
Ilya Nikolaevskiy | 94150ee | 2018-05-23 11:53:19 +0200 | [diff] [blame^] | 860 | statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, |
| 861 | content_type); |
sprang | 892dab5 | 2017-08-15 05:00:33 -0700 | [diff] [blame] | 862 | |
| 863 | statistics_proxy_.reset(); |
| 864 | const int kExpectedInterFrame = |
| 865 | (kInterFrameDelayMs * (kMinRequiredSamples - 1) + |
| 866 | kInterFrameDelayMs * 2) / |
| 867 | kMinRequiredSamples; |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 868 | if (videocontenttypehelpers::IsScreenshare(content_type)) { |
| 869 | EXPECT_EQ( |
| 870 | kExpectedInterFrame, |
| 871 | metrics::MinSample("WebRTC.Video.Screenshare.InterframeDelayInMs")); |
| 872 | EXPECT_EQ( |
| 873 | kInterFrameDelayMs * 2, |
| 874 | metrics::MinSample("WebRTC.Video.Screenshare.InterframeDelayMaxInMs")); |
| 875 | } else { |
| 876 | EXPECT_EQ(kExpectedInterFrame, |
| 877 | metrics::MinSample("WebRTC.Video.InterframeDelayInMs")); |
| 878 | EXPECT_EQ(kInterFrameDelayMs * 2, |
| 879 | metrics::MinSample("WebRTC.Video.InterframeDelayMaxInMs")); |
sprang | 892dab5 | 2017-08-15 05:00:33 -0700 | [diff] [blame] | 880 | } |
| 881 | } |
| 882 | |
Ilya Nikolaevskiy | daa4f7a | 2017-10-06 12:29:47 +0200 | [diff] [blame] | 883 | TEST_P(ReceiveStatisticsProxyTest, InterFrameDelaysPercentilesAreReported) { |
| 884 | const VideoContentType content_type = GetParam(); |
| 885 | const int kInterFrameDelayMs = 33; |
| 886 | const int kLastFivePercentsSamples = kMinRequiredSamples * 5 / 100; |
| 887 | for (int i = 0; i <= kMinRequiredSamples - kLastFivePercentsSamples; ++i) { |
| 888 | fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs); |
Ilya Nikolaevskiy | 94150ee | 2018-05-23 11:53:19 +0200 | [diff] [blame^] | 889 | statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, |
| 890 | content_type); |
Ilya Nikolaevskiy | daa4f7a | 2017-10-06 12:29:47 +0200 | [diff] [blame] | 891 | } |
| 892 | // Last 5% of intervals are double in size. |
| 893 | for (int i = 0; i < kLastFivePercentsSamples; ++i) { |
| 894 | fake_clock_.AdvanceTimeMilliseconds(2 * kInterFrameDelayMs); |
Ilya Nikolaevskiy | 94150ee | 2018-05-23 11:53:19 +0200 | [diff] [blame^] | 895 | statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, |
| 896 | content_type); |
Ilya Nikolaevskiy | daa4f7a | 2017-10-06 12:29:47 +0200 | [diff] [blame] | 897 | } |
| 898 | // Final sample is outlier and 10 times as big. |
| 899 | fake_clock_.AdvanceTimeMilliseconds(10 * kInterFrameDelayMs); |
Ilya Nikolaevskiy | 94150ee | 2018-05-23 11:53:19 +0200 | [diff] [blame^] | 900 | statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, |
| 901 | content_type); |
Ilya Nikolaevskiy | daa4f7a | 2017-10-06 12:29:47 +0200 | [diff] [blame] | 902 | |
| 903 | statistics_proxy_.reset(); |
| 904 | const int kExpectedInterFrame = kInterFrameDelayMs * 2; |
| 905 | if (videocontenttypehelpers::IsScreenshare(content_type)) { |
| 906 | EXPECT_EQ(kExpectedInterFrame, |
| 907 | metrics::MinSample( |
| 908 | "WebRTC.Video.Screenshare.InterframeDelay95PercentileInMs")); |
| 909 | } else { |
| 910 | EXPECT_EQ( |
| 911 | kExpectedInterFrame, |
| 912 | metrics::MinSample("WebRTC.Video.InterframeDelay95PercentileInMs")); |
| 913 | } |
| 914 | } |
| 915 | |
sprang | 892dab5 | 2017-08-15 05:00:33 -0700 | [diff] [blame] | 916 | TEST_P(ReceiveStatisticsProxyTest, MaxInterFrameDelayOnlyWithValidAverage) { |
| 917 | const VideoContentType content_type = GetParam(); |
| 918 | const int kInterFrameDelayMs = 33; |
| 919 | for (int i = 0; i < kMinRequiredSamples; ++i) { |
Ilya Nikolaevskiy | 94150ee | 2018-05-23 11:53:19 +0200 | [diff] [blame^] | 920 | statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, |
| 921 | content_type); |
sprang | 892dab5 | 2017-08-15 05:00:33 -0700 | [diff] [blame] | 922 | fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs); |
| 923 | } |
| 924 | |
| 925 | // |kMinRequiredSamples| samples, and thereby intervals, is required. That |
| 926 | // means we're one frame short of having a valid data set. |
| 927 | statistics_proxy_.reset(); |
| 928 | EXPECT_EQ(0, metrics::NumSamples("WebRTC.Video.InterframeDelayInMs")); |
| 929 | EXPECT_EQ(0, metrics::NumSamples("WebRTC.Video.InterframeDelayMaxInMs")); |
| 930 | EXPECT_EQ( |
| 931 | 0, metrics::NumSamples("WebRTC.Video.Screenshare.InterframeDelayInMs")); |
| 932 | EXPECT_EQ(0, metrics::NumSamples( |
| 933 | "WebRTC.Video.Screenshare.InterframeDelayMaxInMs")); |
| 934 | } |
| 935 | |
sprang | 3e86e7e | 2017-08-22 09:23:28 -0700 | [diff] [blame] | 936 | TEST_P(ReceiveStatisticsProxyTest, MaxInterFrameDelayOnlyWithPause) { |
| 937 | const VideoContentType content_type = GetParam(); |
| 938 | const int kInterFrameDelayMs = 33; |
| 939 | for (int i = 0; i <= kMinRequiredSamples; ++i) { |
Ilya Nikolaevskiy | 94150ee | 2018-05-23 11:53:19 +0200 | [diff] [blame^] | 940 | statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, |
| 941 | content_type); |
sprang | 3e86e7e | 2017-08-22 09:23:28 -0700 | [diff] [blame] | 942 | fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs); |
| 943 | } |
| 944 | |
| 945 | // At this state, we should have a valid inter-frame delay. |
| 946 | // Indicate stream paused and make a large jump in time. |
| 947 | statistics_proxy_->OnStreamInactive(); |
| 948 | fake_clock_.AdvanceTimeMilliseconds(5000); |
| 949 | |
| 950 | // Insert two more frames. The interval during the pause should be disregarded |
| 951 | // in the stats. |
Ilya Nikolaevskiy | 94150ee | 2018-05-23 11:53:19 +0200 | [diff] [blame^] | 952 | statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, |
| 953 | content_type); |
sprang | 3e86e7e | 2017-08-22 09:23:28 -0700 | [diff] [blame] | 954 | fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs); |
Ilya Nikolaevskiy | 94150ee | 2018-05-23 11:53:19 +0200 | [diff] [blame^] | 955 | statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, |
| 956 | content_type); |
sprang | 3e86e7e | 2017-08-22 09:23:28 -0700 | [diff] [blame] | 957 | |
| 958 | statistics_proxy_.reset(); |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 959 | if (videocontenttypehelpers::IsScreenshare(content_type)) { |
sprang | 3e86e7e | 2017-08-22 09:23:28 -0700 | [diff] [blame] | 960 | EXPECT_EQ( |
| 961 | 1, metrics::NumSamples("WebRTC.Video.Screenshare.InterframeDelayInMs")); |
| 962 | EXPECT_EQ(1, metrics::NumSamples( |
| 963 | "WebRTC.Video.Screenshare.InterframeDelayMaxInMs")); |
| 964 | EXPECT_EQ( |
| 965 | kInterFrameDelayMs, |
| 966 | metrics::MinSample("WebRTC.Video.Screenshare.InterframeDelayInMs")); |
| 967 | EXPECT_EQ( |
| 968 | kInterFrameDelayMs, |
| 969 | metrics::MinSample("WebRTC.Video.Screenshare.InterframeDelayMaxInMs")); |
| 970 | } else { |
| 971 | EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.InterframeDelayInMs")); |
| 972 | EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.InterframeDelayMaxInMs")); |
| 973 | EXPECT_EQ(kInterFrameDelayMs, |
| 974 | metrics::MinSample("WebRTC.Video.InterframeDelayInMs")); |
| 975 | EXPECT_EQ(kInterFrameDelayMs, |
| 976 | metrics::MinSample("WebRTC.Video.InterframeDelayMaxInMs")); |
| 977 | } |
| 978 | } |
| 979 | |
Ilya Nikolaevskiy | 94150ee | 2018-05-23 11:53:19 +0200 | [diff] [blame^] | 980 | TEST_P(ReceiveStatisticsProxyTest, FreezesAreReported) { |
| 981 | const VideoContentType content_type = GetParam(); |
| 982 | const int kInterFrameDelayMs = 33; |
| 983 | const int kFreezeDelayMs = 200; |
| 984 | for (int i = 0; i < kMinRequiredSamples; ++i) { |
| 985 | statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, |
| 986 | content_type); |
| 987 | fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs); |
| 988 | } |
| 989 | // Add extra freeze. |
| 990 | fake_clock_.AdvanceTimeMilliseconds(kFreezeDelayMs); |
| 991 | statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, |
| 992 | content_type); |
| 993 | |
| 994 | statistics_proxy_.reset(); |
| 995 | const int kExpectedTimeBetweenFreezes = |
| 996 | kInterFrameDelayMs * (kMinRequiredSamples - 1); |
| 997 | if (videocontenttypehelpers::IsScreenshare(content_type)) { |
| 998 | EXPECT_EQ( |
| 999 | kFreezeDelayMs + kInterFrameDelayMs, |
| 1000 | metrics::MinSample("WebRTC.Video.Screenshare.MeanFreezeDurationMs")); |
| 1001 | EXPECT_EQ(kExpectedTimeBetweenFreezes, |
| 1002 | metrics::MinSample( |
| 1003 | "WebRTC.Video.Screenshare.MeanTimeBetweenFreezesMs")); |
| 1004 | } else { |
| 1005 | EXPECT_EQ(kFreezeDelayMs + kInterFrameDelayMs, |
| 1006 | metrics::MinSample("WebRTC.Video.MeanFreezeDurationMs")); |
| 1007 | EXPECT_EQ(kExpectedTimeBetweenFreezes, |
| 1008 | metrics::MinSample("WebRTC.Video.MeanTimeBetweenFreezesMs")); |
| 1009 | } |
| 1010 | } |
| 1011 | |
| 1012 | TEST_P(ReceiveStatisticsProxyTest, PausesAreIgnored) { |
| 1013 | const VideoContentType content_type = GetParam(); |
| 1014 | const int kInterFrameDelayMs = 33; |
| 1015 | const int kPauseDurationMs = 10000; |
| 1016 | for (int i = 0; i <= kMinRequiredSamples; ++i) { |
| 1017 | statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, |
| 1018 | content_type); |
| 1019 | fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs); |
| 1020 | } |
| 1021 | // Add a pause. |
| 1022 | fake_clock_.AdvanceTimeMilliseconds(kPauseDurationMs); |
| 1023 | statistics_proxy_->OnStreamInactive(); |
| 1024 | |
| 1025 | // Second playback interval with triple the length. |
| 1026 | for (int i = 0; i <= kMinRequiredSamples * 3; ++i) { |
| 1027 | statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, |
| 1028 | content_type); |
| 1029 | fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs); |
| 1030 | } |
| 1031 | |
| 1032 | statistics_proxy_.reset(); |
| 1033 | // Average of two playback intervals. |
| 1034 | const int kExpectedTimeBetweenFreezes = |
| 1035 | kInterFrameDelayMs * kMinRequiredSamples * 2; |
| 1036 | if (videocontenttypehelpers::IsScreenshare(content_type)) { |
| 1037 | EXPECT_EQ(-1, metrics::MinSample( |
| 1038 | "WebRTC.Video.Screenshare.MeanFreezeDurationMs")); |
| 1039 | EXPECT_EQ(kExpectedTimeBetweenFreezes, |
| 1040 | metrics::MinSample( |
| 1041 | "WebRTC.Video.Screenshare.MeanTimeBetweenFreezesMs")); |
| 1042 | } else { |
| 1043 | EXPECT_EQ(-1, metrics::MinSample("WebRTC.Video.MeanFreezeDurationMs")); |
| 1044 | EXPECT_EQ(kExpectedTimeBetweenFreezes, |
| 1045 | metrics::MinSample("WebRTC.Video.MeanTimeBetweenFreezesMs")); |
| 1046 | } |
| 1047 | } |
| 1048 | |
| 1049 | TEST_P(ReceiveStatisticsProxyTest, TimeInHdReported) { |
| 1050 | const VideoContentType content_type = GetParam(); |
| 1051 | const int kInterFrameDelayMs = 20; |
| 1052 | // HD frames. |
| 1053 | for (int i = 0; i < kMinRequiredSamples; ++i) { |
| 1054 | statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, |
| 1055 | content_type); |
| 1056 | fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs); |
| 1057 | } |
| 1058 | // SD frames. |
| 1059 | for (int i = 0; i < 2 * kMinRequiredSamples; ++i) { |
| 1060 | statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth / 2, kHeight / 2, |
| 1061 | content_type); |
| 1062 | fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs); |
| 1063 | } |
| 1064 | // Extra last frame. |
| 1065 | statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth / 2, kHeight / 2, |
| 1066 | content_type); |
| 1067 | statistics_proxy_.reset(); |
| 1068 | const int kExpectedTimeInHdPercents = 33; |
| 1069 | if (videocontenttypehelpers::IsScreenshare(content_type)) { |
| 1070 | EXPECT_EQ( |
| 1071 | kExpectedTimeInHdPercents, |
| 1072 | metrics::MinSample("WebRTC.Video.Screenshare.TimeInHdPercentage")); |
| 1073 | } else { |
| 1074 | EXPECT_EQ(kExpectedTimeInHdPercents, |
| 1075 | metrics::MinSample("WebRTC.Video.TimeInHdPercentage")); |
| 1076 | } |
| 1077 | } |
| 1078 | |
| 1079 | TEST_P(ReceiveStatisticsProxyTest, TimeInBlockyVideoReported) { |
| 1080 | const VideoContentType content_type = GetParam(); |
| 1081 | const int kInterFrameDelayMs = 20; |
| 1082 | const int kHighQp = 80; |
| 1083 | const int kLowQp = 30; |
| 1084 | // High quality frames. |
| 1085 | for (int i = 0; i < kMinRequiredSamples; ++i) { |
| 1086 | statistics_proxy_->OnDecodedFrame(kLowQp, kWidth, kHeight, content_type); |
| 1087 | fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs); |
| 1088 | } |
| 1089 | // Blocky frames. |
| 1090 | for (int i = 0; i < 2 * kMinRequiredSamples; ++i) { |
| 1091 | statistics_proxy_->OnDecodedFrame(kHighQp, kWidth, kHeight, content_type); |
| 1092 | fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs); |
| 1093 | } |
| 1094 | // Extra last frame. |
| 1095 | statistics_proxy_->OnDecodedFrame(kHighQp, kWidth, kHeight, content_type); |
| 1096 | statistics_proxy_.reset(); |
| 1097 | const int kExpectedTimeInHdPercents = 66; |
| 1098 | if (videocontenttypehelpers::IsScreenshare(content_type)) { |
| 1099 | EXPECT_EQ(kExpectedTimeInHdPercents, |
| 1100 | metrics::MinSample( |
| 1101 | "WebRTC.Video.Screenshare.TimeInBlockyVideoPercentage")); |
| 1102 | } else { |
| 1103 | EXPECT_EQ(kExpectedTimeInHdPercents, |
| 1104 | metrics::MinSample("WebRTC.Video.TimeInBlockyVideoPercentage")); |
| 1105 | } |
| 1106 | } |
| 1107 | |
| 1108 | TEST_P(ReceiveStatisticsProxyTest, DownscalesReported) { |
| 1109 | const VideoContentType content_type = GetParam(); |
| 1110 | const int kInterFrameDelayMs = 1000; // To ensure long enough call duration. |
| 1111 | const int kLowQp = 30; |
| 1112 | |
| 1113 | statistics_proxy_->OnDecodedFrame(kLowQp, kWidth / 2, kHeight / 2, |
| 1114 | content_type); |
| 1115 | fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs); |
| 1116 | |
| 1117 | // Downscale. |
| 1118 | statistics_proxy_->OnDecodedFrame(kLowQp, kWidth, kHeight, content_type); |
| 1119 | fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs); |
| 1120 | |
| 1121 | statistics_proxy_->OnDecodedFrame(kLowQp, kWidth / 2, kHeight / 2, |
| 1122 | content_type); |
| 1123 | fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs); |
| 1124 | |
| 1125 | statistics_proxy_->OnDecodedFrame(kLowQp, kWidth / 2, kHeight / 2, |
| 1126 | content_type); |
| 1127 | fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs); |
| 1128 | |
| 1129 | // Downscale. |
| 1130 | statistics_proxy_->OnDecodedFrame(kLowQp, kWidth / 4, kHeight / 4, |
| 1131 | content_type); |
| 1132 | fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs); |
| 1133 | |
| 1134 | statistics_proxy_.reset(); |
| 1135 | const int kExpectedDownscales = 30; // 2 per 5 seconds = 30 per minute. |
| 1136 | if (videocontenttypehelpers::IsScreenshare(content_type)) { |
| 1137 | EXPECT_EQ( |
| 1138 | kExpectedDownscales, |
| 1139 | metrics::MinSample( |
| 1140 | "WebRTC.Video.Screenshare.NumberResolutionDownswitchesPerMinute")); |
| 1141 | } else { |
| 1142 | EXPECT_EQ(kExpectedDownscales, |
| 1143 | metrics::MinSample( |
| 1144 | "WebRTC.Video.NumberResolutionDownswitchesPerMinute")); |
| 1145 | } |
| 1146 | } |
| 1147 | |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 1148 | TEST_P(ReceiveStatisticsProxyTest, StatsAreSlicedOnSimulcastAndExperiment) { |
| 1149 | VideoContentType content_type = GetParam(); |
| 1150 | const uint8_t experiment_id = 1; |
| 1151 | videocontenttypehelpers::SetExperimentId(&content_type, experiment_id); |
| 1152 | const int kInterFrameDelayMs1 = 30; |
| 1153 | const int kInterFrameDelayMs2 = 50; |
| 1154 | |
| 1155 | videocontenttypehelpers::SetSimulcastId(&content_type, 1); |
| 1156 | for (int i = 0; i <= kMinRequiredSamples; ++i) { |
| 1157 | fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs1); |
Ilya Nikolaevskiy | 94150ee | 2018-05-23 11:53:19 +0200 | [diff] [blame^] | 1158 | statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, |
| 1159 | content_type); |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 1160 | } |
| 1161 | |
| 1162 | videocontenttypehelpers::SetSimulcastId(&content_type, 2); |
| 1163 | for (int i = 0; i <= kMinRequiredSamples; ++i) { |
| 1164 | fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs2); |
Ilya Nikolaevskiy | 94150ee | 2018-05-23 11:53:19 +0200 | [diff] [blame^] | 1165 | statistics_proxy_->OnDecodedFrame(rtc::nullopt, kWidth, kHeight, |
| 1166 | content_type); |
ilnik | 6d5b4d6 | 2017-08-30 03:32:14 -0700 | [diff] [blame] | 1167 | } |
| 1168 | statistics_proxy_.reset(); |
| 1169 | |
| 1170 | if (videocontenttypehelpers::IsScreenshare(content_type)) { |
| 1171 | EXPECT_EQ( |
| 1172 | 1, metrics::NumSamples("WebRTC.Video.Screenshare.InterframeDelayInMs")); |
| 1173 | EXPECT_EQ(1, metrics::NumSamples( |
| 1174 | "WebRTC.Video.Screenshare.InterframeDelayMaxInMs")); |
| 1175 | EXPECT_EQ(1, metrics::NumSamples( |
| 1176 | "WebRTC.Video.Screenshare.InterframeDelayInMs.S0")); |
| 1177 | EXPECT_EQ(1, metrics::NumSamples( |
| 1178 | "WebRTC.Video.Screenshare.InterframeDelayMaxInMs.S0")); |
| 1179 | EXPECT_EQ(1, metrics::NumSamples( |
| 1180 | "WebRTC.Video.Screenshare.InterframeDelayInMs.S1")); |
| 1181 | EXPECT_EQ(1, metrics::NumSamples( |
| 1182 | "WebRTC.Video.Screenshare.InterframeDelayMaxInMs.S1")); |
| 1183 | EXPECT_EQ(1, |
| 1184 | metrics::NumSamples("WebRTC.Video.Screenshare.InterframeDelayInMs" |
| 1185 | ".ExperimentGroup0")); |
| 1186 | EXPECT_EQ( |
| 1187 | 1, metrics::NumSamples("WebRTC.Video.Screenshare.InterframeDelayMaxInMs" |
| 1188 | ".ExperimentGroup0")); |
| 1189 | EXPECT_EQ( |
| 1190 | kInterFrameDelayMs1, |
| 1191 | metrics::MinSample("WebRTC.Video.Screenshare.InterframeDelayInMs.S0")); |
| 1192 | EXPECT_EQ( |
| 1193 | kInterFrameDelayMs2, |
| 1194 | metrics::MinSample("WebRTC.Video.Screenshare.InterframeDelayInMs.S1")); |
| 1195 | EXPECT_EQ( |
| 1196 | (kInterFrameDelayMs1 + kInterFrameDelayMs2) / 2, |
| 1197 | metrics::MinSample("WebRTC.Video.Screenshare.InterframeDelayInMs")); |
| 1198 | EXPECT_EQ( |
| 1199 | kInterFrameDelayMs2, |
| 1200 | metrics::MinSample("WebRTC.Video.Screenshare.InterframeDelayMaxInMs")); |
| 1201 | EXPECT_EQ( |
| 1202 | (kInterFrameDelayMs1 + kInterFrameDelayMs2) / 2, |
| 1203 | metrics::MinSample( |
| 1204 | "WebRTC.Video.Screenshare.InterframeDelayInMs.ExperimentGroup0")); |
| 1205 | } else { |
| 1206 | EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.InterframeDelayInMs")); |
| 1207 | EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.InterframeDelayMaxInMs")); |
| 1208 | EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.InterframeDelayInMs.S0")); |
| 1209 | EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.InterframeDelayMaxInMs.S0")); |
| 1210 | EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.InterframeDelayInMs.S1")); |
| 1211 | EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.InterframeDelayMaxInMs.S1")); |
| 1212 | EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.InterframeDelayInMs" |
| 1213 | ".ExperimentGroup0")); |
| 1214 | EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.InterframeDelayMaxInMs" |
| 1215 | ".ExperimentGroup0")); |
| 1216 | EXPECT_EQ(kInterFrameDelayMs1, |
| 1217 | metrics::MinSample("WebRTC.Video.InterframeDelayInMs.S0")); |
| 1218 | EXPECT_EQ(kInterFrameDelayMs2, |
| 1219 | metrics::MinSample("WebRTC.Video.InterframeDelayInMs.S1")); |
| 1220 | EXPECT_EQ((kInterFrameDelayMs1 + kInterFrameDelayMs2) / 2, |
| 1221 | metrics::MinSample("WebRTC.Video.InterframeDelayInMs")); |
| 1222 | EXPECT_EQ(kInterFrameDelayMs2, |
| 1223 | metrics::MinSample("WebRTC.Video.InterframeDelayMaxInMs")); |
| 1224 | EXPECT_EQ((kInterFrameDelayMs1 + kInterFrameDelayMs2) / 2, |
| 1225 | metrics::MinSample( |
| 1226 | "WebRTC.Video.InterframeDelayInMs.ExperimentGroup0")); |
| 1227 | } |
| 1228 | } |
sakal | e5ba44e | 2016-10-26 07:09:24 -0700 | [diff] [blame] | 1229 | } // namespace webrtc |