OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2004 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 1715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1726 } | 1726 } |
1727 | 1727 |
1728 TEST_F(WebRtcVideoChannel2Test, DoesNotAdaptOnOveruseWhenDisabled) { | 1728 TEST_F(WebRtcVideoChannel2Test, DoesNotAdaptOnOveruseWhenDisabled) { |
1729 TestCpuAdaptation(false, false); | 1729 TestCpuAdaptation(false, false); |
1730 } | 1730 } |
1731 | 1731 |
1732 TEST_F(WebRtcVideoChannel2Test, DoesNotAdaptOnOveruseWhenScreensharing) { | 1732 TEST_F(WebRtcVideoChannel2Test, DoesNotAdaptOnOveruseWhenScreensharing) { |
1733 TestCpuAdaptation(true, true); | 1733 TestCpuAdaptation(true, true); |
1734 } | 1734 } |
1735 | 1735 |
| 1736 TEST_F(WebRtcVideoChannel2Test, AdaptsOnOveruseAndChangeResolution) { |
| 1737 cricket::VideoCodec codec = kVp8Codec720p; |
| 1738 cricket::VideoSendParameters parameters; |
| 1739 parameters.codecs.push_back(codec); |
| 1740 |
| 1741 MediaConfig media_config = MediaConfig(); |
| 1742 channel_.reset( |
| 1743 engine_.CreateChannel(fake_call_.get(), media_config, VideoOptions())); |
| 1744 ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
| 1745 |
| 1746 AddSendStream(); |
| 1747 |
| 1748 cricket::FakeVideoCapturer capturer; |
| 1749 capturer.SetScreencast(false); |
| 1750 ASSERT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); |
| 1751 ASSERT_EQ(cricket::CS_RUNNING, |
| 1752 capturer.Start(capturer.GetSupportedFormats()->front())); |
| 1753 ASSERT_TRUE(channel_->SetSend(true)); |
| 1754 |
| 1755 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size()); |
| 1756 FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front(); |
| 1757 webrtc::LoadObserver* overuse_callback = |
| 1758 send_stream->GetConfig().overuse_callback; |
| 1759 ASSERT_TRUE(overuse_callback != NULL); |
| 1760 |
| 1761 EXPECT_TRUE(capturer.CaptureCustomFrame(1280, 720, cricket::FOURCC_I420)); |
| 1762 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames()); |
| 1763 EXPECT_EQ(1280, send_stream->GetLastWidth()); |
| 1764 EXPECT_EQ(720, send_stream->GetLastHeight()); |
| 1765 |
| 1766 // Trigger overuse. |
| 1767 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kOveruse); |
| 1768 EXPECT_TRUE(capturer.CaptureCustomFrame(1280, 720, cricket::FOURCC_I420)); |
| 1769 EXPECT_EQ(2, send_stream->GetNumberOfSwappedFrames()); |
| 1770 EXPECT_EQ(1280 * 3 / 4, send_stream->GetLastWidth()); |
| 1771 EXPECT_EQ(720 * 3 / 4, send_stream->GetLastHeight()); |
| 1772 |
| 1773 // Trigger overuse again. |
| 1774 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kOveruse); |
| 1775 EXPECT_TRUE(capturer.CaptureCustomFrame(1280, 720, cricket::FOURCC_I420)); |
| 1776 EXPECT_EQ(3, send_stream->GetNumberOfSwappedFrames()); |
| 1777 EXPECT_EQ(1280 * 2 / 4, send_stream->GetLastWidth()); |
| 1778 EXPECT_EQ(720 * 2 / 4, send_stream->GetLastHeight()); |
| 1779 |
| 1780 // Change input resolution. |
| 1781 EXPECT_TRUE(capturer.CaptureCustomFrame(1284, 724, cricket::FOURCC_I420)); |
| 1782 EXPECT_EQ(4, send_stream->GetNumberOfSwappedFrames()); |
| 1783 EXPECT_EQ(1284 / 2, send_stream->GetLastWidth()); |
| 1784 EXPECT_EQ(724 / 2, send_stream->GetLastHeight()); |
| 1785 |
| 1786 // Trigger underuse which should go back up in resolution. |
| 1787 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kUnderuse); |
| 1788 EXPECT_TRUE(capturer.CaptureCustomFrame(1284, 724, cricket::FOURCC_I420)); |
| 1789 EXPECT_EQ(5, send_stream->GetNumberOfSwappedFrames()); |
| 1790 EXPECT_EQ(1284 * 3 / 4, send_stream->GetLastWidth()); |
| 1791 EXPECT_EQ(724 * 3 / 4, send_stream->GetLastHeight()); |
| 1792 |
| 1793 // Trigger underuse which should go back up in resolution. |
| 1794 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kUnderuse); |
| 1795 EXPECT_TRUE(capturer.CaptureCustomFrame(1284, 724, cricket::FOURCC_I420)); |
| 1796 EXPECT_EQ(6, send_stream->GetNumberOfSwappedFrames()); |
| 1797 EXPECT_EQ(1284, send_stream->GetLastWidth()); |
| 1798 EXPECT_EQ(724, send_stream->GetLastHeight()); |
| 1799 |
| 1800 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); |
| 1801 } |
| 1802 |
1736 void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse, | 1803 void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse, |
1737 bool is_screenshare) { | 1804 bool is_screenshare) { |
1738 cricket::VideoCodec codec = kVp8Codec720p; | 1805 cricket::VideoCodec codec = kVp8Codec720p; |
1739 cricket::VideoSendParameters parameters; | 1806 cricket::VideoSendParameters parameters; |
1740 parameters.codecs.push_back(codec); | 1807 parameters.codecs.push_back(codec); |
1741 | 1808 |
1742 MediaConfig media_config = MediaConfig(); | 1809 MediaConfig media_config = MediaConfig(); |
1743 if (!enable_overuse) { | 1810 if (!enable_overuse) { |
1744 media_config.enable_cpu_overuse_detection = false; | 1811 media_config.enable_cpu_overuse_detection = false; |
1745 } | 1812 } |
(...skipping 10 matching lines...) Expand all Loading... |
1756 EXPECT_EQ(cricket::CS_RUNNING, | 1823 EXPECT_EQ(cricket::CS_RUNNING, |
1757 capturer.Start(capturer.GetSupportedFormats()->front())); | 1824 capturer.Start(capturer.GetSupportedFormats()->front())); |
1758 | 1825 |
1759 EXPECT_TRUE(channel_->SetSend(true)); | 1826 EXPECT_TRUE(channel_->SetSend(true)); |
1760 | 1827 |
1761 // Trigger overuse. | 1828 // Trigger overuse. |
1762 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size()); | 1829 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size()); |
1763 FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front(); | 1830 FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front(); |
1764 webrtc::LoadObserver* overuse_callback = | 1831 webrtc::LoadObserver* overuse_callback = |
1765 send_stream->GetConfig().overuse_callback; | 1832 send_stream->GetConfig().overuse_callback; |
| 1833 |
| 1834 if (!enable_overuse) { |
| 1835 ASSERT_TRUE(overuse_callback == NULL); |
| 1836 |
| 1837 EXPECT_TRUE(capturer.CaptureFrame()); |
| 1838 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames()); |
| 1839 |
| 1840 EXPECT_EQ(codec.width, send_stream->GetLastWidth()); |
| 1841 EXPECT_EQ(codec.height, send_stream->GetLastHeight()); |
| 1842 |
| 1843 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); |
| 1844 return; |
| 1845 } |
| 1846 |
1766 ASSERT_TRUE(overuse_callback != NULL); | 1847 ASSERT_TRUE(overuse_callback != NULL); |
| 1848 EXPECT_TRUE(capturer.CaptureFrame()); |
| 1849 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames()); |
1767 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kOveruse); | 1850 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kOveruse); |
1768 | 1851 |
1769 EXPECT_TRUE(capturer.CaptureFrame()); | 1852 EXPECT_TRUE(capturer.CaptureFrame()); |
1770 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames()); | 1853 EXPECT_EQ(2, send_stream->GetNumberOfSwappedFrames()); |
1771 | 1854 |
1772 if (enable_overuse && !is_screenshare) { | 1855 if (is_screenshare) { |
| 1856 // Do not adapt screen share. |
| 1857 EXPECT_EQ(codec.width, send_stream->GetLastWidth()); |
| 1858 EXPECT_EQ(codec.height, send_stream->GetLastHeight()); |
| 1859 } else { |
1773 EXPECT_LT(send_stream->GetLastWidth(), codec.width); | 1860 EXPECT_LT(send_stream->GetLastWidth(), codec.width); |
1774 EXPECT_LT(send_stream->GetLastHeight(), codec.height); | 1861 EXPECT_LT(send_stream->GetLastHeight(), codec.height); |
1775 } else { | |
1776 EXPECT_EQ(codec.width, send_stream->GetLastWidth()); | |
1777 EXPECT_EQ(codec.height, send_stream->GetLastHeight()); | |
1778 } | 1862 } |
1779 | 1863 |
1780 // Trigger underuse which should go back to normal resolution. | 1864 // Trigger underuse which should go back to normal resolution. |
1781 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kUnderuse); | 1865 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kUnderuse); |
1782 EXPECT_TRUE(capturer.CaptureFrame()); | 1866 EXPECT_TRUE(capturer.CaptureFrame()); |
1783 | 1867 EXPECT_EQ(3, send_stream->GetNumberOfSwappedFrames()); |
1784 EXPECT_EQ(2, send_stream->GetNumberOfSwappedFrames()); | |
1785 | 1868 |
1786 EXPECT_EQ(codec.width, send_stream->GetLastWidth()); | 1869 EXPECT_EQ(codec.width, send_stream->GetLastWidth()); |
1787 EXPECT_EQ(codec.height, send_stream->GetLastHeight()); | 1870 EXPECT_EQ(codec.height, send_stream->GetLastHeight()); |
1788 | 1871 |
1789 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); | 1872 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); |
1790 } | 1873 } |
1791 | 1874 |
1792 TEST_F(WebRtcVideoChannel2Test, EstimatesNtpStartTimeCorrectly) { | 1875 TEST_F(WebRtcVideoChannel2Test, EstimatesNtpStartTimeCorrectly) { |
1793 // Start at last timestamp to verify that wraparounds are estimated correctly. | 1876 // Start at last timestamp to verify that wraparounds are estimated correctly. |
1794 static const uint32_t kInitialTimestamp = 0xFFFFFFFFu; | 1877 static const uint32_t kInitialTimestamp = 0xFFFFFFFFu; |
(...skipping 1283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3078 // Test that we normalize send codec format size in simulcast. | 3161 // Test that we normalize send codec format size in simulcast. |
3079 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { | 3162 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { |
3080 cricket::VideoCodec codec(kVp8Codec270p); | 3163 cricket::VideoCodec codec(kVp8Codec270p); |
3081 codec.width += 1; | 3164 codec.width += 1; |
3082 codec.height += 1; | 3165 codec.height += 1; |
3083 VerifySimulcastSettings(codec, 2, 2); | 3166 VerifySimulcastSettings(codec, 2, 2); |
3084 } | 3167 } |
3085 } // namespace cricket | 3168 } // namespace cricket |
3086 | 3169 |
3087 #endif // HAVE_WEBRTC_VIDEO | 3170 #endif // HAVE_WEBRTC_VIDEO |
OLD | NEW |