| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 3909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3920 TestReceiverLocalSsrcConfiguration(false); | 3920 TestReceiverLocalSsrcConfiguration(false); |
| 3921 } | 3921 } |
| 3922 | 3922 |
| 3923 TEST_F(WebRtcVideoChannel2Test, ConfiguresLocalSsrcOnExistingReceivers) { | 3923 TEST_F(WebRtcVideoChannel2Test, ConfiguresLocalSsrcOnExistingReceivers) { |
| 3924 TestReceiverLocalSsrcConfiguration(true); | 3924 TestReceiverLocalSsrcConfiguration(true); |
| 3925 } | 3925 } |
| 3926 | 3926 |
| 3927 class WebRtcVideoChannel2SimulcastTest : public testing::Test { | 3927 class WebRtcVideoChannel2SimulcastTest : public testing::Test { |
| 3928 public: | 3928 public: |
| 3929 WebRtcVideoChannel2SimulcastTest() | 3929 WebRtcVideoChannel2SimulcastTest() |
| 3930 : fake_call_(webrtc::Call::Config(&event_log_)) {} | 3930 : fake_call_(webrtc::Call::Config(&event_log_)), last_ssrc_(0) {} |
| 3931 | 3931 |
| 3932 void SetUp() override { | 3932 void SetUp() override { |
| 3933 engine_.Init(); | 3933 engine_.Init(); |
| 3934 channel_.reset( | 3934 channel_.reset( |
| 3935 engine_.CreateChannel(&fake_call_, MediaConfig(), VideoOptions())); | 3935 engine_.CreateChannel(&fake_call_, MediaConfig(), VideoOptions())); |
| 3936 channel_->OnReadyToSend(true); | 3936 channel_->OnReadyToSend(true); |
| 3937 last_ssrc_ = 123; | 3937 last_ssrc_ = 123; |
| 3938 } | 3938 } |
| 3939 | 3939 |
| 3940 protected: | 3940 protected: |
| 3941 void VerifySimulcastSettings(const VideoCodec& codec, | 3941 void VerifySimulcastSettings(const VideoCodec& codec, |
| 3942 int capture_width, | 3942 int capture_width, |
| 3943 int capture_height, | 3943 int capture_height, |
| 3944 size_t num_configured_streams, | 3944 size_t num_configured_streams, |
| 3945 size_t expected_num_streams) { | 3945 size_t expected_num_streams, |
| 3946 bool screenshare) { |
| 3946 cricket::VideoSendParameters parameters; | 3947 cricket::VideoSendParameters parameters; |
| 3948 VideoOptions options; |
| 3947 parameters.codecs.push_back(codec); | 3949 parameters.codecs.push_back(codec); |
| 3950 if (screenshare) { |
| 3951 parameters.conference_mode = true; |
| 3952 options.is_screencast = rtc::Optional<bool>(screenshare); |
| 3953 } |
| 3948 ASSERT_TRUE(channel_->SetSendParameters(parameters)); | 3954 ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
| 3949 | 3955 |
| 3950 std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs3); | 3956 std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs3); |
| 3951 RTC_DCHECK(num_configured_streams <= ssrcs.size()); | 3957 RTC_DCHECK(num_configured_streams <= ssrcs.size()); |
| 3952 ssrcs.resize(num_configured_streams); | 3958 ssrcs.resize(num_configured_streams); |
| 3953 | 3959 |
| 3954 FakeVideoSendStream* stream = | 3960 FakeVideoSendStream* stream = |
| 3955 AddSendStream(CreateSimStreamParams("cname", ssrcs)); | 3961 AddSendStream(CreateSimStreamParams("cname", ssrcs)); |
| 3956 // Send a full-size frame to trigger a stream reconfiguration to use all | 3962 // Send a full-size frame to trigger a stream reconfiguration to use all |
| 3957 // expected simulcast layers. | 3963 // expected simulcast layers. |
| 3958 cricket::FakeVideoCapturer capturer; | 3964 cricket::FakeVideoCapturer capturer; |
| 3959 EXPECT_TRUE( | 3965 EXPECT_TRUE( |
| 3960 channel_->SetVideoSend(ssrcs.front(), true, nullptr, &capturer)); | 3966 channel_->SetVideoSend(ssrcs.front(), true, &options, &capturer)); |
| 3961 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(cricket::VideoFormat( | 3967 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(cricket::VideoFormat( |
| 3962 capture_width, capture_height, | 3968 capture_width, capture_height, |
| 3963 cricket::VideoFormat::FpsToInterval(30), | 3969 cricket::VideoFormat::FpsToInterval(30), |
| 3964 cricket::FOURCC_I420))); | 3970 cricket::FOURCC_I420))); |
| 3965 channel_->SetSend(true); | 3971 channel_->SetSend(true); |
| 3966 EXPECT_TRUE(capturer.CaptureFrame()); | 3972 EXPECT_TRUE(capturer.CaptureFrame()); |
| 3967 | 3973 |
| 3968 std::vector<webrtc::VideoStream> video_streams = stream->GetVideoStreams(); | 3974 std::vector<webrtc::VideoStream> video_streams = stream->GetVideoStreams(); |
| 3969 ASSERT_EQ(expected_num_streams, video_streams.size()); | 3975 ASSERT_EQ(expected_num_streams, video_streams.size()); |
| 3970 | 3976 |
| 3971 std::vector<webrtc::VideoStream> expected_streams = GetSimulcastConfig( | 3977 std::vector<webrtc::VideoStream> expected_streams = GetSimulcastConfig( |
| 3972 num_configured_streams, capture_width, capture_height, 0, kDefaultQpMax, | 3978 num_configured_streams, capture_width, capture_height, 0, kDefaultQpMax, |
| 3973 kDefaultVideoMaxFramerate); | 3979 kDefaultVideoMaxFramerate, screenshare); |
| 3974 | 3980 |
| 3975 ASSERT_EQ(expected_streams.size(), video_streams.size()); | 3981 ASSERT_EQ(expected_streams.size(), video_streams.size()); |
| 3976 | 3982 |
| 3977 size_t num_streams = video_streams.size(); | 3983 size_t num_streams = video_streams.size(); |
| 3978 int total_max_bitrate_bps = 0; | 3984 int total_max_bitrate_bps = 0; |
| 3979 for (size_t i = 0; i < num_streams; ++i) { | 3985 for (size_t i = 0; i < num_streams; ++i) { |
| 3980 EXPECT_EQ(expected_streams[i].width, video_streams[i].width); | 3986 EXPECT_EQ(expected_streams[i].width, video_streams[i].width); |
| 3981 EXPECT_EQ(expected_streams[i].height, video_streams[i].height); | 3987 EXPECT_EQ(expected_streams[i].height, video_streams[i].height); |
| 3982 | 3988 |
| 3983 EXPECT_GT(video_streams[i].max_framerate, 0); | 3989 EXPECT_GT(video_streams[i].max_framerate, 0); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4046 } | 4052 } |
| 4047 | 4053 |
| 4048 webrtc::RtcEventLogNullImpl event_log_; | 4054 webrtc::RtcEventLogNullImpl event_log_; |
| 4049 FakeCall fake_call_; | 4055 FakeCall fake_call_; |
| 4050 WebRtcVideoEngine2 engine_; | 4056 WebRtcVideoEngine2 engine_; |
| 4051 std::unique_ptr<VideoMediaChannel> channel_; | 4057 std::unique_ptr<VideoMediaChannel> channel_; |
| 4052 uint32_t last_ssrc_; | 4058 uint32_t last_ssrc_; |
| 4053 }; | 4059 }; |
| 4054 | 4060 |
| 4055 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith2SimulcastStreams) { | 4061 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith2SimulcastStreams) { |
| 4056 VerifySimulcastSettings(cricket::VideoCodec("VP8"), 640, 360, 2, 2); | 4062 VerifySimulcastSettings(cricket::VideoCodec("VP8"), 640, 360, 2, 2, false); |
| 4057 } | 4063 } |
| 4058 | 4064 |
| 4059 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith3SimulcastStreams) { | 4065 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith3SimulcastStreams) { |
| 4060 VerifySimulcastSettings(cricket::VideoCodec("VP8"), 1280, 720, 3, 3); | 4066 VerifySimulcastSettings(cricket::VideoCodec("VP8"), 1280, 720, 3, 3, false); |
| 4061 } | 4067 } |
| 4062 | 4068 |
| 4063 // Test that we normalize send codec format size in simulcast. | 4069 // Test that we normalize send codec format size in simulcast. |
| 4064 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { | 4070 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { |
| 4065 VerifySimulcastSettings(cricket::VideoCodec("VP8"), 541, 271, 2, 2); | 4071 VerifySimulcastSettings(cricket::VideoCodec("VP8"), 541, 271, 2, 2, false); |
| 4066 } | 4072 } |
| 4073 |
| 4074 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsForScreenshare) { |
| 4075 VerifySimulcastSettings(cricket::VideoCodec("VP8"), 1280, 720, 3, 1, true); |
| 4076 } |
| 4077 |
| 4078 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsForSimulcastScreenshare) { |
| 4079 webrtc::test::ScopedFieldTrials override_field_trials_( |
| 4080 "WebRTC-SimulcastScreenshare/Enabled/"); |
| 4081 VerifySimulcastSettings(cricket::VideoCodec("VP8"), 1280, 720, 3, 2, true); |
| 4082 } |
| 4083 |
| 4067 } // namespace cricket | 4084 } // namespace cricket |
| OLD | NEW |