Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 | |
| 297 VideoEncoderConfig config; | |
| 298 int preferred_media_bitrate_bps = 50; | |
|
sprang_webrtc
2016/09/27 10:55:07
Maybe have this as named constant at the top, and
perkj_webrtc
2016/09/27 11:33:12
Done.
| |
| 299 | |
| 300 statistics_proxy_->OnEncoderReconfigured(config, preferred_media_bitrate_bps); | |
| 301 stats = statistics_proxy_->GetStats(); | |
| 302 EXPECT_EQ(preferred_media_bitrate_bps, stats.preferred_media_bitrate_bps); | |
| 303 } | |
| 304 | |
| 291 TEST_F(SendStatisticsProxyTest, SwitchContentTypeUpdatesHistograms) { | 305 TEST_F(SendStatisticsProxyTest, SwitchContentTypeUpdatesHistograms) { |
| 292 const int kWidth = 640; | 306 const int kWidth = 640; |
| 293 const int kHeight = 480; | 307 const int kHeight = 480; |
| 294 | 308 |
| 295 for (int i = 0; i < kMinRequiredSamples; ++i) | 309 for (int i = 0; i < kMinRequiredSamples; ++i) |
| 296 statistics_proxy_->OnIncomingFrame(kWidth, kHeight); | 310 statistics_proxy_->OnIncomingFrame(kWidth, kHeight); |
| 297 | 311 |
| 298 // No switch, stats not should be updated. | 312 // No switch, stats should not be updated. |
| 299 statistics_proxy_->SetContentType( | 313 VideoEncoderConfig config; |
| 300 VideoEncoderConfig::ContentType::kRealtimeVideo); | 314 config.content_type = VideoEncoderConfig::ContentType::kRealtimeVideo; |
| 315 statistics_proxy_->OnEncoderReconfigured(config, 50); | |
| 301 EXPECT_EQ(0, metrics::NumSamples("WebRTC.Video.InputWidthInPixels")); | 316 EXPECT_EQ(0, metrics::NumSamples("WebRTC.Video.InputWidthInPixels")); |
| 302 | 317 |
| 303 // Switch to screenshare, real-time stats should be updated. | 318 // Switch to screenshare, real-time stats should be updated. |
| 304 statistics_proxy_->SetContentType(VideoEncoderConfig::ContentType::kScreen); | 319 config.content_type = VideoEncoderConfig::ContentType::kScreen; |
| 320 statistics_proxy_->OnEncoderReconfigured(config, 50); | |
| 305 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.InputWidthInPixels")); | 321 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.InputWidthInPixels")); |
| 306 } | 322 } |
| 307 | 323 |
| 308 TEST_F(SendStatisticsProxyTest, LifetimeHistogramIsUpdated) { | 324 TEST_F(SendStatisticsProxyTest, LifetimeHistogramIsUpdated) { |
| 309 const int64_t kTimeSec = 3; | 325 const int64_t kTimeSec = 3; |
| 310 fake_clock_.AdvanceTimeMilliseconds(kTimeSec * 1000); | 326 fake_clock_.AdvanceTimeMilliseconds(kTimeSec * 1000); |
| 311 statistics_proxy_.reset(); | 327 statistics_proxy_.reset(); |
| 312 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.SendStreamLifetimeInSeconds")); | 328 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.SendStreamLifetimeInSeconds")); |
| 313 EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.SendStreamLifetimeInSeconds", | 329 EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.SendStreamLifetimeInSeconds", |
| 314 kTimeSec)); | 330 kTimeSec)); |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 531 counters.nack_packets += 1 * metrics::kMinRunTimeInSeconds; | 547 counters.nack_packets += 1 * metrics::kMinRunTimeInSeconds; |
| 532 counters.fir_packets += 2 * metrics::kMinRunTimeInSeconds; | 548 counters.fir_packets += 2 * metrics::kMinRunTimeInSeconds; |
| 533 counters.pli_packets += 3 * metrics::kMinRunTimeInSeconds; | 549 counters.pli_packets += 3 * metrics::kMinRunTimeInSeconds; |
| 534 counters.unique_nack_requests += 4 * metrics::kMinRunTimeInSeconds; | 550 counters.unique_nack_requests += 4 * metrics::kMinRunTimeInSeconds; |
| 535 counters.nack_requests += 5 * metrics::kMinRunTimeInSeconds; | 551 counters.nack_requests += 5 * metrics::kMinRunTimeInSeconds; |
| 536 | 552 |
| 537 proxy->RtcpPacketTypesCounterUpdated(kFirstSsrc, counters); | 553 proxy->RtcpPacketTypesCounterUpdated(kFirstSsrc, counters); |
| 538 proxy->RtcpPacketTypesCounterUpdated(kSecondSsrc, counters); | 554 proxy->RtcpPacketTypesCounterUpdated(kSecondSsrc, counters); |
| 539 | 555 |
| 540 // Changing content type causes histograms to be reported. | 556 // Changing content type causes histograms to be reported. |
| 541 statistics_proxy_->SetContentType(VideoEncoderConfig::ContentType::kScreen); | 557 VideoEncoderConfig config; |
| 558 config.content_type = VideoEncoderConfig::ContentType::kScreen; | |
| 559 statistics_proxy_->OnEncoderReconfigured(config, 50); | |
| 542 | 560 |
| 543 EXPECT_EQ(1, | 561 EXPECT_EQ(1, |
| 544 metrics::NumSamples("WebRTC.Video.NackPacketsReceivedPerMinute")); | 562 metrics::NumSamples("WebRTC.Video.NackPacketsReceivedPerMinute")); |
| 545 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.FirPacketsReceivedPerMinute")); | 563 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.FirPacketsReceivedPerMinute")); |
| 546 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.PliPacketsReceivedPerMinute")); | 564 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.PliPacketsReceivedPerMinute")); |
| 547 EXPECT_EQ(1, metrics::NumSamples( | 565 EXPECT_EQ(1, metrics::NumSamples( |
| 548 "WebRTC.Video.UniqueNackRequestsReceivedInPercent")); | 566 "WebRTC.Video.UniqueNackRequestsReceivedInPercent")); |
| 549 | 567 |
| 550 const int kRate = 60 * 2; // Packets per minute with two streams. | 568 const int kRate = 60 * 2; // Packets per minute with two streams. |
| 551 | 569 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 626 | 644 |
| 627 rtx_counters.transmitted = counters.transmitted; | 645 rtx_counters.transmitted = counters.transmitted; |
| 628 | 646 |
| 629 fake_clock_.AdvanceTimeMilliseconds(1000 * metrics::kMinRunTimeInSeconds); | 647 fake_clock_.AdvanceTimeMilliseconds(1000 * metrics::kMinRunTimeInSeconds); |
| 630 proxy->DataCountersUpdated(counters, kFirstSsrc); | 648 proxy->DataCountersUpdated(counters, kFirstSsrc); |
| 631 proxy->DataCountersUpdated(counters, kSecondSsrc); | 649 proxy->DataCountersUpdated(counters, kSecondSsrc); |
| 632 proxy->DataCountersUpdated(rtx_counters, kFirstRtxSsrc); | 650 proxy->DataCountersUpdated(rtx_counters, kFirstRtxSsrc); |
| 633 proxy->DataCountersUpdated(rtx_counters, kSecondRtxSsrc); | 651 proxy->DataCountersUpdated(rtx_counters, kSecondRtxSsrc); |
| 634 | 652 |
| 635 // Changing content type causes histograms to be reported. | 653 // Changing content type causes histograms to be reported. |
| 636 statistics_proxy_->SetContentType(VideoEncoderConfig::ContentType::kScreen); | 654 VideoEncoderConfig config; |
| 655 config.content_type = VideoEncoderConfig::ContentType::kScreen; | |
| 656 statistics_proxy_->OnEncoderReconfigured(config, 50); | |
| 637 | 657 |
| 638 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.BitrateSentInKbps")); | 658 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.BitrateSentInKbps")); |
| 639 EXPECT_EQ(1, | 659 EXPECT_EQ(1, |
| 640 metrics::NumEvents( | 660 metrics::NumEvents( |
| 641 "WebRTC.Video.BitrateSentInKbps", | 661 "WebRTC.Video.BitrateSentInKbps", |
| 642 static_cast<int>((counters.transmitted.TotalBytes() * 4 * 8) / | 662 static_cast<int>((counters.transmitted.TotalBytes() * 4 * 8) / |
| 643 metrics::kMinRunTimeInSeconds / 1000))); | 663 metrics::kMinRunTimeInSeconds / 1000))); |
| 644 | 664 |
| 645 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.MediaBitrateSentInKbps")); | 665 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.MediaBitrateSentInKbps")); |
| 646 EXPECT_EQ(1, metrics::NumEvents( | 666 EXPECT_EQ(1, metrics::NumEvents( |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 738 | 758 |
| 739 EXPECT_EQ( | 759 EXPECT_EQ( |
| 740 1, metrics::NumSamples("WebRTC.Video.Screenshare.FecBitrateSentInKbps")); | 760 1, metrics::NumSamples("WebRTC.Video.Screenshare.FecBitrateSentInKbps")); |
| 741 EXPECT_EQ(1, metrics::NumEvents( | 761 EXPECT_EQ(1, metrics::NumEvents( |
| 742 "WebRTC.Video.Screenshare.FecBitrateSentInKbps", | 762 "WebRTC.Video.Screenshare.FecBitrateSentInKbps", |
| 743 static_cast<int>((rtx_counters.fec.TotalBytes() * 2 * 8) / | 763 static_cast<int>((rtx_counters.fec.TotalBytes() * 2 * 8) / |
| 744 metrics::kMinRunTimeInSeconds / 1000))); | 764 metrics::kMinRunTimeInSeconds / 1000))); |
| 745 } | 765 } |
| 746 | 766 |
| 747 } // namespace webrtc | 767 } // namespace webrtc |
| OLD | NEW |