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 999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1010 EXPECT_EQ(expected_extension, | 1010 EXPECT_EQ(expected_extension, |
1011 send_stream->GetConfig().rtp.extensions[0].name); | 1011 send_stream->GetConfig().rtp.extensions[0].name); |
1012 } | 1012 } |
1013 | 1013 |
1014 void TestCpuAdaptation(bool enable_overuse, bool is_screenshare); | 1014 void TestCpuAdaptation(bool enable_overuse, bool is_screenshare); |
1015 void TestReceiverLocalSsrcConfiguration(bool receiver_first); | 1015 void TestReceiverLocalSsrcConfiguration(bool receiver_first); |
1016 void TestReceiveUnsignalledSsrcPacket(uint8_t payload_type, | 1016 void TestReceiveUnsignalledSsrcPacket(uint8_t payload_type, |
1017 bool expect_created_receive_stream); | 1017 bool expect_created_receive_stream); |
1018 | 1018 |
1019 FakeVideoSendStream* SetDenoisingOption( | 1019 FakeVideoSendStream* SetDenoisingOption( |
1020 const cricket::VideoSendParameters& parameters, bool enabled) { | 1020 const cricket::VideoSendParameters& parameters, |
| 1021 cricket::FakeVideoCapturer* capturer, |
| 1022 bool enabled) { |
1021 cricket::VideoSendParameters params = parameters; | 1023 cricket::VideoSendParameters params = parameters; |
1022 params.options.video_noise_reduction = rtc::Optional<bool>(enabled); | 1024 params.options.video_noise_reduction = rtc::Optional<bool>(enabled); |
| 1025 // TODO(nisse): Switch to using SetOptions? |
1023 channel_->SetSendParameters(params); | 1026 channel_->SetSendParameters(params); |
| 1027 // Options only take effect on the next frame. |
| 1028 EXPECT_TRUE(capturer->CaptureFrame()); |
| 1029 |
1024 return fake_call_->GetVideoSendStreams().back(); | 1030 return fake_call_->GetVideoSendStreams().back(); |
1025 } | 1031 } |
1026 | 1032 |
1027 FakeVideoSendStream* SetUpSimulcast(bool enabled, bool with_rtx) { | 1033 FakeVideoSendStream* SetUpSimulcast(bool enabled, bool with_rtx) { |
1028 const int kRtxSsrcOffset = 0xDEADBEEF; | 1034 const int kRtxSsrcOffset = 0xDEADBEEF; |
1029 last_ssrc_ += 3; | 1035 last_ssrc_ += 3; |
1030 std::vector<uint32_t> ssrcs; | 1036 std::vector<uint32_t> ssrcs; |
1031 std::vector<uint32_t> rtx_ssrcs; | 1037 std::vector<uint32_t> rtx_ssrcs; |
1032 uint32_t num_streams = enabled ? 3 : 1; | 1038 uint32_t num_streams = enabled ? 3 : 1; |
1033 for (uint32_t i = 0; i < num_streams; ++i) { | 1039 for (uint32_t i = 0; i < num_streams; ++i) { |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1547 encoder_config.streams[0].temporal_layer_thresholds_bps[0]); | 1553 encoder_config.streams[0].temporal_layer_thresholds_bps[0]); |
1548 | 1554 |
1549 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); | 1555 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); |
1550 } | 1556 } |
1551 | 1557 |
1552 TEST_F(WebRtcVideoChannel2Test, SuspendBelowMinBitrateDisabledByDefault) { | 1558 TEST_F(WebRtcVideoChannel2Test, SuspendBelowMinBitrateDisabledByDefault) { |
1553 FakeVideoSendStream* stream = AddSendStream(); | 1559 FakeVideoSendStream* stream = AddSendStream(); |
1554 EXPECT_FALSE(stream->GetConfig().suspend_below_min_bitrate); | 1560 EXPECT_FALSE(stream->GetConfig().suspend_below_min_bitrate); |
1555 } | 1561 } |
1556 | 1562 |
1557 TEST_F(WebRtcVideoChannel2Test, SetOptionsWithSuspendBelowMinBitrate) { | 1563 TEST_F(WebRtcVideoChannel2Test, SetMediaConfigSuspendBelowMinBitrate) { |
1558 send_parameters_.options.suspend_below_min_bitrate = | 1564 MediaConfig media_config = MediaConfig(); |
1559 rtc::Optional<bool>(true); | 1565 media_config.video.suspend_below_min_bitrate = true; |
| 1566 |
| 1567 channel_.reset( |
| 1568 engine_.CreateChannel(fake_call_.get(), media_config, VideoOptions())); |
| 1569 |
1560 channel_->SetSendParameters(send_parameters_); | 1570 channel_->SetSendParameters(send_parameters_); |
1561 | 1571 |
1562 FakeVideoSendStream* stream = AddSendStream(); | 1572 FakeVideoSendStream* stream = AddSendStream(); |
1563 EXPECT_TRUE(stream->GetConfig().suspend_below_min_bitrate); | 1573 EXPECT_TRUE(stream->GetConfig().suspend_below_min_bitrate); |
1564 | 1574 |
1565 send_parameters_.options.suspend_below_min_bitrate = | 1575 media_config.video.suspend_below_min_bitrate = false; |
1566 rtc::Optional<bool>(false); | 1576 channel_.reset( |
| 1577 engine_.CreateChannel(fake_call_.get(), media_config, VideoOptions())); |
| 1578 |
1567 channel_->SetSendParameters(send_parameters_); | 1579 channel_->SetSendParameters(send_parameters_); |
1568 | 1580 |
1569 stream = fake_call_->GetVideoSendStreams()[0]; | 1581 stream = AddSendStream(); |
1570 EXPECT_FALSE(stream->GetConfig().suspend_below_min_bitrate); | 1582 EXPECT_FALSE(stream->GetConfig().suspend_below_min_bitrate); |
1571 } | 1583 } |
1572 | 1584 |
1573 TEST_F(WebRtcVideoChannel2Test, Vp8DenoisingEnabledByDefault) { | 1585 TEST_F(WebRtcVideoChannel2Test, Vp8DenoisingEnabledByDefault) { |
1574 FakeVideoSendStream* stream = AddSendStream(); | 1586 FakeVideoSendStream* stream = AddSendStream(); |
1575 webrtc::VideoCodecVP8 vp8_settings; | 1587 webrtc::VideoCodecVP8 vp8_settings; |
1576 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; | 1588 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; |
1577 EXPECT_TRUE(vp8_settings.denoisingOn); | 1589 EXPECT_TRUE(vp8_settings.denoisingOn); |
1578 } | 1590 } |
1579 | 1591 |
(...skipping 14 matching lines...) Expand all Loading... |
1594 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); | 1606 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); |
1595 channel_->SetSend(true); | 1607 channel_->SetSend(true); |
1596 | 1608 |
1597 EXPECT_TRUE(capturer.CaptureFrame()); | 1609 EXPECT_TRUE(capturer.CaptureFrame()); |
1598 | 1610 |
1599 webrtc::VideoCodecVP8 vp8_settings; | 1611 webrtc::VideoCodecVP8 vp8_settings; |
1600 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; | 1612 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; |
1601 EXPECT_TRUE(vp8_settings.denoisingOn) | 1613 EXPECT_TRUE(vp8_settings.denoisingOn) |
1602 << "VP8 denoising should be on by default."; | 1614 << "VP8 denoising should be on by default."; |
1603 | 1615 |
1604 stream = SetDenoisingOption(parameters, false); | 1616 stream = SetDenoisingOption(parameters, &capturer, false); |
1605 | 1617 |
1606 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; | 1618 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; |
1607 EXPECT_FALSE(vp8_settings.denoisingOn); | 1619 EXPECT_FALSE(vp8_settings.denoisingOn); |
1608 EXPECT_TRUE(vp8_settings.automaticResizeOn); | 1620 EXPECT_TRUE(vp8_settings.automaticResizeOn); |
1609 EXPECT_TRUE(vp8_settings.frameDroppingOn); | 1621 EXPECT_TRUE(vp8_settings.frameDroppingOn); |
1610 | 1622 |
1611 stream = SetDenoisingOption(parameters, true); | 1623 stream = SetDenoisingOption(parameters, &capturer, true); |
1612 | 1624 |
1613 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; | 1625 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; |
1614 EXPECT_TRUE(vp8_settings.denoisingOn); | 1626 EXPECT_TRUE(vp8_settings.denoisingOn); |
1615 EXPECT_TRUE(vp8_settings.automaticResizeOn); | 1627 EXPECT_TRUE(vp8_settings.automaticResizeOn); |
1616 EXPECT_TRUE(vp8_settings.frameDroppingOn); | 1628 EXPECT_TRUE(vp8_settings.frameDroppingOn); |
1617 | 1629 |
1618 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); | 1630 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); |
1619 stream = SetUpSimulcast(true, false); | 1631 stream = SetUpSimulcast(true, false); |
1620 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); | 1632 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); |
1621 channel_->SetSend(true); | 1633 channel_->SetSend(true); |
1622 EXPECT_TRUE(capturer.CaptureFrame()); | 1634 EXPECT_TRUE(capturer.CaptureFrame()); |
1623 | 1635 |
1624 EXPECT_EQ(3, stream->GetVideoStreams().size()); | 1636 EXPECT_EQ(3, stream->GetVideoStreams().size()); |
1625 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; | 1637 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; |
1626 // Autmatic resize off when using simulcast. | 1638 // Autmatic resize off when using simulcast. |
1627 EXPECT_FALSE(vp8_settings.automaticResizeOn); | 1639 EXPECT_FALSE(vp8_settings.automaticResizeOn); |
1628 EXPECT_TRUE(vp8_settings.frameDroppingOn); | 1640 EXPECT_TRUE(vp8_settings.frameDroppingOn); |
1629 | 1641 |
1630 // In screen-share mode, denoising is forced off and simulcast disabled. | 1642 // In screen-share mode, denoising is forced off and simulcast disabled. |
1631 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); | 1643 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); |
1632 capturer.SetScreencast(true); | 1644 capturer.SetScreencast(true); |
1633 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); | 1645 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); |
1634 EXPECT_TRUE(capturer.CaptureFrame()); | 1646 EXPECT_TRUE(capturer.CaptureFrame()); |
1635 stream = SetDenoisingOption(parameters, false); | 1647 stream = SetDenoisingOption(parameters, &capturer, false); |
1636 | 1648 |
1637 EXPECT_EQ(1, stream->GetVideoStreams().size()); | 1649 EXPECT_EQ(1, stream->GetVideoStreams().size()); |
1638 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; | 1650 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; |
1639 EXPECT_FALSE(vp8_settings.denoisingOn); | 1651 EXPECT_FALSE(vp8_settings.denoisingOn); |
1640 // Resizing and frame dropping always off for screen sharing. | 1652 // Resizing and frame dropping always off for screen sharing. |
1641 EXPECT_FALSE(vp8_settings.automaticResizeOn); | 1653 EXPECT_FALSE(vp8_settings.automaticResizeOn); |
1642 EXPECT_FALSE(vp8_settings.frameDroppingOn); | 1654 EXPECT_FALSE(vp8_settings.frameDroppingOn); |
1643 | 1655 |
1644 stream = SetDenoisingOption(parameters, true); | 1656 stream = SetDenoisingOption(parameters, &capturer, true); |
1645 | 1657 |
1646 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; | 1658 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; |
1647 EXPECT_FALSE(vp8_settings.denoisingOn); | 1659 EXPECT_FALSE(vp8_settings.denoisingOn); |
1648 EXPECT_FALSE(vp8_settings.automaticResizeOn); | 1660 EXPECT_FALSE(vp8_settings.automaticResizeOn); |
1649 EXPECT_FALSE(vp8_settings.frameDroppingOn); | 1661 EXPECT_FALSE(vp8_settings.frameDroppingOn); |
1650 | 1662 |
1651 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); | 1663 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); |
1652 } | 1664 } |
1653 | 1665 |
1654 class Vp9SettingsTest : public WebRtcVideoChannel2Test { | 1666 class Vp9SettingsTest : public WebRtcVideoChannel2Test { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1688 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); | 1700 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); |
1689 channel_->SetSend(true); | 1701 channel_->SetSend(true); |
1690 | 1702 |
1691 EXPECT_TRUE(capturer.CaptureFrame()); | 1703 EXPECT_TRUE(capturer.CaptureFrame()); |
1692 | 1704 |
1693 webrtc::VideoCodecVP9 vp9_settings; | 1705 webrtc::VideoCodecVP9 vp9_settings; |
1694 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set."; | 1706 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set."; |
1695 EXPECT_FALSE(vp9_settings.denoisingOn) | 1707 EXPECT_FALSE(vp9_settings.denoisingOn) |
1696 << "VP9 denoising should be off by default."; | 1708 << "VP9 denoising should be off by default."; |
1697 | 1709 |
1698 stream = SetDenoisingOption(parameters, false); | 1710 stream = SetDenoisingOption(parameters, &capturer, false); |
1699 | 1711 |
1700 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set."; | 1712 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set."; |
1701 EXPECT_FALSE(vp9_settings.denoisingOn); | 1713 EXPECT_FALSE(vp9_settings.denoisingOn); |
1702 // Frame dropping always on for real time video. | 1714 // Frame dropping always on for real time video. |
1703 EXPECT_TRUE(vp9_settings.frameDroppingOn); | 1715 EXPECT_TRUE(vp9_settings.frameDroppingOn); |
1704 | 1716 |
1705 stream = SetDenoisingOption(parameters, true); | 1717 stream = SetDenoisingOption(parameters, &capturer, true); |
1706 | 1718 |
1707 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set."; | 1719 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set."; |
1708 EXPECT_TRUE(vp9_settings.denoisingOn); | 1720 EXPECT_TRUE(vp9_settings.denoisingOn); |
1709 EXPECT_TRUE(vp9_settings.frameDroppingOn); | 1721 EXPECT_TRUE(vp9_settings.frameDroppingOn); |
1710 | 1722 |
1711 // In screen-share mode, denoising is forced off. | 1723 // In screen-share mode, denoising is forced off. |
1712 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, nullptr)); | 1724 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, nullptr)); |
1713 capturer.SetScreencast(true); | 1725 capturer.SetScreencast(true); |
1714 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); | 1726 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); |
1715 | 1727 |
1716 EXPECT_TRUE(capturer.CaptureFrame()); | 1728 EXPECT_TRUE(capturer.CaptureFrame()); |
1717 stream = SetDenoisingOption(parameters, false); | 1729 stream = SetDenoisingOption(parameters, &capturer, false); |
1718 | 1730 |
1719 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set."; | 1731 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set."; |
1720 EXPECT_FALSE(vp9_settings.denoisingOn); | 1732 EXPECT_FALSE(vp9_settings.denoisingOn); |
1721 // Frame dropping always off for screen sharing. | 1733 // Frame dropping always off for screen sharing. |
1722 EXPECT_FALSE(vp9_settings.frameDroppingOn); | 1734 EXPECT_FALSE(vp9_settings.frameDroppingOn); |
1723 | 1735 |
1724 stream = SetDenoisingOption(parameters, false); | 1736 stream = SetDenoisingOption(parameters, &capturer, false); |
1725 | 1737 |
1726 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set."; | 1738 ASSERT_TRUE(stream->GetVp9Settings(&vp9_settings)) << "No VP9 config set."; |
1727 EXPECT_FALSE(vp9_settings.denoisingOn); | 1739 EXPECT_FALSE(vp9_settings.denoisingOn); |
1728 EXPECT_FALSE(vp9_settings.frameDroppingOn); | 1740 EXPECT_FALSE(vp9_settings.frameDroppingOn); |
1729 | 1741 |
1730 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); | 1742 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); |
1731 } | 1743 } |
1732 | 1744 |
1733 TEST_F(WebRtcVideoChannel2Test, AdaptsOnOveruse) { | 1745 TEST_F(WebRtcVideoChannel2Test, AdaptsOnOveruse) { |
1734 TestCpuAdaptation(true, false); | 1746 TestCpuAdaptation(true, false); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1810 } | 1822 } |
1811 | 1823 |
1812 void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse, | 1824 void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse, |
1813 bool is_screenshare) { | 1825 bool is_screenshare) { |
1814 cricket::VideoCodec codec = kVp8Codec720p; | 1826 cricket::VideoCodec codec = kVp8Codec720p; |
1815 cricket::VideoSendParameters parameters; | 1827 cricket::VideoSendParameters parameters; |
1816 parameters.codecs.push_back(codec); | 1828 parameters.codecs.push_back(codec); |
1817 | 1829 |
1818 MediaConfig media_config = MediaConfig(); | 1830 MediaConfig media_config = MediaConfig(); |
1819 if (!enable_overuse) { | 1831 if (!enable_overuse) { |
1820 media_config.enable_cpu_overuse_detection = false; | 1832 media_config.video.enable_cpu_overuse_detection = false; |
1821 } | 1833 } |
1822 channel_.reset( | 1834 channel_.reset( |
1823 engine_.CreateChannel(fake_call_.get(), media_config, VideoOptions())); | 1835 engine_.CreateChannel(fake_call_.get(), media_config, VideoOptions())); |
1824 | 1836 |
1825 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1837 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1826 | 1838 |
1827 AddSendStream(); | 1839 AddSendStream(); |
1828 | 1840 |
1829 cricket::FakeVideoCapturer capturer; | 1841 cricket::FakeVideoCapturer capturer; |
1830 capturer.SetScreencast(is_screenshare); | 1842 capturer.SetScreencast(is_screenshare); |
(...skipping 1339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3170 // Test that we normalize send codec format size in simulcast. | 3182 // Test that we normalize send codec format size in simulcast. |
3171 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { | 3183 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { |
3172 cricket::VideoCodec codec(kVp8Codec270p); | 3184 cricket::VideoCodec codec(kVp8Codec270p); |
3173 codec.width += 1; | 3185 codec.width += 1; |
3174 codec.height += 1; | 3186 codec.height += 1; |
3175 VerifySimulcastSettings(codec, 2, 2); | 3187 VerifySimulcastSettings(codec, 2, 2); |
3176 } | 3188 } |
3177 } // namespace cricket | 3189 } // namespace cricket |
3178 | 3190 |
3179 #endif // HAVE_WEBRTC_VIDEO | 3191 #endif // HAVE_WEBRTC_VIDEO |
OLD | NEW |