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

Unified Diff: webrtc/media/engine/webrtcvideoengine2_unittest.cc

Issue 2351633002: Let ViEEncoder handle resolution changes. (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/media/engine/webrtcvideoengine2.cc ('k') | webrtc/test/call_test.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/media/engine/webrtcvideoengine2_unittest.cc
diff --git a/webrtc/media/engine/webrtcvideoengine2_unittest.cc b/webrtc/media/engine/webrtcvideoengine2_unittest.cc
index 955fd35ed6d3a72a2db9b0da9f24324076fcd605..d482509fd6d06e8f52d87b22865ce597d8c2875c 100644
--- a/webrtc/media/engine/webrtcvideoengine2_unittest.cc
+++ b/webrtc/media/engine/webrtcvideoengine2_unittest.cc
@@ -1077,22 +1077,16 @@ class WebRtcVideoChannel2Test : public WebRtcVideoEngine2Test {
return AddSendStream(CreateSimStreamParams("cname", ssrcs));
}
- int GetMaxEncoderBitrate(cricket::FakeVideoCapturer& capturer) {
- EXPECT_TRUE(capturer.CaptureFrame());
-
+ int GetMaxEncoderBitrate() {
std::vector<FakeVideoSendStream*> streams =
fake_call_->GetVideoSendStreams();
- EXPECT_TRUE(streams.size() > 0);
+ EXPECT_EQ(1u, streams.size());
FakeVideoSendStream* stream = streams[streams.size() - 1];
-
- webrtc::VideoEncoderConfig encoder_config =
- stream->GetEncoderConfig().Copy();
- EXPECT_EQ(1, encoder_config.streams.size());
- return encoder_config.streams[0].max_bitrate_bps;
+ EXPECT_EQ(1, stream->GetEncoderConfig().number_of_streams);
+ return stream->GetVideoStreams()[0].max_bitrate_bps;
}
- void SetAndExpectMaxBitrate(cricket::FakeVideoCapturer& capturer,
- int global_max,
+ void SetAndExpectMaxBitrate(int global_max,
int stream_max,
int expected_encoder_bitrate) {
VideoSendParameters limited_send_params = send_parameters_;
@@ -1108,7 +1102,7 @@ class WebRtcVideoChannel2Test : public WebRtcVideoEngine2Test {
EXPECT_EQ(1UL, parameters.encodings.size());
EXPECT_EQ(stream_max, parameters.encodings[0].max_bitrate_bps);
// Verify that the new value propagated down to the encoder
- EXPECT_EQ(expected_encoder_bitrate, GetMaxEncoderBitrate(capturer));
+ EXPECT_EQ(expected_encoder_bitrate, GetMaxEncoderBitrate());
}
std::unique_ptr<FakeCall> fake_call_;
@@ -1520,10 +1514,10 @@ TEST_F(WebRtcVideoChannel2Test, ReconfiguresEncodersWhenNotSending) {
FakeVideoSendStream* stream = AddSendStream();
- // No frames entered, using default dimensions.
+ // No frames entered.
std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams();
- EXPECT_EQ(176u, streams[0].width);
- EXPECT_EQ(144u, streams[0].height);
+ EXPECT_EQ(0u, streams[0].width);
+ EXPECT_EQ(0u, streams[0].height);
cricket::FakeVideoCapturer capturer;
EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer));
@@ -1535,8 +1529,6 @@ TEST_F(WebRtcVideoChannel2Test, ReconfiguresEncodersWhenNotSending) {
streams = stream->GetVideoStreams();
EXPECT_EQ(kVp8Codec720p.width, streams[0].width);
EXPECT_EQ(kVp8Codec720p.height, streams[0].height);
- // No frames should have been actually put in there though.
- EXPECT_EQ(0, stream->GetNumberOfSwappedFrames());
EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
}
@@ -1574,8 +1566,9 @@ TEST_F(WebRtcVideoChannel2Test, UsesCorrectSettingsForScreencast) {
send_stream->GetEncoderConfig().Copy();
EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo,
encoder_config.content_type);
- EXPECT_EQ(codec.width, encoder_config.streams.front().width);
- EXPECT_EQ(codec.height, encoder_config.streams.front().height);
+ std::vector<webrtc::VideoStream> streams = send_stream->GetVideoStreams();
+ EXPECT_EQ(capture_format_hd.width, streams.front().width);
+ EXPECT_EQ(capture_format_hd.height, streams.front().height);
EXPECT_EQ(0, encoder_config.min_transmit_bitrate_bps)
<< "Non-screenshare shouldn't use min-transmit bitrate.";
@@ -1598,10 +1591,10 @@ TEST_F(WebRtcVideoChannel2Test, UsesCorrectSettingsForScreencast) {
EXPECT_EQ(kScreenshareMinBitrateKbps * 1000,
encoder_config.min_transmit_bitrate_bps);
- EXPECT_EQ(capture_format_hd.width, encoder_config.streams.front().width);
- EXPECT_EQ(capture_format_hd.height, encoder_config.streams.front().height);
- EXPECT_TRUE(encoder_config.streams[0].temporal_layer_thresholds_bps.empty());
-
+ streams = send_stream->GetVideoStreams();
+ EXPECT_EQ(capture_format_hd.width, streams.front().width);
+ EXPECT_EQ(capture_format_hd.height, streams.front().height);
+ EXPECT_TRUE(streams[0].temporal_layer_thresholds_bps.empty());
EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
}
@@ -1685,10 +1678,12 @@ TEST_F(WebRtcVideoChannel2Test,
encoder_config = send_stream->GetEncoderConfig().Copy();
EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kScreen,
encoder_config.content_type);
- ASSERT_EQ(1u, encoder_config.streams.size());
- ASSERT_EQ(1u, encoder_config.streams[0].temporal_layer_thresholds_bps.size());
+
+ std::vector<webrtc::VideoStream> streams = send_stream->GetVideoStreams();
+ ASSERT_EQ(1u, streams.size());
+ ASSERT_EQ(1u, streams[0].temporal_layer_thresholds_bps.size());
EXPECT_EQ(kConferenceScreencastTemporalBitrateBps,
- encoder_config.streams[0].temporal_layer_thresholds_bps[0]);
+ streams[0].temporal_layer_thresholds_bps[0]);
EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
}
@@ -1806,18 +1801,27 @@ TEST_F(WebRtcVideoChannel2Test, SetIdenticalOptionsDoesntReconfigureEncoder) {
VideoOptions options;
cricket::FakeVideoCapturer capturer;
- FakeVideoSendStream* send_stream = AddSendStream();
+ AddSendStream();
EXPECT_EQ(cricket::CS_RUNNING,
capturer.Start(capturer.GetSupportedFormats()->front()));
+ cricket::VideoSendParameters parameters;
+ parameters.codecs.push_back(kVp8Codec720p);
+ ASSERT_TRUE(channel_->SetSendParameters(parameters));
+ FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front();
+
+ EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer));
EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer));
EXPECT_TRUE(capturer.CaptureFrame());
- // Expect 2 reconfigurations at this point, from the initial configuration
- // and from the dimensions of the first frame.
- EXPECT_EQ(2, send_stream->num_encoder_reconfigurations());
+ // Expect 1 reconfigurations at this point from the initial configuration.
+ EXPECT_EQ(1, send_stream->num_encoder_reconfigurations());
// Set the options one more time and expect no additional reconfigurations.
EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer));
- EXPECT_TRUE(capturer.CaptureFrame());
+ EXPECT_EQ(1, send_stream->num_encoder_reconfigurations());
+
+ // Change |options| and expect 2 reconfigurations.
+ options.is_screencast = rtc::Optional<bool>(true);
+ EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer));
EXPECT_EQ(2, send_stream->num_encoder_reconfigurations());
EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
@@ -2310,28 +2314,26 @@ TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithoutFecDisablesFec) {
TEST_F(WebRtcVideoChannel2Test, SetSendCodecsChangesExistingStreams) {
cricket::VideoSendParameters parameters;
- parameters.codecs.push_back(kVp8Codec720p);
+ cricket::VideoCodec codec720p(100, "VP8", 1280, 720, 30);
+ codec720p.SetParam(kCodecParamMaxQuantization, kDefaultQpMax);
+ parameters.codecs.push_back(codec720p);
+
ASSERT_TRUE(channel_->SetSendParameters(parameters));
channel_->SetSend(true);
FakeVideoSendStream* stream = AddSendStream();
-
cricket::FakeVideoCapturer capturer;
EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer));
- EXPECT_EQ(cricket::CS_RUNNING,
- capturer.Start(capturer.GetSupportedFormats()->front()));
- EXPECT_TRUE(capturer.CaptureFrame());
std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams();
- EXPECT_EQ(kVp8Codec720p.width, streams[0].width);
- EXPECT_EQ(kVp8Codec720p.height, streams[0].height);
+ EXPECT_EQ(kDefaultQpMax, streams[0].max_qp);
parameters.codecs.clear();
- parameters.codecs.push_back(kVp8Codec360p);
+ codec720p.SetParam(kCodecParamMaxQuantization, kDefaultQpMax + 1);
+ parameters.codecs.push_back(codec720p);
ASSERT_TRUE(channel_->SetSendParameters(parameters));
streams = fake_call_->GetVideoSendStreams()[0]->GetVideoStreams();
- EXPECT_EQ(kVp8Codec360p.width, streams[0].width);
- EXPECT_EQ(kVp8Codec360p.height, streams[0].height);
+ EXPECT_EQ(kDefaultQpMax + 1, streams[0].max_qp);
EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
}
@@ -3416,8 +3418,9 @@ TEST_F(WebRtcVideoChannel2Test, CanSentMaxBitrateForExistingStream) {
EXPECT_EQ(720, capture_format_hd.height);
EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format_hd));
EXPECT_TRUE(channel_->SetSend(true));
+ capturer.CaptureFrame();
- int default_encoder_bitrate = GetMaxEncoderBitrate(capturer);
+ int default_encoder_bitrate = GetMaxEncoderBitrate();
EXPECT_TRUE(default_encoder_bitrate > 1000);
// TODO(skvlad): Resolve the inconsistency between the interpretation
@@ -3428,11 +3431,11 @@ TEST_F(WebRtcVideoChannel2Test, CanSentMaxBitrateForExistingStream) {
// max_bandwidth_bps = -1 - do not change the previously set
// limit.
- SetAndExpectMaxBitrate(capturer, 1000, 0, 1000);
- SetAndExpectMaxBitrate(capturer, 1000, 800, 800);
- SetAndExpectMaxBitrate(capturer, 600, 800, 600);
- SetAndExpectMaxBitrate(capturer, 0, 800, 800);
- SetAndExpectMaxBitrate(capturer, 0, 0, default_encoder_bitrate);
+ SetAndExpectMaxBitrate(1000, 0, 1000);
+ SetAndExpectMaxBitrate(1000, 800, 800);
+ SetAndExpectMaxBitrate(600, 800, 600);
+ SetAndExpectMaxBitrate(0, 800, 800);
+ SetAndExpectMaxBitrate(0, 0, default_encoder_bitrate);
EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
}
« no previous file with comments | « webrtc/media/engine/webrtcvideoengine2.cc ('k') | webrtc/test/call_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698