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

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

Issue 2368223002: Add VideoSendStream::Stats::prefered_media_bitrate_bps (Closed)
Patch Set: Addressed nits Created 4 years, 2 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
« no previous file with comments | « webrtc/video/send_statistics_proxy.cc ('k') | webrtc/video/video_send_stream.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 config.rtp.rtx.ssrcs.push_back(kFirstRtxSsrc); 58 config.rtp.rtx.ssrcs.push_back(kFirstRtxSsrc);
59 config.rtp.rtx.ssrcs.push_back(kSecondRtxSsrc); 59 config.rtp.rtx.ssrcs.push_back(kSecondRtxSsrc);
60 config.rtp.fec.red_payload_type = 17; 60 config.rtp.fec.red_payload_type = 17;
61 return config; 61 return config;
62 } 62 }
63 63
64 void ExpectEqual(VideoSendStream::Stats one, VideoSendStream::Stats other) { 64 void ExpectEqual(VideoSendStream::Stats one, VideoSendStream::Stats other) {
65 EXPECT_EQ(one.input_frame_rate, other.input_frame_rate); 65 EXPECT_EQ(one.input_frame_rate, other.input_frame_rate);
66 EXPECT_EQ(one.encode_frame_rate, other.encode_frame_rate); 66 EXPECT_EQ(one.encode_frame_rate, other.encode_frame_rate);
67 EXPECT_EQ(one.media_bitrate_bps, other.media_bitrate_bps); 67 EXPECT_EQ(one.media_bitrate_bps, other.media_bitrate_bps);
68 EXPECT_EQ(one.preferred_media_bitrate_bps,
69 other.preferred_media_bitrate_bps);
68 EXPECT_EQ(one.suspended, other.suspended); 70 EXPECT_EQ(one.suspended, other.suspended);
69 71
70 EXPECT_EQ(one.substreams.size(), other.substreams.size()); 72 EXPECT_EQ(one.substreams.size(), other.substreams.size());
71 for (std::map<uint32_t, VideoSendStream::StreamStats>::const_iterator it = 73 for (std::map<uint32_t, VideoSendStream::StreamStats>::const_iterator it =
72 one.substreams.begin(); 74 one.substreams.begin();
73 it != one.substreams.end(); ++it) { 75 it != one.substreams.end(); ++it) {
74 std::map<uint32_t, VideoSendStream::StreamStats>::const_iterator 76 std::map<uint32_t, VideoSendStream::StreamStats>::const_iterator
75 corresponding_it = other.substreams.find(it->first); 77 corresponding_it = other.substreams.find(it->first);
76 ASSERT_TRUE(corresponding_it != other.substreams.end()); 78 ASSERT_TRUE(corresponding_it != other.substreams.end());
77 const VideoSendStream::StreamStats& a = it->second; 79 const VideoSendStream::StreamStats& a = it->second;
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 const int kEncodeTimeMs = 11; 283 const int kEncodeTimeMs = 11;
282 CpuOveruseMetrics metrics; 284 CpuOveruseMetrics metrics;
283 metrics.encode_usage_percent = 80; 285 metrics.encode_usage_percent = 80;
284 statistics_proxy_->OnEncodedFrameTimeMeasured(kEncodeTimeMs, metrics); 286 statistics_proxy_->OnEncodedFrameTimeMeasured(kEncodeTimeMs, metrics);
285 287
286 VideoSendStream::Stats stats = statistics_proxy_->GetStats(); 288 VideoSendStream::Stats stats = statistics_proxy_->GetStats();
287 EXPECT_EQ(kEncodeTimeMs, stats.avg_encode_time_ms); 289 EXPECT_EQ(kEncodeTimeMs, stats.avg_encode_time_ms);
288 EXPECT_EQ(metrics.encode_usage_percent, stats.encode_usage_percent); 290 EXPECT_EQ(metrics.encode_usage_percent, stats.encode_usage_percent);
289 } 291 }
290 292
293 TEST_F(SendStatisticsProxyTest, OnEncoderReconfiguredChangePreferredBitrate) {
294 VideoSendStream::Stats stats = statistics_proxy_->GetStats();
295 EXPECT_EQ(0, stats.preferred_media_bitrate_bps);
296 const int kPreferredMediaBitrateBps = 50;
297
298 VideoEncoderConfig config;
299 statistics_proxy_->OnEncoderReconfigured(config, kPreferredMediaBitrateBps);
300 stats = statistics_proxy_->GetStats();
301 EXPECT_EQ(kPreferredMediaBitrateBps, stats.preferred_media_bitrate_bps);
302 }
303
291 TEST_F(SendStatisticsProxyTest, SwitchContentTypeUpdatesHistograms) { 304 TEST_F(SendStatisticsProxyTest, SwitchContentTypeUpdatesHistograms) {
292 const int kWidth = 640; 305 const int kWidth = 640;
293 const int kHeight = 480; 306 const int kHeight = 480;
294 307
295 for (int i = 0; i < kMinRequiredSamples; ++i) 308 for (int i = 0; i < kMinRequiredSamples; ++i)
296 statistics_proxy_->OnIncomingFrame(kWidth, kHeight); 309 statistics_proxy_->OnIncomingFrame(kWidth, kHeight);
297 310
298 // No switch, stats not should be updated. 311 // No switch, stats should not be updated.
299 statistics_proxy_->SetContentType( 312 VideoEncoderConfig config;
300 VideoEncoderConfig::ContentType::kRealtimeVideo); 313 config.content_type = VideoEncoderConfig::ContentType::kRealtimeVideo;
314 statistics_proxy_->OnEncoderReconfigured(config, 50);
301 EXPECT_EQ(0, metrics::NumSamples("WebRTC.Video.InputWidthInPixels")); 315 EXPECT_EQ(0, metrics::NumSamples("WebRTC.Video.InputWidthInPixels"));
302 316
303 // Switch to screenshare, real-time stats should be updated. 317 // Switch to screenshare, real-time stats should be updated.
304 statistics_proxy_->SetContentType(VideoEncoderConfig::ContentType::kScreen); 318 config.content_type = VideoEncoderConfig::ContentType::kScreen;
319 statistics_proxy_->OnEncoderReconfigured(config, 50);
305 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.InputWidthInPixels")); 320 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.InputWidthInPixels"));
306 } 321 }
307 322
308 TEST_F(SendStatisticsProxyTest, LifetimeHistogramIsUpdated) { 323 TEST_F(SendStatisticsProxyTest, LifetimeHistogramIsUpdated) {
309 const int64_t kTimeSec = 3; 324 const int64_t kTimeSec = 3;
310 fake_clock_.AdvanceTimeMilliseconds(kTimeSec * 1000); 325 fake_clock_.AdvanceTimeMilliseconds(kTimeSec * 1000);
311 statistics_proxy_.reset(); 326 statistics_proxy_.reset();
312 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.SendStreamLifetimeInSeconds")); 327 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.SendStreamLifetimeInSeconds"));
313 EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.SendStreamLifetimeInSeconds", 328 EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.SendStreamLifetimeInSeconds",
314 kTimeSec)); 329 kTimeSec));
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 counters.nack_packets += 1 * metrics::kMinRunTimeInSeconds; 546 counters.nack_packets += 1 * metrics::kMinRunTimeInSeconds;
532 counters.fir_packets += 2 * metrics::kMinRunTimeInSeconds; 547 counters.fir_packets += 2 * metrics::kMinRunTimeInSeconds;
533 counters.pli_packets += 3 * metrics::kMinRunTimeInSeconds; 548 counters.pli_packets += 3 * metrics::kMinRunTimeInSeconds;
534 counters.unique_nack_requests += 4 * metrics::kMinRunTimeInSeconds; 549 counters.unique_nack_requests += 4 * metrics::kMinRunTimeInSeconds;
535 counters.nack_requests += 5 * metrics::kMinRunTimeInSeconds; 550 counters.nack_requests += 5 * metrics::kMinRunTimeInSeconds;
536 551
537 proxy->RtcpPacketTypesCounterUpdated(kFirstSsrc, counters); 552 proxy->RtcpPacketTypesCounterUpdated(kFirstSsrc, counters);
538 proxy->RtcpPacketTypesCounterUpdated(kSecondSsrc, counters); 553 proxy->RtcpPacketTypesCounterUpdated(kSecondSsrc, counters);
539 554
540 // Changing content type causes histograms to be reported. 555 // Changing content type causes histograms to be reported.
541 statistics_proxy_->SetContentType(VideoEncoderConfig::ContentType::kScreen); 556 VideoEncoderConfig config;
557 config.content_type = VideoEncoderConfig::ContentType::kScreen;
558 statistics_proxy_->OnEncoderReconfigured(config, 50);
542 559
543 EXPECT_EQ(1, 560 EXPECT_EQ(1,
544 metrics::NumSamples("WebRTC.Video.NackPacketsReceivedPerMinute")); 561 metrics::NumSamples("WebRTC.Video.NackPacketsReceivedPerMinute"));
545 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.FirPacketsReceivedPerMinute")); 562 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.FirPacketsReceivedPerMinute"));
546 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.PliPacketsReceivedPerMinute")); 563 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.PliPacketsReceivedPerMinute"));
547 EXPECT_EQ(1, metrics::NumSamples( 564 EXPECT_EQ(1, metrics::NumSamples(
548 "WebRTC.Video.UniqueNackRequestsReceivedInPercent")); 565 "WebRTC.Video.UniqueNackRequestsReceivedInPercent"));
549 566
550 const int kRate = 60 * 2; // Packets per minute with two streams. 567 const int kRate = 60 * 2; // Packets per minute with two streams.
551 568
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 643
627 rtx_counters.transmitted = counters.transmitted; 644 rtx_counters.transmitted = counters.transmitted;
628 645
629 fake_clock_.AdvanceTimeMilliseconds(1000 * metrics::kMinRunTimeInSeconds); 646 fake_clock_.AdvanceTimeMilliseconds(1000 * metrics::kMinRunTimeInSeconds);
630 proxy->DataCountersUpdated(counters, kFirstSsrc); 647 proxy->DataCountersUpdated(counters, kFirstSsrc);
631 proxy->DataCountersUpdated(counters, kSecondSsrc); 648 proxy->DataCountersUpdated(counters, kSecondSsrc);
632 proxy->DataCountersUpdated(rtx_counters, kFirstRtxSsrc); 649 proxy->DataCountersUpdated(rtx_counters, kFirstRtxSsrc);
633 proxy->DataCountersUpdated(rtx_counters, kSecondRtxSsrc); 650 proxy->DataCountersUpdated(rtx_counters, kSecondRtxSsrc);
634 651
635 // Changing content type causes histograms to be reported. 652 // Changing content type causes histograms to be reported.
636 statistics_proxy_->SetContentType(VideoEncoderConfig::ContentType::kScreen); 653 VideoEncoderConfig config;
654 config.content_type = VideoEncoderConfig::ContentType::kScreen;
655 statistics_proxy_->OnEncoderReconfigured(config, 50);
637 656
638 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.BitrateSentInKbps")); 657 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.BitrateSentInKbps"));
639 EXPECT_EQ(1, 658 EXPECT_EQ(1,
640 metrics::NumEvents( 659 metrics::NumEvents(
641 "WebRTC.Video.BitrateSentInKbps", 660 "WebRTC.Video.BitrateSentInKbps",
642 static_cast<int>((counters.transmitted.TotalBytes() * 4 * 8) / 661 static_cast<int>((counters.transmitted.TotalBytes() * 4 * 8) /
643 metrics::kMinRunTimeInSeconds / 1000))); 662 metrics::kMinRunTimeInSeconds / 1000)));
644 663
645 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.MediaBitrateSentInKbps")); 664 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.MediaBitrateSentInKbps"));
646 EXPECT_EQ(1, metrics::NumEvents( 665 EXPECT_EQ(1, metrics::NumEvents(
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 757
739 EXPECT_EQ( 758 EXPECT_EQ(
740 1, metrics::NumSamples("WebRTC.Video.Screenshare.FecBitrateSentInKbps")); 759 1, metrics::NumSamples("WebRTC.Video.Screenshare.FecBitrateSentInKbps"));
741 EXPECT_EQ(1, metrics::NumEvents( 760 EXPECT_EQ(1, metrics::NumEvents(
742 "WebRTC.Video.Screenshare.FecBitrateSentInKbps", 761 "WebRTC.Video.Screenshare.FecBitrateSentInKbps",
743 static_cast<int>((rtx_counters.fec.TotalBytes() * 2 * 8) / 762 static_cast<int>((rtx_counters.fec.TotalBytes() * 2 * 8) /
744 metrics::kMinRunTimeInSeconds / 1000))); 763 metrics::kMinRunTimeInSeconds / 1000)));
745 } 764 }
746 765
747 } // namespace webrtc 766 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/send_statistics_proxy.cc ('k') | webrtc/video/video_send_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698