Chromium Code Reviews| Index: webrtc/video/vie_encoder_unittest.cc |
| diff --git a/webrtc/video/vie_encoder_unittest.cc b/webrtc/video/vie_encoder_unittest.cc |
| index c42825d05c5cd8fc7ef52c4d7a5955514c3cfa6a..ccb9e432f356559e0e9c373a5b3f889d11b2d491 100644 |
| --- a/webrtc/video/vie_encoder_unittest.cc |
| +++ b/webrtc/video/vie_encoder_unittest.cc |
| @@ -38,7 +38,7 @@ using ScaleReason = ScalingObserverInterface::ScaleReason; |
| namespace { |
| const size_t kMaxPayloadLength = 1440; |
| -const int kTargetBitrateBps = 100000; |
| +const int kTargetBitrateBps = 1000000; |
| class TestBuffer : public webrtc::I420Buffer { |
| public: |
| @@ -144,7 +144,7 @@ class ViEEncoderTest : public ::testing::Test { |
| vie_encoder_->SetSink(&sink_, false /* rotation_applied */); |
| vie_encoder_->SetSource(&video_source_, |
| VideoSendStream::DegradationPreference::kBalanced); |
| - vie_encoder_->SetStartBitrate(10000); |
| + vie_encoder_->SetStartBitrate(kTargetBitrateBps); |
| vie_encoder_->ConfigureEncoder(std::move(video_encoder_config), |
| kMaxPayloadLength, nack_enabled); |
| } |
| @@ -157,7 +157,7 @@ class ViEEncoderTest : public ::testing::Test { |
| VideoEncoderConfig video_encoder_config; |
| video_encoder_config.number_of_streams = num_streams; |
| - video_encoder_config.max_bitrate_bps = 1000000; |
| + video_encoder_config.max_bitrate_bps = kTargetBitrateBps; |
| video_encoder_config.video_stream_factory = |
| new rtc::RefCountedObject<VideoStreamFactory>(num_temporal_layers); |
| ConfigureEncoder(std::move(video_encoder_config), nack_enabled); |
| @@ -673,7 +673,6 @@ TEST_F(ViEEncoderTest, StatsTracksAdaptationStats) { |
| } |
| TEST_F(ViEEncoderTest, SwitchingSourceKeepsCpuAdaptation) { |
| - const int kTargetBitrateBps = 100000; |
| vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); |
| int frame_width = 1280; |
| @@ -743,7 +742,6 @@ TEST_F(ViEEncoderTest, SwitchingSourceKeepsCpuAdaptation) { |
| } |
| TEST_F(ViEEncoderTest, SwitchingSourceKeepsQualityAdaptation) { |
| - const int kTargetBitrateBps = 100000; |
| vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); |
| int frame_width = 1280; |
| @@ -879,7 +877,6 @@ TEST_F(ViEEncoderTest, StatsTracksPreferredBitrate) { |
| } |
| TEST_F(ViEEncoderTest, ScalingUpAndDownDoesNothingWithMaintainResolution) { |
| - const int kTargetBitrateBps = 100000; |
| int frame_width = 1280; |
| int frame_height = 720; |
| vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); |
| @@ -932,7 +929,6 @@ TEST_F(ViEEncoderTest, ScalingUpAndDownDoesNothingWithMaintainResolution) { |
| } |
| TEST_F(ViEEncoderTest, DoesNotScaleBelowSetLimit) { |
| - const int kTargetBitrateBps = 100000; |
| int frame_width = 1280; |
| int frame_height = 720; |
| vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); |
| @@ -979,4 +975,36 @@ TEST_F(ViEEncoderTest, UMACpuLimitedResolutionInPercent) { |
| 1, metrics::NumEvents("WebRTC.Video.CpuLimitedResolutionInPercent", 50)); |
| } |
| +TEST_F(ViEEncoderTest, DropsFramesUntilTartgetBitrateIsReached) { |
| + vie_encoder_->OnBitrateUpdated(100000, 0, 0); |
| + int frame_width = 1000; |
| + int frame_height = 1000; |
| + int dropped_frames = 0; |
| + |
| + rtc::Event ev(false, false); |
| + for (int i = 1; i <= 10; ++i) { |
| + video_source_.IncomingCapturedFrame( |
| + CreateFrame(i, frame_width, frame_height)); |
| + // Don't wait for the dropped frames. |
| + ev.Wait(10); |
|
sprang_webrtc
2017/01/16 13:45:23
What exactly does this sleep accomplish, and why 1
kthelgason
2017/01/16 14:08:45
The idea is to simulate a delay between frames, as
sprang_webrtc
2017/01/16 16:48:34
So does this risk being racy? I like 1000/30 as sl
|
| + if (*video_source_.sink_wants().max_pixel_count < |
| + frame_width * frame_height) |
| + dropped_frames++; |
| + frame_width = frame_height = |
| + std::sqrt(*video_source_.sink_wants().max_pixel_count); |
| + } |
| + sink_.WaitForEncodedFrame(10); |
| + EXPECT_GT(dropped_frames, 0); |
| + |
| + // Expect the sink_wants to specify a scaled frame. |
| + EXPECT_TRUE(video_source_.sink_wants().max_pixel_count); |
| + EXPECT_LT(*video_source_.sink_wants().max_pixel_count, 1000 * 1000); |
| + |
| + const auto stats = stats_proxy_->GetStats(); |
| + EXPECT_FALSE(stats.cpu_limited_resolution); |
| + EXPECT_TRUE(stats.bw_limited_resolution); |
| + |
| + vie_encoder_->Stop(); |
| +} |
| + |
| } // namespace webrtc |