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

Unified Diff: webrtc/video/video_encoder_unittest.cc

Issue 2488833004: Reland of Issue 2434073003: Extract bitrate allocation ... (Closed)
Patch Set: Rebase Created 4 years, 1 month 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/video/video_encoder.cc ('k') | webrtc/video/video_send_stream_tests.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
}
« no previous file with comments | « webrtc/video/video_encoder.cc ('k') | webrtc/video/video_send_stream_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698