Add unit test ReportsUpdatedVideoLayersAllocationWhenResolutionChanges
This test that a new allocation is reported if the input resolution
changes.
Bug: webrtc:12000
Change-Id: Iaf8be1af62bbc8a2ca19b58f0587ceacfcfa5991
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/197807
Reviewed-by: Erik Språng <sprang@webrtc.org>
Commit-Queue: Per Kjellander <perkj@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32837}
diff --git a/video/video_stream_encoder_unittest.cc b/video/video_stream_encoder_unittest.cc
index 267169a..aed619d 100644
--- a/video/video_stream_encoder_unittest.cc
+++ b/video/video_stream_encoder_unittest.cc
@@ -67,6 +67,7 @@
using ::testing::Matcher;
using ::testing::NiceMock;
using ::testing::Return;
+using ::testing::SizeIs;
using ::testing::StrictMock;
namespace {
@@ -4122,6 +4123,44 @@
video_stream_encoder_->Stop();
}
+TEST_F(VideoStreamEncoderTest,
+ ReportsUpdatedVideoLayersAllocationWhenResolutionChanges) {
+ ResetEncoder("VP8", /*num_streams*/ 2, 1, 1, /*screenshare*/ false,
+ VideoStreamEncoderSettings::BitrateAllocationCallbackType::
+ kVideoLayersAllocation);
+
+ video_stream_encoder_->OnBitrateUpdatedAndWaitForManagedResources(
+ DataRate::BitsPerSec(kSimulcastTargetBitrateBps),
+ DataRate::BitsPerSec(kSimulcastTargetBitrateBps),
+ DataRate::BitsPerSec(kSimulcastTargetBitrateBps), 0, 0, 0);
+
+ video_source_.IncomingCapturedFrame(
+ CreateFrame(CurrentTimeMs(), codec_width_, codec_height_));
+ WaitForEncodedFrame(CurrentTimeMs());
+ EXPECT_EQ(sink_.number_of_layers_allocations(), 1);
+ ASSERT_THAT(sink_.GetLastVideoLayersAllocation().active_spatial_layers,
+ SizeIs(2));
+ EXPECT_EQ(sink_.GetLastVideoLayersAllocation().active_spatial_layers[1].width,
+ codec_width_);
+ EXPECT_EQ(
+ sink_.GetLastVideoLayersAllocation().active_spatial_layers[1].height,
+ codec_height_);
+
+ video_source_.IncomingCapturedFrame(
+ CreateFrame(CurrentTimeMs(), codec_width_ / 2, codec_height_ / 2));
+ WaitForEncodedFrame(CurrentTimeMs());
+ EXPECT_EQ(sink_.number_of_layers_allocations(), 2);
+ ASSERT_THAT(sink_.GetLastVideoLayersAllocation().active_spatial_layers,
+ SizeIs(2));
+ EXPECT_EQ(sink_.GetLastVideoLayersAllocation().active_spatial_layers[1].width,
+ codec_width_ / 2);
+ EXPECT_EQ(
+ sink_.GetLastVideoLayersAllocation().active_spatial_layers[1].height,
+ codec_height_ / 2);
+
+ video_stream_encoder_->Stop();
+}
+
TEST_F(VideoStreamEncoderTest, TemporalLayersNotDisabledIfSupported) {
// 2 TLs configured, temporal layers supported by encoder.
const int kNumTemporalLayers = 2;