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

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

Issue 2710493008: Recreate WebrtcVideoSendStream if screen content setting is changed. (Closed)
Patch Set: Fix uses of incorrect stream Created 3 years, 10 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 888 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 StreamParams sp = cricket::StreamParams::CreateLegacy(kSsrc); 899 StreamParams sp = cricket::StreamParams::CreateLegacy(kSsrc);
900 sp.id = "FakeStreamParamsId"; 900 sp.id = "FakeStreamParamsId";
901 EXPECT_TRUE(channel->AddRecvStream(sp)); 901 EXPECT_TRUE(channel->AddRecvStream(sp));
902 EXPECT_EQ(1u, decoder_factory.decoders().size()); 902 EXPECT_EQ(1u, decoder_factory.decoders().size());
903 903
904 std::vector<cricket::VideoDecoderParams> params = decoder_factory.params(); 904 std::vector<cricket::VideoDecoderParams> params = decoder_factory.params();
905 ASSERT_EQ(1u, params.size()); 905 ASSERT_EQ(1u, params.size());
906 EXPECT_EQ(sp.id, params[0].receive_stream_id); 906 EXPECT_EQ(sp.id, params[0].receive_stream_id);
907 } 907 }
908 908
909 TEST_F(WebRtcVideoEngine2Test, RecreatesEncoderOnContentTypeChange) {
pthatcher1 2017/02/22 22:24:14 I think you need a test for when both the content
sprang_webrtc 2017/02/23 15:10:14 I added a change to another option just to verify
910 cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
911 encoder_factory.AddSupportedVideoCodecType("VP8");
912 std::unique_ptr<FakeCall> fake_call(
913 new FakeCall(webrtc::Call::Config(&event_log_)));
914 std::unique_ptr<VideoMediaChannel> channel(
915 SetUpForExternalEncoderFactory(&encoder_factory));
916 ASSERT_TRUE(
917 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc)));
918 cricket::VideoCodec codec = GetEngineCodec("VP8");
919 cricket::VideoSendParameters parameters;
920 parameters.codecs.push_back(codec);
921 channel->OnReadyToSend(true);
922 channel->SetSend(true);
923 ASSERT_TRUE(channel->SetSendParameters(parameters));
924
925 cricket::FakeVideoCapturer capturer;
926 VideoOptions options;
927 EXPECT_TRUE(channel->SetVideoSend(kSsrc, true, &options, &capturer));
928
929 EXPECT_EQ(cricket::CS_RUNNING,
930 capturer.Start(capturer.GetSupportedFormats()->front()));
931 EXPECT_TRUE(capturer.CaptureFrame());
932 ASSERT_TRUE(encoder_factory.WaitForCreatedVideoEncoders(1));
Taylor Brandstetter 2017/02/23 00:46:49 Should this be checking that the created encoder a
sprang_webrtc 2017/02/23 15:10:14 Done.
933
934 EXPECT_TRUE(channel->SetVideoSend(kSsrc, true, &options, &capturer));
935 EXPECT_TRUE(capturer.CaptureFrame());
936 // No change in content type, keep current encoder.
937 EXPECT_EQ(1, encoder_factory.GetNumCreatedEncoders());
938
939 options.is_screencast.emplace(true);
940 EXPECT_TRUE(channel->SetVideoSend(kSsrc, true, &options, &capturer));
941 EXPECT_TRUE(capturer.CaptureFrame());
942 // Change to screen content, recreate encoder. For the simulcast encoder
943 // adapter case, this will result in two calls since InitEncode triggers a
944 // a new instance.
945 ASSERT_TRUE(encoder_factory.WaitForCreatedVideoEncoders(2));
946
947 EXPECT_TRUE(channel->SetVideoSend(kSsrc, true, &options, &capturer));
948 EXPECT_TRUE(capturer.CaptureFrame());
949 // Still screen content, no need to update encoder.
950 EXPECT_EQ(2, encoder_factory.GetNumCreatedEncoders());
951
952 options.is_screencast.emplace(false);
953 EXPECT_TRUE(channel->SetVideoSend(kSsrc, true, &options, &capturer));
954 // Change back to regular video content, update encoder.
955 EXPECT_TRUE(capturer.CaptureFrame());
956 ASSERT_TRUE(encoder_factory.WaitForCreatedVideoEncoders(3));
957
958 // Remove stream previously added to free the external encoder instance.
959 EXPECT_TRUE(channel->RemoveSendStream(kSsrc));
960 EXPECT_EQ(0u, encoder_factory.encoders().size());
961 }
962
909 #define WEBRTC_BASE_TEST(test) \ 963 #define WEBRTC_BASE_TEST(test) \
910 TEST_F(WebRtcVideoChannel2BaseTest, test) { Base::test(); } 964 TEST_F(WebRtcVideoChannel2BaseTest, test) { Base::test(); }
911 965
912 #define WEBRTC_DISABLED_BASE_TEST(test) \ 966 #define WEBRTC_DISABLED_BASE_TEST(test) \
913 TEST_F(WebRtcVideoChannel2BaseTest, DISABLED_##test) { Base::test(); } 967 TEST_F(WebRtcVideoChannel2BaseTest, DISABLED_##test) { Base::test(); }
914 968
915 WEBRTC_BASE_TEST(SetSend); 969 WEBRTC_BASE_TEST(SetSend);
916 WEBRTC_BASE_TEST(SetSendWithoutCodecs); 970 WEBRTC_BASE_TEST(SetSendWithoutCodecs);
917 WEBRTC_BASE_TEST(SetSendSetsTransportBufferSizes); 971 WEBRTC_BASE_TEST(SetSendSetsTransportBufferSizes);
918 972
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after
1661 EXPECT_EQ(0, encoder_config.min_transmit_bitrate_bps) 1715 EXPECT_EQ(0, encoder_config.min_transmit_bitrate_bps)
1662 << "Non-screenshare shouldn't use min-transmit bitrate."; 1716 << "Non-screenshare shouldn't use min-transmit bitrate.";
1663 1717
1664 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); 1718 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
1665 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames()); 1719 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames());
1666 VideoOptions screencast_options; 1720 VideoOptions screencast_options;
1667 screencast_options.is_screencast = rtc::Optional<bool>(true); 1721 screencast_options.is_screencast = rtc::Optional<bool>(true);
1668 EXPECT_TRUE( 1722 EXPECT_TRUE(
1669 channel_->SetVideoSend(last_ssrc_, true, &screencast_options, &capturer)); 1723 channel_->SetVideoSend(last_ssrc_, true, &screencast_options, &capturer));
1670 EXPECT_TRUE(capturer.CaptureFrame()); 1724 EXPECT_TRUE(capturer.CaptureFrame());
1671 // Send stream not recreated after option change. 1725 // Send stream recreated after option change.
1672 ASSERT_EQ(send_stream, fake_call_->GetVideoSendStreams().front()); 1726 ASSERT_EQ(send_stream, fake_call_->GetVideoSendStreams().front());
1673 EXPECT_EQ(2, send_stream->GetNumberOfSwappedFrames()); 1727 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames());
1674 1728
1675 // Verify screencast settings. 1729 // Verify screencast settings.
1676 encoder_config = send_stream->GetEncoderConfig().Copy(); 1730 encoder_config = send_stream->GetEncoderConfig().Copy();
1677 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kScreen, 1731 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kScreen,
1678 encoder_config.content_type); 1732 encoder_config.content_type);
1679 EXPECT_EQ(kScreenshareMinBitrateKbps * 1000, 1733 EXPECT_EQ(kScreenshareMinBitrateKbps * 1000,
1680 encoder_config.min_transmit_bitrate_bps); 1734 encoder_config.min_transmit_bitrate_bps);
1681 1735
1682 streams = send_stream->GetVideoStreams(); 1736 streams = send_stream->GetVideoStreams();
1683 EXPECT_EQ(capture_format_hd.width, streams.front().width); 1737 EXPECT_EQ(capture_format_hd.width, streams.front().width);
1684 EXPECT_EQ(capture_format_hd.height, streams.front().height); 1738 EXPECT_EQ(capture_format_hd.height, streams.front().height);
1685 EXPECT_TRUE(streams[0].temporal_layer_thresholds_bps.empty()); 1739 EXPECT_TRUE(streams[0].temporal_layer_thresholds_bps.empty());
1686 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); 1740 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
1687 } 1741 }
1688 1742
1689 TEST_F(WebRtcVideoChannel2Test, NoRecreateStreamForScreencast) { 1743 TEST_F(WebRtcVideoChannel2Test, RecreateStreamForScreencast) {
Taylor Brandstetter 2017/02/23 00:46:49 It seems odd to make this test the opposite of wha
sprang_webrtc 2017/02/23 15:10:14 Maybe not, it's covered by RecreatesEncoderOnConte
Taylor Brandstetter 2017/02/24 00:13:55 Acknowledged.
1690 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 1744 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
1691 ASSERT_TRUE( 1745 ASSERT_TRUE(
1692 channel_->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); 1746 channel_->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc)));
1693 EXPECT_TRUE(channel_->SetSend(true)); 1747 EXPECT_TRUE(channel_->SetSend(true));
1694 1748
1695 cricket::FakeVideoCapturer capturer; 1749 cricket::FakeVideoCapturer capturer;
1696 EXPECT_TRUE(channel_->SetVideoSend(kSsrc, true, nullptr, &capturer)); 1750 EXPECT_TRUE(channel_->SetVideoSend(kSsrc, true, nullptr, &capturer));
1697 EXPECT_EQ(cricket::CS_RUNNING, 1751 EXPECT_EQ(cricket::CS_RUNNING,
1698 capturer.Start(capturer.GetSupportedFormats()->front())); 1752 capturer.Start(capturer.GetSupportedFormats()->front()));
1699 EXPECT_TRUE(capturer.CaptureFrame()); 1753 EXPECT_TRUE(capturer.CaptureFrame());
1700 1754
1701 ASSERT_EQ(1, fake_call_->GetNumCreatedSendStreams()); 1755 ASSERT_EQ(1, fake_call_->GetNumCreatedSendStreams());
1702 FakeVideoSendStream* stream = fake_call_->GetVideoSendStreams().front(); 1756 FakeVideoSendStream* stream = fake_call_->GetVideoSendStreams().front();
1703 webrtc::VideoEncoderConfig encoder_config = stream->GetEncoderConfig().Copy(); 1757 webrtc::VideoEncoderConfig encoder_config = stream->GetEncoderConfig().Copy();
1704 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo, 1758 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo,
1705 encoder_config.content_type); 1759 encoder_config.content_type);
1706 1760
1707 EXPECT_EQ(1, stream->GetNumberOfSwappedFrames()); 1761 EXPECT_EQ(1, stream->GetNumberOfSwappedFrames());
1708 1762
1709 /* Switch to screencast source. We expect a reconfigure of the 1763 /* Switch to screencast source. We expect a reconfigure of the
1710 * encoder, but no change of the send stream. */ 1764 * encoder, and an update of the send stream. */
1711 struct VideoOptions video_options; 1765 struct VideoOptions video_options;
1712 video_options.is_screencast = rtc::Optional<bool>(true); 1766 video_options.is_screencast = rtc::Optional<bool>(true);
1713 EXPECT_TRUE(channel_->SetVideoSend(kSsrc, true, &video_options, &capturer)); 1767 EXPECT_TRUE(channel_->SetVideoSend(kSsrc, true, &video_options, &capturer));
1714 1768
1715 EXPECT_TRUE(capturer.CaptureFrame()); 1769 EXPECT_TRUE(capturer.CaptureFrame());
1716 ASSERT_EQ(1, fake_call_->GetNumCreatedSendStreams()); 1770 ASSERT_EQ(2, fake_call_->GetNumCreatedSendStreams());
1717 ASSERT_EQ(stream, fake_call_->GetVideoSendStreams().front()); 1771 stream = fake_call_->GetVideoSendStreams().front();
1718 EXPECT_EQ(2, stream->GetNumberOfSwappedFrames()); 1772 EXPECT_EQ(1, stream->GetNumberOfSwappedFrames());
1719 1773
1720 encoder_config = stream->GetEncoderConfig().Copy(); 1774 encoder_config = stream->GetEncoderConfig().Copy();
1721 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kScreen, 1775 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kScreen,
1722 encoder_config.content_type); 1776 encoder_config.content_type);
1723 1777
1724 /* Switch back. */ 1778 /* Switch back. */
1725 video_options.is_screencast = rtc::Optional<bool>(false); 1779 video_options.is_screencast = rtc::Optional<bool>(false);
1726 EXPECT_TRUE(channel_->SetVideoSend(kSsrc, true, &video_options, &capturer)); 1780 EXPECT_TRUE(channel_->SetVideoSend(kSsrc, true, &video_options, &capturer));
1727 1781
1728 EXPECT_TRUE(capturer.CaptureFrame()); 1782 EXPECT_TRUE(capturer.CaptureFrame());
1729 ASSERT_EQ(1, fake_call_->GetNumCreatedSendStreams()); 1783 ASSERT_EQ(3, fake_call_->GetNumCreatedSendStreams());
1730 ASSERT_EQ(stream, fake_call_->GetVideoSendStreams().front()); 1784 stream = fake_call_->GetVideoSendStreams().front();
1731 EXPECT_EQ(3, stream->GetNumberOfSwappedFrames()); 1785 EXPECT_EQ(1, stream->GetNumberOfSwappedFrames());
1732 1786
1733 encoder_config = stream->GetEncoderConfig().Copy(); 1787 encoder_config = stream->GetEncoderConfig().Copy();
1734 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo, 1788 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo,
1735 encoder_config.content_type); 1789 encoder_config.content_type);
1736 1790
1737 EXPECT_TRUE(channel_->SetVideoSend(kSsrc, true, nullptr, nullptr)); 1791 EXPECT_TRUE(channel_->SetVideoSend(kSsrc, true, nullptr, nullptr));
1738 } 1792 }
1739 1793
1740 TEST_F(WebRtcVideoChannel2Test, 1794 TEST_F(WebRtcVideoChannel2Test,
1741 ConferenceModeScreencastConfiguresTemporalLayer) { 1795 ConferenceModeScreencastConfiguresTemporalLayer) {
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1903 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer)); 1957 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer));
1904 EXPECT_TRUE(capturer.CaptureFrame()); 1958 EXPECT_TRUE(capturer.CaptureFrame());
1905 // Expect 1 reconfigurations at this point from the initial configuration. 1959 // Expect 1 reconfigurations at this point from the initial configuration.
1906 EXPECT_EQ(1, send_stream->num_encoder_reconfigurations()); 1960 EXPECT_EQ(1, send_stream->num_encoder_reconfigurations());
1907 1961
1908 // Set the options one more time and expect no additional reconfigurations. 1962 // Set the options one more time and expect no additional reconfigurations.
1909 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer)); 1963 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer));
1910 EXPECT_EQ(1, send_stream->num_encoder_reconfigurations()); 1964 EXPECT_EQ(1, send_stream->num_encoder_reconfigurations());
1911 1965
1912 // Change |options| and expect 2 reconfigurations. 1966 // Change |options| and expect 2 reconfigurations.
1913 options.is_screencast = rtc::Optional<bool>(true); 1967 options.video_noise_reduction = rtc::Optional<bool>(true);
1914 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer)); 1968 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer));
1915 EXPECT_EQ(2, send_stream->num_encoder_reconfigurations()); 1969 EXPECT_EQ(2, send_stream->num_encoder_reconfigurations());
1916 1970
1917 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); 1971 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
1918 } 1972 }
1919 1973
1920 class Vp9SettingsTest : public WebRtcVideoChannel2Test { 1974 class Vp9SettingsTest : public WebRtcVideoChannel2Test {
1921 public: 1975 public:
1922 Vp9SettingsTest() : Vp9SettingsTest("") {} 1976 Vp9SettingsTest() : Vp9SettingsTest("") {}
1923 explicit Vp9SettingsTest(const char* field_trials) 1977 explicit Vp9SettingsTest(const char* field_trials)
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
2174 ASSERT_TRUE(channel_->SetSend(true)); 2228 ASSERT_TRUE(channel_->SetSend(true));
2175 cricket::VideoOptions camera_options; 2229 cricket::VideoOptions camera_options;
2176 camera_options.is_screencast = rtc::Optional<bool>(false); 2230 camera_options.is_screencast = rtc::Optional<bool>(false);
2177 channel_->SetVideoSend(last_ssrc_, true /* enable */, &camera_options, 2231 channel_->SetVideoSend(last_ssrc_, true /* enable */, &camera_options,
2178 &capturer); 2232 &capturer);
2179 2233
2180 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size()); 2234 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size());
2181 FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front(); 2235 FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front();
2182 2236
2183 EXPECT_TRUE(capturer.CaptureCustomFrame(1280, 720, cricket::FOURCC_I420)); 2237 EXPECT_TRUE(capturer.CaptureCustomFrame(1280, 720, cricket::FOURCC_I420));
2238 EXPECT_EQ(1, fake_call_->GetNumCreatedSendStreams());
Taylor Brandstetter 2017/02/23 00:46:49 This expectation doesn't seem necessary for this t
sprang_webrtc 2017/02/23 15:10:14 This one, no. It's already assert just above.
2184 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames()); 2239 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames());
2185 EXPECT_EQ(1280, send_stream->GetLastWidth()); 2240 EXPECT_EQ(1280, send_stream->GetLastWidth());
2186 EXPECT_EQ(720, send_stream->GetLastHeight()); 2241 EXPECT_EQ(720, send_stream->GetLastHeight());
2187 2242
2188 // Trigger overuse. 2243 // Trigger overuse.
2189 rtc::VideoSinkWants wants; 2244 rtc::VideoSinkWants wants;
2190 wants.max_pixel_count = rtc::Optional<int>( 2245 wants.max_pixel_count = rtc::Optional<int>(
2191 send_stream->GetLastWidth() * send_stream->GetLastHeight() - 1); 2246 send_stream->GetLastWidth() * send_stream->GetLastHeight() - 1);
2192 send_stream->InjectVideoSinkWants(wants); 2247 send_stream->InjectVideoSinkWants(wants);
2193 EXPECT_TRUE(capturer.CaptureCustomFrame(1280, 720, cricket::FOURCC_I420)); 2248 EXPECT_TRUE(capturer.CaptureCustomFrame(1280, 720, cricket::FOURCC_I420));
2194 EXPECT_EQ(2, send_stream->GetNumberOfSwappedFrames()); 2249 EXPECT_EQ(2, send_stream->GetNumberOfSwappedFrames());
2195 EXPECT_EQ(1280 * 3 / 4, send_stream->GetLastWidth()); 2250 EXPECT_EQ(1280 * 3 / 4, send_stream->GetLastWidth());
2196 EXPECT_EQ(720 * 3 / 4, send_stream->GetLastHeight()); 2251 EXPECT_EQ(720 * 3 / 4, send_stream->GetLastHeight());
2197 2252
2198 // Switch to screen share. Expect no CPU adaptation. 2253 // Switch to screen share. Expect no CPU adaptation.
2199 cricket::FakeVideoCapturer screen_share(true); 2254 cricket::FakeVideoCapturer screen_share(true);
2200 ASSERT_EQ(cricket::CS_RUNNING, 2255 ASSERT_EQ(cricket::CS_RUNNING,
2201 screen_share.Start(screen_share.GetSupportedFormats()->front())); 2256 screen_share.Start(screen_share.GetSupportedFormats()->front()));
2202 cricket::VideoOptions screenshare_options; 2257 cricket::VideoOptions screenshare_options;
2203 screenshare_options.is_screencast = rtc::Optional<bool>(true); 2258 screenshare_options.is_screencast = rtc::Optional<bool>(true);
2204 channel_->SetVideoSend(last_ssrc_, true /* enable */, &screenshare_options, 2259 channel_->SetVideoSend(last_ssrc_, true /* enable */, &screenshare_options,
2205 &screen_share); 2260 &screen_share);
2206 EXPECT_TRUE(screen_share.CaptureCustomFrame(1284, 724, cricket::FOURCC_I420)); 2261 EXPECT_TRUE(screen_share.CaptureCustomFrame(1284, 724, cricket::FOURCC_I420));
2207 EXPECT_EQ(3, send_stream->GetNumberOfSwappedFrames()); 2262 EXPECT_EQ(2, fake_call_->GetNumCreatedSendStreams());
Taylor Brandstetter 2017/02/23 00:46:49 Same here
sprang_webrtc 2017/02/23 15:10:14 I actually changed this to an assert, since we wil
Taylor Brandstetter 2017/02/24 00:13:55 Acknowledged.
2263 send_stream = fake_call_->GetVideoSendStreams().front();
2264 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames());
2208 EXPECT_EQ(1284, send_stream->GetLastWidth()); 2265 EXPECT_EQ(1284, send_stream->GetLastWidth());
2209 EXPECT_EQ(724, send_stream->GetLastHeight()); 2266 EXPECT_EQ(724, send_stream->GetLastHeight());
2210 2267
2211 // Switch back to the normal capturer. Expect the frame to be CPU adapted. 2268 // Switch back to the normal capturer. Expect the frame to be CPU adapted.
2212 channel_->SetVideoSend(last_ssrc_, true /* enable */, &camera_options, 2269 channel_->SetVideoSend(last_ssrc_, true /* enable */, &camera_options,
2213 &capturer); 2270 &capturer);
2271 send_stream = fake_call_->GetVideoSendStreams().front();
2272 // We have a new fake send stream, so it doesn't remember the old sink wants.
2273 // In practice, it will be populated from
2274 // ViEEncoder::VideoSourceProxy::SetSource(), so simulate that here.
2275 send_stream->InjectVideoSinkWants(wants);
2214 EXPECT_TRUE(capturer.CaptureCustomFrame(1280, 720, cricket::FOURCC_I420)); 2276 EXPECT_TRUE(capturer.CaptureCustomFrame(1280, 720, cricket::FOURCC_I420));
2215 EXPECT_EQ(4, send_stream->GetNumberOfSwappedFrames()); 2277 EXPECT_EQ(3, fake_call_->GetNumCreatedSendStreams());
2278 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames());
2216 EXPECT_EQ(1280 * 3 / 4, send_stream->GetLastWidth()); 2279 EXPECT_EQ(1280 * 3 / 4, send_stream->GetLastWidth());
2217 EXPECT_EQ(720 * 3 / 4, send_stream->GetLastHeight()); 2280 EXPECT_EQ(720 * 3 / 4, send_stream->GetLastHeight());
2218 2281
2219 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); 2282 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
2220 } 2283 }
2221 2284
2222 void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse, 2285 void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse,
2223 bool is_screenshare) { 2286 bool is_screenshare) {
2224 cricket::VideoCodec codec = GetEngineCodec("VP8"); 2287 cricket::VideoCodec codec = GetEngineCodec("VP8");
2225 cricket::VideoSendParameters parameters; 2288 cricket::VideoSendParameters parameters;
(...skipping 1949 matching lines...) Expand 10 before | Expand all | Expand 10 after
4175 parameters.conference_mode = conference_mode; 4238 parameters.conference_mode = conference_mode;
4176 if (screenshare) { 4239 if (screenshare) {
4177 options.is_screencast = rtc::Optional<bool>(screenshare); 4240 options.is_screencast = rtc::Optional<bool>(screenshare);
4178 } 4241 }
4179 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 4242 ASSERT_TRUE(channel_->SetSendParameters(parameters));
4180 4243
4181 std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs3); 4244 std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs3);
4182 RTC_DCHECK(num_configured_streams <= ssrcs.size()); 4245 RTC_DCHECK(num_configured_streams <= ssrcs.size());
4183 ssrcs.resize(num_configured_streams); 4246 ssrcs.resize(num_configured_streams);
4184 4247
4185 FakeVideoSendStream* stream = 4248 AddSendStream(CreateSimStreamParams("cname", ssrcs));
4186 AddSendStream(CreateSimStreamParams("cname", ssrcs));
4187 // Send a full-size frame to trigger a stream reconfiguration to use all 4249 // Send a full-size frame to trigger a stream reconfiguration to use all
4188 // expected simulcast layers. 4250 // expected simulcast layers.
4189 cricket::FakeVideoCapturer capturer; 4251 cricket::FakeVideoCapturer capturer;
4190 EXPECT_TRUE( 4252 EXPECT_TRUE(
4191 channel_->SetVideoSend(ssrcs.front(), true, &options, &capturer)); 4253 channel_->SetVideoSend(ssrcs.front(), true, &options, &capturer));
4254 // Fetch the new stream created for the screenshare content.
Taylor Brandstetter 2017/02/23 00:46:49 |screenshare| can be false, so this comment may be
sprang_webrtc 2017/02/23 15:10:14 Done.
4255 FakeVideoSendStream* stream = fake_call_.GetVideoSendStreams().front();
4192 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(cricket::VideoFormat( 4256 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(cricket::VideoFormat(
4193 capture_width, capture_height, 4257 capture_width, capture_height,
4194 cricket::VideoFormat::FpsToInterval(30), 4258 cricket::VideoFormat::FpsToInterval(30),
4195 cricket::FOURCC_I420))); 4259 cricket::FOURCC_I420)));
4196 channel_->SetSend(true); 4260 channel_->SetSend(true);
4197 EXPECT_TRUE(capturer.CaptureFrame()); 4261 EXPECT_TRUE(capturer.CaptureFrame());
4198 4262
4199 std::vector<webrtc::VideoStream> video_streams = stream->GetVideoStreams(); 4263 std::vector<webrtc::VideoStream> video_streams = stream->GetVideoStreams();
4200 ASSERT_EQ(expected_num_streams, video_streams.size()); 4264 ASSERT_EQ(expected_num_streams, video_streams.size());
4201 4265
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
4342 } 4406 }
4343 4407
4344 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsForSimulcastScreenshare) { 4408 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsForSimulcastScreenshare) {
4345 webrtc::test::ScopedFieldTrials override_field_trials_( 4409 webrtc::test::ScopedFieldTrials override_field_trials_(
4346 "WebRTC-SimulcastScreenshare/Enabled/"); 4410 "WebRTC-SimulcastScreenshare/Enabled/");
4347 VerifySimulcastSettings(cricket::VideoCodec("VP8"), 1280, 720, 3, 2, true, 4411 VerifySimulcastSettings(cricket::VideoCodec("VP8"), 1280, 720, 3, 2, true,
4348 true); 4412 true);
4349 } 4413 }
4350 4414
4351 } // namespace cricket 4415 } // namespace cricket
OLDNEW
« webrtc/media/engine/webrtcvideoengine2.cc ('K') | « webrtc/media/engine/webrtcvideoengine2.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698