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 13 matching lines...) Expand all Loading... |
24 #include "webrtc/media/engine/simulcast.h" | 24 #include "webrtc/media/engine/simulcast.h" |
25 #include "webrtc/media/engine/webrtcvideoengine2.h" | 25 #include "webrtc/media/engine/webrtcvideoengine2.h" |
26 #include "webrtc/media/engine/webrtcvoiceengine.h" | 26 #include "webrtc/media/engine/webrtcvoiceengine.h" |
27 #include "webrtc/test/field_trial.h" | 27 #include "webrtc/test/field_trial.h" |
28 #include "webrtc/video_encoder.h" | 28 #include "webrtc/video_encoder.h" |
29 | 29 |
30 using webrtc::RtpExtension; | 30 using webrtc::RtpExtension; |
31 | 31 |
32 namespace { | 32 namespace { |
33 static const int kDefaultQpMax = 56; | 33 static const int kDefaultQpMax = 56; |
34 static const int kDefaultFramerate = 30; | |
35 | 34 |
36 static const cricket::VideoCodec kVp8Codec720p(100, "VP8", 1280, 720, 30); | 35 static const cricket::VideoCodec kVp8Codec(100, "VP8"); |
37 static const cricket::VideoCodec kVp8Codec360p(100, "VP8", 640, 360, 30); | 36 static const cricket::VideoCodec kVp9Codec(101, "VP9"); |
38 static const cricket::VideoCodec kVp8Codec270p(100, "VP8", 480, 270, 30); | 37 static const cricket::VideoCodec kH264Codec(102, "H264"); |
39 | 38 |
40 static const cricket::VideoCodec kVp8Codec(100, "VP8", 640, 400, 30); | 39 static const cricket::VideoCodec kRedCodec(116, "red"); |
41 static const cricket::VideoCodec kVp9Codec(101, "VP9", 640, 400, 30); | 40 static const cricket::VideoCodec kUlpfecCodec(117, "ulpfec"); |
42 static const cricket::VideoCodec kH264Codec(102, "H264", 640, 400, 30); | |
43 | |
44 static const cricket::VideoCodec kRedCodec(116, "red", 0, 0, 0); | |
45 static const cricket::VideoCodec kUlpfecCodec(117, "ulpfec", 0, 0, 0); | |
46 | 41 |
47 static const uint8_t kRedRtxPayloadType = 125; | 42 static const uint8_t kRedRtxPayloadType = 125; |
48 | 43 |
49 static const uint32_t kSsrcs1[] = {1}; | 44 static const uint32_t kSsrcs1[] = {1}; |
50 static const uint32_t kSsrcs3[] = {1, 2, 3}; | 45 static const uint32_t kSsrcs3[] = {1, 2, 3}; |
51 static const uint32_t kRtxSsrcs1[] = {4}; | 46 static const uint32_t kRtxSsrcs1[] = {4}; |
52 static const uint32_t kIncomingUnsignalledSsrc = 0xC0FFEE; | 47 static const uint32_t kIncomingUnsignalledSsrc = 0xC0FFEE; |
53 static const char kUnsupportedExtensionName[] = | 48 static const char kUnsupportedExtensionName[] = |
54 "urn:ietf:params:rtp-hdrext:unsupported"; | 49 "urn:ietf:params:rtp-hdrext:unsupported"; |
55 | 50 |
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
826 WEBRTC_BASE_TEST(AddRemoveSendStreams); | 821 WEBRTC_BASE_TEST(AddRemoveSendStreams); |
827 | 822 |
828 WEBRTC_BASE_TEST(SimulateConference); | 823 WEBRTC_BASE_TEST(SimulateConference); |
829 | 824 |
830 WEBRTC_DISABLED_BASE_TEST(AddRemoveCapturer); | 825 WEBRTC_DISABLED_BASE_TEST(AddRemoveCapturer); |
831 | 826 |
832 WEBRTC_BASE_TEST(RemoveCapturerWithoutAdd); | 827 WEBRTC_BASE_TEST(RemoveCapturerWithoutAdd); |
833 | 828 |
834 WEBRTC_BASE_TEST(AddRemoveCapturerMultipleSources); | 829 WEBRTC_BASE_TEST(AddRemoveCapturerMultipleSources); |
835 | 830 |
836 // TODO(pbos): Figure out why this fails so often. | |
837 WEBRTC_DISABLED_BASE_TEST(HighAspectHighHeightCapturer); | |
838 | |
839 WEBRTC_BASE_TEST(RejectEmptyStreamParams); | 831 WEBRTC_BASE_TEST(RejectEmptyStreamParams); |
840 | 832 |
841 WEBRTC_BASE_TEST(AdaptResolution16x10); | |
842 | |
843 WEBRTC_BASE_TEST(AdaptResolution4x3); | |
844 | |
845 // TODO(juberti): Restore this test once we support sending 0 fps. | |
846 WEBRTC_DISABLED_BASE_TEST(AdaptDropAllFrames); | |
847 // TODO(juberti): Understand why we get decode errors on this test. | |
848 WEBRTC_DISABLED_BASE_TEST(AdaptFramerate); | |
849 | |
850 WEBRTC_BASE_TEST(SendsLowerResolutionOnSmallerFrames); | |
851 | |
852 WEBRTC_BASE_TEST(MultipleSendStreams); | 833 WEBRTC_BASE_TEST(MultipleSendStreams); |
853 | 834 |
854 TEST_F(WebRtcVideoChannel2BaseTest, SendAndReceiveVp8Vga) { | 835 TEST_F(WebRtcVideoChannel2BaseTest, SendAndReceiveVp8Vga) { |
855 SendAndReceive(cricket::VideoCodec(100, "VP8", 640, 400, 30)); | 836 SendAndReceive(cricket::VideoCodec(100, "VP8")); |
856 } | 837 } |
857 | 838 |
858 TEST_F(WebRtcVideoChannel2BaseTest, SendAndReceiveVp8Qvga) { | 839 TEST_F(WebRtcVideoChannel2BaseTest, SendAndReceiveVp8Qvga) { |
859 SendAndReceive(cricket::VideoCodec(100, "VP8", 320, 200, 30)); | 840 SendAndReceive(cricket::VideoCodec(100, "VP8")); |
860 } | 841 } |
861 | 842 |
862 TEST_F(WebRtcVideoChannel2BaseTest, SendAndReceiveVp8SvcQqvga) { | 843 TEST_F(WebRtcVideoChannel2BaseTest, SendAndReceiveVp8SvcQqvga) { |
863 SendAndReceive(cricket::VideoCodec(100, "VP8", 160, 100, 30)); | 844 SendAndReceive(cricket::VideoCodec(100, "VP8")); |
864 } | 845 } |
865 | 846 |
866 TEST_F(WebRtcVideoChannel2BaseTest, TwoStreamsSendAndReceive) { | 847 TEST_F(WebRtcVideoChannel2BaseTest, TwoStreamsSendAndReceive) { |
867 // Set a high bitrate to not be downscaled by VP8 due to low initial start | 848 // Set a high bitrate to not be downscaled by VP8 due to low initial start |
868 // bitrates. This currently happens at <250k, and two streams sharing 300k | 849 // bitrates. This currently happens at <250k, and two streams sharing 300k |
869 // initially will use QVGA instead of VGA. | 850 // initially will use QVGA instead of VGA. |
870 // TODO(pbos): Set up the quality scaler so that both senders reliably start | 851 // TODO(pbos): Set up the quality scaler so that both senders reliably start |
871 // at QVGA, then verify that instead. | 852 // at QVGA, then verify that instead. |
872 cricket::VideoCodec codec = kVp8Codec; | 853 cricket::VideoCodec codec = kVp8Codec; |
873 codec.params[kCodecParamStartBitrate] = "1000000"; | 854 codec.params[kCodecParamStartBitrate] = "1000000"; |
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1501 EXPECT_GT(send_stream->GetConfig().rtp.nack.rtp_history_ms, 0); | 1482 EXPECT_GT(send_stream->GetConfig().rtp.nack.rtp_history_ms, 0); |
1502 } | 1483 } |
1503 | 1484 |
1504 // This test verifies that new frame sizes reconfigures encoders even though not | 1485 // This test verifies that new frame sizes reconfigures encoders even though not |
1505 // (yet) sending. The purpose of this is to permit encoding as quickly as | 1486 // (yet) sending. The purpose of this is to permit encoding as quickly as |
1506 // possible once we start sending. Likely the frames being input are from the | 1487 // possible once we start sending. Likely the frames being input are from the |
1507 // same source that will be sent later, which just means that we're ready | 1488 // same source that will be sent later, which just means that we're ready |
1508 // earlier. | 1489 // earlier. |
1509 TEST_F(WebRtcVideoChannel2Test, ReconfiguresEncodersWhenNotSending) { | 1490 TEST_F(WebRtcVideoChannel2Test, ReconfiguresEncodersWhenNotSending) { |
1510 cricket::VideoSendParameters parameters; | 1491 cricket::VideoSendParameters parameters; |
1511 parameters.codecs.push_back(kVp8Codec720p); | 1492 parameters.codecs.push_back(kVp8Codec); |
1512 ASSERT_TRUE(channel_->SetSendParameters(parameters)); | 1493 ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
1513 channel_->SetSend(false); | 1494 channel_->SetSend(false); |
1514 | 1495 |
1515 FakeVideoSendStream* stream = AddSendStream(); | 1496 FakeVideoSendStream* stream = AddSendStream(); |
1516 | 1497 |
1517 // No frames entered. | 1498 // No frames entered. |
1518 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams(); | 1499 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams(); |
1519 EXPECT_EQ(0u, streams[0].width); | 1500 EXPECT_EQ(0u, streams[0].width); |
1520 EXPECT_EQ(0u, streams[0].height); | 1501 EXPECT_EQ(0u, streams[0].height); |
1521 | 1502 |
1522 cricket::FakeVideoCapturer capturer; | 1503 cricket::FakeVideoCapturer capturer; |
1523 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer)); | 1504 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer)); |
1524 EXPECT_EQ(cricket::CS_RUNNING, | 1505 VideoFormat capture_format = capturer.GetSupportedFormats()->front(); |
1525 capturer.Start(capturer.GetSupportedFormats()->front())); | 1506 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format)); |
1526 EXPECT_TRUE(capturer.CaptureFrame()); | 1507 EXPECT_TRUE(capturer.CaptureFrame()); |
1527 | 1508 |
1528 // Frame entered, should be reconfigured to new dimensions. | 1509 // Frame entered, should be reconfigured to new dimensions. |
1529 streams = stream->GetVideoStreams(); | 1510 streams = stream->GetVideoStreams(); |
1530 EXPECT_EQ(kVp8Codec720p.width, streams[0].width); | 1511 EXPECT_EQ(capture_format.width, streams[0].width); |
1531 EXPECT_EQ(kVp8Codec720p.height, streams[0].height); | 1512 EXPECT_EQ(capture_format.height, streams[0].height); |
1532 | 1513 |
1533 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); | 1514 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); |
1534 } | 1515 } |
1535 | 1516 |
1536 TEST_F(WebRtcVideoChannel2Test, UsesCorrectSettingsForScreencast) { | 1517 TEST_F(WebRtcVideoChannel2Test, UsesCorrectSettingsForScreencast) { |
1537 static const int kScreenshareMinBitrateKbps = 800; | 1518 static const int kScreenshareMinBitrateKbps = 800; |
1538 cricket::VideoCodec codec = kVp8Codec360p; | 1519 cricket::VideoCodec codec = kVp8Codec; |
1539 cricket::VideoSendParameters parameters; | 1520 cricket::VideoSendParameters parameters; |
1540 parameters.codecs.push_back(codec); | 1521 parameters.codecs.push_back(codec); |
1541 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1522 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
1542 AddSendStream(); | 1523 AddSendStream(); |
1543 | 1524 |
1544 cricket::FakeVideoCapturer capturer; | 1525 cricket::FakeVideoCapturer capturer; |
1545 VideoOptions min_bitrate_options; | 1526 VideoOptions min_bitrate_options; |
1546 min_bitrate_options.screencast_min_bitrate_kbps = | 1527 min_bitrate_options.screencast_min_bitrate_kbps = |
1547 rtc::Optional<int>(kScreenshareMinBitrateKbps); | 1528 rtc::Optional<int>(kScreenshareMinBitrateKbps); |
1548 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &min_bitrate_options, | 1529 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &min_bitrate_options, |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1717 | 1698 |
1718 TEST_F(WebRtcVideoChannel2Test, Vp8DenoisingEnabledByDefault) { | 1699 TEST_F(WebRtcVideoChannel2Test, Vp8DenoisingEnabledByDefault) { |
1719 FakeVideoSendStream* stream = AddSendStream(); | 1700 FakeVideoSendStream* stream = AddSendStream(); |
1720 webrtc::VideoCodecVP8 vp8_settings; | 1701 webrtc::VideoCodecVP8 vp8_settings; |
1721 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; | 1702 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; |
1722 EXPECT_TRUE(vp8_settings.denoisingOn); | 1703 EXPECT_TRUE(vp8_settings.denoisingOn); |
1723 } | 1704 } |
1724 | 1705 |
1725 TEST_F(WebRtcVideoChannel2Test, VerifyVp8SpecificSettings) { | 1706 TEST_F(WebRtcVideoChannel2Test, VerifyVp8SpecificSettings) { |
1726 cricket::VideoSendParameters parameters; | 1707 cricket::VideoSendParameters parameters; |
1727 parameters.codecs.push_back(kVp8Codec720p); | 1708 parameters.codecs.push_back(kVp8Codec); |
1728 ASSERT_TRUE(channel_->SetSendParameters(parameters)); | 1709 ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
1729 | 1710 |
1730 // Single-stream settings should apply with RTX as well (verifies that we | 1711 // Single-stream settings should apply with RTX as well (verifies that we |
1731 // check number of regular SSRCs and not StreamParams::ssrcs which contains | 1712 // check number of regular SSRCs and not StreamParams::ssrcs which contains |
1732 // both RTX and regular SSRCs). | 1713 // both RTX and regular SSRCs). |
1733 FakeVideoSendStream* stream = SetUpSimulcast(false, true); | 1714 FakeVideoSendStream* stream = SetUpSimulcast(false, true); |
1734 | 1715 |
1735 cricket::FakeVideoCapturer capturer; | 1716 cricket::FakeVideoCapturer capturer; |
1736 EXPECT_EQ(cricket::CS_RUNNING, | 1717 EXPECT_EQ(cricket::CS_RUNNING, |
1737 capturer.Start(capturer.GetSupportedFormats()->front())); | 1718 capturer.Start(capturer.GetSupportedFormats()->front())); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1798 // Test that setting the same options doesn't result in the encoder being | 1779 // Test that setting the same options doesn't result in the encoder being |
1799 // reconfigured. | 1780 // reconfigured. |
1800 TEST_F(WebRtcVideoChannel2Test, SetIdenticalOptionsDoesntReconfigureEncoder) { | 1781 TEST_F(WebRtcVideoChannel2Test, SetIdenticalOptionsDoesntReconfigureEncoder) { |
1801 VideoOptions options; | 1782 VideoOptions options; |
1802 cricket::FakeVideoCapturer capturer; | 1783 cricket::FakeVideoCapturer capturer; |
1803 | 1784 |
1804 AddSendStream(); | 1785 AddSendStream(); |
1805 EXPECT_EQ(cricket::CS_RUNNING, | 1786 EXPECT_EQ(cricket::CS_RUNNING, |
1806 capturer.Start(capturer.GetSupportedFormats()->front())); | 1787 capturer.Start(capturer.GetSupportedFormats()->front())); |
1807 cricket::VideoSendParameters parameters; | 1788 cricket::VideoSendParameters parameters; |
1808 parameters.codecs.push_back(kVp8Codec720p); | 1789 parameters.codecs.push_back(kVp8Codec); |
1809 ASSERT_TRUE(channel_->SetSendParameters(parameters)); | 1790 ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
1810 FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front(); | 1791 FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front(); |
1811 | 1792 |
1812 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer)); | 1793 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer)); |
1813 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer)); | 1794 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer)); |
1814 EXPECT_TRUE(capturer.CaptureFrame()); | 1795 EXPECT_TRUE(capturer.CaptureFrame()); |
1815 // Expect 1 reconfigurations at this point from the initial configuration. | 1796 // Expect 1 reconfigurations at this point from the initial configuration. |
1816 EXPECT_EQ(1, send_stream->num_encoder_reconfigurations()); | 1797 EXPECT_EQ(1, send_stream->num_encoder_reconfigurations()); |
1817 | 1798 |
1818 // Set the options one more time and expect no additional reconfigurations. | 1799 // Set the options one more time and expect no additional reconfigurations. |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1978 | 1959 |
1979 TEST_F(WebRtcVideoChannel2Test, DoesNotAdaptOnOveruseWhenDisabled) { | 1960 TEST_F(WebRtcVideoChannel2Test, DoesNotAdaptOnOveruseWhenDisabled) { |
1980 TestCpuAdaptation(false, false); | 1961 TestCpuAdaptation(false, false); |
1981 } | 1962 } |
1982 | 1963 |
1983 TEST_F(WebRtcVideoChannel2Test, DoesNotAdaptOnOveruseWhenScreensharing) { | 1964 TEST_F(WebRtcVideoChannel2Test, DoesNotAdaptOnOveruseWhenScreensharing) { |
1984 TestCpuAdaptation(true, true); | 1965 TestCpuAdaptation(true, true); |
1985 } | 1966 } |
1986 | 1967 |
1987 TEST_F(WebRtcVideoChannel2Test, AdaptsOnOveruseAndChangeResolution) { | 1968 TEST_F(WebRtcVideoChannel2Test, AdaptsOnOveruseAndChangeResolution) { |
1988 cricket::VideoCodec codec = kVp8Codec720p; | 1969 cricket::VideoCodec codec = kVp8Codec; |
1989 cricket::VideoSendParameters parameters; | 1970 cricket::VideoSendParameters parameters; |
1990 parameters.codecs.push_back(codec); | 1971 parameters.codecs.push_back(codec); |
1991 | 1972 |
1992 MediaConfig media_config = MediaConfig(); | 1973 MediaConfig media_config = MediaConfig(); |
1993 channel_.reset( | 1974 channel_.reset( |
1994 engine_.CreateChannel(fake_call_.get(), media_config, VideoOptions())); | 1975 engine_.CreateChannel(fake_call_.get(), media_config, VideoOptions())); |
1995 ASSERT_TRUE(channel_->SetSendParameters(parameters)); | 1976 ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
1996 | 1977 |
1997 AddSendStream(); | 1978 AddSendStream(); |
1998 | 1979 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2052 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kUnderuse); | 2033 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kUnderuse); |
2053 EXPECT_TRUE(capturer.CaptureCustomFrame(1284, 724, cricket::FOURCC_I420)); | 2034 EXPECT_TRUE(capturer.CaptureCustomFrame(1284, 724, cricket::FOURCC_I420)); |
2054 EXPECT_EQ(7, send_stream->GetNumberOfSwappedFrames()); | 2035 EXPECT_EQ(7, send_stream->GetNumberOfSwappedFrames()); |
2055 EXPECT_EQ(1284, send_stream->GetLastWidth()); | 2036 EXPECT_EQ(1284, send_stream->GetLastWidth()); |
2056 EXPECT_EQ(724, send_stream->GetLastHeight()); | 2037 EXPECT_EQ(724, send_stream->GetLastHeight()); |
2057 | 2038 |
2058 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); | 2039 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); |
2059 } | 2040 } |
2060 | 2041 |
2061 TEST_F(WebRtcVideoChannel2Test, PreviousAdaptationDoesNotApplyToScreenshare) { | 2042 TEST_F(WebRtcVideoChannel2Test, PreviousAdaptationDoesNotApplyToScreenshare) { |
2062 cricket::VideoCodec codec = kVp8Codec720p; | 2043 cricket::VideoCodec codec = kVp8Codec; |
2063 cricket::VideoSendParameters parameters; | 2044 cricket::VideoSendParameters parameters; |
2064 parameters.codecs.push_back(codec); | 2045 parameters.codecs.push_back(codec); |
2065 | 2046 |
2066 MediaConfig media_config = MediaConfig(); | 2047 MediaConfig media_config = MediaConfig(); |
2067 channel_.reset( | 2048 channel_.reset( |
2068 engine_.CreateChannel(fake_call_.get(), media_config, VideoOptions())); | 2049 engine_.CreateChannel(fake_call_.get(), media_config, VideoOptions())); |
2069 ASSERT_TRUE(channel_->SetSendParameters(parameters)); | 2050 ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
2070 | 2051 |
2071 AddSendStream(); | 2052 AddSendStream(); |
2072 | 2053 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2115 EXPECT_TRUE(capturer.CaptureCustomFrame(1280, 720, cricket::FOURCC_I420)); | 2096 EXPECT_TRUE(capturer.CaptureCustomFrame(1280, 720, cricket::FOURCC_I420)); |
2116 EXPECT_EQ(4, send_stream->GetNumberOfSwappedFrames()); | 2097 EXPECT_EQ(4, send_stream->GetNumberOfSwappedFrames()); |
2117 EXPECT_EQ(1280 * 3 / 4, send_stream->GetLastWidth()); | 2098 EXPECT_EQ(1280 * 3 / 4, send_stream->GetLastWidth()); |
2118 EXPECT_EQ(720 * 3 / 4, send_stream->GetLastHeight()); | 2099 EXPECT_EQ(720 * 3 / 4, send_stream->GetLastHeight()); |
2119 | 2100 |
2120 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); | 2101 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); |
2121 } | 2102 } |
2122 | 2103 |
2123 void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse, | 2104 void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse, |
2124 bool is_screenshare) { | 2105 bool is_screenshare) { |
2125 cricket::VideoCodec codec = kVp8Codec720p; | 2106 cricket::VideoCodec codec = kVp8Codec; |
2126 cricket::VideoSendParameters parameters; | 2107 cricket::VideoSendParameters parameters; |
2127 parameters.codecs.push_back(codec); | 2108 parameters.codecs.push_back(codec); |
2128 | 2109 |
2129 MediaConfig media_config = MediaConfig(); | 2110 MediaConfig media_config = MediaConfig(); |
2130 if (!enable_overuse) { | 2111 if (!enable_overuse) { |
2131 media_config.video.enable_cpu_overuse_detection = false; | 2112 media_config.video.enable_cpu_overuse_detection = false; |
2132 } | 2113 } |
2133 channel_.reset( | 2114 channel_.reset( |
2134 engine_.CreateChannel(fake_call_.get(), media_config, VideoOptions())); | 2115 engine_.CreateChannel(fake_call_.get(), media_config, VideoOptions())); |
2135 | 2116 |
2136 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 2117 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
2137 | 2118 |
2138 AddSendStream(); | 2119 AddSendStream(); |
2139 | 2120 |
2140 cricket::FakeVideoCapturer capturer; | 2121 cricket::FakeVideoCapturer capturer; |
2141 VideoOptions options; | 2122 VideoOptions options; |
2142 options.is_screencast = rtc::Optional<bool>(is_screenshare); | 2123 options.is_screencast = rtc::Optional<bool>(is_screenshare); |
2143 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer)); | 2124 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer)); |
2144 EXPECT_EQ(cricket::CS_RUNNING, | 2125 cricket::VideoFormat capture_format = capturer.GetSupportedFormats()->front(); |
2145 capturer.Start(capturer.GetSupportedFormats()->front())); | 2126 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format)); |
2146 | 2127 |
2147 EXPECT_TRUE(channel_->SetSend(true)); | 2128 EXPECT_TRUE(channel_->SetSend(true)); |
2148 | 2129 |
2149 // Trigger overuse. | 2130 // Trigger overuse. |
2150 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size()); | 2131 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size()); |
2151 FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front(); | 2132 FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front(); |
2152 webrtc::LoadObserver* overuse_callback = | 2133 webrtc::LoadObserver* overuse_callback = |
2153 send_stream->GetConfig().overuse_callback; | 2134 send_stream->GetConfig().overuse_callback; |
2154 | 2135 |
2155 if (!enable_overuse) { | 2136 if (!enable_overuse) { |
2156 ASSERT_TRUE(overuse_callback == NULL); | 2137 ASSERT_TRUE(overuse_callback == NULL); |
2157 | 2138 |
2158 EXPECT_TRUE(capturer.CaptureFrame()); | 2139 EXPECT_TRUE(capturer.CaptureFrame()); |
2159 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames()); | 2140 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames()); |
2160 | 2141 |
2161 EXPECT_EQ(codec.width, send_stream->GetLastWidth()); | 2142 EXPECT_EQ(capture_format.width, send_stream->GetLastWidth()); |
2162 EXPECT_EQ(codec.height, send_stream->GetLastHeight()); | 2143 EXPECT_EQ(capture_format.height, send_stream->GetLastHeight()); |
2163 | 2144 |
2164 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); | 2145 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); |
2165 return; | 2146 return; |
2166 } | 2147 } |
2167 | 2148 |
2168 ASSERT_TRUE(overuse_callback != NULL); | 2149 ASSERT_TRUE(overuse_callback != NULL); |
2169 EXPECT_TRUE(capturer.CaptureFrame()); | 2150 EXPECT_TRUE(capturer.CaptureFrame()); |
2170 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames()); | 2151 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames()); |
2171 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kOveruse); | 2152 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kOveruse); |
2172 | 2153 |
2173 EXPECT_TRUE(capturer.CaptureFrame()); | 2154 EXPECT_TRUE(capturer.CaptureFrame()); |
2174 EXPECT_EQ(2, send_stream->GetNumberOfSwappedFrames()); | 2155 EXPECT_EQ(2, send_stream->GetNumberOfSwappedFrames()); |
2175 | 2156 |
2176 if (is_screenshare) { | 2157 if (is_screenshare) { |
2177 // Do not adapt screen share. | 2158 // Do not adapt screen share. |
2178 EXPECT_EQ(codec.width, send_stream->GetLastWidth()); | 2159 EXPECT_EQ(capture_format.width, send_stream->GetLastWidth()); |
2179 EXPECT_EQ(codec.height, send_stream->GetLastHeight()); | 2160 EXPECT_EQ(capture_format.height, send_stream->GetLastHeight()); |
2180 } else { | 2161 } else { |
2181 EXPECT_LT(send_stream->GetLastWidth(), codec.width); | 2162 EXPECT_LT(send_stream->GetLastWidth(), capture_format.width); |
2182 EXPECT_LT(send_stream->GetLastHeight(), codec.height); | 2163 EXPECT_LT(send_stream->GetLastHeight(), capture_format.height); |
2183 } | 2164 } |
2184 | 2165 |
2185 // Trigger underuse which should go back to normal resolution. | 2166 // Trigger underuse which should go back to normal resolution. |
2186 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kUnderuse); | 2167 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kUnderuse); |
2187 EXPECT_TRUE(capturer.CaptureFrame()); | 2168 EXPECT_TRUE(capturer.CaptureFrame()); |
2188 EXPECT_EQ(3, send_stream->GetNumberOfSwappedFrames()); | 2169 EXPECT_EQ(3, send_stream->GetNumberOfSwappedFrames()); |
2189 | 2170 |
2190 EXPECT_EQ(codec.width, send_stream->GetLastWidth()); | 2171 EXPECT_EQ(capture_format.width, send_stream->GetLastWidth()); |
2191 EXPECT_EQ(codec.height, send_stream->GetLastHeight()); | 2172 EXPECT_EQ(capture_format.height, send_stream->GetLastHeight()); |
2192 | 2173 |
2193 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); | 2174 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); |
2194 } | 2175 } |
2195 | 2176 |
2196 TEST_F(WebRtcVideoChannel2Test, EstimatesNtpStartTimeCorrectly) { | 2177 TEST_F(WebRtcVideoChannel2Test, EstimatesNtpStartTimeCorrectly) { |
2197 // Start at last timestamp to verify that wraparounds are estimated correctly. | 2178 // Start at last timestamp to verify that wraparounds are estimated correctly. |
2198 static const uint32_t kInitialTimestamp = 0xFFFFFFFFu; | 2179 static const uint32_t kInitialTimestamp = 0xFFFFFFFFu; |
2199 static const int64_t kInitialNtpTimeMs = 1247891230; | 2180 static const int64_t kInitialNtpTimeMs = 1247891230; |
2200 static const int kFrameOffsetMs = 20; | 2181 static const int kFrameOffsetMs = 20; |
2201 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); | 2182 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2262 FakeVideoSendStream* stream = AddSendStream(); | 2243 FakeVideoSendStream* stream = AddSendStream(); |
2263 webrtc::VideoSendStream::Config config = stream->GetConfig().Copy(); | 2244 webrtc::VideoSendStream::Config config = stream->GetConfig().Copy(); |
2264 | 2245 |
2265 EXPECT_EQ(-1, config.rtp.ulpfec.ulpfec_payload_type); | 2246 EXPECT_EQ(-1, config.rtp.ulpfec.ulpfec_payload_type); |
2266 EXPECT_EQ(-1, config.rtp.ulpfec.red_payload_type); | 2247 EXPECT_EQ(-1, config.rtp.ulpfec.red_payload_type); |
2267 } | 2248 } |
2268 | 2249 |
2269 TEST_F(WebRtcVideoChannel2Test, | 2250 TEST_F(WebRtcVideoChannel2Test, |
2270 SetSendCodecRejectsRtxWithoutAssociatedPayloadType) { | 2251 SetSendCodecRejectsRtxWithoutAssociatedPayloadType) { |
2271 cricket::VideoSendParameters parameters; | 2252 cricket::VideoSendParameters parameters; |
2272 cricket::VideoCodec rtx_codec(96, "rtx", 0, 0, 0); | 2253 cricket::VideoCodec rtx_codec(96, "rtx"); |
2273 parameters.codecs.push_back(rtx_codec); | 2254 parameters.codecs.push_back(rtx_codec); |
2274 EXPECT_FALSE(channel_->SetSendParameters(parameters)) | 2255 EXPECT_FALSE(channel_->SetSendParameters(parameters)) |
2275 << "RTX codec without associated payload type should be rejected."; | 2256 << "RTX codec without associated payload type should be rejected."; |
2276 } | 2257 } |
2277 | 2258 |
2278 TEST_F(WebRtcVideoChannel2Test, | 2259 TEST_F(WebRtcVideoChannel2Test, |
2279 SetSendCodecRejectsRtxWithoutMatchingVideoCodec) { | 2260 SetSendCodecRejectsRtxWithoutMatchingVideoCodec) { |
2280 cricket::VideoSendParameters parameters; | 2261 cricket::VideoSendParameters parameters; |
2281 cricket::VideoCodec rtx_codec = | 2262 cricket::VideoCodec rtx_codec = |
2282 cricket::VideoCodec::CreateRtxCodec(96, kVp8Codec.id); | 2263 cricket::VideoCodec::CreateRtxCodec(96, kVp8Codec.id); |
(...skipping 24 matching lines...) Expand all Loading... |
2307 ASSERT_TRUE(channel_->SetSendParameters(parameters)); | 2288 ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
2308 stream = fake_call_->GetVideoSendStreams()[0]; | 2289 stream = fake_call_->GetVideoSendStreams()[0]; |
2309 ASSERT_TRUE(stream != NULL); | 2290 ASSERT_TRUE(stream != NULL); |
2310 config = stream->GetConfig().Copy(); | 2291 config = stream->GetConfig().Copy(); |
2311 EXPECT_EQ(-1, config.rtp.ulpfec.ulpfec_payload_type) | 2292 EXPECT_EQ(-1, config.rtp.ulpfec.ulpfec_payload_type) |
2312 << "SetSendCodec without FEC should disable current FEC."; | 2293 << "SetSendCodec without FEC should disable current FEC."; |
2313 } | 2294 } |
2314 | 2295 |
2315 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsChangesExistingStreams) { | 2296 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsChangesExistingStreams) { |
2316 cricket::VideoSendParameters parameters; | 2297 cricket::VideoSendParameters parameters; |
2317 cricket::VideoCodec codec720p(100, "VP8", 1280, 720, 30); | 2298 cricket::VideoCodec codec(100, "VP8"); |
2318 codec720p.SetParam(kCodecParamMaxQuantization, kDefaultQpMax); | 2299 codec.SetParam(kCodecParamMaxQuantization, kDefaultQpMax); |
2319 parameters.codecs.push_back(codec720p); | 2300 parameters.codecs.push_back(codec); |
2320 | 2301 |
2321 ASSERT_TRUE(channel_->SetSendParameters(parameters)); | 2302 ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
2322 channel_->SetSend(true); | 2303 channel_->SetSend(true); |
2323 | 2304 |
2324 FakeVideoSendStream* stream = AddSendStream(); | 2305 FakeVideoSendStream* stream = AddSendStream(); |
2325 cricket::FakeVideoCapturer capturer; | 2306 cricket::FakeVideoCapturer capturer; |
2326 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer)); | 2307 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer)); |
2327 | 2308 |
2328 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams(); | 2309 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams(); |
2329 EXPECT_EQ(kDefaultQpMax, streams[0].max_qp); | 2310 EXPECT_EQ(kDefaultQpMax, streams[0].max_qp); |
2330 | 2311 |
2331 parameters.codecs.clear(); | 2312 parameters.codecs.clear(); |
2332 codec720p.SetParam(kCodecParamMaxQuantization, kDefaultQpMax + 1); | 2313 codec.SetParam(kCodecParamMaxQuantization, kDefaultQpMax + 1); |
2333 parameters.codecs.push_back(codec720p); | 2314 parameters.codecs.push_back(codec); |
2334 ASSERT_TRUE(channel_->SetSendParameters(parameters)); | 2315 ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
2335 streams = fake_call_->GetVideoSendStreams()[0]->GetVideoStreams(); | 2316 streams = fake_call_->GetVideoSendStreams()[0]->GetVideoStreams(); |
2336 EXPECT_EQ(kDefaultQpMax + 1, streams[0].max_qp); | 2317 EXPECT_EQ(kDefaultQpMax + 1, streams[0].max_qp); |
2337 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); | 2318 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); |
2338 } | 2319 } |
2339 | 2320 |
2340 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithBitrates) { | 2321 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithBitrates) { |
2341 SetSendCodecsShouldWorkForBitrates("100", 100000, "150", 150000, "200", | 2322 SetSendCodecsShouldWorkForBitrates("100", 100000, "150", 150000, "200", |
2342 200000); | 2323 200000); |
2343 } | 2324 } |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2439 send_parameters_.max_bandwidth_bps = 77777; | 2420 send_parameters_.max_bandwidth_bps = 77777; |
2440 ASSERT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2421 ASSERT_TRUE(channel_->SetSendParameters(send_parameters_)); |
2441 EXPECT_EQ(send_parameters_.max_bandwidth_bps, | 2422 EXPECT_EQ(send_parameters_.max_bandwidth_bps, |
2442 fake_call_->GetConfig().bitrate_config.max_bitrate_bps); | 2423 fake_call_->GetConfig().bitrate_config.max_bitrate_bps); |
2443 EXPECT_EQ(send_parameters_.max_bandwidth_bps, | 2424 EXPECT_EQ(send_parameters_.max_bandwidth_bps, |
2444 stream->GetVideoStreams()[0].max_bitrate_bps); | 2425 stream->GetVideoStreams()[0].max_bitrate_bps); |
2445 } | 2426 } |
2446 | 2427 |
2447 TEST_F(WebRtcVideoChannel2Test, SetMaxSendBitrateCanIncreaseSenderBitrate) { | 2428 TEST_F(WebRtcVideoChannel2Test, SetMaxSendBitrateCanIncreaseSenderBitrate) { |
2448 cricket::VideoSendParameters parameters; | 2429 cricket::VideoSendParameters parameters; |
2449 parameters.codecs.push_back(kVp8Codec720p); | 2430 parameters.codecs.push_back(kVp8Codec); |
2450 ASSERT_TRUE(channel_->SetSendParameters(parameters)); | 2431 ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
2451 channel_->SetSend(true); | 2432 channel_->SetSend(true); |
2452 | 2433 |
2453 FakeVideoSendStream* stream = AddSendStream(); | 2434 FakeVideoSendStream* stream = AddSendStream(); |
2454 | 2435 |
2455 cricket::FakeVideoCapturer capturer; | 2436 cricket::FakeVideoCapturer capturer; |
2456 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer)); | 2437 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer)); |
2457 EXPECT_EQ(cricket::CS_RUNNING, | 2438 EXPECT_EQ(cricket::CS_RUNNING, |
2458 capturer.Start(capturer.GetSupportedFormats()->front())); | 2439 capturer.Start(capturer.GetSupportedFormats()->front())); |
2459 | 2440 |
2460 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams(); | 2441 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams(); |
2461 int initial_max_bitrate_bps = streams[0].max_bitrate_bps; | 2442 int initial_max_bitrate_bps = streams[0].max_bitrate_bps; |
2462 EXPECT_GT(initial_max_bitrate_bps, 0); | 2443 EXPECT_GT(initial_max_bitrate_bps, 0); |
2463 | 2444 |
2464 parameters.max_bandwidth_bps = initial_max_bitrate_bps * 2; | 2445 parameters.max_bandwidth_bps = initial_max_bitrate_bps * 2; |
2465 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 2446 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
2466 // Insert a frame to update the encoder config. | 2447 // Insert a frame to update the encoder config. |
2467 EXPECT_TRUE(capturer.CaptureFrame()); | 2448 EXPECT_TRUE(capturer.CaptureFrame()); |
2468 streams = stream->GetVideoStreams(); | 2449 streams = stream->GetVideoStreams(); |
2469 EXPECT_EQ(initial_max_bitrate_bps * 2, streams[0].max_bitrate_bps); | 2450 EXPECT_EQ(initial_max_bitrate_bps * 2, streams[0].max_bitrate_bps); |
2470 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); | 2451 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); |
2471 } | 2452 } |
2472 | 2453 |
2473 TEST_F(WebRtcVideoChannel2Test, | 2454 TEST_F(WebRtcVideoChannel2Test, |
2474 SetMaxSendBitrateCanIncreaseSimulcastSenderBitrate) { | 2455 SetMaxSendBitrateCanIncreaseSimulcastSenderBitrate) { |
2475 cricket::VideoSendParameters parameters; | 2456 cricket::VideoSendParameters parameters; |
2476 parameters.codecs.push_back(kVp8Codec720p); | 2457 parameters.codecs.push_back(kVp8Codec); |
2477 ASSERT_TRUE(channel_->SetSendParameters(parameters)); | 2458 ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
2478 channel_->SetSend(true); | 2459 channel_->SetSend(true); |
2479 | 2460 |
2480 FakeVideoSendStream* stream = AddSendStream( | 2461 FakeVideoSendStream* stream = AddSendStream( |
2481 cricket::CreateSimStreamParams("cname", MAKE_VECTOR(kSsrcs3))); | 2462 cricket::CreateSimStreamParams("cname", MAKE_VECTOR(kSsrcs3))); |
2482 | 2463 |
2483 // Send a frame to make sure this scales up to >1 stream (simulcast). | 2464 // Send a frame to make sure this scales up to >1 stream (simulcast). |
2484 cricket::FakeVideoCapturer capturer; | 2465 cricket::FakeVideoCapturer capturer; |
2485 EXPECT_TRUE(channel_->SetVideoSend(kSsrcs3[0], true, nullptr, &capturer)); | 2466 EXPECT_TRUE(channel_->SetVideoSend(kSsrcs3[0], true, nullptr, &capturer)); |
2486 EXPECT_EQ(cricket::CS_RUNNING, | 2467 EXPECT_EQ(cricket::CS_RUNNING, |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2563 TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsWithOnlyVp8) { | 2544 TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsWithOnlyVp8) { |
2564 cricket::VideoRecvParameters parameters; | 2545 cricket::VideoRecvParameters parameters; |
2565 parameters.codecs.push_back(kVp8Codec); | 2546 parameters.codecs.push_back(kVp8Codec); |
2566 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 2547 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
2567 } | 2548 } |
2568 | 2549 |
2569 // Test that we set our inbound RTX codecs properly. | 2550 // Test that we set our inbound RTX codecs properly. |
2570 TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsWithRtx) { | 2551 TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsWithRtx) { |
2571 cricket::VideoRecvParameters parameters; | 2552 cricket::VideoRecvParameters parameters; |
2572 parameters.codecs.push_back(kVp8Codec); | 2553 parameters.codecs.push_back(kVp8Codec); |
2573 cricket::VideoCodec rtx_codec(96, "rtx", 0, 0, 0); | 2554 cricket::VideoCodec rtx_codec(96, "rtx"); |
2574 parameters.codecs.push_back(rtx_codec); | 2555 parameters.codecs.push_back(rtx_codec); |
2575 EXPECT_FALSE(channel_->SetRecvParameters(parameters)) | 2556 EXPECT_FALSE(channel_->SetRecvParameters(parameters)) |
2576 << "RTX codec without associated payload should be rejected."; | 2557 << "RTX codec without associated payload should be rejected."; |
2577 | 2558 |
2578 parameters.codecs[1].SetParam("apt", kVp8Codec.id + 1); | 2559 parameters.codecs[1].SetParam("apt", kVp8Codec.id + 1); |
2579 EXPECT_FALSE(channel_->SetRecvParameters(parameters)) | 2560 EXPECT_FALSE(channel_->SetRecvParameters(parameters)) |
2580 << "RTX codec with invalid associated payload type should be rejected."; | 2561 << "RTX codec with invalid associated payload type should be rejected."; |
2581 | 2562 |
2582 parameters.codecs[1].SetParam("apt", kVp8Codec.id); | 2563 parameters.codecs[1].SetParam("apt", kVp8Codec.id); |
2583 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 2564 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
2584 | 2565 |
2585 cricket::VideoCodec rtx_codec2(97, "rtx", 0, 0, 0); | 2566 cricket::VideoCodec rtx_codec2(97, "rtx"); |
2586 rtx_codec2.SetParam("apt", rtx_codec.id); | 2567 rtx_codec2.SetParam("apt", rtx_codec.id); |
2587 parameters.codecs.push_back(rtx_codec2); | 2568 parameters.codecs.push_back(rtx_codec2); |
2588 | 2569 |
2589 EXPECT_FALSE(channel_->SetRecvParameters(parameters)) << | 2570 EXPECT_FALSE(channel_->SetRecvParameters(parameters)) << |
2590 "RTX codec with another RTX as associated payload type should be " | 2571 "RTX codec with another RTX as associated payload type should be " |
2591 "rejected."; | 2572 "rejected."; |
2592 } | 2573 } |
2593 | 2574 |
2594 TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsDifferentPayloadType) { | 2575 TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsDifferentPayloadType) { |
2595 cricket::VideoRecvParameters parameters; | 2576 cricket::VideoRecvParameters parameters; |
2596 parameters.codecs.push_back(kVp8Codec); | 2577 parameters.codecs.push_back(kVp8Codec); |
2597 parameters.codecs[0].id = 99; | 2578 parameters.codecs[0].id = 99; |
2598 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 2579 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
2599 } | 2580 } |
2600 | 2581 |
2601 TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsAcceptDefaultCodecs) { | 2582 TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsAcceptDefaultCodecs) { |
2602 cricket::VideoRecvParameters parameters; | 2583 cricket::VideoRecvParameters parameters; |
2603 parameters.codecs = engine_.codecs(); | 2584 parameters.codecs = engine_.codecs(); |
2604 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 2585 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
2605 | 2586 |
2606 FakeVideoReceiveStream* stream = AddRecvStream(); | 2587 FakeVideoReceiveStream* stream = AddRecvStream(); |
2607 const webrtc::VideoReceiveStream::Config& config = stream->GetConfig(); | 2588 const webrtc::VideoReceiveStream::Config& config = stream->GetConfig(); |
2608 EXPECT_EQ(engine_.codecs()[0].name, config.decoders[0].payload_name); | 2589 EXPECT_EQ(engine_.codecs()[0].name, config.decoders[0].payload_name); |
2609 EXPECT_EQ(engine_.codecs()[0].id, config.decoders[0].payload_type); | 2590 EXPECT_EQ(engine_.codecs()[0].id, config.decoders[0].payload_type); |
2610 } | 2591 } |
2611 | 2592 |
2612 TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsRejectUnsupportedCodec) { | 2593 TEST_F(WebRtcVideoChannel2Test, SetRecvCodecsRejectUnsupportedCodec) { |
2613 cricket::VideoRecvParameters parameters; | 2594 cricket::VideoRecvParameters parameters; |
2614 parameters.codecs.push_back(kVp8Codec); | 2595 parameters.codecs.push_back(kVp8Codec); |
2615 parameters.codecs.push_back(VideoCodec(101, "WTF3", 640, 400, 30)); | 2596 parameters.codecs.push_back(VideoCodec(101, "WTF3")); |
2616 EXPECT_FALSE(channel_->SetRecvParameters(parameters)); | 2597 EXPECT_FALSE(channel_->SetRecvParameters(parameters)); |
2617 } | 2598 } |
2618 | 2599 |
2619 // TODO(pbos): Enable VP9 through external codec support | 2600 // TODO(pbos): Enable VP9 through external codec support |
2620 TEST_F(WebRtcVideoChannel2Test, | 2601 TEST_F(WebRtcVideoChannel2Test, |
2621 DISABLED_SetRecvCodecsAcceptsMultipleVideoCodecs) { | 2602 DISABLED_SetRecvCodecsAcceptsMultipleVideoCodecs) { |
2622 cricket::VideoRecvParameters parameters; | 2603 cricket::VideoRecvParameters parameters; |
2623 parameters.codecs.push_back(kVp8Codec); | 2604 parameters.codecs.push_back(kVp8Codec); |
2624 parameters.codecs.push_back(kVp9Codec); | 2605 parameters.codecs.push_back(kVp9Codec); |
2625 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 2606 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2916 // Capture format VGA. | 2897 // Capture format VGA. |
2917 cricket::FakeVideoCapturer video_capturer_vga; | 2898 cricket::FakeVideoCapturer video_capturer_vga; |
2918 const std::vector<cricket::VideoFormat>* formats = | 2899 const std::vector<cricket::VideoFormat>* formats = |
2919 video_capturer_vga.GetSupportedFormats(); | 2900 video_capturer_vga.GetSupportedFormats(); |
2920 cricket::VideoFormat capture_format_vga = (*formats)[1]; | 2901 cricket::VideoFormat capture_format_vga = (*formats)[1]; |
2921 EXPECT_EQ(cricket::CS_RUNNING, video_capturer_vga.Start(capture_format_vga)); | 2902 EXPECT_EQ(cricket::CS_RUNNING, video_capturer_vga.Start(capture_format_vga)); |
2922 EXPECT_TRUE( | 2903 EXPECT_TRUE( |
2923 channel_->SetVideoSend(kSsrcs3[0], true, nullptr, &video_capturer_vga)); | 2904 channel_->SetVideoSend(kSsrcs3[0], true, nullptr, &video_capturer_vga)); |
2924 EXPECT_TRUE(video_capturer_vga.CaptureFrame()); | 2905 EXPECT_TRUE(video_capturer_vga.CaptureFrame()); |
2925 | 2906 |
2926 cricket::VideoCodec send_codec(100, "VP8", 640, 480, 30); | 2907 cricket::VideoCodec send_codec(100, "VP8"); |
2927 cricket::VideoSendParameters parameters; | 2908 cricket::VideoSendParameters parameters; |
2928 parameters.codecs.push_back(send_codec); | 2909 parameters.codecs.push_back(send_codec); |
2929 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 2910 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
2930 EXPECT_TRUE(channel_->SetSend(true)); | 2911 EXPECT_TRUE(channel_->SetSend(true)); |
2931 | 2912 |
2932 // Verify that the CpuOveruseObserver is registered and trigger downgrade. | 2913 // Verify that the CpuOveruseObserver is registered and trigger downgrade. |
2933 | 2914 |
2934 // Trigger overuse. | 2915 // Trigger overuse. |
2935 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size()); | 2916 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size()); |
2936 webrtc::LoadObserver* overuse_callback = | 2917 webrtc::LoadObserver* overuse_callback = |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2991 // Capture format VGA. | 2972 // Capture format VGA. |
2992 cricket::FakeVideoCapturer video_capturer_vga; | 2973 cricket::FakeVideoCapturer video_capturer_vga; |
2993 const std::vector<cricket::VideoFormat>* formats = | 2974 const std::vector<cricket::VideoFormat>* formats = |
2994 video_capturer_vga.GetSupportedFormats(); | 2975 video_capturer_vga.GetSupportedFormats(); |
2995 cricket::VideoFormat capture_format_vga = (*formats)[1]; | 2976 cricket::VideoFormat capture_format_vga = (*formats)[1]; |
2996 EXPECT_EQ(cricket::CS_RUNNING, video_capturer_vga.Start(capture_format_vga)); | 2977 EXPECT_EQ(cricket::CS_RUNNING, video_capturer_vga.Start(capture_format_vga)); |
2997 EXPECT_TRUE( | 2978 EXPECT_TRUE( |
2998 channel_->SetVideoSend(kSsrcs3[0], true, nullptr, &video_capturer_vga)); | 2979 channel_->SetVideoSend(kSsrcs3[0], true, nullptr, &video_capturer_vga)); |
2999 EXPECT_TRUE(video_capturer_vga.CaptureFrame()); | 2980 EXPECT_TRUE(video_capturer_vga.CaptureFrame()); |
3000 | 2981 |
3001 cricket::VideoCodec send_codec(100, "VP8", 640, 480, 30); | 2982 cricket::VideoCodec send_codec(100, "VP8"); |
3002 cricket::VideoSendParameters parameters; | 2983 cricket::VideoSendParameters parameters; |
3003 parameters.codecs.push_back(send_codec); | 2984 parameters.codecs.push_back(send_codec); |
3004 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 2985 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
3005 EXPECT_TRUE(channel_->SetSend(true)); | 2986 EXPECT_TRUE(channel_->SetSend(true)); |
3006 | 2987 |
3007 // Verify that the CpuOveruseObserver is registered and trigger downgrade. | 2988 // Verify that the CpuOveruseObserver is registered and trigger downgrade. |
3008 | 2989 |
3009 // Trigger overuse -> adapt CPU. | 2990 // Trigger overuse -> adapt CPU. |
3010 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size()); | 2991 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size()); |
3011 webrtc::LoadObserver* overuse_callback = | 2992 webrtc::LoadObserver* overuse_callback = |
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3586 EXPECT_EQ(kVp8Codec.ToCodecParameters(), rtp_parameters.codecs[0]); | 3567 EXPECT_EQ(kVp8Codec.ToCodecParameters(), rtp_parameters.codecs[0]); |
3587 EXPECT_EQ(kVp9Codec.ToCodecParameters(), rtp_parameters.codecs[1]); | 3568 EXPECT_EQ(kVp9Codec.ToCodecParameters(), rtp_parameters.codecs[1]); |
3588 } | 3569 } |
3589 | 3570 |
3590 #if defined(WEBRTC_USE_H264) | 3571 #if defined(WEBRTC_USE_H264) |
3591 TEST_F(WebRtcVideoChannel2Test, GetRtpReceiveFmtpSprop) { | 3572 TEST_F(WebRtcVideoChannel2Test, GetRtpReceiveFmtpSprop) { |
3592 #else | 3573 #else |
3593 TEST_F(WebRtcVideoChannel2Test, DISABLED_GetRtpReceiveFmtpSprop) { | 3574 TEST_F(WebRtcVideoChannel2Test, DISABLED_GetRtpReceiveFmtpSprop) { |
3594 #endif | 3575 #endif |
3595 cricket::VideoRecvParameters parameters; | 3576 cricket::VideoRecvParameters parameters; |
3596 cricket::VideoCodec kH264sprop1(101, "H264", 640, 400, 15); | 3577 cricket::VideoCodec kH264sprop1(101, "H264"); |
3597 kH264sprop1.SetParam("sprop-parameter-sets", "uvw"); | 3578 kH264sprop1.SetParam("sprop-parameter-sets", "uvw"); |
3598 parameters.codecs.push_back(kH264sprop1); | 3579 parameters.codecs.push_back(kH264sprop1); |
3599 cricket::VideoCodec kH264sprop2(102, "H264", 640, 400, 15); | 3580 cricket::VideoCodec kH264sprop2(102, "H264"); |
3600 kH264sprop2.SetParam("sprop-parameter-sets", "xyz"); | 3581 kH264sprop2.SetParam("sprop-parameter-sets", "xyz"); |
3601 parameters.codecs.push_back(kH264sprop2); | 3582 parameters.codecs.push_back(kH264sprop2); |
3602 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 3583 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
3603 | 3584 |
3604 FakeVideoReceiveStream* recv_stream = AddRecvStream(); | 3585 FakeVideoReceiveStream* recv_stream = AddRecvStream(); |
3605 const webrtc::VideoReceiveStream::Config& cfg = recv_stream->GetConfig(); | 3586 const webrtc::VideoReceiveStream::Config& cfg = recv_stream->GetConfig(); |
3606 webrtc::RtpParameters rtp_parameters = | 3587 webrtc::RtpParameters rtp_parameters = |
3607 channel_->GetRtpReceiveParameters(last_ssrc_); | 3588 channel_->GetRtpReceiveParameters(last_ssrc_); |
3608 ASSERT_EQ(2u, rtp_parameters.codecs.size()); | 3589 ASSERT_EQ(2u, rtp_parameters.codecs.size()); |
3609 EXPECT_EQ(kH264sprop1.ToCodecParameters(), rtp_parameters.codecs[0]); | 3590 EXPECT_EQ(kH264sprop1.ToCodecParameters(), rtp_parameters.codecs[0]); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3715 | 3696 |
3716 void SetUp() override { | 3697 void SetUp() override { |
3717 engine_.Init(); | 3698 engine_.Init(); |
3718 channel_.reset( | 3699 channel_.reset( |
3719 engine_.CreateChannel(&fake_call_, MediaConfig(), VideoOptions())); | 3700 engine_.CreateChannel(&fake_call_, MediaConfig(), VideoOptions())); |
3720 last_ssrc_ = 123; | 3701 last_ssrc_ = 123; |
3721 } | 3702 } |
3722 | 3703 |
3723 protected: | 3704 protected: |
3724 void VerifySimulcastSettings(const VideoCodec& codec, | 3705 void VerifySimulcastSettings(const VideoCodec& codec, |
| 3706 int capture_width, |
| 3707 int capture_height, |
3725 size_t num_configured_streams, | 3708 size_t num_configured_streams, |
3726 size_t expected_num_streams) { | 3709 size_t expected_num_streams) { |
3727 cricket::VideoSendParameters parameters; | 3710 cricket::VideoSendParameters parameters; |
3728 parameters.codecs.push_back(codec); | 3711 parameters.codecs.push_back(codec); |
3729 ASSERT_TRUE(channel_->SetSendParameters(parameters)); | 3712 ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
3730 | 3713 |
3731 std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs3); | 3714 std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs3); |
3732 RTC_DCHECK(num_configured_streams <= ssrcs.size()); | 3715 RTC_DCHECK(num_configured_streams <= ssrcs.size()); |
3733 ssrcs.resize(num_configured_streams); | 3716 ssrcs.resize(num_configured_streams); |
3734 | 3717 |
3735 FakeVideoSendStream* stream = | 3718 FakeVideoSendStream* stream = |
3736 AddSendStream(CreateSimStreamParams("cname", ssrcs)); | 3719 AddSendStream(CreateSimStreamParams("cname", ssrcs)); |
3737 // Send a full-size frame to trigger a stream reconfiguration to use all | 3720 // Send a full-size frame to trigger a stream reconfiguration to use all |
3738 // expected simulcast layers. | 3721 // expected simulcast layers. |
3739 cricket::FakeVideoCapturer capturer; | 3722 cricket::FakeVideoCapturer capturer; |
3740 EXPECT_TRUE( | 3723 EXPECT_TRUE( |
3741 channel_->SetVideoSend(ssrcs.front(), true, nullptr, &capturer)); | 3724 channel_->SetVideoSend(ssrcs.front(), true, nullptr, &capturer)); |
3742 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(cricket::VideoFormat( | 3725 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(cricket::VideoFormat( |
3743 codec.width, codec.height, | 3726 capture_width, capture_height, |
3744 cricket::VideoFormat::FpsToInterval(30), | 3727 cricket::VideoFormat::FpsToInterval(30), |
3745 cricket::FOURCC_I420))); | 3728 cricket::FOURCC_I420))); |
3746 channel_->SetSend(true); | 3729 channel_->SetSend(true); |
3747 EXPECT_TRUE(capturer.CaptureFrame()); | 3730 EXPECT_TRUE(capturer.CaptureFrame()); |
3748 | 3731 |
3749 std::vector<webrtc::VideoStream> video_streams = stream->GetVideoStreams(); | 3732 std::vector<webrtc::VideoStream> video_streams = stream->GetVideoStreams(); |
3750 ASSERT_EQ(expected_num_streams, video_streams.size()); | 3733 ASSERT_EQ(expected_num_streams, video_streams.size()); |
3751 | 3734 |
3752 std::vector<webrtc::VideoStream> expected_streams = GetSimulcastConfig( | 3735 std::vector<webrtc::VideoStream> expected_streams = GetSimulcastConfig( |
3753 num_configured_streams, codec.width, codec.height, 0, kDefaultQpMax, | 3736 num_configured_streams, capture_width, capture_height, 0, kDefaultQpMax, |
3754 codec.framerate != 0 ? codec.framerate : kDefaultFramerate); | 3737 kDefaultVideoMaxFramerate); |
3755 | 3738 |
3756 ASSERT_EQ(expected_streams.size(), video_streams.size()); | 3739 ASSERT_EQ(expected_streams.size(), video_streams.size()); |
3757 | 3740 |
3758 size_t num_streams = video_streams.size(); | 3741 size_t num_streams = video_streams.size(); |
3759 int total_max_bitrate_bps = 0; | 3742 int total_max_bitrate_bps = 0; |
3760 for (size_t i = 0; i < num_streams; ++i) { | 3743 for (size_t i = 0; i < num_streams; ++i) { |
3761 EXPECT_EQ(expected_streams[i].width, video_streams[i].width); | 3744 EXPECT_EQ(expected_streams[i].width, video_streams[i].width); |
3762 EXPECT_EQ(expected_streams[i].height, video_streams[i].height); | 3745 EXPECT_EQ(expected_streams[i].height, video_streams[i].height); |
3763 | 3746 |
3764 EXPECT_GT(video_streams[i].max_framerate, 0); | 3747 EXPECT_GT(video_streams[i].max_framerate, 0); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3827 } | 3810 } |
3828 | 3811 |
3829 webrtc::RtcEventLogNullImpl event_log_; | 3812 webrtc::RtcEventLogNullImpl event_log_; |
3830 FakeCall fake_call_; | 3813 FakeCall fake_call_; |
3831 WebRtcVideoEngine2 engine_; | 3814 WebRtcVideoEngine2 engine_; |
3832 std::unique_ptr<VideoMediaChannel> channel_; | 3815 std::unique_ptr<VideoMediaChannel> channel_; |
3833 uint32_t last_ssrc_; | 3816 uint32_t last_ssrc_; |
3834 }; | 3817 }; |
3835 | 3818 |
3836 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith2SimulcastStreams) { | 3819 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith2SimulcastStreams) { |
3837 VerifySimulcastSettings(kVp8Codec, 2, 2); | 3820 VerifySimulcastSettings(kVp8Codec, 640, 360, 2, 2); |
3838 } | 3821 } |
3839 | 3822 |
3840 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith3SimulcastStreams) { | 3823 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith3SimulcastStreams) { |
3841 VerifySimulcastSettings(kVp8Codec720p, 3, 3); | 3824 VerifySimulcastSettings(kVp8Codec, 1280, 720, 3, 3); |
3842 } | 3825 } |
3843 | 3826 |
3844 // Test that we normalize send codec format size in simulcast. | 3827 // Test that we normalize send codec format size in simulcast. |
3845 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { | 3828 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { |
3846 cricket::VideoCodec codec(kVp8Codec270p); | 3829 cricket::VideoCodec codec(kVp8Codec); |
3847 codec.width += 1; | 3830 VerifySimulcastSettings(codec, 541, 271, 2, 2); |
3848 codec.height += 1; | |
3849 VerifySimulcastSettings(codec, 2, 2); | |
3850 } | 3831 } |
3851 } // namespace cricket | 3832 } // namespace cricket |
OLD | NEW |