Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Side by Side Diff: webrtc/media/engine/webrtcvideoengine2_unittest.cc

Issue 1695263002: Move direct use of VideoCapturer::VideoAdapter to VideoSinkWants. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixed wants.rotation_applied = false + fixed unittests. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1472 matching lines...) Expand 10 before | Expand all | Expand 10 after
1483 1483
1484 // Verify non-screencast settings. 1484 // Verify non-screencast settings.
1485 webrtc::VideoEncoderConfig encoder_config = send_stream->GetEncoderConfig(); 1485 webrtc::VideoEncoderConfig encoder_config = send_stream->GetEncoderConfig();
1486 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo, 1486 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo,
1487 encoder_config.content_type); 1487 encoder_config.content_type);
1488 EXPECT_EQ(codec.width, encoder_config.streams.front().width); 1488 EXPECT_EQ(codec.width, encoder_config.streams.front().width);
1489 EXPECT_EQ(codec.height, encoder_config.streams.front().height); 1489 EXPECT_EQ(codec.height, encoder_config.streams.front().height);
1490 EXPECT_EQ(0, encoder_config.min_transmit_bitrate_bps) 1490 EXPECT_EQ(0, encoder_config.min_transmit_bitrate_bps)
1491 << "Non-screenshare shouldn't use min-transmit bitrate."; 1491 << "Non-screenshare shouldn't use min-transmit bitrate.";
1492 1492
1493 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, nullptr));
1494 // Removing a capturer triggers a black frame to be sent.
1495 EXPECT_EQ(2, send_stream->GetNumberOfSwappedFrames());
1493 capturer.SetScreencast(true); 1496 capturer.SetScreencast(true);
1497 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer));
1494 EXPECT_TRUE(capturer.CaptureFrame()); 1498 EXPECT_TRUE(capturer.CaptureFrame());
1495 1499 EXPECT_EQ(3, send_stream->GetNumberOfSwappedFrames());
1496 EXPECT_EQ(2, send_stream->GetNumberOfSwappedFrames());
1497 1500
1498 // Verify screencast settings. 1501 // Verify screencast settings.
1499 encoder_config = send_stream->GetEncoderConfig(); 1502 encoder_config = send_stream->GetEncoderConfig();
1500 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kScreen, 1503 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kScreen,
1501 encoder_config.content_type); 1504 encoder_config.content_type);
1502 EXPECT_EQ(kScreenshareMinBitrateKbps * 1000, 1505 EXPECT_EQ(kScreenshareMinBitrateKbps * 1000,
1503 encoder_config.min_transmit_bitrate_bps); 1506 encoder_config.min_transmit_bitrate_bps);
1504 1507
1505 EXPECT_EQ(capture_format_hd.width, encoder_config.streams.front().width); 1508 EXPECT_EQ(capture_format_hd.width, encoder_config.streams.front().width);
1506 EXPECT_EQ(capture_format_hd.height, encoder_config.streams.front().height); 1509 EXPECT_EQ(capture_format_hd.height, encoder_config.streams.front().height);
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1617 channel_->SetSend(true); 1620 channel_->SetSend(true);
1618 EXPECT_TRUE(capturer.CaptureFrame()); 1621 EXPECT_TRUE(capturer.CaptureFrame());
1619 1622
1620 EXPECT_EQ(3, stream->GetVideoStreams().size()); 1623 EXPECT_EQ(3, stream->GetVideoStreams().size());
1621 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; 1624 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set.";
1622 // Autmatic resize off when using simulcast. 1625 // Autmatic resize off when using simulcast.
1623 EXPECT_FALSE(vp8_settings.automaticResizeOn); 1626 EXPECT_FALSE(vp8_settings.automaticResizeOn);
1624 EXPECT_TRUE(vp8_settings.frameDroppingOn); 1627 EXPECT_TRUE(vp8_settings.frameDroppingOn);
1625 1628
1626 // In screen-share mode, denoising is forced off and simulcast disabled. 1629 // In screen-share mode, denoising is forced off and simulcast disabled.
1630 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL));
1627 capturer.SetScreencast(true); 1631 capturer.SetScreencast(true);
1632 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer));
1628 EXPECT_TRUE(capturer.CaptureFrame()); 1633 EXPECT_TRUE(capturer.CaptureFrame());
1629 stream = SetDenoisingOption(parameters, false); 1634 stream = SetDenoisingOption(parameters, false);
1630 1635
1631 EXPECT_EQ(1, stream->GetVideoStreams().size()); 1636 EXPECT_EQ(1, stream->GetVideoStreams().size());
1632 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; 1637 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set.";
1633 EXPECT_FALSE(vp8_settings.denoisingOn); 1638 EXPECT_FALSE(vp8_settings.denoisingOn);
1634 // Resizing and frame dropping always off for screen sharing. 1639 // Resizing and frame dropping always off for screen sharing.
1635 EXPECT_FALSE(vp8_settings.automaticResizeOn); 1640 EXPECT_FALSE(vp8_settings.automaticResizeOn);
1636 EXPECT_FALSE(vp8_settings.frameDroppingOn); 1641 EXPECT_FALSE(vp8_settings.frameDroppingOn);
1637 1642
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1696 // Frame dropping always on for real time video. 1701 // Frame dropping always on for real time video.
1697 EXPECT_TRUE(vp9_settings.frameDroppingOn); 1702 EXPECT_TRUE(vp9_settings.frameDroppingOn);
1698 1703
1699 stream = SetDenoisingOption(parameters, true); 1704 stream = SetDenoisingOption(parameters, true);
1700 1705
1701 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set."; 1706 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set.";
1702 EXPECT_TRUE(vp9_settings.denoisingOn); 1707 EXPECT_TRUE(vp9_settings.denoisingOn);
1703 EXPECT_TRUE(vp9_settings.frameDroppingOn); 1708 EXPECT_TRUE(vp9_settings.frameDroppingOn);
1704 1709
1705 // In screen-share mode, denoising is forced off. 1710 // In screen-share mode, denoising is forced off.
1711 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, nullptr));
1706 capturer.SetScreencast(true); 1712 capturer.SetScreencast(true);
1713 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer));
1714
1707 EXPECT_TRUE(capturer.CaptureFrame()); 1715 EXPECT_TRUE(capturer.CaptureFrame());
1708 stream = SetDenoisingOption(parameters, false); 1716 stream = SetDenoisingOption(parameters, false);
1709 1717
1710 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set."; 1718 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set.";
1711 EXPECT_FALSE(vp9_settings.denoisingOn); 1719 EXPECT_FALSE(vp9_settings.denoisingOn);
1712 // Frame dropping always off for screen sharing. 1720 // Frame dropping always off for screen sharing.
1713 EXPECT_FALSE(vp9_settings.frameDroppingOn); 1721 EXPECT_FALSE(vp9_settings.frameDroppingOn);
1714 1722
1715 stream = SetDenoisingOption(parameters, false); 1723 stream = SetDenoisingOption(parameters, false);
1716 1724
1717 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set."; 1725 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set.";
1718 EXPECT_FALSE(vp9_settings.denoisingOn); 1726 EXPECT_FALSE(vp9_settings.denoisingOn);
1719 EXPECT_FALSE(vp9_settings.frameDroppingOn); 1727 EXPECT_FALSE(vp9_settings.frameDroppingOn);
1720 1728
1721 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); 1729 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL));
1722 } 1730 }
1723 1731
1724 TEST_F(WebRtcVideoChannel2Test, AdaptsOnOveruse) { 1732 TEST_F(WebRtcVideoChannel2Test, AdaptsOnOveruse) {
1725 TestCpuAdaptation(true, false); 1733 TestCpuAdaptation(true, false);
1726 } 1734 }
1727 1735
1728 TEST_F(WebRtcVideoChannel2Test, DoesNotAdaptOnOveruseWhenDisabled) { 1736 TEST_F(WebRtcVideoChannel2Test, DoesNotAdaptOnOveruseWhenDisabled) {
1729 TestCpuAdaptation(false, false); 1737 TestCpuAdaptation(false, false);
1730 } 1738 }
1731 1739
1732 TEST_F(WebRtcVideoChannel2Test, DoesNotAdaptOnOveruseWhenScreensharing) { 1740 TEST_F(WebRtcVideoChannel2Test, DoesNotAdaptOnOveruseWhenScreensharing) {
1733 TestCpuAdaptation(true, true); 1741 TestCpuAdaptation(true, true);
1734 } 1742 }
1735 1743
1744 TEST_F(WebRtcVideoChannel2Test, AdaptsOnOveruseAndChangeResolution) {
1745 cricket::VideoCodec codec = kVp8Codec720p;
1746 cricket::VideoSendParameters parameters;
1747 parameters.codecs.push_back(codec);
1748
1749 MediaConfig media_config = MediaConfig();
1750 channel_.reset(
1751 engine_.CreateChannel(fake_call_.get(), media_config, VideoOptions()));
1752 ASSERT_TRUE(channel_->SetSendParameters(parameters));
1753
1754 AddSendStream();
1755
1756 cricket::FakeVideoCapturer capturer;
1757 capturer.SetScreencast(false);
1758 ASSERT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer));
1759 ASSERT_EQ(cricket::CS_RUNNING,
1760 capturer.Start(capturer.GetSupportedFormats()->front()));
1761 ASSERT_TRUE(channel_->SetSend(true));
1762
1763 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size());
1764 FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front();
1765 webrtc::LoadObserver* overuse_callback =
1766 send_stream->GetConfig().overuse_callback;
1767 ASSERT_TRUE(overuse_callback != NULL);
1768
1769 EXPECT_TRUE(capturer.CaptureCustomFrame(1280, 720, cricket::FOURCC_I420));
1770 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames());
1771 EXPECT_EQ(1280, send_stream->GetLastWidth());
1772 EXPECT_EQ(720, send_stream->GetLastHeight());
1773
1774 // Trigger overuse.
1775 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kOveruse);
1776 EXPECT_TRUE(capturer.CaptureCustomFrame(1280, 720, cricket::FOURCC_I420));
1777 EXPECT_EQ(2, send_stream->GetNumberOfSwappedFrames());
1778 EXPECT_EQ(1280 * 3 / 4, send_stream->GetLastWidth());
1779 EXPECT_EQ(720 * 3 / 4, send_stream->GetLastHeight());
1780
1781 // Trigger overuse again.
1782 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kOveruse);
1783 EXPECT_TRUE(capturer.CaptureCustomFrame(1280, 720, cricket::FOURCC_I420));
1784 EXPECT_EQ(3, send_stream->GetNumberOfSwappedFrames());
1785 EXPECT_EQ(1280 * 2 / 4, send_stream->GetLastWidth());
1786 EXPECT_EQ(720 * 2 / 4, send_stream->GetLastHeight());
1787
1788 // Change input resolution.
1789 EXPECT_TRUE(capturer.CaptureCustomFrame(1284, 724, cricket::FOURCC_I420));
1790 EXPECT_EQ(4, send_stream->GetNumberOfSwappedFrames());
1791 EXPECT_EQ(1284 / 2, send_stream->GetLastWidth());
1792 EXPECT_EQ(724 / 2, send_stream->GetLastHeight());
1793
1794 // Trigger underuse which should go back up in resolution.
1795 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kUnderuse);
1796 EXPECT_TRUE(capturer.CaptureCustomFrame(1284, 724, cricket::FOURCC_I420));
1797 EXPECT_EQ(5, send_stream->GetNumberOfSwappedFrames());
1798 EXPECT_EQ(1284 * 3 / 4, send_stream->GetLastWidth());
1799 EXPECT_EQ(724 * 3 / 4, send_stream->GetLastHeight());
1800
1801 // Trigger underuse which should go back up in resolution.
1802 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kUnderuse);
1803 EXPECT_TRUE(capturer.CaptureCustomFrame(1284, 724, cricket::FOURCC_I420));
1804 EXPECT_EQ(6, send_stream->GetNumberOfSwappedFrames());
1805 EXPECT_EQ(1284, send_stream->GetLastWidth());
1806 EXPECT_EQ(724, send_stream->GetLastHeight());
1807
1808 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL));
1809 }
1810
1736 void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse, 1811 void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse,
1737 bool is_screenshare) { 1812 bool is_screenshare) {
1738 cricket::VideoCodec codec = kVp8Codec720p; 1813 cricket::VideoCodec codec = kVp8Codec720p;
1739 cricket::VideoSendParameters parameters; 1814 cricket::VideoSendParameters parameters;
1740 parameters.codecs.push_back(codec); 1815 parameters.codecs.push_back(codec);
1741 1816
1742 MediaConfig media_config = MediaConfig(); 1817 MediaConfig media_config = MediaConfig();
1743 if (!enable_overuse) { 1818 if (!enable_overuse) {
1744 media_config.enable_cpu_overuse_detection = false; 1819 media_config.enable_cpu_overuse_detection = false;
1745 } 1820 }
(...skipping 10 matching lines...) Expand all
1756 EXPECT_EQ(cricket::CS_RUNNING, 1831 EXPECT_EQ(cricket::CS_RUNNING,
1757 capturer.Start(capturer.GetSupportedFormats()->front())); 1832 capturer.Start(capturer.GetSupportedFormats()->front()));
1758 1833
1759 EXPECT_TRUE(channel_->SetSend(true)); 1834 EXPECT_TRUE(channel_->SetSend(true));
1760 1835
1761 // Trigger overuse. 1836 // Trigger overuse.
1762 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size()); 1837 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size());
1763 FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front(); 1838 FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front();
1764 webrtc::LoadObserver* overuse_callback = 1839 webrtc::LoadObserver* overuse_callback =
1765 send_stream->GetConfig().overuse_callback; 1840 send_stream->GetConfig().overuse_callback;
1841
1842 if (!enable_overuse) {
1843 ASSERT_TRUE(overuse_callback == NULL);
1844
1845 EXPECT_TRUE(capturer.CaptureFrame());
1846 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames());
1847
1848 EXPECT_EQ(codec.width, send_stream->GetLastWidth());
1849 EXPECT_EQ(codec.height, send_stream->GetLastHeight());
1850
1851 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL));
1852 return;
1853 }
1854
1766 ASSERT_TRUE(overuse_callback != NULL); 1855 ASSERT_TRUE(overuse_callback != NULL);
1856 EXPECT_TRUE(capturer.CaptureFrame());
1857 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames());
1767 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kOveruse); 1858 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kOveruse);
1768 1859
1769 EXPECT_TRUE(capturer.CaptureFrame()); 1860 EXPECT_TRUE(capturer.CaptureFrame());
1770 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames()); 1861 EXPECT_EQ(2, send_stream->GetNumberOfSwappedFrames());
1771 1862
1772 if (enable_overuse && !is_screenshare) { 1863 if (is_screenshare) {
1864 // Do not adapt screen share.
1865 EXPECT_EQ(codec.width, send_stream->GetLastWidth());
1866 EXPECT_EQ(codec.height, send_stream->GetLastHeight());
1867 } else {
1773 EXPECT_LT(send_stream->GetLastWidth(), codec.width); 1868 EXPECT_LT(send_stream->GetLastWidth(), codec.width);
1774 EXPECT_LT(send_stream->GetLastHeight(), codec.height); 1869 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 } 1870 }
1779 1871
1780 // Trigger underuse which should go back to normal resolution. 1872 // Trigger underuse which should go back to normal resolution.
1781 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kUnderuse); 1873 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kUnderuse);
1782 EXPECT_TRUE(capturer.CaptureFrame()); 1874 EXPECT_TRUE(capturer.CaptureFrame());
1783 1875 EXPECT_EQ(3, send_stream->GetNumberOfSwappedFrames());
1784 EXPECT_EQ(2, send_stream->GetNumberOfSwappedFrames());
1785 1876
1786 EXPECT_EQ(codec.width, send_stream->GetLastWidth()); 1877 EXPECT_EQ(codec.width, send_stream->GetLastWidth());
1787 EXPECT_EQ(codec.height, send_stream->GetLastHeight()); 1878 EXPECT_EQ(codec.height, send_stream->GetLastHeight());
1788 1879
1789 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); 1880 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL));
1790 } 1881 }
1791 1882
1792 TEST_F(WebRtcVideoChannel2Test, EstimatesNtpStartTimeCorrectly) { 1883 TEST_F(WebRtcVideoChannel2Test, EstimatesNtpStartTimeCorrectly) {
1793 // Start at last timestamp to verify that wraparounds are estimated correctly. 1884 // Start at last timestamp to verify that wraparounds are estimated correctly.
1794 static const uint32_t kInitialTimestamp = 0xFFFFFFFFu; 1885 static const uint32_t kInitialTimestamp = 0xFFFFFFFFu;
(...skipping 1283 matching lines...) Expand 10 before | Expand all | Expand 10 after
3078 // Test that we normalize send codec format size in simulcast. 3169 // Test that we normalize send codec format size in simulcast.
3079 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { 3170 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) {
3080 cricket::VideoCodec codec(kVp8Codec270p); 3171 cricket::VideoCodec codec(kVp8Codec270p);
3081 codec.width += 1; 3172 codec.width += 1;
3082 codec.height += 1; 3173 codec.height += 1;
3083 VerifySimulcastSettings(codec, 2, 2); 3174 VerifySimulcastSettings(codec, 2, 2);
3084 } 3175 }
3085 } // namespace cricket 3176 } // namespace cricket
3086 3177
3087 #endif // HAVE_WEBRTC_VIDEO 3178 #endif // HAVE_WEBRTC_VIDEO
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698