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 1641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1652 // Insert frames at min fps, all should go through. | 1652 // Insert frames at min fps, all should go through. |
1653 for (int i = 0; i < 10; ++i) { | 1653 for (int i = 0; i < 10; ++i) { |
1654 timestamp_ms += kMinFpsFrameInterval; | 1654 timestamp_ms += kMinFpsFrameInterval; |
1655 fake_clock.AdvanceTimeMicros(kMinFpsFrameInterval * 1000); | 1655 fake_clock.AdvanceTimeMicros(kMinFpsFrameInterval * 1000); |
1656 video_source_.IncomingCapturedFrame( | 1656 video_source_.IncomingCapturedFrame( |
1657 CreateFrame(timestamp_ms, kFrameWidth, kFrameHeight)); | 1657 CreateFrame(timestamp_ms, kFrameWidth, kFrameHeight)); |
1658 sink_.WaitForEncodedFrame(timestamp_ms); | 1658 sink_.WaitForEncodedFrame(timestamp_ms); |
1659 } | 1659 } |
1660 vie_encoder_->Stop(); | 1660 vie_encoder_->Stop(); |
1661 } | 1661 } |
| 1662 |
| 1663 TEST_F(ViEEncoderTest, PriodicallyUpdatesChannelParameters) { |
| 1664 const int kFrameWidth = 1280; |
| 1665 const int kFrameHeight = 720; |
| 1666 const int kLowFps = 2; |
| 1667 const int kHighFps = 30; |
| 1668 |
| 1669 rtc::ScopedFakeClock fake_clock; |
| 1670 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); |
| 1671 |
| 1672 int64_t timestamp_ms = 1000; |
| 1673 |
| 1674 // Insert 2 seconds of 2fps video. |
| 1675 for (int i = 0; i < kLowFps * 2; ++i) { |
| 1676 video_source_.IncomingCapturedFrame( |
| 1677 CreateFrame(timestamp_ms, kFrameWidth, kFrameHeight)); |
| 1678 sink_.WaitForEncodedFrame(timestamp_ms); |
| 1679 timestamp_ms += 1000 / kLowFps; |
| 1680 fake_clock.AdvanceTimeMicros((1000 / kLowFps) * 1000); |
| 1681 } |
| 1682 |
| 1683 // Make sure encoder is updated with new target. |
| 1684 vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); |
| 1685 video_source_.IncomingCapturedFrame( |
| 1686 CreateFrame(timestamp_ms, kFrameWidth, kFrameHeight)); |
| 1687 sink_.WaitForEncodedFrame(timestamp_ms); |
| 1688 timestamp_ms += 1000 / kLowFps; |
| 1689 fake_clock.AdvanceTimeMicros((1000 / kLowFps) * 1000); |
| 1690 |
| 1691 EXPECT_EQ(kLowFps, fake_encoder_.GetConfiguredInputFramerate()); |
| 1692 |
| 1693 // Insert 30fps frames for just a little more than the forced update period. |
| 1694 const int kVcmTimerIntervalFrames = |
| 1695 (vcm::VCMProcessTimer::kDefaultProcessIntervalMs * kHighFps) / 1000; |
| 1696 for (int i = 0; i < kVcmTimerIntervalFrames + 2; ++i) { |
| 1697 video_source_.IncomingCapturedFrame( |
| 1698 CreateFrame(timestamp_ms, kFrameWidth, kFrameHeight)); |
| 1699 sink_.WaitForEncodedFrame(timestamp_ms); |
| 1700 timestamp_ms += 1000 / kHighFps; |
| 1701 fake_clock.AdvanceTimeMicros((1000 / kHighFps) * 1000); |
| 1702 } |
| 1703 |
| 1704 // Don expect correct measurement just yet, but it should be higher than |
| 1705 // before. |
| 1706 EXPECT_GT(fake_encoder_.GetConfiguredInputFramerate(), kLowFps); |
| 1707 |
| 1708 vie_encoder_->Stop(); |
| 1709 } |
1662 } // namespace webrtc | 1710 } // namespace webrtc |
OLD | NEW |