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

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

Issue 2510583002: Reland #2 of Issue 2434073003: Extract bitrate allocation ... (Closed)
Patch Set: Addressed comments 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/media/engine/videoencodersoftwarefallbackwrapper.cc ('k') | webrtc/modules/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/media/engine/videoencodersoftwarefallbackwrapper_unittest.cc
diff --git a/webrtc/media/engine/videoencodersoftwarefallbackwrapper_unittest.cc b/webrtc/media/engine/videoencodersoftwarefallbackwrapper_unittest.cc
index e7d1fabea456565f757f9fd25fa8e1b90b751da7..42d6b473cd8a99872d4199a15ab1889febe9b01e 100644
--- a/webrtc/media/engine/videoencodersoftwarefallbackwrapper_unittest.cc
+++ b/webrtc/media/engine/videoencodersoftwarefallbackwrapper_unittest.cc
@@ -12,8 +12,11 @@
#include <utility>
+#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 {
@@ -65,7 +68,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;
}
@@ -119,6 +123,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() {
@@ -141,10 +146,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_;
@@ -159,8 +173,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.
@@ -243,7 +265,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/media/engine/videoencodersoftwarefallbackwrapper.cc ('k') | webrtc/modules/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698