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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 EXPECT_EQ(metrics.encode_usage_percent, stats.encode_usage_percent); | 288 EXPECT_EQ(metrics.encode_usage_percent, stats.encode_usage_percent); |
289 } | 289 } |
290 | 290 |
291 TEST_F(SendStatisticsProxyTest, SwitchContentTypeUpdatesHistograms) { | 291 TEST_F(SendStatisticsProxyTest, SwitchContentTypeUpdatesHistograms) { |
292 const int kWidth = 640; | 292 const int kWidth = 640; |
293 const int kHeight = 480; | 293 const int kHeight = 480; |
294 | 294 |
295 for (int i = 0; i < kMinRequiredSamples; ++i) | 295 for (int i = 0; i < kMinRequiredSamples; ++i) |
296 statistics_proxy_->OnIncomingFrame(kWidth, kHeight); | 296 statistics_proxy_->OnIncomingFrame(kWidth, kHeight); |
297 | 297 |
298 // No switch, stats not should be updated. | 298 // No switch, stats should not be updated. |
299 statistics_proxy_->SetContentType( | 299 VideoEncoderConfig config; |
300 VideoEncoderConfig::ContentType::kRealtimeVideo); | 300 config.content_type = VideoEncoderConfig::ContentType::kRealtimeVideo; |
| 301 std::vector<VideoStream> video_streams; |
| 302 statistics_proxy_->OnEncoderReconfigured(config, video_streams); |
301 EXPECT_EQ(0, metrics::NumSamples("WebRTC.Video.InputWidthInPixels")); | 303 EXPECT_EQ(0, metrics::NumSamples("WebRTC.Video.InputWidthInPixels")); |
302 | 304 |
303 // Switch to screenshare, real-time stats should be updated. | 305 // Switch to screenshare, real-time stats should be updated. |
304 statistics_proxy_->SetContentType(VideoEncoderConfig::ContentType::kScreen); | 306 config.content_type = VideoEncoderConfig::ContentType::kScreen; |
| 307 statistics_proxy_->OnEncoderReconfigured(config, video_streams); |
305 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.InputWidthInPixels")); | 308 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.InputWidthInPixels")); |
306 } | 309 } |
307 | 310 |
308 TEST_F(SendStatisticsProxyTest, LifetimeHistogramIsUpdated) { | 311 TEST_F(SendStatisticsProxyTest, LifetimeHistogramIsUpdated) { |
309 const int64_t kTimeSec = 3; | 312 const int64_t kTimeSec = 3; |
310 fake_clock_.AdvanceTimeMilliseconds(kTimeSec * 1000); | 313 fake_clock_.AdvanceTimeMilliseconds(kTimeSec * 1000); |
311 statistics_proxy_.reset(); | 314 statistics_proxy_.reset(); |
312 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.SendStreamLifetimeInSeconds")); | 315 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.SendStreamLifetimeInSeconds")); |
313 EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.SendStreamLifetimeInSeconds", | 316 EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.SendStreamLifetimeInSeconds", |
314 kTimeSec)); | 317 kTimeSec)); |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 counters.nack_packets += 1 * metrics::kMinRunTimeInSeconds; | 534 counters.nack_packets += 1 * metrics::kMinRunTimeInSeconds; |
532 counters.fir_packets += 2 * metrics::kMinRunTimeInSeconds; | 535 counters.fir_packets += 2 * metrics::kMinRunTimeInSeconds; |
533 counters.pli_packets += 3 * metrics::kMinRunTimeInSeconds; | 536 counters.pli_packets += 3 * metrics::kMinRunTimeInSeconds; |
534 counters.unique_nack_requests += 4 * metrics::kMinRunTimeInSeconds; | 537 counters.unique_nack_requests += 4 * metrics::kMinRunTimeInSeconds; |
535 counters.nack_requests += 5 * metrics::kMinRunTimeInSeconds; | 538 counters.nack_requests += 5 * metrics::kMinRunTimeInSeconds; |
536 | 539 |
537 proxy->RtcpPacketTypesCounterUpdated(kFirstSsrc, counters); | 540 proxy->RtcpPacketTypesCounterUpdated(kFirstSsrc, counters); |
538 proxy->RtcpPacketTypesCounterUpdated(kSecondSsrc, counters); | 541 proxy->RtcpPacketTypesCounterUpdated(kSecondSsrc, counters); |
539 | 542 |
540 // Changing content type causes histograms to be reported. | 543 // Changing content type causes histograms to be reported. |
541 statistics_proxy_->SetContentType(VideoEncoderConfig::ContentType::kScreen); | 544 VideoEncoderConfig config; |
| 545 config.content_type = VideoEncoderConfig::ContentType::kScreen; |
| 546 std::vector<VideoStream> video_streams; |
| 547 statistics_proxy_->OnEncoderReconfigured(config, video_streams); |
542 | 548 |
543 EXPECT_EQ(1, | 549 EXPECT_EQ(1, |
544 metrics::NumSamples("WebRTC.Video.NackPacketsReceivedPerMinute")); | 550 metrics::NumSamples("WebRTC.Video.NackPacketsReceivedPerMinute")); |
545 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.FirPacketsReceivedPerMinute")); | 551 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.FirPacketsReceivedPerMinute")); |
546 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.PliPacketsReceivedPerMinute")); | 552 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.PliPacketsReceivedPerMinute")); |
547 EXPECT_EQ(1, metrics::NumSamples( | 553 EXPECT_EQ(1, metrics::NumSamples( |
548 "WebRTC.Video.UniqueNackRequestsReceivedInPercent")); | 554 "WebRTC.Video.UniqueNackRequestsReceivedInPercent")); |
549 | 555 |
550 const int kRate = 60 * 2; // Packets per minute with two streams. | 556 const int kRate = 60 * 2; // Packets per minute with two streams. |
551 | 557 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 | 632 |
627 rtx_counters.transmitted = counters.transmitted; | 633 rtx_counters.transmitted = counters.transmitted; |
628 | 634 |
629 fake_clock_.AdvanceTimeMilliseconds(1000 * metrics::kMinRunTimeInSeconds); | 635 fake_clock_.AdvanceTimeMilliseconds(1000 * metrics::kMinRunTimeInSeconds); |
630 proxy->DataCountersUpdated(counters, kFirstSsrc); | 636 proxy->DataCountersUpdated(counters, kFirstSsrc); |
631 proxy->DataCountersUpdated(counters, kSecondSsrc); | 637 proxy->DataCountersUpdated(counters, kSecondSsrc); |
632 proxy->DataCountersUpdated(rtx_counters, kFirstRtxSsrc); | 638 proxy->DataCountersUpdated(rtx_counters, kFirstRtxSsrc); |
633 proxy->DataCountersUpdated(rtx_counters, kSecondRtxSsrc); | 639 proxy->DataCountersUpdated(rtx_counters, kSecondRtxSsrc); |
634 | 640 |
635 // Changing content type causes histograms to be reported. | 641 // Changing content type causes histograms to be reported. |
636 statistics_proxy_->SetContentType(VideoEncoderConfig::ContentType::kScreen); | 642 VideoEncoderConfig config; |
| 643 config.content_type = VideoEncoderConfig::ContentType::kScreen; |
| 644 std::vector<VideoStream> video_streams; |
| 645 statistics_proxy_->OnEncoderReconfigured(config, video_streams); |
637 | 646 |
638 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.BitrateSentInKbps")); | 647 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.BitrateSentInKbps")); |
639 EXPECT_EQ(1, | 648 EXPECT_EQ(1, |
640 metrics::NumEvents( | 649 metrics::NumEvents( |
641 "WebRTC.Video.BitrateSentInKbps", | 650 "WebRTC.Video.BitrateSentInKbps", |
642 static_cast<int>((counters.transmitted.TotalBytes() * 4 * 8) / | 651 static_cast<int>((counters.transmitted.TotalBytes() * 4 * 8) / |
643 metrics::kMinRunTimeInSeconds / 1000))); | 652 metrics::kMinRunTimeInSeconds / 1000))); |
644 | 653 |
645 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.MediaBitrateSentInKbps")); | 654 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.MediaBitrateSentInKbps")); |
646 EXPECT_EQ(1, metrics::NumEvents( | 655 EXPECT_EQ(1, metrics::NumEvents( |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 | 747 |
739 EXPECT_EQ( | 748 EXPECT_EQ( |
740 1, metrics::NumSamples("WebRTC.Video.Screenshare.FecBitrateSentInKbps")); | 749 1, metrics::NumSamples("WebRTC.Video.Screenshare.FecBitrateSentInKbps")); |
741 EXPECT_EQ(1, metrics::NumEvents( | 750 EXPECT_EQ(1, metrics::NumEvents( |
742 "WebRTC.Video.Screenshare.FecBitrateSentInKbps", | 751 "WebRTC.Video.Screenshare.FecBitrateSentInKbps", |
743 static_cast<int>((rtx_counters.fec.TotalBytes() * 2 * 8) / | 752 static_cast<int>((rtx_counters.fec.TotalBytes() * 2 * 8) / |
744 metrics::kMinRunTimeInSeconds / 1000))); | 753 metrics::kMinRunTimeInSeconds / 1000))); |
745 } | 754 } |
746 | 755 |
747 } // namespace webrtc | 756 } // namespace webrtc |
OLD | NEW |