Index: webrtc/video/video_encoder_unittest.cc |
diff --git a/webrtc/video/video_encoder_unittest.cc b/webrtc/video/video_encoder_unittest.cc |
index 5f6f17e7b49e2da1655df6b4b0d5722e31e39dfb..899304f88635660a0f6f8d51bdce080422871732 100644 |
--- a/webrtc/video/video_encoder_unittest.cc |
+++ b/webrtc/video/video_encoder_unittest.cc |
@@ -10,8 +10,11 @@ |
#include "webrtc/video_encoder.h" |
+#include "webrtc/base/checks.h" |
+#include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h" |
#include "webrtc/modules/video_coding/include/video_codec_interface.h" |
#include "webrtc/modules/video_coding/include/video_error_codes.h" |
+#include "webrtc/modules/video_coding/utility/simulcast_rate_allocator.h" |
#include "webrtc/test/gtest.h" |
namespace webrtc { |
@@ -63,7 +66,8 @@ class VideoEncoderSoftwareFallbackWrapperTest : public ::testing::Test { |
return WEBRTC_VIDEO_CODEC_OK; |
} |
- int32_t SetRates(uint32_t bitrate, uint32_t framerate) override { |
+ int32_t SetRateAllocation(const BitrateAllocation& bitrate_allocation, |
+ uint32_t framerate) override { |
++set_rates_count_; |
return WEBRTC_VIDEO_CODEC_OK; |
} |
@@ -117,6 +121,7 @@ class VideoEncoderSoftwareFallbackWrapperTest : public ::testing::Test { |
VideoEncoderSoftwareFallbackWrapper fallback_wrapper_; |
VideoCodec codec_ = {}; |
std::unique_ptr<VideoFrame> frame_; |
+ std::unique_ptr<SimulcastRateAllocator> rate_allocator_; |
}; |
void VideoEncoderSoftwareFallbackWrapperTest::EncodeFrame() { |
@@ -139,10 +144,19 @@ void VideoEncoderSoftwareFallbackWrapperTest::UtilizeFallbackEncoder() { |
codec_.maxFramerate = 30; |
codec_.width = kWidth; |
codec_.height = kHeight; |
+ codec_.VP8()->numberOfTemporalLayers = 1; |
+ std::unique_ptr<TemporalLayersFactory> tl_factory( |
+ new TemporalLayersFactory()); |
+ codec_.VP8()->tl_factory = tl_factory.get(); |
+ rate_allocator_.reset( |
+ new SimulcastRateAllocator(codec_, std::move(tl_factory))); |
+ |
fake_encoder_.init_encode_return_code_ = WEBRTC_VIDEO_CODEC_ERROR; |
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, |
fallback_wrapper_.InitEncode(&codec_, 2, kMaxPayloadSize)); |
- EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, fallback_wrapper_.SetRates(300, 30)); |
+ EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, |
+ fallback_wrapper_.SetRateAllocation( |
+ rate_allocator_->GetAllocation(300000, 30), 30)); |
int callback_count = callback_.callback_count_; |
int encode_count = fake_encoder_.encode_count_; |
@@ -157,8 +171,16 @@ void VideoEncoderSoftwareFallbackWrapperTest::FallbackFromEncodeRequest() { |
codec_.maxFramerate = 30; |
codec_.width = kWidth; |
codec_.height = kHeight; |
+ codec_.VP8()->numberOfTemporalLayers = 1; |
+ std::unique_ptr<TemporalLayersFactory> tl_factory( |
+ new TemporalLayersFactory()); |
+ codec_.VP8()->tl_factory = tl_factory.get(); |
+ rate_allocator_.reset( |
+ new SimulcastRateAllocator(codec_, std::move(tl_factory))); |
fallback_wrapper_.InitEncode(&codec_, 2, kMaxPayloadSize); |
- EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, fallback_wrapper_.SetRates(300, 30)); |
+ EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, |
+ fallback_wrapper_.SetRateAllocation( |
+ rate_allocator_->GetAllocation(300000, 30), 30)); |
EXPECT_EQ(1, fake_encoder_.init_encode_count_); |
// Have the non-fallback encoder request a software fallback. |
@@ -241,7 +263,7 @@ TEST_F(VideoEncoderSoftwareFallbackWrapperTest, |
SetRatesForwardedDuringFallback) { |
UtilizeFallbackEncoder(); |
EXPECT_EQ(1, fake_encoder_.set_rates_count_); |
- fallback_wrapper_.SetRates(1, 1); |
+ fallback_wrapper_.SetRateAllocation(BitrateAllocation(), 1); |
EXPECT_EQ(2, fake_encoder_.set_rates_count_); |
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, fallback_wrapper_.Release()); |
} |