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

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

Powered by Google App Engine
This is Rietveld 408576698