OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 1407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1418 CreateFrame(i, frame_width, frame_height)); | 1418 CreateFrame(i, frame_width, frame_height)); |
1419 sink_.WaitForEncodedFrame(i); | 1419 sink_.WaitForEncodedFrame(i); |
1420 // Trigger scale down. | 1420 // Trigger scale down. |
1421 vie_encoder_->TriggerQualityLow(); | 1421 vie_encoder_->TriggerQualityLow(); |
1422 EXPECT_GE(video_source_.sink_wants().max_pixel_count, kMinPixelsPerFrame); | 1422 EXPECT_GE(video_source_.sink_wants().max_pixel_count, kMinPixelsPerFrame); |
1423 } | 1423 } |
1424 | 1424 |
1425 vie_encoder_->Stop(); | 1425 vie_encoder_->Stop(); |
1426 } | 1426 } |
1427 | 1427 |
1428 TEST_F(ViEEncoderTest, UMACpuLimitedResolutionInPercent) { | 1428 TEST_F(ViEEncoderTest, CpuLimitedHistogramIsReported) { |
1429 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); | 1429 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); |
1430 | |
1431 const int kWidth = 640; | 1430 const int kWidth = 640; |
1432 const int kHeight = 360; | 1431 const int kHeight = 360; |
1433 | 1432 |
1434 for (int i = 1; i <= SendStatisticsProxy::kMinRequiredMetricsSamples; ++i) { | 1433 for (int i = 1; i <= SendStatisticsProxy::kMinRequiredMetricsSamples; ++i) { |
1435 video_source_.IncomingCapturedFrame(CreateFrame(i, kWidth, kHeight)); | 1434 video_source_.IncomingCapturedFrame(CreateFrame(i, kWidth, kHeight)); |
1436 sink_.WaitForEncodedFrame(i); | 1435 sink_.WaitForEncodedFrame(i); |
1437 } | 1436 } |
1438 | 1437 |
1439 vie_encoder_->TriggerCpuOveruse(); | 1438 vie_encoder_->TriggerCpuOveruse(); |
1440 for (int i = 1; i <= SendStatisticsProxy::kMinRequiredMetricsSamples; ++i) { | 1439 for (int i = 1; i <= SendStatisticsProxy::kMinRequiredMetricsSamples; ++i) { |
1441 video_source_.IncomingCapturedFrame(CreateFrame( | 1440 video_source_.IncomingCapturedFrame(CreateFrame( |
1442 SendStatisticsProxy::kMinRequiredMetricsSamples + i, kWidth, kHeight)); | 1441 SendStatisticsProxy::kMinRequiredMetricsSamples + i, kWidth, kHeight)); |
1443 sink_.WaitForEncodedFrame(SendStatisticsProxy::kMinRequiredMetricsSamples + | 1442 sink_.WaitForEncodedFrame(SendStatisticsProxy::kMinRequiredMetricsSamples + |
1444 i); | 1443 i); |
1445 } | 1444 } |
1446 | 1445 |
1447 vie_encoder_->Stop(); | 1446 vie_encoder_->Stop(); |
1448 vie_encoder_.reset(); | 1447 vie_encoder_.reset(); |
1449 stats_proxy_.reset(); | 1448 stats_proxy_.reset(); |
1450 | 1449 |
1451 EXPECT_EQ(1, | 1450 EXPECT_EQ(1, |
1452 metrics::NumSamples("WebRTC.Video.CpuLimitedResolutionInPercent")); | 1451 metrics::NumSamples("WebRTC.Video.CpuLimitedResolutionInPercent")); |
1453 EXPECT_EQ( | 1452 EXPECT_EQ( |
1454 1, metrics::NumEvents("WebRTC.Video.CpuLimitedResolutionInPercent", 50)); | 1453 1, metrics::NumEvents("WebRTC.Video.CpuLimitedResolutionInPercent", 50)); |
1455 } | 1454 } |
1456 | 1455 |
| 1456 TEST_F(ViEEncoderTest, CpuLimitedHistogramIsNotReportedForDisabledDegradation) { |
| 1457 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); |
| 1458 const int kWidth = 640; |
| 1459 const int kHeight = 360; |
| 1460 |
| 1461 vie_encoder_->SetSource( |
| 1462 &video_source_, |
| 1463 VideoSendStream::DegradationPreference::kDegradationDisabled); |
| 1464 |
| 1465 for (int i = 1; i <= SendStatisticsProxy::kMinRequiredMetricsSamples; ++i) { |
| 1466 video_source_.IncomingCapturedFrame(CreateFrame(i, kWidth, kHeight)); |
| 1467 sink_.WaitForEncodedFrame(i); |
| 1468 } |
| 1469 |
| 1470 vie_encoder_->Stop(); |
| 1471 vie_encoder_.reset(); |
| 1472 stats_proxy_.reset(); |
| 1473 |
| 1474 EXPECT_EQ(0, |
| 1475 metrics::NumSamples("WebRTC.Video.CpuLimitedResolutionInPercent")); |
| 1476 } |
| 1477 |
1457 TEST_F(ViEEncoderTest, CallsBitrateObserver) { | 1478 TEST_F(ViEEncoderTest, CallsBitrateObserver) { |
1458 class MockBitrateObserver : public VideoBitrateAllocationObserver { | 1479 class MockBitrateObserver : public VideoBitrateAllocationObserver { |
1459 public: | 1480 public: |
1460 MOCK_METHOD1(OnBitrateAllocationUpdated, void(const BitrateAllocation&)); | 1481 MOCK_METHOD1(OnBitrateAllocationUpdated, void(const BitrateAllocation&)); |
1461 } bitrate_observer; | 1482 } bitrate_observer; |
1462 vie_encoder_->SetBitrateObserver(&bitrate_observer); | 1483 vie_encoder_->SetBitrateObserver(&bitrate_observer); |
1463 | 1484 |
1464 const int kDefaultFps = 30; | 1485 const int kDefaultFps = 30; |
1465 const BitrateAllocation expected_bitrate = | 1486 const BitrateAllocation expected_bitrate = |
1466 DefaultVideoBitrateAllocator(fake_encoder_.codec_config()) | 1487 DefaultVideoBitrateAllocator(fake_encoder_.codec_config()) |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1770 for (int i = 0; i < 10; ++i) { | 1791 for (int i = 0; i < 10; ++i) { |
1771 timestamp_ms += kMinFpsFrameInterval; | 1792 timestamp_ms += kMinFpsFrameInterval; |
1772 fake_clock.AdvanceTimeMicros(kMinFpsFrameInterval * 1000); | 1793 fake_clock.AdvanceTimeMicros(kMinFpsFrameInterval * 1000); |
1773 video_source_.IncomingCapturedFrame( | 1794 video_source_.IncomingCapturedFrame( |
1774 CreateFrame(timestamp_ms, kFrameWidth, kFrameHeight)); | 1795 CreateFrame(timestamp_ms, kFrameWidth, kFrameHeight)); |
1775 sink_.WaitForEncodedFrame(timestamp_ms); | 1796 sink_.WaitForEncodedFrame(timestamp_ms); |
1776 } | 1797 } |
1777 vie_encoder_->Stop(); | 1798 vie_encoder_->Stop(); |
1778 } | 1799 } |
1779 } // namespace webrtc | 1800 } // namespace webrtc |
OLD | NEW |