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

Side by Side Diff: webrtc/video/receive_statistics_proxy_unittest.cc

Issue 2986893002: Piggybacking simulcast id and ALR experiment id into video content type extension. (Closed)
Patch Set: Remove static initialization from VideoContentType and remove memoization in AlrDetector Created 3 years, 3 months 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2016 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 63
64 SimulatedClock fake_clock_; 64 SimulatedClock fake_clock_;
65 const VideoReceiveStream::Config config_; 65 const VideoReceiveStream::Config config_;
66 std::unique_ptr<ReceiveStatisticsProxy> statistics_proxy_; 66 std::unique_ptr<ReceiveStatisticsProxy> statistics_proxy_;
67 }; 67 };
68 68
69 TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameIncreasesFramesDecoded) { 69 TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameIncreasesFramesDecoded) {
70 EXPECT_EQ(0u, statistics_proxy_->GetStats().frames_decoded); 70 EXPECT_EQ(0u, statistics_proxy_->GetStats().frames_decoded);
71 for (uint32_t i = 1; i <= 3; ++i) { 71 for (uint32_t i = 1; i <= 3; ++i) {
72 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(), 72 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(),
73 VideoContentType::UNSPECIFIED); 73 VideoContentType::Unspecified());
74 EXPECT_EQ(i, statistics_proxy_->GetStats().frames_decoded); 74 EXPECT_EQ(i, statistics_proxy_->GetStats().frames_decoded);
75 } 75 }
76 } 76 }
77 77
78 TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameWithQpResetsFramesDecoded) { 78 TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameWithQpResetsFramesDecoded) {
79 EXPECT_EQ(0u, statistics_proxy_->GetStats().frames_decoded); 79 EXPECT_EQ(0u, statistics_proxy_->GetStats().frames_decoded);
80 for (uint32_t i = 1; i <= 3; ++i) { 80 for (uint32_t i = 1; i <= 3; ++i) {
81 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(), 81 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(),
82 VideoContentType::UNSPECIFIED); 82 VideoContentType::Unspecified());
83 EXPECT_EQ(i, statistics_proxy_->GetStats().frames_decoded); 83 EXPECT_EQ(i, statistics_proxy_->GetStats().frames_decoded);
84 } 84 }
85 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(1u), 85 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(1u),
86 VideoContentType::UNSPECIFIED); 86 VideoContentType::Unspecified());
87 EXPECT_EQ(1u, statistics_proxy_->GetStats().frames_decoded); 87 EXPECT_EQ(1u, statistics_proxy_->GetStats().frames_decoded);
88 } 88 }
89 89
90 TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameIncreasesQpSum) { 90 TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameIncreasesQpSum) {
91 EXPECT_EQ(rtc::Optional<uint64_t>(), statistics_proxy_->GetStats().qp_sum); 91 EXPECT_EQ(rtc::Optional<uint64_t>(), statistics_proxy_->GetStats().qp_sum);
92 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(3u), 92 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(3u),
93 VideoContentType::UNSPECIFIED); 93 VideoContentType::Unspecified());
94 EXPECT_EQ(rtc::Optional<uint64_t>(3u), statistics_proxy_->GetStats().qp_sum); 94 EXPECT_EQ(rtc::Optional<uint64_t>(3u), statistics_proxy_->GetStats().qp_sum);
95 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(127u), 95 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(127u),
96 VideoContentType::UNSPECIFIED); 96 VideoContentType::Unspecified());
97 EXPECT_EQ(rtc::Optional<uint64_t>(130u), 97 EXPECT_EQ(rtc::Optional<uint64_t>(130u),
98 statistics_proxy_->GetStats().qp_sum); 98 statistics_proxy_->GetStats().qp_sum);
99 } 99 }
100 100
101 TEST_F(ReceiveStatisticsProxyTest, ReportsMaxInterframeDelay) { 101 TEST_F(ReceiveStatisticsProxyTest, ReportsMaxInterframeDelay) {
102 const int64_t kInterframeDelayMs1 = 100; 102 const int64_t kInterframeDelayMs1 = 100;
103 const int64_t kInterframeDelayMs2 = 200; 103 const int64_t kInterframeDelayMs2 = 200;
104 const int64_t kInterframeDelayMs3 = 100; 104 const int64_t kInterframeDelayMs3 = 100;
105 EXPECT_EQ(-1, statistics_proxy_->GetStats().interframe_delay_max_ms); 105 EXPECT_EQ(-1, statistics_proxy_->GetStats().interframe_delay_max_ms);
106 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(3u), 106 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(3u),
107 VideoContentType::UNSPECIFIED); 107 VideoContentType::Unspecified());
108 EXPECT_EQ(-1, statistics_proxy_->GetStats().interframe_delay_max_ms); 108 EXPECT_EQ(-1, statistics_proxy_->GetStats().interframe_delay_max_ms);
109 109
110 fake_clock_.AdvanceTimeMilliseconds(kInterframeDelayMs1); 110 fake_clock_.AdvanceTimeMilliseconds(kInterframeDelayMs1);
111 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(127u), 111 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(127u),
112 VideoContentType::UNSPECIFIED); 112 VideoContentType::Unspecified());
113 EXPECT_EQ(kInterframeDelayMs1, 113 EXPECT_EQ(kInterframeDelayMs1,
114 statistics_proxy_->GetStats().interframe_delay_max_ms); 114 statistics_proxy_->GetStats().interframe_delay_max_ms);
115 115
116 fake_clock_.AdvanceTimeMilliseconds(kInterframeDelayMs2); 116 fake_clock_.AdvanceTimeMilliseconds(kInterframeDelayMs2);
117 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(127u), 117 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(127u),
118 VideoContentType::UNSPECIFIED); 118 VideoContentType::Unspecified());
119 EXPECT_EQ(kInterframeDelayMs2, 119 EXPECT_EQ(kInterframeDelayMs2,
120 statistics_proxy_->GetStats().interframe_delay_max_ms); 120 statistics_proxy_->GetStats().interframe_delay_max_ms);
121 121
122 fake_clock_.AdvanceTimeMilliseconds(kInterframeDelayMs3); 122 fake_clock_.AdvanceTimeMilliseconds(kInterframeDelayMs3);
123 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(127u), 123 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(127u),
124 VideoContentType::UNSPECIFIED); 124 VideoContentType::Unspecified());
125 // kInterframeDelayMs3 is smaller than kInterframeDelayMs2. 125 // kInterframeDelayMs3 is smaller than kInterframeDelayMs2.
126 EXPECT_EQ(kInterframeDelayMs2, 126 EXPECT_EQ(kInterframeDelayMs2,
127 statistics_proxy_->GetStats().interframe_delay_max_ms); 127 statistics_proxy_->GetStats().interframe_delay_max_ms);
128 } 128 }
129 129
130 TEST_F(ReceiveStatisticsProxyTest, ReportInterframeDelayInWindow) { 130 TEST_F(ReceiveStatisticsProxyTest, ReportInterframeDelayInWindow) {
131 const int64_t kInterframeDelayMs1 = 9000; 131 const int64_t kInterframeDelayMs1 = 9000;
132 const int64_t kInterframeDelayMs2 = 7500; 132 const int64_t kInterframeDelayMs2 = 7500;
133 const int64_t kInterframeDelayMs3 = 7000; 133 const int64_t kInterframeDelayMs3 = 7000;
134 EXPECT_EQ(-1, statistics_proxy_->GetStats().interframe_delay_max_ms); 134 EXPECT_EQ(-1, statistics_proxy_->GetStats().interframe_delay_max_ms);
135 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(3u), 135 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(3u),
136 VideoContentType::UNSPECIFIED); 136 VideoContentType::Unspecified());
137 EXPECT_EQ(-1, statistics_proxy_->GetStats().interframe_delay_max_ms); 137 EXPECT_EQ(-1, statistics_proxy_->GetStats().interframe_delay_max_ms);
138 138
139 fake_clock_.AdvanceTimeMilliseconds(kInterframeDelayMs1); 139 fake_clock_.AdvanceTimeMilliseconds(kInterframeDelayMs1);
140 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(127u), 140 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(127u),
141 VideoContentType::UNSPECIFIED); 141 VideoContentType::Unspecified());
142 EXPECT_EQ(kInterframeDelayMs1, 142 EXPECT_EQ(kInterframeDelayMs1,
143 statistics_proxy_->GetStats().interframe_delay_max_ms); 143 statistics_proxy_->GetStats().interframe_delay_max_ms);
144 144
145 fake_clock_.AdvanceTimeMilliseconds(kInterframeDelayMs2); 145 fake_clock_.AdvanceTimeMilliseconds(kInterframeDelayMs2);
146 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(127u), 146 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(127u),
147 VideoContentType::UNSPECIFIED); 147 VideoContentType::Unspecified());
148 // Still first delay is the maximum 148 // Still first delay is the maximum
149 EXPECT_EQ(kInterframeDelayMs1, 149 EXPECT_EQ(kInterframeDelayMs1,
150 statistics_proxy_->GetStats().interframe_delay_max_ms); 150 statistics_proxy_->GetStats().interframe_delay_max_ms);
151 151
152 fake_clock_.AdvanceTimeMilliseconds(kInterframeDelayMs3); 152 fake_clock_.AdvanceTimeMilliseconds(kInterframeDelayMs3);
153 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(127u), 153 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(127u),
154 VideoContentType::UNSPECIFIED); 154 VideoContentType::Unspecified());
155 // Now the first sample is out of the window, so the second is the maximum. 155 // Now the first sample is out of the window, so the second is the maximum.
156 EXPECT_EQ(kInterframeDelayMs2, 156 EXPECT_EQ(kInterframeDelayMs2,
157 statistics_proxy_->GetStats().interframe_delay_max_ms); 157 statistics_proxy_->GetStats().interframe_delay_max_ms);
158 } 158 }
159 159
160 TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameWithoutQpQpSumWontExist) { 160 TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameWithoutQpQpSumWontExist) {
161 EXPECT_EQ(rtc::Optional<uint64_t>(), statistics_proxy_->GetStats().qp_sum); 161 EXPECT_EQ(rtc::Optional<uint64_t>(), statistics_proxy_->GetStats().qp_sum);
162 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(), 162 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(),
163 VideoContentType::UNSPECIFIED); 163 VideoContentType::Unspecified());
164 EXPECT_EQ(rtc::Optional<uint64_t>(), statistics_proxy_->GetStats().qp_sum); 164 EXPECT_EQ(rtc::Optional<uint64_t>(), statistics_proxy_->GetStats().qp_sum);
165 } 165 }
166 166
167 TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameWithoutQpResetsQpSum) { 167 TEST_F(ReceiveStatisticsProxyTest, OnDecodedFrameWithoutQpResetsQpSum) {
168 EXPECT_EQ(rtc::Optional<uint64_t>(), statistics_proxy_->GetStats().qp_sum); 168 EXPECT_EQ(rtc::Optional<uint64_t>(), statistics_proxy_->GetStats().qp_sum);
169 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(3u), 169 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(3u),
170 VideoContentType::UNSPECIFIED); 170 VideoContentType::Unspecified());
171 EXPECT_EQ(rtc::Optional<uint64_t>(3u), statistics_proxy_->GetStats().qp_sum); 171 EXPECT_EQ(rtc::Optional<uint64_t>(3u), statistics_proxy_->GetStats().qp_sum);
172 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(), 172 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(),
173 VideoContentType::UNSPECIFIED); 173 VideoContentType::Unspecified());
174 EXPECT_EQ(rtc::Optional<uint64_t>(), statistics_proxy_->GetStats().qp_sum); 174 EXPECT_EQ(rtc::Optional<uint64_t>(), statistics_proxy_->GetStats().qp_sum);
175 } 175 }
176 176
177 TEST_F(ReceiveStatisticsProxyTest, OnRenderedFrameIncreasesFramesRendered) { 177 TEST_F(ReceiveStatisticsProxyTest, OnRenderedFrameIncreasesFramesRendered) {
178 EXPECT_EQ(0u, statistics_proxy_->GetStats().frames_rendered); 178 EXPECT_EQ(0u, statistics_proxy_->GetStats().frames_rendered);
179 webrtc::VideoFrame frame(webrtc::I420Buffer::Create(1, 1), 0, 0, 179 webrtc::VideoFrame frame(webrtc::I420Buffer::Create(1, 1), 0, 0,
180 webrtc::kVideoRotation_0); 180 webrtc::kVideoRotation_0);
181 for (uint32_t i = 1; i <= 3; ++i) { 181 for (uint32_t i = 1; i <= 3; ++i) {
182 statistics_proxy_->OnRenderedFrame(frame); 182 statistics_proxy_->OnRenderedFrame(frame);
183 EXPECT_EQ(i, statistics_proxy_->GetStats().frames_rendered); 183 EXPECT_EQ(i, statistics_proxy_->GetStats().frames_rendered);
(...skipping 12 matching lines...) Expand all
196 196
197 TEST_F(ReceiveStatisticsProxyTest, GetStatsReportsDecoderImplementationName) { 197 TEST_F(ReceiveStatisticsProxyTest, GetStatsReportsDecoderImplementationName) {
198 const char* kName = "decoderName"; 198 const char* kName = "decoderName";
199 statistics_proxy_->OnDecoderImplementationName(kName); 199 statistics_proxy_->OnDecoderImplementationName(kName);
200 EXPECT_STREQ( 200 EXPECT_STREQ(
201 kName, statistics_proxy_->GetStats().decoder_implementation_name.c_str()); 201 kName, statistics_proxy_->GetStats().decoder_implementation_name.c_str());
202 } 202 }
203 203
204 TEST_F(ReceiveStatisticsProxyTest, GetStatsReportsOnCompleteFrame) { 204 TEST_F(ReceiveStatisticsProxyTest, GetStatsReportsOnCompleteFrame) {
205 const int kFrameSizeBytes = 1000; 205 const int kFrameSizeBytes = 1000;
206 statistics_proxy_->OnCompleteFrame(true, kFrameSizeBytes); 206 statistics_proxy_->OnCompleteFrame(true, kFrameSizeBytes,
207 VideoContentType::Unspecified());
207 VideoReceiveStream::Stats stats = statistics_proxy_->GetStats(); 208 VideoReceiveStream::Stats stats = statistics_proxy_->GetStats();
208 EXPECT_EQ(1, stats.network_frame_rate); 209 EXPECT_EQ(1, stats.network_frame_rate);
209 EXPECT_EQ(1, stats.frame_counts.key_frames); 210 EXPECT_EQ(1, stats.frame_counts.key_frames);
210 EXPECT_EQ(0, stats.frame_counts.delta_frames); 211 EXPECT_EQ(0, stats.frame_counts.delta_frames);
211 } 212 }
212 213
213 TEST_F(ReceiveStatisticsProxyTest, GetStatsReportsDecodeTimingStats) { 214 TEST_F(ReceiveStatisticsProxyTest, GetStatsReportsDecodeTimingStats) {
214 const int kDecodeMs = 1; 215 const int kDecodeMs = 1;
215 const int kMaxDecodeMs = 2; 216 const int kMaxDecodeMs = 2;
216 const int kCurrentDelayMs = 3; 217 const int kCurrentDelayMs = 3;
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 result = statistics_proxy_->GetAndResetTimingFrameInfo(); 346 result = statistics_proxy_->GetAndResetTimingFrameInfo();
346 EXPECT_TRUE(result); 347 EXPECT_TRUE(result);
347 EXPECT_EQ(kExpectedRtpTimestamp, result->rtp_timestamp); 348 EXPECT_EQ(kExpectedRtpTimestamp, result->rtp_timestamp);
348 result = statistics_proxy_->GetAndResetTimingFrameInfo(); 349 result = statistics_proxy_->GetAndResetTimingFrameInfo();
349 EXPECT_FALSE(result); 350 EXPECT_FALSE(result);
350 } 351 }
351 352
352 TEST_F(ReceiveStatisticsProxyTest, LifetimeHistogramIsUpdated) { 353 TEST_F(ReceiveStatisticsProxyTest, LifetimeHistogramIsUpdated) {
353 const int64_t kTimeSec = 3; 354 const int64_t kTimeSec = 3;
354 fake_clock_.AdvanceTimeMilliseconds(kTimeSec * 1000); 355 fake_clock_.AdvanceTimeMilliseconds(kTimeSec * 1000);
356 // Need at least one frame to report stream lifetime.
357 statistics_proxy_->OnCompleteFrame(true, 1000,
358 VideoContentType::Unspecified());
355 // Histograms are updated when the statistics_proxy_ is deleted. 359 // Histograms are updated when the statistics_proxy_ is deleted.
356 statistics_proxy_.reset(); 360 statistics_proxy_.reset();
357 EXPECT_EQ(1, 361 EXPECT_EQ(1,
358 metrics::NumSamples("WebRTC.Video.ReceiveStreamLifetimeInSeconds")); 362 metrics::NumSamples("WebRTC.Video.ReceiveStreamLifetimeInSeconds"));
359 EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.ReceiveStreamLifetimeInSeconds", 363 EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.ReceiveStreamLifetimeInSeconds",
360 kTimeSec)); 364 kTimeSec));
361 } 365 }
362 366
367 TEST_F(ReceiveStatisticsProxyTest,
368 LifetimeHistogramNotReportedForEmptyStreams) {
369 const int64_t kTimeSec = 3;
370 fake_clock_.AdvanceTimeMilliseconds(kTimeSec * 1000);
371 // No frames received.
372 // Histograms are updated when the statistics_proxy_ is deleted.
373 statistics_proxy_.reset();
374 EXPECT_EQ(0,
375 metrics::NumSamples("WebRTC.Video.ReceiveStreamLifetimeInSeconds"));
376 }
377
363 TEST_F(ReceiveStatisticsProxyTest, BadCallHistogramsAreUpdated) { 378 TEST_F(ReceiveStatisticsProxyTest, BadCallHistogramsAreUpdated) {
364 // Based on the tuning parameters this will produce 7 uncertain states, 379 // Based on the tuning parameters this will produce 7 uncertain states,
365 // then 10 certainly bad states. There has to be 10 certain states before 380 // then 10 certainly bad states. There has to be 10 certain states before
366 // any histograms are recorded. 381 // any histograms are recorded.
367 const int kNumBadSamples = 17; 382 const int kNumBadSamples = 17;
368 383
369 StreamDataCounters counters; 384 StreamDataCounters counters;
370 counters.first_packet_time_ms = fake_clock_.TimeInMilliseconds(); 385 counters.first_packet_time_ms = fake_clock_.TimeInMilliseconds();
371 statistics_proxy_->DataCountersUpdated(counters, config_.rtp.remote_ssrc); 386 statistics_proxy_->DataCountersUpdated(counters, config_.rtp.remote_ssrc);
372 387
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 statistics_proxy_.reset(); 541 statistics_proxy_.reset();
527 EXPECT_EQ(0, metrics::NumSamples("WebRTC.Video.Decoded.Vp8.Qp")); 542 EXPECT_EQ(0, metrics::NumSamples("WebRTC.Video.Decoded.Vp8.Qp"));
528 } 543 }
529 544
530 TEST_F(ReceiveStatisticsProxyTest, 545 TEST_F(ReceiveStatisticsProxyTest,
531 KeyFrameHistogramNotUpdatedForTooFewSamples) { 546 KeyFrameHistogramNotUpdatedForTooFewSamples) {
532 const bool kIsKeyFrame = false; 547 const bool kIsKeyFrame = false;
533 const int kFrameSizeBytes = 1000; 548 const int kFrameSizeBytes = 1000;
534 549
535 for (int i = 0; i < kMinRequiredSamples - 1; ++i) 550 for (int i = 0; i < kMinRequiredSamples - 1; ++i)
536 statistics_proxy_->OnCompleteFrame(kIsKeyFrame, kFrameSizeBytes); 551 statistics_proxy_->OnCompleteFrame(kIsKeyFrame, kFrameSizeBytes,
552 VideoContentType::Unspecified());
537 553
538 EXPECT_EQ(0, statistics_proxy_->GetStats().frame_counts.key_frames); 554 EXPECT_EQ(0, statistics_proxy_->GetStats().frame_counts.key_frames);
539 EXPECT_EQ(kMinRequiredSamples - 1, 555 EXPECT_EQ(kMinRequiredSamples - 1,
540 statistics_proxy_->GetStats().frame_counts.delta_frames); 556 statistics_proxy_->GetStats().frame_counts.delta_frames);
541 557
542 statistics_proxy_.reset(); 558 statistics_proxy_.reset();
543 EXPECT_EQ(0, metrics::NumSamples("WebRTC.Video.KeyFramesReceivedInPermille")); 559 EXPECT_EQ(0, metrics::NumSamples("WebRTC.Video.KeyFramesReceivedInPermille"));
544 } 560 }
545 561
546 TEST_F(ReceiveStatisticsProxyTest, 562 TEST_F(ReceiveStatisticsProxyTest,
547 KeyFrameHistogramUpdatedForMinRequiredSamples) { 563 KeyFrameHistogramUpdatedForMinRequiredSamples) {
548 const bool kIsKeyFrame = false; 564 const bool kIsKeyFrame = false;
549 const int kFrameSizeBytes = 1000; 565 const int kFrameSizeBytes = 1000;
550 566
551 for (int i = 0; i < kMinRequiredSamples; ++i) 567 for (int i = 0; i < kMinRequiredSamples; ++i)
552 statistics_proxy_->OnCompleteFrame(kIsKeyFrame, kFrameSizeBytes); 568 statistics_proxy_->OnCompleteFrame(kIsKeyFrame, kFrameSizeBytes,
569 VideoContentType::Unspecified());
553 570
554 EXPECT_EQ(0, statistics_proxy_->GetStats().frame_counts.key_frames); 571 EXPECT_EQ(0, statistics_proxy_->GetStats().frame_counts.key_frames);
555 EXPECT_EQ(kMinRequiredSamples, 572 EXPECT_EQ(kMinRequiredSamples,
556 statistics_proxy_->GetStats().frame_counts.delta_frames); 573 statistics_proxy_->GetStats().frame_counts.delta_frames);
557 574
558 statistics_proxy_.reset(); 575 statistics_proxy_.reset();
559 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.KeyFramesReceivedInPermille")); 576 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.KeyFramesReceivedInPermille"));
560 EXPECT_EQ(1, 577 EXPECT_EQ(1,
561 metrics::NumEvents("WebRTC.Video.KeyFramesReceivedInPermille", 0)); 578 metrics::NumEvents("WebRTC.Video.KeyFramesReceivedInPermille", 0));
562 } 579 }
563 580
564 TEST_F(ReceiveStatisticsProxyTest, KeyFrameHistogramIsUpdated) { 581 TEST_F(ReceiveStatisticsProxyTest, KeyFrameHistogramIsUpdated) {
565 const int kFrameSizeBytes = 1000; 582 const int kFrameSizeBytes = 1000;
566 583
567 for (int i = 0; i < kMinRequiredSamples; ++i) 584 for (int i = 0; i < kMinRequiredSamples; ++i)
568 statistics_proxy_->OnCompleteFrame(true, kFrameSizeBytes); 585 statistics_proxy_->OnCompleteFrame(true, kFrameSizeBytes,
586 VideoContentType::Unspecified());
569 587
570 for (int i = 0; i < kMinRequiredSamples; ++i) 588 for (int i = 0; i < kMinRequiredSamples; ++i)
571 statistics_proxy_->OnCompleteFrame(false, kFrameSizeBytes); 589 statistics_proxy_->OnCompleteFrame(false, kFrameSizeBytes,
590 VideoContentType::Unspecified());
572 591
573 EXPECT_EQ(kMinRequiredSamples, 592 EXPECT_EQ(kMinRequiredSamples,
574 statistics_proxy_->GetStats().frame_counts.key_frames); 593 statistics_proxy_->GetStats().frame_counts.key_frames);
575 EXPECT_EQ(kMinRequiredSamples, 594 EXPECT_EQ(kMinRequiredSamples,
576 statistics_proxy_->GetStats().frame_counts.delta_frames); 595 statistics_proxy_->GetStats().frame_counts.delta_frames);
577 596
578 statistics_proxy_.reset(); 597 statistics_proxy_.reset();
579 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.KeyFramesReceivedInPermille")); 598 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.KeyFramesReceivedInPermille"));
580 EXPECT_EQ( 599 EXPECT_EQ(
581 1, metrics::NumEvents("WebRTC.Video.KeyFramesReceivedInPermille", 500)); 600 1, metrics::NumEvents("WebRTC.Video.KeyFramesReceivedInPermille", 500));
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 663
645 rtc::scoped_refptr<VideoFrameBuffer> video_frame_buffer( 664 rtc::scoped_refptr<VideoFrameBuffer> video_frame_buffer(
646 I420Buffer::Create(kWidth, kHeight)); 665 I420Buffer::Create(kWidth, kHeight));
647 VideoFrame frame(video_frame_buffer, kVideoRotation_0, 0); 666 VideoFrame frame(video_frame_buffer, kVideoRotation_0, 0);
648 667
649 for (int i = 0; i < kDefaultFps; ++i) { 668 for (int i = 0; i < kDefaultFps; ++i) {
650 // Since OnRenderedFrame is never called the fps in each sample will be 0, 669 // Since OnRenderedFrame is never called the fps in each sample will be 0,
651 // i.e. bad 670 // i.e. bad
652 frame.set_ntp_time_ms(fake_clock_.CurrentNtpInMilliseconds()); 671 frame.set_ntp_time_ms(fake_clock_.CurrentNtpInMilliseconds());
653 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(), 672 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(),
654 VideoContentType::UNSPECIFIED); 673 VideoContentType::Unspecified());
655 statistics_proxy_->OnRenderedFrame(frame); 674 statistics_proxy_->OnRenderedFrame(frame);
656 fake_clock_.AdvanceTimeMilliseconds(1000 / kDefaultFps); 675 fake_clock_.AdvanceTimeMilliseconds(1000 / kDefaultFps);
657 } 676 }
658 677
659 EXPECT_EQ(kDefaultFps, statistics_proxy_->GetStats().decode_frame_rate); 678 EXPECT_EQ(kDefaultFps, statistics_proxy_->GetStats().decode_frame_rate);
660 EXPECT_EQ(kDefaultFps, statistics_proxy_->GetStats().render_frame_rate); 679 EXPECT_EQ(kDefaultFps, statistics_proxy_->GetStats().render_frame_rate);
661 680
662 // FPS trackers in stats proxy have a 1000ms sliding window. 681 // FPS trackers in stats proxy have a 1000ms sliding window.
663 fake_clock_.AdvanceTimeMilliseconds(1000); 682 fake_clock_.AdvanceTimeMilliseconds(1000);
664 EXPECT_EQ(0, statistics_proxy_->GetStats().decode_frame_rate); 683 EXPECT_EQ(0, statistics_proxy_->GetStats().decode_frame_rate);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 EXPECT_EQ( 770 EXPECT_EQ(
752 1, metrics::NumEvents("WebRTC.Video.PliPacketsSentPerMinute", 771 1, metrics::NumEvents("WebRTC.Video.PliPacketsSentPerMinute",
753 kPliPackets * 60 / metrics::kMinRunTimeInSeconds)); 772 kPliPackets * 60 / metrics::kMinRunTimeInSeconds));
754 EXPECT_EQ( 773 EXPECT_EQ(
755 1, metrics::NumEvents("WebRTC.Video.NackPacketsSentPerMinute", 774 1, metrics::NumEvents("WebRTC.Video.NackPacketsSentPerMinute",
756 kNackPackets * 60 / metrics::kMinRunTimeInSeconds)); 775 kNackPackets * 60 / metrics::kMinRunTimeInSeconds));
757 } 776 }
758 777
759 INSTANTIATE_TEST_CASE_P(ContentTypes, 778 INSTANTIATE_TEST_CASE_P(ContentTypes,
760 ReceiveStatisticsProxyTest, 779 ReceiveStatisticsProxyTest,
761 ::testing::Values(VideoContentType::UNSPECIFIED, 780 ::testing::Values(VideoContentType::Unspecified(),
762 VideoContentType::SCREENSHARE)); 781 VideoContentType::Screenshare()));
763 782
764 TEST_P(ReceiveStatisticsProxyTest, InterFrameDelaysAreReported) { 783 TEST_P(ReceiveStatisticsProxyTest, InterFrameDelaysAreReported) {
765 const VideoContentType content_type = GetParam(); 784 const VideoContentType content_type = GetParam();
766 const int kInterFrameDelayMs = 33; 785 const int kInterFrameDelayMs = 33;
767 for (int i = 0; i < kMinRequiredSamples; ++i) { 786 for (int i = 0; i < kMinRequiredSamples; ++i) {
768 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(), content_type); 787 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(), content_type);
769 fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs); 788 fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs);
770 } 789 }
771 // One extra with with double the interval. 790 // One extra with with double the interval.
772 fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs); 791 fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs);
773 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(), content_type); 792 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(), content_type);
774 793
775 statistics_proxy_.reset(); 794 statistics_proxy_.reset();
776 const int kExpectedInterFrame = 795 const int kExpectedInterFrame =
777 (kInterFrameDelayMs * (kMinRequiredSamples - 1) + 796 (kInterFrameDelayMs * (kMinRequiredSamples - 1) +
778 kInterFrameDelayMs * 2) / 797 kInterFrameDelayMs * 2) /
779 kMinRequiredSamples; 798 kMinRequiredSamples;
780 switch (content_type) { 799 if (content_type.IsScreenshare()) {
781 case VideoContentType::UNSPECIFIED: 800 EXPECT_EQ(
782 EXPECT_EQ(kExpectedInterFrame, 801 kExpectedInterFrame,
783 metrics::MinSample("WebRTC.Video.InterframeDelayInMs")); 802 metrics::MinSample("WebRTC.Video.Screenshare.InterframeDelayInMs"));
784 EXPECT_EQ(kInterFrameDelayMs * 2, 803 EXPECT_EQ(
785 metrics::MinSample("WebRTC.Video.InterframeDelayMaxInMs")); 804 kInterFrameDelayMs * 2,
786 break; 805 metrics::MinSample("WebRTC.Video.Screenshare.InterframeDelayMaxInMs"));
787 case VideoContentType::SCREENSHARE: 806 } else {
788 EXPECT_EQ( 807 EXPECT_EQ(kExpectedInterFrame,
789 kExpectedInterFrame, 808 metrics::MinSample("WebRTC.Video.InterframeDelayInMs"));
790 metrics::MinSample("WebRTC.Video.Screenshare.InterframeDelayInMs")); 809 EXPECT_EQ(kInterFrameDelayMs * 2,
791 EXPECT_EQ(kInterFrameDelayMs * 2, 810 metrics::MinSample("WebRTC.Video.InterframeDelayMaxInMs"));
792 metrics::MinSample(
793 "WebRTC.Video.Screenshare.InterframeDelayMaxInMs"));
794 break;
795 default:
796 RTC_NOTREACHED();
797 } 811 }
798 } 812 }
799 813
800 TEST_P(ReceiveStatisticsProxyTest, MaxInterFrameDelayOnlyWithValidAverage) { 814 TEST_P(ReceiveStatisticsProxyTest, MaxInterFrameDelayOnlyWithValidAverage) {
801 const VideoContentType content_type = GetParam(); 815 const VideoContentType content_type = GetParam();
802 const int kInterFrameDelayMs = 33; 816 const int kInterFrameDelayMs = 33;
803 for (int i = 0; i < kMinRequiredSamples; ++i) { 817 for (int i = 0; i < kMinRequiredSamples; ++i) {
804 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(), content_type); 818 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(), content_type);
805 fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs); 819 fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs);
806 } 820 }
(...skipping 22 matching lines...) Expand all
829 statistics_proxy_->OnStreamInactive(); 843 statistics_proxy_->OnStreamInactive();
830 fake_clock_.AdvanceTimeMilliseconds(5000); 844 fake_clock_.AdvanceTimeMilliseconds(5000);
831 845
832 // Insert two more frames. The interval during the pause should be disregarded 846 // Insert two more frames. The interval during the pause should be disregarded
833 // in the stats. 847 // in the stats.
834 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(), content_type); 848 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(), content_type);
835 fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs); 849 fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs);
836 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(), content_type); 850 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(), content_type);
837 851
838 statistics_proxy_.reset(); 852 statistics_proxy_.reset();
839 if (content_type == VideoContentType::SCREENSHARE) { 853 if (content_type.IsScreenshare()) {
840 EXPECT_EQ( 854 EXPECT_EQ(
841 1, metrics::NumSamples("WebRTC.Video.Screenshare.InterframeDelayInMs")); 855 1, metrics::NumSamples("WebRTC.Video.Screenshare.InterframeDelayInMs"));
842 EXPECT_EQ(1, metrics::NumSamples( 856 EXPECT_EQ(1, metrics::NumSamples(
843 "WebRTC.Video.Screenshare.InterframeDelayMaxInMs")); 857 "WebRTC.Video.Screenshare.InterframeDelayMaxInMs"));
844 EXPECT_EQ( 858 EXPECT_EQ(
845 kInterFrameDelayMs, 859 kInterFrameDelayMs,
846 metrics::MinSample("WebRTC.Video.Screenshare.InterframeDelayInMs")); 860 metrics::MinSample("WebRTC.Video.Screenshare.InterframeDelayInMs"));
847 EXPECT_EQ( 861 EXPECT_EQ(
848 kInterFrameDelayMs, 862 kInterFrameDelayMs,
849 metrics::MinSample("WebRTC.Video.Screenshare.InterframeDelayMaxInMs")); 863 metrics::MinSample("WebRTC.Video.Screenshare.InterframeDelayMaxInMs"));
850 } else { 864 } else {
851 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.InterframeDelayInMs")); 865 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.InterframeDelayInMs"));
852 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.InterframeDelayMaxInMs")); 866 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.InterframeDelayMaxInMs"));
853 EXPECT_EQ(kInterFrameDelayMs, 867 EXPECT_EQ(kInterFrameDelayMs,
854 metrics::MinSample("WebRTC.Video.InterframeDelayInMs")); 868 metrics::MinSample("WebRTC.Video.InterframeDelayInMs"));
855 EXPECT_EQ(kInterFrameDelayMs, 869 EXPECT_EQ(kInterFrameDelayMs,
856 metrics::MinSample("WebRTC.Video.InterframeDelayMaxInMs")); 870 metrics::MinSample("WebRTC.Video.InterframeDelayMaxInMs"));
857 } 871 }
858 } 872 }
859 873
874 TEST_P(ReceiveStatisticsProxyTest, StatsAreSlicedOnSimulcastAndExperiment) {
875 VideoContentType content_type = GetParam();
876 const uint8_t experiment_id = 1;
877 content_type.SetExperimentId(experiment_id);
878 const int kInterFrameDelayMs1 = 30;
879 const int kInterFrameDelayMs2 = 50;
880
881 content_type.SetSimulcastId(1);
882 for (int i = 0; i <= kMinRequiredSamples; ++i) {
883 fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs1);
884 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(), content_type);
885 }
886
887 content_type.SetSimulcastId(2);
888 for (int i = 0; i <= kMinRequiredSamples; ++i) {
889 fake_clock_.AdvanceTimeMilliseconds(kInterFrameDelayMs2);
890 statistics_proxy_->OnDecodedFrame(rtc::Optional<uint8_t>(), content_type);
891 }
892 statistics_proxy_.reset();
893
894 if (content_type.IsScreenshare()) {
895 EXPECT_EQ(
896 1, metrics::NumSamples("WebRTC.Video.Screenshare.InterframeDelayInMs"));
897 EXPECT_EQ(1, metrics::NumSamples(
898 "WebRTC.Video.Screenshare.InterframeDelayMaxInMs"));
899 EXPECT_EQ(1, metrics::NumSamples(
900 "WebRTC.Video.Screenshare.InterframeDelayInMs.S0"));
901 EXPECT_EQ(1, metrics::NumSamples(
902 "WebRTC.Video.Screenshare.InterframeDelayMaxInMs.S0"));
903 EXPECT_EQ(1, metrics::NumSamples(
904 "WebRTC.Video.Screenshare.InterframeDelayInMs.S1"));
905 EXPECT_EQ(1, metrics::NumSamples(
906 "WebRTC.Video.Screenshare.InterframeDelayMaxInMs.S1"));
907 EXPECT_EQ(1,
908 metrics::NumSamples("WebRTC.Video.Screenshare.InterframeDelayInMs"
909 ".ExperimentGroup0"));
910 EXPECT_EQ(
911 1, metrics::NumSamples("WebRTC.Video.Screenshare.InterframeDelayMaxInMs"
912 ".ExperimentGroup0"));
913 EXPECT_EQ(
914 kInterFrameDelayMs1,
915 metrics::MinSample("WebRTC.Video.Screenshare.InterframeDelayInMs.S0"));
916 EXPECT_EQ(
917 kInterFrameDelayMs2,
918 metrics::MinSample("WebRTC.Video.Screenshare.InterframeDelayInMs.S1"));
919 EXPECT_EQ(
920 (kInterFrameDelayMs1 + kInterFrameDelayMs2) / 2,
921 metrics::MinSample("WebRTC.Video.Screenshare.InterframeDelayInMs"));
922 EXPECT_EQ(
923 kInterFrameDelayMs2,
924 metrics::MinSample("WebRTC.Video.Screenshare.InterframeDelayMaxInMs"));
925 EXPECT_EQ(
926 (kInterFrameDelayMs1 + kInterFrameDelayMs2) / 2,
927 metrics::MinSample(
928 "WebRTC.Video.Screenshare.InterframeDelayInMs.ExperimentGroup0"));
929 } else {
930 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.InterframeDelayInMs"));
931 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.InterframeDelayMaxInMs"));
932 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.InterframeDelayInMs.S0"));
933 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.InterframeDelayMaxInMs.S0"));
934 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.InterframeDelayInMs.S1"));
935 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.InterframeDelayMaxInMs.S1"));
936 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.InterframeDelayInMs"
937 ".ExperimentGroup0"));
938 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.InterframeDelayMaxInMs"
939 ".ExperimentGroup0"));
940 EXPECT_EQ(kInterFrameDelayMs1,
941 metrics::MinSample("WebRTC.Video.InterframeDelayInMs.S0"));
942 EXPECT_EQ(kInterFrameDelayMs2,
943 metrics::MinSample("WebRTC.Video.InterframeDelayInMs.S1"));
944 EXPECT_EQ((kInterFrameDelayMs1 + kInterFrameDelayMs2) / 2,
945 metrics::MinSample("WebRTC.Video.InterframeDelayInMs"));
946 EXPECT_EQ(kInterFrameDelayMs2,
947 metrics::MinSample("WebRTC.Video.InterframeDelayMaxInMs"));
948 EXPECT_EQ((kInterFrameDelayMs1 + kInterFrameDelayMs2) / 2,
949 metrics::MinSample(
950 "WebRTC.Video.InterframeDelayInMs.ExperimentGroup0"));
951 }
952 }
953
860 } // namespace webrtc 954 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698