Index: webrtc/video/vie_encoder_unittest.cc |
diff --git a/webrtc/video/vie_encoder_unittest.cc b/webrtc/video/vie_encoder_unittest.cc |
index 5dee314683ac3368cf2739e74e8cae64dda09b5f..dae172dea353e5d198584f8a01921fbb86103c69 100644 |
--- a/webrtc/video/vie_encoder_unittest.cc |
+++ b/webrtc/video/vie_encoder_unittest.cc |
@@ -43,9 +43,7 @@ |
namespace { |
const size_t kMaxPayloadLength = 1440; |
-const int kTargetBitrateBps = 1000000; |
-const int kLowTargetBitrateBps = kTargetBitrateBps / 10; |
-const int kMaxInitialFramedrop = 4; |
+const int kTargetBitrateBps = 100000; |
class TestBuffer : public webrtc::I420Buffer { |
public: |
@@ -151,7 +149,7 @@ |
vie_encoder_->SetSink(&sink_, false /* rotation_applied */); |
vie_encoder_->SetSource(&video_source_, |
VideoSendStream::DegradationPreference::kBalanced); |
- vie_encoder_->SetStartBitrate(kTargetBitrateBps); |
+ vie_encoder_->SetStartBitrate(10000); |
vie_encoder_->ConfigureEncoder(std::move(video_encoder_config), |
kMaxPayloadLength, nack_enabled); |
} |
@@ -164,7 +162,7 @@ |
VideoEncoderConfig video_encoder_config; |
video_encoder_config.number_of_streams = num_streams; |
- video_encoder_config.max_bitrate_bps = kTargetBitrateBps; |
+ video_encoder_config.max_bitrate_bps = 1000000; |
video_encoder_config.video_stream_factory = |
new rtc::RefCountedObject<VideoStreamFactory>(num_temporal_layers); |
ConfigureEncoder(std::move(video_encoder_config), nack_enabled); |
@@ -265,8 +263,6 @@ |
test_encoder_->CheckLastTimeStampsMatch(expected_ntp_time, timestamp); |
} |
- void ExpectDroppedFrame() { EXPECT_FALSE(encoded_frame_event_.Wait(20)); } |
- |
void SetExpectNoFrames() { |
rtc::CritScope lock(&crit_); |
expect_frames_ = false; |
@@ -683,6 +679,7 @@ |
} |
TEST_F(ViEEncoderTest, SwitchingSourceKeepsCpuAdaptation) { |
+ const int kTargetBitrateBps = 100000; |
vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); |
int frame_width = 1280; |
@@ -752,6 +749,7 @@ |
} |
TEST_F(ViEEncoderTest, SwitchingSourceKeepsQualityAdaptation) { |
+ const int kTargetBitrateBps = 100000; |
vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); |
int frame_width = 1280; |
@@ -887,6 +885,7 @@ |
} |
TEST_F(ViEEncoderTest, ScalingUpAndDownDoesNothingWithMaintainResolution) { |
+ const int kTargetBitrateBps = 100000; |
int frame_width = 1280; |
int frame_height = 720; |
vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); |
@@ -939,6 +938,7 @@ |
} |
TEST_F(ViEEncoderTest, DoesNotScaleBelowSetLimit) { |
+ const int kTargetBitrateBps = 100000; |
int frame_width = 1280; |
int frame_height = 720; |
vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); |
@@ -995,12 +995,12 @@ |
const int kDefaultFps = 30; |
const BitrateAllocation expected_bitrate = |
DefaultVideoBitrateAllocator(fake_encoder_.codec_config()) |
- .GetAllocation(kLowTargetBitrateBps, kDefaultFps); |
+ .GetAllocation(kTargetBitrateBps, kDefaultFps); |
// First called on bitrate updated, then again on first frame. |
EXPECT_CALL(bitrate_observer, OnBitrateAllocationUpdated(expected_bitrate)) |
.Times(2); |
- vie_encoder_->OnBitrateUpdated(kLowTargetBitrateBps, 0, 0); |
+ vie_encoder_->OnBitrateUpdated(kTargetBitrateBps, 0, 0); |
const int64_t kStartTimeMs = 1; |
video_source_.IncomingCapturedFrame( |
@@ -1029,76 +1029,4 @@ |
vie_encoder_->Stop(); |
} |
-TEST_F(ViEEncoderTest, DropsFramesAndScalesWhenBitrateIsTooLow) { |
- vie_encoder_->OnBitrateUpdated(kLowTargetBitrateBps, 0, 0); |
- int frame_width = 640; |
- int frame_height = 360; |
- |
- video_source_.IncomingCapturedFrame( |
- CreateFrame(1, frame_width, frame_height)); |
- |
- // Expect to drop this frame, the wait should time out. |
- sink_.ExpectDroppedFrame(); |
- |
- // 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); |
- |
- int last_pixel_count = *video_source_.sink_wants().max_pixel_count; |
- |
- // Next frame is scaled |
- video_source_.IncomingCapturedFrame( |
- CreateFrame(2, frame_width * 3 / 4, frame_height * 3 / 4)); |
- |
- // Expect to drop this frame, the wait should time out. |
- sink_.ExpectDroppedFrame(); |
- |
- EXPECT_LT(*video_source_.sink_wants().max_pixel_count, last_pixel_count); |
- |
- vie_encoder_->Stop(); |
-} |
- |
-TEST_F(ViEEncoderTest, NrOfDroppedFramesLimited) { |
- // 1kbps. This can never be achieved. |
- vie_encoder_->OnBitrateUpdated(1000, 0, 0); |
- int frame_width = 640; |
- int frame_height = 360; |
- |
- // We expect the n initial frames to get dropped. |
- int i; |
- for (i = 1; i <= kMaxInitialFramedrop; ++i) { |
- video_source_.IncomingCapturedFrame( |
- CreateFrame(i, frame_width, frame_height)); |
- sink_.ExpectDroppedFrame(); |
- } |
- // The n+1th frame should not be dropped, even though it's size is too large. |
- video_source_.IncomingCapturedFrame( |
- CreateFrame(i, frame_width, frame_height)); |
- sink_.WaitForEncodedFrame(i); |
- |
- // 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); |
- |
- vie_encoder_->Stop(); |
-} |
- |
-TEST_F(ViEEncoderTest, InitialFrameDropOffWithMaintainResolutionPreference) { |
- int frame_width = 640; |
- int frame_height = 360; |
- vie_encoder_->OnBitrateUpdated(kLowTargetBitrateBps, 0, 0); |
- |
- // Set degradation preference. |
- vie_encoder_->SetSource( |
- &video_source_, |
- VideoSendStream::DegradationPreference::kMaintainResolution); |
- |
- video_source_.IncomingCapturedFrame( |
- CreateFrame(1, frame_width, frame_height)); |
- // Frame should not be dropped, even if it's too large. |
- sink_.WaitForEncodedFrame(1); |
- |
- vie_encoder_->Stop(); |
-} |
- |
} // namespace webrtc |