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

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

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

Powered by Google App Engine
This is Rietveld 408576698