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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 420 for (int i = 0; i < kMinRequiredSamples; ++i) { | 420 for (int i = 0; i < kMinRequiredSamples; ++i) { |
| 421 encoded_image.qp_ = kQpIdx0; | 421 encoded_image.qp_ = kQpIdx0; |
| 422 codec_info.codecSpecific.VP9.spatial_idx = 0; | 422 codec_info.codecSpecific.VP9.spatial_idx = 0; |
| 423 statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info); | 423 statistics_proxy_->OnSendEncodedImage(encoded_image, &codec_info); |
| 424 } | 424 } |
| 425 statistics_proxy_.reset(); | 425 statistics_proxy_.reset(); |
| 426 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.Encoded.Qp.Vp9")); | 426 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.Encoded.Qp.Vp9")); |
| 427 EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.Encoded.Qp.Vp9", kQpIdx0)); | 427 EXPECT_EQ(1, metrics::NumEvents("WebRTC.Video.Encoded.Qp.Vp9", kQpIdx0)); |
| 428 } | 428 } |
| 429 | 429 |
| 430 TEST_F(SendStatisticsProxyTest, | |
| 431 BandwidthLimitedHistogramsNotUpdatedWhenDisabled) { | |
| 432 EncodedImage encoded_image; | |
| 433 // encoded_image.adapt_reason_.bw_resolutions_disabled by default: -1 | |
| 434 for (int i = 0; i < kMinRequiredSamples; ++i) | |
| 435 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); | |
| 436 | |
| 437 statistics_proxy_.reset(); | |
|
stefan-webrtc
2016/10/31 09:46:25
Why reset?
åsapersson
2016/10/31 10:07:27
Added comment.
| |
| 438 EXPECT_EQ(0, metrics::NumSamples( | |
| 439 "WebRTC.Video.BandwidthLimitedResolutionInPercent")); | |
| 440 EXPECT_EQ(0, metrics::NumSamples( | |
| 441 "WebRTC.Video.BandwidthLimitedResolutionsDisabled")); | |
| 442 } | |
| 443 | |
| 444 TEST_F(SendStatisticsProxyTest, | |
| 445 BandwidthLimitedHistogramsUpdatedWhenEnabled_NoResolutionDisabled) { | |
| 446 const int kResolutionsDisabled = 0; | |
| 447 EncodedImage encoded_image; | |
| 448 encoded_image.adapt_reason_.bw_resolutions_disabled = kResolutionsDisabled; | |
| 449 for (int i = 0; i < kMinRequiredSamples; ++i) | |
| 450 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); | |
| 451 | |
| 452 statistics_proxy_.reset(); | |
| 453 EXPECT_EQ(1, metrics::NumSamples( | |
| 454 "WebRTC.Video.BandwidthLimitedResolutionInPercent")); | |
| 455 EXPECT_EQ(1, metrics::NumEvents( | |
| 456 "WebRTC.Video.BandwidthLimitedResolutionInPercent", 0)); | |
| 457 // No resolution disabled. | |
| 458 EXPECT_EQ(0, metrics::NumSamples( | |
| 459 "WebRTC.Video.BandwidthLimitedResolutionsDisabled")); | |
| 460 } | |
| 461 | |
| 462 TEST_F(SendStatisticsProxyTest, | |
| 463 BandwidthLimitedHistogramsUpdatedWhenEnabled_OneResolutionDisabled) { | |
| 464 const int kResolutionsDisabled = 1; | |
| 465 EncodedImage encoded_image; | |
| 466 encoded_image.adapt_reason_.bw_resolutions_disabled = kResolutionsDisabled; | |
| 467 for (int i = 0; i < kMinRequiredSamples; ++i) | |
| 468 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); | |
| 469 | |
| 470 statistics_proxy_.reset(); | |
| 471 EXPECT_EQ(1, metrics::NumSamples( | |
| 472 "WebRTC.Video.BandwidthLimitedResolutionInPercent")); | |
| 473 EXPECT_EQ(1, metrics::NumEvents( | |
| 474 "WebRTC.Video.BandwidthLimitedResolutionInPercent", 100)); | |
| 475 // Resolutions disabled. | |
| 476 EXPECT_EQ(1, metrics::NumSamples( | |
| 477 "WebRTC.Video.BandwidthLimitedResolutionsDisabled")); | |
| 478 EXPECT_EQ( | |
| 479 1, metrics::NumEvents("WebRTC.Video.BandwidthLimitedResolutionsDisabled", | |
| 480 kResolutionsDisabled)); | |
| 481 } | |
| 482 | |
| 483 TEST_F(SendStatisticsProxyTest, | |
| 484 QualityLimitedHistogramsNotUpdatedWhenDisabled) { | |
| 485 EncodedImage encoded_image; | |
| 486 // encoded_image.adapt_reason_.quality_resolution_downscales disabled by | |
| 487 // default: -1 | |
| 488 for (int i = 0; i < kMinRequiredSamples; ++i) | |
| 489 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); | |
| 490 | |
| 491 statistics_proxy_.reset(); | |
| 492 EXPECT_EQ( | |
| 493 0, metrics::NumSamples("WebRTC.Video.QualityLimitedResolutionInPercent")); | |
| 494 EXPECT_EQ(0, metrics::NumSamples( | |
| 495 "WebRTC.Video.QualityLimitedResolutionDownscales")); | |
| 496 } | |
| 497 | |
| 498 TEST_F(SendStatisticsProxyTest, | |
| 499 QualityLimitedHistogramsUpdatedWhenEnabled_NoResolutionDownscale) { | |
| 500 const int kDownscales = 0; | |
| 501 EncodedImage encoded_image; | |
| 502 encoded_image.adapt_reason_.quality_resolution_downscales = kDownscales; | |
| 503 for (int i = 0; i < kMinRequiredSamples; ++i) | |
| 504 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); | |
| 505 | |
| 506 statistics_proxy_.reset(); | |
| 507 EXPECT_EQ( | |
| 508 1, metrics::NumSamples("WebRTC.Video.QualityLimitedResolutionInPercent")); | |
| 509 EXPECT_EQ(1, metrics::NumEvents( | |
| 510 "WebRTC.Video.QualityLimitedResolutionInPercent", 0)); | |
| 511 // No resolution downscale. | |
| 512 EXPECT_EQ(0, metrics::NumSamples( | |
| 513 "WebRTC.Video.QualityLimitedResolutionDownscales")); | |
| 514 } | |
| 515 | |
| 516 TEST_F(SendStatisticsProxyTest, | |
| 517 QualityLimitedHistogramsUpdatedWhenEnabled_TwoResolutionDownscales) { | |
| 518 const int kDownscales = 2; | |
| 519 EncodedImage encoded_image; | |
| 520 encoded_image.adapt_reason_.quality_resolution_downscales = kDownscales; | |
| 521 for (int i = 0; i < kMinRequiredSamples; ++i) | |
| 522 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); | |
| 523 | |
| 524 statistics_proxy_.reset(); | |
| 525 EXPECT_EQ( | |
| 526 1, metrics::NumSamples("WebRTC.Video.QualityLimitedResolutionInPercent")); | |
| 527 EXPECT_EQ(1, metrics::NumEvents( | |
| 528 "WebRTC.Video.QualityLimitedResolutionInPercent", 100)); | |
| 529 // Resolution downscales. | |
| 530 EXPECT_EQ(1, metrics::NumSamples( | |
| 531 "WebRTC.Video.QualityLimitedResolutionDownscales")); | |
| 532 EXPECT_EQ( | |
| 533 1, metrics::NumEvents("WebRTC.Video.QualityLimitedResolutionDownscales", | |
| 534 kDownscales)); | |
| 535 } | |
| 536 | |
| 537 TEST_F(SendStatisticsProxyTest, GetStatsReportsBandwidthLimitedResolution) { | |
| 538 // Initially false. | |
| 539 EXPECT_FALSE(statistics_proxy_->GetStats().bw_limited_resolution); | |
| 540 // No resolution scale by default. | |
| 541 EncodedImage encoded_image; | |
| 542 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); | |
| 543 EXPECT_FALSE(statistics_proxy_->GetStats().bw_limited_resolution); | |
| 544 // Resolution not scaled. | |
| 545 encoded_image.adapt_reason_.bw_resolutions_disabled = 0; | |
| 546 encoded_image.adapt_reason_.quality_resolution_downscales = 0; | |
| 547 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); | |
| 548 EXPECT_FALSE(statistics_proxy_->GetStats().bw_limited_resolution); | |
| 549 // Resolution scaled due to bandwidth. | |
| 550 encoded_image.adapt_reason_.bw_resolutions_disabled = 1; | |
| 551 encoded_image.adapt_reason_.quality_resolution_downscales = 0; | |
| 552 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); | |
| 553 EXPECT_TRUE(statistics_proxy_->GetStats().bw_limited_resolution); | |
| 554 // Resolution not scaled. | |
| 555 encoded_image.adapt_reason_.bw_resolutions_disabled = 0; | |
| 556 encoded_image.adapt_reason_.quality_resolution_downscales = 0; | |
| 557 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); | |
| 558 EXPECT_FALSE(statistics_proxy_->GetStats().bw_limited_resolution); | |
| 559 // Resolution scaled due to quality. | |
| 560 encoded_image.adapt_reason_.bw_resolutions_disabled = 0; | |
| 561 encoded_image.adapt_reason_.quality_resolution_downscales = 1; | |
| 562 statistics_proxy_->OnSendEncodedImage(encoded_image, nullptr); | |
| 563 EXPECT_TRUE(statistics_proxy_->GetStats().bw_limited_resolution); | |
| 564 } | |
| 565 | |
| 430 TEST_F(SendStatisticsProxyTest, NoSubstreams) { | 566 TEST_F(SendStatisticsProxyTest, NoSubstreams) { |
| 431 uint32_t excluded_ssrc = | 567 uint32_t excluded_ssrc = |
| 432 std::max( | 568 std::max( |
| 433 *std::max_element(config_.rtp.ssrcs.begin(), config_.rtp.ssrcs.end()), | 569 *std::max_element(config_.rtp.ssrcs.begin(), config_.rtp.ssrcs.end()), |
| 434 *std::max_element(config_.rtp.rtx.ssrcs.begin(), | 570 *std::max_element(config_.rtp.rtx.ssrcs.begin(), |
| 435 config_.rtp.rtx.ssrcs.end())) + | 571 config_.rtp.rtx.ssrcs.end())) + |
| 436 1; | 572 1; |
| 437 // From RtcpStatisticsCallback. | 573 // From RtcpStatisticsCallback. |
| 438 RtcpStatistics rtcp_stats; | 574 RtcpStatistics rtcp_stats; |
| 439 RtcpStatisticsCallback* rtcp_callback = statistics_proxy_.get(); | 575 RtcpStatisticsCallback* rtcp_callback = statistics_proxy_.get(); |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 767 | 903 |
| 768 EXPECT_EQ( | 904 EXPECT_EQ( |
| 769 1, metrics::NumSamples("WebRTC.Video.Screenshare.FecBitrateSentInKbps")); | 905 1, metrics::NumSamples("WebRTC.Video.Screenshare.FecBitrateSentInKbps")); |
| 770 EXPECT_EQ(1, metrics::NumEvents( | 906 EXPECT_EQ(1, metrics::NumEvents( |
| 771 "WebRTC.Video.Screenshare.FecBitrateSentInKbps", | 907 "WebRTC.Video.Screenshare.FecBitrateSentInKbps", |
| 772 static_cast<int>((rtx_counters.fec.TotalBytes() * 2 * 8) / | 908 static_cast<int>((rtx_counters.fec.TotalBytes() * 2 * 8) / |
| 773 metrics::kMinRunTimeInSeconds / 1000))); | 909 metrics::kMinRunTimeInSeconds / 1000))); |
| 774 } | 910 } |
| 775 | 911 |
| 776 } // namespace webrtc | 912 } // namespace webrtc |
| OLD | NEW |