Chromium Code Reviews| 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 |
| 11 #include <algorithm> | 11 #include <algorithm> |
| 12 #include <map> | 12 #include <map> |
| 13 #include <memory> | 13 #include <memory> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "webrtc/test/gtest.h" | |
| 16 #include "webrtc/base/arraysize.h" | 17 #include "webrtc/base/arraysize.h" |
| 17 #include "webrtc/base/gunit.h" | 18 //#include "webrtc/base/gunit.h" |
|
Taylor Brandstetter
2017/02/24 00:13:55
Left over from debugging?
sprang_webrtc
2017/02/26 13:41:27
Oops, yes. For some reason eclipse can't properly
| |
| 18 #include "webrtc/base/stringutils.h" | 19 #include "webrtc/base/stringutils.h" |
| 19 #include "webrtc/call/flexfec_receive_stream.h" | 20 #include "webrtc/call/flexfec_receive_stream.h" |
| 20 #include "webrtc/common_video/h264/profile_level_id.h" | 21 #include "webrtc/common_video/h264/profile_level_id.h" |
| 21 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" | 22 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" |
| 22 #include "webrtc/media/base/mediaconstants.h" | 23 #include "webrtc/media/base/mediaconstants.h" |
| 23 #include "webrtc/media/base/rtputils.h" | 24 #include "webrtc/media/base/rtputils.h" |
| 24 #include "webrtc/media/base/testutils.h" | 25 #include "webrtc/media/base/testutils.h" |
| 25 #include "webrtc/media/base/videoengine_unittest.h" | 26 #include "webrtc/media/base/videoengine_unittest.h" |
| 26 #include "webrtc/media/engine/constants.h" | 27 #include "webrtc/media/engine/constants.h" |
| 27 #include "webrtc/media/engine/fakewebrtccall.h" | 28 #include "webrtc/media/engine/fakewebrtccall.h" |
| (...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 899 StreamParams sp = cricket::StreamParams::CreateLegacy(kSsrc); | 900 StreamParams sp = cricket::StreamParams::CreateLegacy(kSsrc); |
| 900 sp.id = "FakeStreamParamsId"; | 901 sp.id = "FakeStreamParamsId"; |
| 901 EXPECT_TRUE(channel->AddRecvStream(sp)); | 902 EXPECT_TRUE(channel->AddRecvStream(sp)); |
| 902 EXPECT_EQ(1u, decoder_factory.decoders().size()); | 903 EXPECT_EQ(1u, decoder_factory.decoders().size()); |
| 903 | 904 |
| 904 std::vector<cricket::VideoDecoderParams> params = decoder_factory.params(); | 905 std::vector<cricket::VideoDecoderParams> params = decoder_factory.params(); |
| 905 ASSERT_EQ(1u, params.size()); | 906 ASSERT_EQ(1u, params.size()); |
| 906 EXPECT_EQ(sp.id, params[0].receive_stream_id); | 907 EXPECT_EQ(sp.id, params[0].receive_stream_id); |
| 907 } | 908 } |
| 908 | 909 |
| 910 TEST_F(WebRtcVideoEngine2Test, RecreatesEncoderOnContentTypeChange) { | |
| 911 cricket::FakeWebRtcVideoEncoderFactory encoder_factory; | |
| 912 encoder_factory.AddSupportedVideoCodecType("VP8"); | |
| 913 std::unique_ptr<FakeCall> fake_call( | |
| 914 new FakeCall(webrtc::Call::Config(&event_log_))); | |
| 915 std::unique_ptr<VideoMediaChannel> channel( | |
| 916 SetUpForExternalEncoderFactory(&encoder_factory)); | |
| 917 ASSERT_TRUE( | |
| 918 channel->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); | |
| 919 cricket::VideoCodec codec = GetEngineCodec("VP8"); | |
| 920 cricket::VideoSendParameters parameters; | |
| 921 parameters.codecs.push_back(codec); | |
| 922 channel->OnReadyToSend(true); | |
| 923 channel->SetSend(true); | |
| 924 ASSERT_TRUE(channel->SetSendParameters(parameters)); | |
| 925 | |
| 926 cricket::FakeVideoCapturer capturer; | |
| 927 VideoOptions options; | |
| 928 EXPECT_TRUE(channel->SetVideoSend(kSsrc, true, &options, &capturer)); | |
| 929 | |
| 930 EXPECT_EQ(cricket::CS_RUNNING, | |
| 931 capturer.Start(capturer.GetSupportedFormats()->front())); | |
| 932 EXPECT_TRUE(capturer.CaptureFrame()); | |
| 933 ASSERT_TRUE(encoder_factory.WaitForCreatedVideoEncoders(1)); | |
| 934 EXPECT_EQ(webrtc::kRealtimeVideo, | |
| 935 encoder_factory.encoders().back()->GetCodecSettings().mode); | |
| 936 | |
| 937 EXPECT_TRUE(channel->SetVideoSend(kSsrc, true, &options, &capturer)); | |
| 938 EXPECT_TRUE(capturer.CaptureFrame()); | |
| 939 // No change in content type, keep current encoder. | |
| 940 EXPECT_EQ(1, encoder_factory.GetNumCreatedEncoders()); | |
| 941 | |
| 942 options.is_screencast.emplace(true); | |
| 943 EXPECT_TRUE(channel->SetVideoSend(kSsrc, true, &options, &capturer)); | |
| 944 EXPECT_TRUE(capturer.CaptureFrame()); | |
| 945 // Change to screen content, recreate encoder. For the simulcast encoder | |
| 946 // adapter case, this will result in two calls since InitEncode triggers a | |
| 947 // a new instance. | |
| 948 ASSERT_TRUE(encoder_factory.WaitForCreatedVideoEncoders(2)); | |
| 949 EXPECT_EQ(webrtc::kScreensharing, | |
| 950 encoder_factory.encoders().back()->GetCodecSettings().mode); | |
| 951 | |
| 952 EXPECT_TRUE(channel->SetVideoSend(kSsrc, true, &options, &capturer)); | |
| 953 EXPECT_TRUE(capturer.CaptureFrame()); | |
| 954 // Still screen content, no need to update encoder. | |
| 955 EXPECT_EQ(2, encoder_factory.GetNumCreatedEncoders()); | |
| 956 | |
| 957 options.is_screencast.emplace(false); | |
| 958 options.video_noise_reduction.emplace(false); | |
| 959 EXPECT_TRUE(channel->SetVideoSend(kSsrc, true, &options, &capturer)); | |
| 960 // Change back to regular video content, update encoder. Also change | |
| 961 // a non is_screencast option just verify it doesn not affect recreation. | |
|
Taylor Brandstetter
2017/02/24 00:13:55
nit: "doesn not" typo
sprang_webrtc
2017/02/26 13:41:27
Done.
| |
| 962 EXPECT_TRUE(capturer.CaptureFrame()); | |
| 963 ASSERT_TRUE(encoder_factory.WaitForCreatedVideoEncoders(3)); | |
| 964 EXPECT_EQ(webrtc::kRealtimeVideo, | |
| 965 encoder_factory.encoders().back()->GetCodecSettings().mode); | |
| 966 | |
| 967 // Remove stream previously added to free the external encoder instance. | |
| 968 EXPECT_TRUE(channel->RemoveSendStream(kSsrc)); | |
| 969 EXPECT_EQ(0u, encoder_factory.encoders().size()); | |
| 970 } | |
| 971 | |
| 909 #define WEBRTC_BASE_TEST(test) \ | 972 #define WEBRTC_BASE_TEST(test) \ |
| 910 TEST_F(WebRtcVideoChannel2BaseTest, test) { Base::test(); } | 973 TEST_F(WebRtcVideoChannel2BaseTest, test) { Base::test(); } |
| 911 | 974 |
| 912 #define WEBRTC_DISABLED_BASE_TEST(test) \ | 975 #define WEBRTC_DISABLED_BASE_TEST(test) \ |
| 913 TEST_F(WebRtcVideoChannel2BaseTest, DISABLED_##test) { Base::test(); } | 976 TEST_F(WebRtcVideoChannel2BaseTest, DISABLED_##test) { Base::test(); } |
| 914 | 977 |
| 915 WEBRTC_BASE_TEST(SetSend); | 978 WEBRTC_BASE_TEST(SetSend); |
| 916 WEBRTC_BASE_TEST(SetSendWithoutCodecs); | 979 WEBRTC_BASE_TEST(SetSendWithoutCodecs); |
| 917 WEBRTC_BASE_TEST(SetSendSetsTransportBufferSizes); | 980 WEBRTC_BASE_TEST(SetSendSetsTransportBufferSizes); |
| 918 | 981 |
| (...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1661 EXPECT_EQ(0, encoder_config.min_transmit_bitrate_bps) | 1724 EXPECT_EQ(0, encoder_config.min_transmit_bitrate_bps) |
| 1662 << "Non-screenshare shouldn't use min-transmit bitrate."; | 1725 << "Non-screenshare shouldn't use min-transmit bitrate."; |
| 1663 | 1726 |
| 1664 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); | 1727 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); |
| 1665 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames()); | 1728 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames()); |
| 1666 VideoOptions screencast_options; | 1729 VideoOptions screencast_options; |
| 1667 screencast_options.is_screencast = rtc::Optional<bool>(true); | 1730 screencast_options.is_screencast = rtc::Optional<bool>(true); |
| 1668 EXPECT_TRUE( | 1731 EXPECT_TRUE( |
| 1669 channel_->SetVideoSend(last_ssrc_, true, &screencast_options, &capturer)); | 1732 channel_->SetVideoSend(last_ssrc_, true, &screencast_options, &capturer)); |
| 1670 EXPECT_TRUE(capturer.CaptureFrame()); | 1733 EXPECT_TRUE(capturer.CaptureFrame()); |
| 1671 // Send stream not recreated after option change. | 1734 // Send stream recreated after option change. |
| 1672 ASSERT_EQ(send_stream, fake_call_->GetVideoSendStreams().front()); | 1735 ASSERT_EQ(2, fake_call_->GetNumCreatedSendStreams()); |
| 1673 EXPECT_EQ(2, send_stream->GetNumberOfSwappedFrames()); | 1736 send_stream = fake_call_->GetVideoSendStreams().front(); |
| 1737 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames()); | |
| 1674 | 1738 |
| 1675 // Verify screencast settings. | 1739 // Verify screencast settings. |
| 1676 encoder_config = send_stream->GetEncoderConfig().Copy(); | 1740 encoder_config = send_stream->GetEncoderConfig().Copy(); |
| 1677 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kScreen, | 1741 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kScreen, |
| 1678 encoder_config.content_type); | 1742 encoder_config.content_type); |
| 1679 EXPECT_EQ(kScreenshareMinBitrateKbps * 1000, | 1743 EXPECT_EQ(kScreenshareMinBitrateKbps * 1000, |
| 1680 encoder_config.min_transmit_bitrate_bps); | 1744 encoder_config.min_transmit_bitrate_bps); |
| 1681 | 1745 |
| 1682 streams = send_stream->GetVideoStreams(); | 1746 streams = send_stream->GetVideoStreams(); |
| 1683 EXPECT_EQ(capture_format_hd.width, streams.front().width); | 1747 EXPECT_EQ(capture_format_hd.width, streams.front().width); |
| 1684 EXPECT_EQ(capture_format_hd.height, streams.front().height); | 1748 EXPECT_EQ(capture_format_hd.height, streams.front().height); |
| 1685 EXPECT_TRUE(streams[0].temporal_layer_thresholds_bps.empty()); | 1749 EXPECT_TRUE(streams[0].temporal_layer_thresholds_bps.empty()); |
| 1686 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); | 1750 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); |
| 1687 } | 1751 } |
| 1688 | 1752 |
| 1689 TEST_F(WebRtcVideoChannel2Test, NoRecreateStreamForScreencast) { | |
| 1690 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | |
| 1691 ASSERT_TRUE( | |
| 1692 channel_->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); | |
| 1693 EXPECT_TRUE(channel_->SetSend(true)); | |
| 1694 | |
| 1695 cricket::FakeVideoCapturer capturer; | |
| 1696 EXPECT_TRUE(channel_->SetVideoSend(kSsrc, true, nullptr, &capturer)); | |
| 1697 EXPECT_EQ(cricket::CS_RUNNING, | |
| 1698 capturer.Start(capturer.GetSupportedFormats()->front())); | |
| 1699 EXPECT_TRUE(capturer.CaptureFrame()); | |
| 1700 | |
| 1701 ASSERT_EQ(1, fake_call_->GetNumCreatedSendStreams()); | |
| 1702 FakeVideoSendStream* stream = fake_call_->GetVideoSendStreams().front(); | |
| 1703 webrtc::VideoEncoderConfig encoder_config = stream->GetEncoderConfig().Copy(); | |
| 1704 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo, | |
| 1705 encoder_config.content_type); | |
| 1706 | |
| 1707 EXPECT_EQ(1, stream->GetNumberOfSwappedFrames()); | |
| 1708 | |
| 1709 /* Switch to screencast source. We expect a reconfigure of the | |
| 1710 * encoder, but no change of the send stream. */ | |
| 1711 struct VideoOptions video_options; | |
| 1712 video_options.is_screencast = rtc::Optional<bool>(true); | |
| 1713 EXPECT_TRUE(channel_->SetVideoSend(kSsrc, true, &video_options, &capturer)); | |
| 1714 | |
| 1715 EXPECT_TRUE(capturer.CaptureFrame()); | |
| 1716 ASSERT_EQ(1, fake_call_->GetNumCreatedSendStreams()); | |
| 1717 ASSERT_EQ(stream, fake_call_->GetVideoSendStreams().front()); | |
| 1718 EXPECT_EQ(2, stream->GetNumberOfSwappedFrames()); | |
| 1719 | |
| 1720 encoder_config = stream->GetEncoderConfig().Copy(); | |
| 1721 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kScreen, | |
| 1722 encoder_config.content_type); | |
| 1723 | |
| 1724 /* Switch back. */ | |
| 1725 video_options.is_screencast = rtc::Optional<bool>(false); | |
| 1726 EXPECT_TRUE(channel_->SetVideoSend(kSsrc, true, &video_options, &capturer)); | |
| 1727 | |
| 1728 EXPECT_TRUE(capturer.CaptureFrame()); | |
| 1729 ASSERT_EQ(1, fake_call_->GetNumCreatedSendStreams()); | |
| 1730 ASSERT_EQ(stream, fake_call_->GetVideoSendStreams().front()); | |
| 1731 EXPECT_EQ(3, stream->GetNumberOfSwappedFrames()); | |
| 1732 | |
| 1733 encoder_config = stream->GetEncoderConfig().Copy(); | |
| 1734 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo, | |
| 1735 encoder_config.content_type); | |
| 1736 | |
| 1737 EXPECT_TRUE(channel_->SetVideoSend(kSsrc, true, nullptr, nullptr)); | |
| 1738 } | |
| 1739 | |
| 1740 TEST_F(WebRtcVideoChannel2Test, | 1753 TEST_F(WebRtcVideoChannel2Test, |
| 1741 ConferenceModeScreencastConfiguresTemporalLayer) { | 1754 ConferenceModeScreencastConfiguresTemporalLayer) { |
| 1742 static const int kConferenceScreencastTemporalBitrateBps = | 1755 static const int kConferenceScreencastTemporalBitrateBps = |
| 1743 ScreenshareLayerConfig::GetDefault().tl0_bitrate_kbps * 1000; | 1756 ScreenshareLayerConfig::GetDefault().tl0_bitrate_kbps * 1000; |
| 1744 send_parameters_.conference_mode = true; | 1757 send_parameters_.conference_mode = true; |
| 1745 channel_->SetSendParameters(send_parameters_); | 1758 channel_->SetSendParameters(send_parameters_); |
| 1746 | 1759 |
| 1747 AddSendStream(); | 1760 AddSendStream(); |
| 1748 VideoOptions options; | 1761 VideoOptions options; |
| 1749 options.is_screencast = rtc::Optional<bool>(true); | 1762 options.is_screencast = rtc::Optional<bool>(true); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1903 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer)); | 1916 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer)); |
| 1904 EXPECT_TRUE(capturer.CaptureFrame()); | 1917 EXPECT_TRUE(capturer.CaptureFrame()); |
| 1905 // Expect 1 reconfigurations at this point from the initial configuration. | 1918 // Expect 1 reconfigurations at this point from the initial configuration. |
| 1906 EXPECT_EQ(1, send_stream->num_encoder_reconfigurations()); | 1919 EXPECT_EQ(1, send_stream->num_encoder_reconfigurations()); |
| 1907 | 1920 |
| 1908 // Set the options one more time and expect no additional reconfigurations. | 1921 // Set the options one more time and expect no additional reconfigurations. |
| 1909 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer)); | 1922 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer)); |
| 1910 EXPECT_EQ(1, send_stream->num_encoder_reconfigurations()); | 1923 EXPECT_EQ(1, send_stream->num_encoder_reconfigurations()); |
| 1911 | 1924 |
| 1912 // Change |options| and expect 2 reconfigurations. | 1925 // Change |options| and expect 2 reconfigurations. |
| 1913 options.is_screencast = rtc::Optional<bool>(true); | 1926 options.video_noise_reduction = rtc::Optional<bool>(true); |
| 1914 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer)); | 1927 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer)); |
| 1915 EXPECT_EQ(2, send_stream->num_encoder_reconfigurations()); | 1928 EXPECT_EQ(2, send_stream->num_encoder_reconfigurations()); |
| 1916 | 1929 |
| 1917 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); | 1930 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); |
| 1918 } | 1931 } |
| 1919 | 1932 |
| 1920 class Vp9SettingsTest : public WebRtcVideoChannel2Test { | 1933 class Vp9SettingsTest : public WebRtcVideoChannel2Test { |
| 1921 public: | 1934 public: |
| 1922 Vp9SettingsTest() : Vp9SettingsTest("") {} | 1935 Vp9SettingsTest() : Vp9SettingsTest("") {} |
| 1923 explicit Vp9SettingsTest(const char* field_trials) | 1936 explicit Vp9SettingsTest(const char* field_trials) |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2197 | 2210 |
| 2198 // Switch to screen share. Expect no CPU adaptation. | 2211 // Switch to screen share. Expect no CPU adaptation. |
| 2199 cricket::FakeVideoCapturer screen_share(true); | 2212 cricket::FakeVideoCapturer screen_share(true); |
| 2200 ASSERT_EQ(cricket::CS_RUNNING, | 2213 ASSERT_EQ(cricket::CS_RUNNING, |
| 2201 screen_share.Start(screen_share.GetSupportedFormats()->front())); | 2214 screen_share.Start(screen_share.GetSupportedFormats()->front())); |
| 2202 cricket::VideoOptions screenshare_options; | 2215 cricket::VideoOptions screenshare_options; |
| 2203 screenshare_options.is_screencast = rtc::Optional<bool>(true); | 2216 screenshare_options.is_screencast = rtc::Optional<bool>(true); |
| 2204 channel_->SetVideoSend(last_ssrc_, true /* enable */, &screenshare_options, | 2217 channel_->SetVideoSend(last_ssrc_, true /* enable */, &screenshare_options, |
| 2205 &screen_share); | 2218 &screen_share); |
| 2206 EXPECT_TRUE(screen_share.CaptureCustomFrame(1284, 724, cricket::FOURCC_I420)); | 2219 EXPECT_TRUE(screen_share.CaptureCustomFrame(1284, 724, cricket::FOURCC_I420)); |
| 2207 EXPECT_EQ(3, send_stream->GetNumberOfSwappedFrames()); | 2220 ASSERT_EQ(2, fake_call_->GetNumCreatedSendStreams()); |
| 2221 send_stream = fake_call_->GetVideoSendStreams().front(); | |
| 2222 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames()); | |
| 2208 EXPECT_EQ(1284, send_stream->GetLastWidth()); | 2223 EXPECT_EQ(1284, send_stream->GetLastWidth()); |
| 2209 EXPECT_EQ(724, send_stream->GetLastHeight()); | 2224 EXPECT_EQ(724, send_stream->GetLastHeight()); |
| 2210 | 2225 |
| 2211 // Switch back to the normal capturer. Expect the frame to be CPU adapted. | 2226 // Switch back to the normal capturer. Expect the frame to be CPU adapted. |
| 2212 channel_->SetVideoSend(last_ssrc_, true /* enable */, &camera_options, | 2227 channel_->SetVideoSend(last_ssrc_, true /* enable */, &camera_options, |
| 2213 &capturer); | 2228 &capturer); |
| 2229 send_stream = fake_call_->GetVideoSendStreams().front(); | |
| 2230 // We have a new fake send stream, so it doesn't remember the old sink wants. | |
| 2231 // In practice, it will be populated from | |
| 2232 // ViEEncoder::VideoSourceProxy::SetSource(), so simulate that here. | |
| 2233 send_stream->InjectVideoSinkWants(wants); | |
| 2214 EXPECT_TRUE(capturer.CaptureCustomFrame(1280, 720, cricket::FOURCC_I420)); | 2234 EXPECT_TRUE(capturer.CaptureCustomFrame(1280, 720, cricket::FOURCC_I420)); |
| 2215 EXPECT_EQ(4, send_stream->GetNumberOfSwappedFrames()); | 2235 ASSERT_EQ(3, fake_call_->GetNumCreatedSendStreams()); |
| 2236 send_stream = fake_call_->GetVideoSendStreams().front(); | |
| 2237 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames()); | |
| 2216 EXPECT_EQ(1280 * 3 / 4, send_stream->GetLastWidth()); | 2238 EXPECT_EQ(1280 * 3 / 4, send_stream->GetLastWidth()); |
| 2217 EXPECT_EQ(720 * 3 / 4, send_stream->GetLastHeight()); | 2239 EXPECT_EQ(720 * 3 / 4, send_stream->GetLastHeight()); |
| 2218 | 2240 |
| 2219 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); | 2241 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); |
| 2220 } | 2242 } |
| 2221 | 2243 |
| 2222 void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse, | 2244 void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse, |
| 2223 bool is_screenshare) { | 2245 bool is_screenshare) { |
| 2224 cricket::VideoCodec codec = GetEngineCodec("VP8"); | 2246 cricket::VideoCodec codec = GetEngineCodec("VP8"); |
| 2225 cricket::VideoSendParameters parameters; | 2247 cricket::VideoSendParameters parameters; |
| (...skipping 1937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4163 | 4185 |
| 4164 protected: | 4186 protected: |
| 4165 void VerifySimulcastSettings(const VideoCodec& codec, | 4187 void VerifySimulcastSettings(const VideoCodec& codec, |
| 4166 int capture_width, | 4188 int capture_width, |
| 4167 int capture_height, | 4189 int capture_height, |
| 4168 size_t num_configured_streams, | 4190 size_t num_configured_streams, |
| 4169 size_t expected_num_streams, | 4191 size_t expected_num_streams, |
| 4170 bool screenshare, | 4192 bool screenshare, |
| 4171 bool conference_mode) { | 4193 bool conference_mode) { |
| 4172 cricket::VideoSendParameters parameters; | 4194 cricket::VideoSendParameters parameters; |
| 4173 VideoOptions options; | |
| 4174 parameters.codecs.push_back(codec); | 4195 parameters.codecs.push_back(codec); |
| 4175 parameters.conference_mode = conference_mode; | 4196 parameters.conference_mode = conference_mode; |
| 4176 if (screenshare) { | |
| 4177 options.is_screencast = rtc::Optional<bool>(screenshare); | |
| 4178 } | |
| 4179 ASSERT_TRUE(channel_->SetSendParameters(parameters)); | 4197 ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
| 4180 | 4198 |
| 4181 std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs3); | 4199 std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs3); |
| 4182 RTC_DCHECK(num_configured_streams <= ssrcs.size()); | 4200 RTC_DCHECK(num_configured_streams <= ssrcs.size()); |
| 4183 ssrcs.resize(num_configured_streams); | 4201 ssrcs.resize(num_configured_streams); |
| 4184 | 4202 |
| 4185 FakeVideoSendStream* stream = | 4203 AddSendStream(CreateSimStreamParams("cname", ssrcs)); |
| 4186 AddSendStream(CreateSimStreamParams("cname", ssrcs)); | |
| 4187 // Send a full-size frame to trigger a stream reconfiguration to use all | 4204 // Send a full-size frame to trigger a stream reconfiguration to use all |
| 4188 // expected simulcast layers. | 4205 // expected simulcast layers. |
| 4189 cricket::FakeVideoCapturer capturer; | 4206 cricket::FakeVideoCapturer capturer; |
| 4207 VideoOptions options; | |
| 4208 if (screenshare) | |
| 4209 options.is_screencast = rtc::Optional<bool>(screenshare); | |
| 4190 EXPECT_TRUE( | 4210 EXPECT_TRUE( |
| 4191 channel_->SetVideoSend(ssrcs.front(), true, &options, &capturer)); | 4211 channel_->SetVideoSend(ssrcs.front(), true, &options, &capturer)); |
| 4212 // Fetch the latest stream since SetVideoSend() may recreate it if the | |
| 4213 // screen content setting is changed. | |
| 4214 FakeVideoSendStream* stream = fake_call_.GetVideoSendStreams().front(); | |
| 4192 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(cricket::VideoFormat( | 4215 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(cricket::VideoFormat( |
| 4193 capture_width, capture_height, | 4216 capture_width, capture_height, |
| 4194 cricket::VideoFormat::FpsToInterval(30), | 4217 cricket::VideoFormat::FpsToInterval(30), |
| 4195 cricket::FOURCC_I420))); | 4218 cricket::FOURCC_I420))); |
| 4196 channel_->SetSend(true); | 4219 channel_->SetSend(true); |
| 4197 EXPECT_TRUE(capturer.CaptureFrame()); | 4220 EXPECT_TRUE(capturer.CaptureFrame()); |
| 4198 | 4221 |
| 4199 std::vector<webrtc::VideoStream> video_streams = stream->GetVideoStreams(); | 4222 std::vector<webrtc::VideoStream> video_streams = stream->GetVideoStreams(); |
| 4200 ASSERT_EQ(expected_num_streams, video_streams.size()); | 4223 ASSERT_EQ(expected_num_streams, video_streams.size()); |
| 4201 | 4224 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4342 } | 4365 } |
| 4343 | 4366 |
| 4344 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsForSimulcastScreenshare) { | 4367 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsForSimulcastScreenshare) { |
| 4345 webrtc::test::ScopedFieldTrials override_field_trials_( | 4368 webrtc::test::ScopedFieldTrials override_field_trials_( |
| 4346 "WebRTC-SimulcastScreenshare/Enabled/"); | 4369 "WebRTC-SimulcastScreenshare/Enabled/"); |
| 4347 VerifySimulcastSettings(cricket::VideoCodec("VP8"), 1280, 720, 3, 2, true, | 4370 VerifySimulcastSettings(cricket::VideoCodec("VP8"), 1280, 720, 3, 2, true, |
| 4348 true); | 4371 true); |
| 4349 } | 4372 } |
| 4350 | 4373 |
| 4351 } // namespace cricket | 4374 } // namespace cricket |
| OLD | NEW |