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