Replace Verify methods with matchers in VideoStreamEncoder tests
This only replaces the methods with the signatures VerifyX(wants, value). This ensures that failing expectations give the corrent line, where previously it gave the line in the helper methods. Bug: None Change-Id: I89e883ccd15b3ea5ce364d2c16b0c3ac219f139c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/175912 Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Commit-Queue: Evan Shrubsole <eshr@google.com> Cr-Commit-Position: refs/heads/master@{#31345}
This commit is contained in:
parent
03d9e52998
commit
5cd7eb84c3
@ -53,7 +53,12 @@ namespace webrtc {
|
||||
|
||||
using ::testing::_;
|
||||
using ::testing::AllOf;
|
||||
using ::testing::Eq;
|
||||
using ::testing::Field;
|
||||
using ::testing::Ge;
|
||||
using ::testing::Gt;
|
||||
using ::testing::Le;
|
||||
using ::testing::Lt;
|
||||
using ::testing::Matcher;
|
||||
using ::testing::NiceMock;
|
||||
using ::testing::Return;
|
||||
@ -208,6 +213,60 @@ class VideoSourceRestrictionsUpdatedListener
|
||||
rtc::Event restrictions_updated_event_;
|
||||
};
|
||||
|
||||
auto ResolutionMax() {
|
||||
return AllOf(
|
||||
Field("max_pixel_count", &rtc::VideoSinkWants::max_pixel_count,
|
||||
Eq(std::numeric_limits<int>::max())),
|
||||
Field("target_pixel_count", &rtc::VideoSinkWants::target_pixel_count,
|
||||
Eq(absl::nullopt)));
|
||||
}
|
||||
|
||||
auto FpsMax() {
|
||||
return Field("max_framerate_fps", &rtc::VideoSinkWants::max_framerate_fps,
|
||||
Eq(kDefaultFramerate));
|
||||
}
|
||||
|
||||
auto FpsUnlimited() {
|
||||
return Field("max_framerate_fps", &rtc::VideoSinkWants::max_framerate_fps,
|
||||
Eq(std::numeric_limits<int>::max()));
|
||||
}
|
||||
|
||||
auto FpsMatchesResolutionMax(Matcher<int> fps_matcher) {
|
||||
return AllOf(Field("max_framerate_fps",
|
||||
&rtc::VideoSinkWants::max_framerate_fps, fps_matcher),
|
||||
ResolutionMax());
|
||||
}
|
||||
|
||||
auto FpsMaxResolutionMatches(Matcher<int> pixel_matcher) {
|
||||
return AllOf(FpsMax(),
|
||||
Field("max_pixel_count", &rtc::VideoSinkWants::max_pixel_count,
|
||||
AllOf(pixel_matcher, Gt(0))));
|
||||
}
|
||||
|
||||
auto FpsMaxResolutionMax() {
|
||||
return AllOf(FpsMax(), ResolutionMax());
|
||||
}
|
||||
|
||||
auto UnlimitedSinkWants() {
|
||||
return AllOf(FpsUnlimited(), ResolutionMax());
|
||||
}
|
||||
|
||||
auto FpsInRangeForPixelsInBalanced(int last_frame_pixels) {
|
||||
Matcher<int> fps_range_matcher;
|
||||
|
||||
if (last_frame_pixels <= 320 * 240) {
|
||||
fps_range_matcher = AllOf(Ge(7), Le(10));
|
||||
} else if (last_frame_pixels <= 480 * 270) {
|
||||
fps_range_matcher = AllOf(Ge(10), Le(15));
|
||||
} else if (last_frame_pixels <= 640 * 480) {
|
||||
fps_range_matcher = Ge(15);
|
||||
} else {
|
||||
fps_range_matcher = Eq(kDefaultFramerate);
|
||||
}
|
||||
return Field("max_framerate_fps", &rtc::VideoSinkWants::max_framerate_fps,
|
||||
fps_range_matcher);
|
||||
}
|
||||
|
||||
class VideoStreamEncoderUnderTest : public VideoStreamEncoder {
|
||||
public:
|
||||
VideoStreamEncoderUnderTest(SendStatisticsProxy* stats_proxy,
|
||||
@ -698,24 +757,12 @@ class VideoStreamEncoderTest : public ::testing::Test {
|
||||
WaitForEncodedFrame(1);
|
||||
}
|
||||
|
||||
void VerifyNoLimitation(const rtc::VideoSinkWants& wants) {
|
||||
EXPECT_EQ(std::numeric_limits<int>::max(), wants.max_framerate_fps);
|
||||
EXPECT_EQ(std::numeric_limits<int>::max(), wants.max_pixel_count);
|
||||
EXPECT_FALSE(wants.target_pixel_count);
|
||||
}
|
||||
|
||||
void VerifyFpsEqResolutionEq(const rtc::VideoSinkWants& wants1,
|
||||
const rtc::VideoSinkWants& wants2) {
|
||||
EXPECT_EQ(wants1.max_framerate_fps, wants2.max_framerate_fps);
|
||||
EXPECT_EQ(wants1.max_pixel_count, wants2.max_pixel_count);
|
||||
}
|
||||
|
||||
void VerifyFpsMaxResolutionMax(const rtc::VideoSinkWants& wants) {
|
||||
EXPECT_EQ(kDefaultFramerate, wants.max_framerate_fps);
|
||||
EXPECT_EQ(std::numeric_limits<int>::max(), wants.max_pixel_count);
|
||||
EXPECT_FALSE(wants.target_pixel_count);
|
||||
}
|
||||
|
||||
void VerifyFpsMaxResolutionLt(const rtc::VideoSinkWants& wants1,
|
||||
const rtc::VideoSinkWants& wants2) {
|
||||
EXPECT_EQ(kDefaultFramerate, wants1.max_framerate_fps);
|
||||
@ -760,44 +807,6 @@ class VideoStreamEncoderTest : public ::testing::Test {
|
||||
EXPECT_GT(wants1.max_pixel_count, wants2.max_pixel_count);
|
||||
}
|
||||
|
||||
void VerifyFpsMaxResolutionLt(const rtc::VideoSinkWants& wants,
|
||||
int pixel_count) {
|
||||
EXPECT_EQ(kDefaultFramerate, wants.max_framerate_fps);
|
||||
EXPECT_LT(wants.max_pixel_count, pixel_count);
|
||||
EXPECT_GT(wants.max_pixel_count, 0);
|
||||
}
|
||||
|
||||
void VerifyFpsLtResolutionMax(const rtc::VideoSinkWants& wants, int fps) {
|
||||
EXPECT_LT(wants.max_framerate_fps, fps);
|
||||
EXPECT_EQ(std::numeric_limits<int>::max(), wants.max_pixel_count);
|
||||
EXPECT_FALSE(wants.target_pixel_count);
|
||||
}
|
||||
|
||||
void VerifyFpsEqResolutionMax(const rtc::VideoSinkWants& wants,
|
||||
int expected_fps) {
|
||||
EXPECT_EQ(expected_fps, wants.max_framerate_fps);
|
||||
EXPECT_EQ(std::numeric_limits<int>::max(), wants.max_pixel_count);
|
||||
EXPECT_FALSE(wants.target_pixel_count);
|
||||
}
|
||||
|
||||
void VerifyBalancedModeFpsRange(const rtc::VideoSinkWants& wants,
|
||||
int last_frame_pixels) {
|
||||
// Balanced mode should always scale FPS to the desired range before
|
||||
// attempting to scale resolution.
|
||||
int fps_limit = wants.max_framerate_fps;
|
||||
if (last_frame_pixels <= 320 * 240) {
|
||||
EXPECT_LE(7, fps_limit);
|
||||
EXPECT_LE(fps_limit, 10);
|
||||
} else if (last_frame_pixels <= 480 * 270) {
|
||||
EXPECT_LE(10, fps_limit);
|
||||
EXPECT_LE(fps_limit, 15);
|
||||
} else if (last_frame_pixels <= 640 * 480) {
|
||||
EXPECT_LE(15, fps_limit);
|
||||
} else {
|
||||
EXPECT_EQ(kDefaultFramerate, fps_limit);
|
||||
}
|
||||
}
|
||||
|
||||
void WaitForEncodedFrame(int64_t expected_ntp_time) {
|
||||
sink_.WaitForEncodedFrame(expected_ntp_time);
|
||||
fake_clock_.AdvanceTime(TimeDelta::Seconds(1) / max_framerate_);
|
||||
@ -1873,7 +1882,7 @@ TEST_F(VideoStreamEncoderTest, TestCpuDowngrades_BalancedMode) {
|
||||
DataRate::BitsPerSec(kTargetBitrateBps), 0, 0, 0);
|
||||
video_stream_encoder_->SetSource(&video_source_,
|
||||
webrtc::DegradationPreference::BALANCED);
|
||||
VerifyNoLimitation(video_source_.sink_wants());
|
||||
EXPECT_THAT(video_source_.sink_wants(), UnlimitedSinkWants());
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_resolution);
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_framerate);
|
||||
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_cpu_adapt_changes);
|
||||
@ -1898,9 +1907,10 @@ TEST_F(VideoStreamEncoderTest, TestCpuDowngrades_BalancedMode) {
|
||||
t += frame_interval_ms;
|
||||
|
||||
video_stream_encoder_->TriggerCpuOveruse();
|
||||
VerifyBalancedModeFpsRange(
|
||||
EXPECT_THAT(
|
||||
video_source_.sink_wants(),
|
||||
*video_source_.last_sent_width() * *video_source_.last_sent_height());
|
||||
FpsInRangeForPixelsInBalanced(*video_source_.last_sent_width() *
|
||||
*video_source_.last_sent_height()));
|
||||
} while (video_source_.sink_wants().max_pixel_count <
|
||||
last_wants.max_pixel_count ||
|
||||
video_source_.sink_wants().max_framerate_fps <
|
||||
@ -1933,16 +1943,17 @@ TEST_F(VideoStreamEncoderTest, TestCpuDowngrades_BalancedMode) {
|
||||
t += frame_interval_ms;
|
||||
|
||||
video_stream_encoder_->TriggerCpuUnderuse();
|
||||
VerifyBalancedModeFpsRange(
|
||||
EXPECT_THAT(
|
||||
video_source_.sink_wants(),
|
||||
*video_source_.last_sent_width() * *video_source_.last_sent_height());
|
||||
FpsInRangeForPixelsInBalanced(*video_source_.last_sent_width() *
|
||||
*video_source_.last_sent_height()));
|
||||
EXPECT_TRUE(video_source_.sink_wants().max_pixel_count >
|
||||
last_wants.max_pixel_count ||
|
||||
video_source_.sink_wants().max_framerate_fps >
|
||||
last_wants.max_framerate_fps);
|
||||
}
|
||||
|
||||
VerifyFpsMaxResolutionMax(video_source_.sink_wants());
|
||||
EXPECT_THAT(video_source_.sink_wants(), FpsMaxResolutionMax());
|
||||
stats_proxy_->ResetMockStats();
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_resolution);
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_framerate);
|
||||
@ -1958,7 +1969,7 @@ TEST_F(VideoStreamEncoderTest,
|
||||
DataRate::BitsPerSec(kTargetBitrateBps),
|
||||
DataRate::BitsPerSec(kTargetBitrateBps),
|
||||
DataRate::BitsPerSec(kTargetBitrateBps), 0, 0, 0);
|
||||
VerifyNoLimitation(video_source_.sink_wants());
|
||||
EXPECT_THAT(video_source_.sink_wants(), UnlimitedSinkWants());
|
||||
|
||||
const int kFrameWidth = 1280;
|
||||
const int kFrameHeight = 720;
|
||||
@ -1975,7 +1986,7 @@ TEST_F(VideoStreamEncoderTest,
|
||||
video_source_.set_adaptation_enabled(true);
|
||||
video_stream_encoder_->SetSource(
|
||||
&video_source_, webrtc::DegradationPreference::MAINTAIN_RESOLUTION);
|
||||
VerifyNoLimitation(video_source_.sink_wants());
|
||||
EXPECT_THAT(video_source_.sink_wants(), UnlimitedSinkWants());
|
||||
video_source_.IncomingCapturedFrame(
|
||||
CreateFrame(ntp_time, kFrameWidth, kFrameHeight));
|
||||
sink_.WaitForEncodedFrame(ntp_time);
|
||||
@ -2061,7 +2072,7 @@ TEST_F(VideoStreamEncoderTest, SinkWantsStoredByDegradationPreference) {
|
||||
DataRate::BitsPerSec(kTargetBitrateBps),
|
||||
DataRate::BitsPerSec(kTargetBitrateBps),
|
||||
DataRate::BitsPerSec(kTargetBitrateBps), 0, 0, 0);
|
||||
VerifyNoLimitation(video_source_.sink_wants());
|
||||
EXPECT_THAT(video_source_.sink_wants(), UnlimitedSinkWants());
|
||||
|
||||
const int kFrameWidth = 1280;
|
||||
const int kFrameHeight = 720;
|
||||
@ -2098,7 +2109,7 @@ TEST_F(VideoStreamEncoderTest, SinkWantsStoredByDegradationPreference) {
|
||||
sink_.WaitForEncodedFrame(frame_timestamp);
|
||||
frame_timestamp += kFrameIntervalMs;
|
||||
// Initially no degradation registered.
|
||||
VerifyFpsMaxResolutionMax(new_video_source.sink_wants());
|
||||
EXPECT_THAT(new_video_source.sink_wants(), FpsMaxResolutionMax());
|
||||
|
||||
// Force an input frame rate to be available, or the adaptation call won't
|
||||
// know what framerate to adapt form.
|
||||
@ -2128,7 +2139,7 @@ TEST_F(VideoStreamEncoderTest, SinkWantsStoredByDegradationPreference) {
|
||||
CreateFrame(frame_timestamp, kFrameWidth, kFrameWidth));
|
||||
sink_.WaitForEncodedFrame(frame_timestamp);
|
||||
frame_timestamp += kFrameIntervalMs;
|
||||
VerifyFpsMaxResolutionMax(new_video_source.sink_wants());
|
||||
EXPECT_THAT(new_video_source.sink_wants(), FpsMaxResolutionMax());
|
||||
|
||||
video_stream_encoder_->TriggerCpuOveruse();
|
||||
new_video_source.IncomingCapturedFrame(
|
||||
@ -2137,7 +2148,7 @@ TEST_F(VideoStreamEncoderTest, SinkWantsStoredByDegradationPreference) {
|
||||
frame_timestamp += kFrameIntervalMs;
|
||||
|
||||
// Still no degradation.
|
||||
VerifyFpsMaxResolutionMax(new_video_source.sink_wants());
|
||||
EXPECT_THAT(new_video_source.sink_wants(), FpsMaxResolutionMax());
|
||||
|
||||
// Calling SetSource with resolution scaling enabled apply the old SinkWants.
|
||||
video_stream_encoder_->SetSourceAndWaitForRestrictionsUpdated(
|
||||
@ -2647,7 +2658,7 @@ TEST_F(VideoStreamEncoderTest,
|
||||
DataRate::BitsPerSec(kTargetBitrateBps), 0, 0, 0);
|
||||
|
||||
// Expect no scaling to begin with.
|
||||
VerifyNoLimitation(video_source_.sink_wants());
|
||||
EXPECT_THAT(video_source_.sink_wants(), UnlimitedSinkWants());
|
||||
|
||||
video_source_.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
|
||||
WaitForEncodedFrame(1);
|
||||
@ -2704,13 +2715,14 @@ TEST_F(VideoStreamEncoderTest,
|
||||
|
||||
source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
|
||||
WaitForEncodedFrame(1);
|
||||
VerifyFpsMaxResolutionMax(source.sink_wants());
|
||||
EXPECT_THAT(source.sink_wants(), FpsMaxResolutionMax());
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_resolution);
|
||||
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_cpu_adapt_changes);
|
||||
|
||||
// Trigger adapt down, expect scaled down resolution.
|
||||
video_stream_encoder_->TriggerCpuOveruse();
|
||||
VerifyFpsMaxResolutionLt(source.sink_wants(), kWidth * kHeight);
|
||||
EXPECT_THAT(source.sink_wants(),
|
||||
FpsMaxResolutionMatches(Lt(kWidth * kHeight)));
|
||||
const int kLastMaxPixelCount = source.sink_wants().max_pixel_count;
|
||||
EXPECT_TRUE(stats_proxy_->GetStats().cpu_limited_resolution);
|
||||
EXPECT_EQ(1, stats_proxy_->GetStats().number_of_cpu_adapt_changes);
|
||||
@ -2738,11 +2750,12 @@ TEST_F(VideoStreamEncoderTest, SkipsSameOrLargerAdaptDownRequest_BalancedMode) {
|
||||
webrtc::DegradationPreference::BALANCED);
|
||||
source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
|
||||
sink_.WaitForEncodedFrame(1);
|
||||
VerifyFpsMaxResolutionMax(source.sink_wants());
|
||||
EXPECT_THAT(source.sink_wants(), FpsMaxResolutionMax());
|
||||
|
||||
// Trigger adapt down, expect scaled down resolution.
|
||||
video_stream_encoder_->TriggerQualityLow();
|
||||
VerifyFpsMaxResolutionLt(source.sink_wants(), kWidth * kHeight);
|
||||
EXPECT_THAT(source.sink_wants(),
|
||||
FpsMaxResolutionMatches(Lt(kWidth * kHeight)));
|
||||
EXPECT_TRUE(stats_proxy_->GetStats().bw_limited_resolution);
|
||||
EXPECT_EQ(1, stats_proxy_->GetStats().number_of_quality_adapt_changes);
|
||||
const int kLastMaxPixelCount = source.sink_wants().max_pixel_count;
|
||||
@ -2782,13 +2795,13 @@ TEST_F(VideoStreamEncoderTest,
|
||||
|
||||
source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
|
||||
WaitForEncodedFrame(kWidth, kHeight);
|
||||
VerifyFpsMaxResolutionMax(source.sink_wants());
|
||||
EXPECT_THAT(source.sink_wants(), FpsMaxResolutionMax());
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_resolution);
|
||||
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_cpu_adapt_changes);
|
||||
|
||||
// Trigger adapt up, expect no change.
|
||||
video_stream_encoder_->TriggerCpuUnderuse();
|
||||
VerifyFpsMaxResolutionMax(source.sink_wants());
|
||||
EXPECT_THAT(source.sink_wants(), FpsMaxResolutionMax());
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_resolution);
|
||||
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_cpu_adapt_changes);
|
||||
|
||||
@ -2811,13 +2824,13 @@ TEST_F(VideoStreamEncoderTest,
|
||||
|
||||
source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
|
||||
WaitForEncodedFrame(kWidth, kHeight);
|
||||
VerifyFpsMaxResolutionMax(source.sink_wants());
|
||||
EXPECT_THAT(source.sink_wants(), FpsMaxResolutionMax());
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_framerate);
|
||||
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_cpu_adapt_changes);
|
||||
|
||||
// Trigger adapt up, expect no change.
|
||||
video_stream_encoder_->TriggerCpuUnderuse();
|
||||
VerifyFpsMaxResolutionMax(source.sink_wants());
|
||||
EXPECT_THAT(source.sink_wants(), FpsMaxResolutionMax());
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_framerate);
|
||||
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_cpu_adapt_changes);
|
||||
|
||||
@ -2839,14 +2852,14 @@ TEST_F(VideoStreamEncoderTest, NoChangeForInitialNormalUsage_BalancedMode) {
|
||||
|
||||
source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
|
||||
sink_.WaitForEncodedFrame(kWidth, kHeight);
|
||||
VerifyFpsMaxResolutionMax(source.sink_wants());
|
||||
EXPECT_THAT(source.sink_wants(), FpsMaxResolutionMax());
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution);
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_framerate);
|
||||
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_quality_adapt_changes);
|
||||
|
||||
// Trigger adapt up, expect no change.
|
||||
video_stream_encoder_->TriggerQualityHigh();
|
||||
VerifyFpsMaxResolutionMax(source.sink_wants());
|
||||
EXPECT_THAT(source.sink_wants(), FpsMaxResolutionMax());
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution);
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_framerate);
|
||||
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_quality_adapt_changes);
|
||||
@ -2869,14 +2882,14 @@ TEST_F(VideoStreamEncoderTest, NoChangeForInitialNormalUsage_DisabledMode) {
|
||||
|
||||
source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
|
||||
sink_.WaitForEncodedFrame(kWidth, kHeight);
|
||||
VerifyFpsMaxResolutionMax(source.sink_wants());
|
||||
EXPECT_THAT(source.sink_wants(), FpsMaxResolutionMax());
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution);
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_framerate);
|
||||
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_quality_adapt_changes);
|
||||
|
||||
// Trigger adapt up, expect no change.
|
||||
video_stream_encoder_->TriggerQualityHigh();
|
||||
VerifyFpsMaxResolutionMax(source.sink_wants());
|
||||
EXPECT_THAT(source.sink_wants(), FpsMaxResolutionMax());
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution);
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_framerate);
|
||||
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_quality_adapt_changes);
|
||||
@ -2901,7 +2914,7 @@ TEST_F(VideoStreamEncoderTest,
|
||||
|
||||
source.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
|
||||
WaitForEncodedFrame(1);
|
||||
VerifyFpsMaxResolutionMax(source.sink_wants());
|
||||
EXPECT_THAT(source.sink_wants(), FpsMaxResolutionMax());
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution);
|
||||
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_quality_adapt_changes);
|
||||
|
||||
@ -2909,13 +2922,14 @@ TEST_F(VideoStreamEncoderTest,
|
||||
video_stream_encoder_->TriggerQualityLow();
|
||||
source.IncomingCapturedFrame(CreateFrame(2, kWidth, kHeight));
|
||||
WaitForEncodedFrame(2);
|
||||
VerifyFpsMaxResolutionLt(source.sink_wants(), kWidth * kHeight);
|
||||
EXPECT_THAT(source.sink_wants(),
|
||||
FpsMaxResolutionMatches(Lt(kWidth * kHeight)));
|
||||
EXPECT_TRUE(stats_proxy_->GetStats().bw_limited_resolution);
|
||||
EXPECT_EQ(1, stats_proxy_->GetStats().number_of_quality_adapt_changes);
|
||||
|
||||
// Trigger adapt up, expect no restriction.
|
||||
video_stream_encoder_->TriggerQualityHigh();
|
||||
VerifyFpsMaxResolutionMax(source.sink_wants());
|
||||
EXPECT_THAT(source.sink_wants(), FpsMaxResolutionMax());
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution);
|
||||
EXPECT_EQ(2, stats_proxy_->GetStats().number_of_quality_adapt_changes);
|
||||
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_cpu_adapt_changes);
|
||||
@ -2940,13 +2954,14 @@ TEST_F(VideoStreamEncoderTest,
|
||||
// Expect no scaling to begin with (preference: MAINTAIN_FRAMERATE).
|
||||
video_source_.IncomingCapturedFrame(CreateFrame(1, kWidth, kHeight));
|
||||
sink_.WaitForEncodedFrame(1);
|
||||
VerifyFpsMaxResolutionMax(video_source_.sink_wants());
|
||||
EXPECT_THAT(video_source_.sink_wants(), FpsMaxResolutionMax());
|
||||
|
||||
// Trigger adapt down, expect scaled down resolution.
|
||||
video_stream_encoder_->TriggerQualityLow();
|
||||
video_source_.IncomingCapturedFrame(CreateFrame(2, kWidth, kHeight));
|
||||
sink_.WaitForEncodedFrame(2);
|
||||
VerifyFpsMaxResolutionLt(video_source_.sink_wants(), kWidth * kHeight);
|
||||
EXPECT_THAT(video_source_.sink_wants(),
|
||||
FpsMaxResolutionMatches(Lt(kWidth * kHeight)));
|
||||
|
||||
// Enable MAINTAIN_RESOLUTION preference.
|
||||
test::FrameForwarder new_video_source;
|
||||
@ -2956,17 +2971,18 @@ TEST_F(VideoStreamEncoderTest,
|
||||
// by waiting for an encoded frame.
|
||||
new_video_source.IncomingCapturedFrame(CreateFrame(3, kWidth, kHeight));
|
||||
sink_.WaitForEncodedFrame(3);
|
||||
VerifyFpsMaxResolutionMax(new_video_source.sink_wants());
|
||||
EXPECT_THAT(new_video_source.sink_wants(), FpsMaxResolutionMax());
|
||||
|
||||
// Trigger adapt down, expect reduced framerate.
|
||||
video_stream_encoder_->TriggerQualityLow();
|
||||
new_video_source.IncomingCapturedFrame(CreateFrame(4, kWidth, kHeight));
|
||||
sink_.WaitForEncodedFrame(4);
|
||||
VerifyFpsLtResolutionMax(new_video_source.sink_wants(), kInputFps);
|
||||
EXPECT_THAT(new_video_source.sink_wants(),
|
||||
FpsMatchesResolutionMax(Lt(kInputFps)));
|
||||
|
||||
// Trigger adapt up, expect no restriction.
|
||||
video_stream_encoder_->TriggerQualityHigh();
|
||||
VerifyFpsMaxResolutionMax(new_video_source.sink_wants());
|
||||
EXPECT_THAT(new_video_source.sink_wants(), FpsMaxResolutionMax());
|
||||
|
||||
video_stream_encoder_->Stop();
|
||||
}
|
||||
@ -3028,7 +3044,7 @@ TEST_F(VideoStreamEncoderTest,
|
||||
int64_t timestamp_ms = kFrameIntervalMs;
|
||||
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
|
||||
WaitForEncodedFrame(kWidth, kHeight);
|
||||
VerifyFpsMaxResolutionMax(source.sink_wants());
|
||||
EXPECT_THAT(source.sink_wants(), FpsMaxResolutionMax());
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_resolution);
|
||||
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_cpu_adapt_changes);
|
||||
|
||||
@ -3037,7 +3053,8 @@ TEST_F(VideoStreamEncoderTest,
|
||||
timestamp_ms += kFrameIntervalMs;
|
||||
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
|
||||
WaitForEncodedFrame(timestamp_ms);
|
||||
VerifyFpsMaxResolutionLt(source.sink_wants(), kWidth * kHeight);
|
||||
EXPECT_THAT(source.sink_wants(),
|
||||
FpsMaxResolutionMatches(Lt(kWidth * kHeight)));
|
||||
EXPECT_TRUE(stats_proxy_->GetStats().cpu_limited_resolution);
|
||||
EXPECT_EQ(1, stats_proxy_->GetStats().number_of_cpu_adapt_changes);
|
||||
|
||||
@ -3046,7 +3063,7 @@ TEST_F(VideoStreamEncoderTest,
|
||||
timestamp_ms += kFrameIntervalMs;
|
||||
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
|
||||
WaitForEncodedFrame(kWidth, kHeight);
|
||||
VerifyFpsMaxResolutionMax(source.sink_wants());
|
||||
EXPECT_THAT(source.sink_wants(), FpsMaxResolutionMax());
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_resolution);
|
||||
EXPECT_EQ(2, stats_proxy_->GetStats().number_of_cpu_adapt_changes);
|
||||
|
||||
@ -3055,7 +3072,8 @@ TEST_F(VideoStreamEncoderTest,
|
||||
timestamp_ms += kFrameIntervalMs;
|
||||
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
|
||||
WaitForEncodedFrame(timestamp_ms);
|
||||
VerifyFpsMaxResolutionLt(source.sink_wants(), kWidth * kHeight);
|
||||
EXPECT_THAT(source.sink_wants(),
|
||||
FpsMaxResolutionMatches(Lt(kWidth * kHeight)));
|
||||
EXPECT_TRUE(stats_proxy_->GetStats().cpu_limited_resolution);
|
||||
EXPECT_EQ(3, stats_proxy_->GetStats().number_of_cpu_adapt_changes);
|
||||
|
||||
@ -3064,7 +3082,7 @@ TEST_F(VideoStreamEncoderTest,
|
||||
timestamp_ms += kFrameIntervalMs;
|
||||
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
|
||||
sink_.WaitForEncodedFrame(kWidth, kHeight);
|
||||
VerifyFpsMaxResolutionMax(source.sink_wants());
|
||||
EXPECT_THAT(source.sink_wants(), FpsMaxResolutionMax());
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_resolution);
|
||||
EXPECT_EQ(4, stats_proxy_->GetStats().number_of_cpu_adapt_changes);
|
||||
|
||||
@ -3089,7 +3107,7 @@ TEST_F(VideoStreamEncoderTest,
|
||||
int64_t timestamp_ms = kFrameIntervalMs;
|
||||
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
|
||||
sink_.WaitForEncodedFrame(kWidth, kHeight);
|
||||
VerifyFpsMaxResolutionMax(source.sink_wants());
|
||||
EXPECT_THAT(source.sink_wants(), FpsMaxResolutionMax());
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution);
|
||||
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_quality_adapt_changes);
|
||||
|
||||
@ -3098,7 +3116,8 @@ TEST_F(VideoStreamEncoderTest,
|
||||
timestamp_ms += kFrameIntervalMs;
|
||||
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
|
||||
sink_.WaitForEncodedFrame(timestamp_ms);
|
||||
VerifyFpsMaxResolutionLt(source.sink_wants(), kWidth * kHeight);
|
||||
EXPECT_THAT(source.sink_wants(),
|
||||
FpsMaxResolutionMatches(Lt(kWidth * kHeight)));
|
||||
EXPECT_TRUE(stats_proxy_->GetStats().bw_limited_resolution);
|
||||
EXPECT_EQ(1, stats_proxy_->GetStats().number_of_quality_adapt_changes);
|
||||
|
||||
@ -3107,7 +3126,7 @@ TEST_F(VideoStreamEncoderTest,
|
||||
timestamp_ms += kFrameIntervalMs;
|
||||
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
|
||||
sink_.WaitForEncodedFrame(kWidth, kHeight);
|
||||
VerifyFpsMaxResolutionMax(source.sink_wants());
|
||||
EXPECT_THAT(source.sink_wants(), FpsMaxResolutionMax());
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution);
|
||||
EXPECT_EQ(2, stats_proxy_->GetStats().number_of_quality_adapt_changes);
|
||||
|
||||
@ -3116,7 +3135,8 @@ TEST_F(VideoStreamEncoderTest,
|
||||
timestamp_ms += kFrameIntervalMs;
|
||||
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
|
||||
sink_.WaitForEncodedFrame(timestamp_ms);
|
||||
VerifyFpsMaxResolutionLt(source.sink_wants(), kWidth * kHeight);
|
||||
EXPECT_THAT(source.sink_wants(),
|
||||
FpsMaxResolutionMatches(Lt(kWidth * kHeight)));
|
||||
EXPECT_TRUE(stats_proxy_->GetStats().bw_limited_resolution);
|
||||
EXPECT_EQ(3, stats_proxy_->GetStats().number_of_quality_adapt_changes);
|
||||
|
||||
@ -3125,7 +3145,7 @@ TEST_F(VideoStreamEncoderTest,
|
||||
timestamp_ms += kFrameIntervalMs;
|
||||
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
|
||||
sink_.WaitForEncodedFrame(kWidth, kHeight);
|
||||
VerifyFpsMaxResolutionMax(source.sink_wants());
|
||||
EXPECT_THAT(source.sink_wants(), FpsMaxResolutionMax());
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution);
|
||||
EXPECT_EQ(4, stats_proxy_->GetStats().number_of_quality_adapt_changes);
|
||||
|
||||
@ -3169,7 +3189,7 @@ TEST_F(VideoStreamEncoderTest, AdaptUpIfBwEstimateIsHigherThanMinBitrate) {
|
||||
// Trigger adapt up. Higher resolution should not be requested duo to lack
|
||||
// of bitrate.
|
||||
video_stream_encoder_->TriggerQualityHigh();
|
||||
VerifyFpsMaxResolutionLt(source.sink_wants(), 1280 * 720);
|
||||
EXPECT_THAT(source.sink_wants(), FpsMaxResolutionMatches(Lt(1280 * 720)));
|
||||
|
||||
// Increase bitrate.
|
||||
video_stream_encoder_->OnBitrateUpdatedAndWaitForManagedResources(
|
||||
@ -3180,7 +3200,7 @@ TEST_F(VideoStreamEncoderTest, AdaptUpIfBwEstimateIsHigherThanMinBitrate) {
|
||||
|
||||
// Trigger adapt up. Higher resolution should be requested.
|
||||
video_stream_encoder_->TriggerQualityHigh();
|
||||
VerifyFpsMaxResolutionMax(source.sink_wants());
|
||||
EXPECT_THAT(source.sink_wants(), FpsMaxResolutionMax());
|
||||
|
||||
video_stream_encoder_->Stop();
|
||||
}
|
||||
@ -3265,7 +3285,7 @@ TEST_F(BalancedDegradationTest, AdaptDownReturnsFalseIfFpsDiffLtThreshold) {
|
||||
stats_proxy_->SetMockStats(stats);
|
||||
|
||||
InsertFrameAndWaitForEncoded();
|
||||
VerifyFpsMaxResolutionMax(source_.sink_wants());
|
||||
EXPECT_THAT(source_.sink_wants(), FpsMaxResolutionMax());
|
||||
|
||||
// Trigger adapt down, expect scaled down framerate (640x360@24fps).
|
||||
// Fps diff (input-requested:0) < threshold, expect adapting down not to clear
|
||||
@ -3273,7 +3293,7 @@ TEST_F(BalancedDegradationTest, AdaptDownReturnsFalseIfFpsDiffLtThreshold) {
|
||||
EXPECT_FALSE(
|
||||
video_stream_encoder_
|
||||
->TriggerQualityScalerHighQpAndReturnIfQpSamplesShouldBeCleared());
|
||||
VerifyFpsEqResolutionMax(source_.sink_wants(), 24);
|
||||
EXPECT_THAT(source_.sink_wants(), FpsMatchesResolutionMax(Eq(24)));
|
||||
|
||||
video_stream_encoder_->Stop();
|
||||
}
|
||||
@ -3291,7 +3311,7 @@ TEST_F(BalancedDegradationTest, AdaptDownReturnsTrueIfFpsDiffGeThreshold) {
|
||||
stats_proxy_->SetMockStats(stats);
|
||||
|
||||
InsertFrameAndWaitForEncoded();
|
||||
VerifyFpsMaxResolutionMax(source_.sink_wants());
|
||||
EXPECT_THAT(source_.sink_wants(), FpsMaxResolutionMax());
|
||||
|
||||
// Trigger adapt down, expect scaled down framerate (640x360@24fps).
|
||||
// Fps diff (input-requested:1) == threshold, expect adapting down to clear QP
|
||||
@ -3299,7 +3319,7 @@ TEST_F(BalancedDegradationTest, AdaptDownReturnsTrueIfFpsDiffGeThreshold) {
|
||||
EXPECT_TRUE(
|
||||
video_stream_encoder_
|
||||
->TriggerQualityScalerHighQpAndReturnIfQpSamplesShouldBeCleared());
|
||||
VerifyFpsEqResolutionMax(source_.sink_wants(), 24);
|
||||
EXPECT_THAT(source_.sink_wants(), FpsMatchesResolutionMax(Eq(24)));
|
||||
|
||||
video_stream_encoder_->Stop();
|
||||
}
|
||||
@ -3313,11 +3333,11 @@ TEST_F(BalancedDegradationTest, AdaptDownUsesCodecSpecificFps) {
|
||||
EXPECT_EQ(kVideoCodecVP8, video_encoder_config_.codec_type);
|
||||
|
||||
InsertFrameAndWaitForEncoded();
|
||||
VerifyFpsMaxResolutionMax(source_.sink_wants());
|
||||
EXPECT_THAT(source_.sink_wants(), FpsMaxResolutionMax());
|
||||
|
||||
// Trigger adapt down, expect scaled down framerate (640x360@22fps).
|
||||
video_stream_encoder_->TriggerQualityLow();
|
||||
VerifyFpsEqResolutionMax(source_.sink_wants(), 22);
|
||||
EXPECT_THAT(source_.sink_wants(), FpsMatchesResolutionMax(Eq(22)));
|
||||
|
||||
video_stream_encoder_->Stop();
|
||||
}
|
||||
@ -3333,13 +3353,13 @@ TEST_F(BalancedDegradationTest, NoAdaptUpIfBwEstimateIsLessThanMinBitrate) {
|
||||
OnBitrateUpdated(kTooLowMinBitrateBps);
|
||||
|
||||
InsertFrameAndWaitForEncoded();
|
||||
VerifyFpsMaxResolutionMax(source_.sink_wants());
|
||||
EXPECT_THAT(source_.sink_wants(), FpsMaxResolutionMax());
|
||||
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_quality_adapt_changes);
|
||||
|
||||
// Trigger adapt down, expect scaled down framerate (640x360@14fps).
|
||||
video_stream_encoder_->TriggerQualityLow();
|
||||
InsertFrameAndWaitForEncoded();
|
||||
VerifyFpsEqResolutionMax(source_.sink_wants(), 14);
|
||||
EXPECT_THAT(source_.sink_wants(), FpsMatchesResolutionMax(Eq(14)));
|
||||
EXPECT_EQ(1, stats_proxy_->GetStats().number_of_quality_adapt_changes);
|
||||
|
||||
// Trigger adapt down, expect scaled down resolution (480x270@14fps).
|
||||
@ -3378,7 +3398,7 @@ TEST_F(BalancedDegradationTest,
|
||||
SetupTest();
|
||||
OnBitrateUpdated(kLowTargetBitrateBps);
|
||||
|
||||
VerifyNoLimitation(source_.sink_wants());
|
||||
EXPECT_THAT(source_.sink_wants(), UnlimitedSinkWants());
|
||||
|
||||
// Insert frame, expect scaled down:
|
||||
// framerate (640x360@24fps) -> resolution (480x270@24fps).
|
||||
@ -3413,13 +3433,13 @@ TEST_F(BalancedDegradationTest,
|
||||
OnBitrateUpdated(kTooLowMinResolutionBitrateBps);
|
||||
|
||||
InsertFrameAndWaitForEncoded();
|
||||
VerifyFpsMaxResolutionMax(source_.sink_wants());
|
||||
EXPECT_THAT(source_.sink_wants(), FpsMaxResolutionMax());
|
||||
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_quality_adapt_changes);
|
||||
|
||||
// Trigger adapt down, expect scaled down framerate (640x360@14fps).
|
||||
video_stream_encoder_->TriggerQualityLow();
|
||||
InsertFrameAndWaitForEncoded();
|
||||
VerifyFpsEqResolutionMax(source_.sink_wants(), 14);
|
||||
EXPECT_THAT(source_.sink_wants(), FpsMatchesResolutionMax(Eq(14)));
|
||||
EXPECT_EQ(1, stats_proxy_->GetStats().number_of_quality_adapt_changes);
|
||||
|
||||
// Trigger adapt down, expect scaled down resolution (480x270@14fps).
|
||||
@ -3469,13 +3489,13 @@ TEST_F(BalancedDegradationTest,
|
||||
OnBitrateUpdated(kTooLowMinBitrateBps);
|
||||
|
||||
InsertFrameAndWaitForEncoded();
|
||||
VerifyFpsMaxResolutionMax(source_.sink_wants());
|
||||
EXPECT_THAT(source_.sink_wants(), FpsMaxResolutionMax());
|
||||
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_quality_adapt_changes);
|
||||
|
||||
// Trigger adapt down, expect scaled down framerate (640x360@14fps).
|
||||
video_stream_encoder_->TriggerQualityLow();
|
||||
InsertFrameAndWaitForEncoded();
|
||||
VerifyFpsEqResolutionMax(source_.sink_wants(), 14);
|
||||
EXPECT_THAT(source_.sink_wants(), FpsMatchesResolutionMax(Eq(14)));
|
||||
EXPECT_EQ(1, stats_proxy_->GetStats().number_of_quality_adapt_changes);
|
||||
|
||||
// Trigger adapt down, expect scaled down resolution (480x270@14fps).
|
||||
@ -3536,7 +3556,7 @@ TEST_F(VideoStreamEncoderTest,
|
||||
int64_t timestamp_ms = kFrameIntervalMs;
|
||||
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
|
||||
WaitForEncodedFrame(kWidth, kHeight);
|
||||
VerifyFpsMaxResolutionMax(source.sink_wants());
|
||||
EXPECT_THAT(source.sink_wants(), FpsMaxResolutionMax());
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_resolution);
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution);
|
||||
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_cpu_adapt_changes);
|
||||
@ -3547,7 +3567,8 @@ TEST_F(VideoStreamEncoderTest,
|
||||
timestamp_ms += kFrameIntervalMs;
|
||||
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
|
||||
WaitForEncodedFrame(timestamp_ms);
|
||||
VerifyFpsMaxResolutionLt(source.sink_wants(), kWidth * kHeight);
|
||||
EXPECT_THAT(source.sink_wants(),
|
||||
FpsMaxResolutionMatches(Lt(kWidth * kHeight)));
|
||||
EXPECT_TRUE(stats_proxy_->GetStats().cpu_limited_resolution);
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution);
|
||||
EXPECT_EQ(1, stats_proxy_->GetStats().number_of_cpu_adapt_changes);
|
||||
@ -3649,7 +3670,7 @@ TEST_F(VideoStreamEncoderTest,
|
||||
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
|
||||
WaitForEncodedFrame(kWidth, kHeight);
|
||||
VerifyFpsMaxResolutionGt(source.sink_wants(), source.last_wants());
|
||||
VerifyFpsMaxResolutionMax(source.sink_wants());
|
||||
EXPECT_THAT(source.sink_wants(), FpsMaxResolutionMax());
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_resolution);
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution);
|
||||
EXPECT_EQ(6, stats_proxy_->GetStats().number_of_cpu_adapt_changes);
|
||||
@ -4213,7 +4234,7 @@ TEST_F(VideoStreamEncoderTest, RampsUpInQualityWhenBwIsHigh) {
|
||||
// The ramp-up code involves the adaptation queue, give it time to execute.
|
||||
// TODO(hbos): Can we await an appropriate event instead?
|
||||
video_stream_encoder_->WaitUntilAdaptationTaskQueueIsIdle();
|
||||
VerifyFpsMaxResolutionMax(source.sink_wants());
|
||||
EXPECT_THAT(source.sink_wants(), FpsMaxResolutionMax());
|
||||
|
||||
// Frame should not be adapted.
|
||||
timestamp_ms += kFrameIntervalMs;
|
||||
@ -4237,14 +4258,14 @@ TEST_F(VideoStreamEncoderTest,
|
||||
test::FrameForwarder source;
|
||||
video_stream_encoder_->SetSource(
|
||||
&source, webrtc::DegradationPreference::MAINTAIN_FRAMERATE);
|
||||
VerifyNoLimitation(source.sink_wants());
|
||||
EXPECT_THAT(source.sink_wants(), UnlimitedSinkWants());
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_resolution);
|
||||
|
||||
// Trigger adapt down, too small frame, expect no change.
|
||||
source.IncomingCapturedFrame(CreateFrame(1, kTooSmallWidth, kTooSmallHeight));
|
||||
WaitForEncodedFrame(1);
|
||||
video_stream_encoder_->TriggerCpuOveruse();
|
||||
VerifyFpsMaxResolutionMax(source.sink_wants());
|
||||
EXPECT_THAT(source.sink_wants(), FpsMaxResolutionMax());
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_resolution);
|
||||
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_cpu_adapt_changes);
|
||||
|
||||
@ -4265,7 +4286,7 @@ TEST_F(VideoStreamEncoderTest,
|
||||
test::FrameForwarder source;
|
||||
video_stream_encoder_->SetSource(&source,
|
||||
webrtc::DegradationPreference::BALANCED);
|
||||
VerifyNoLimitation(source.sink_wants());
|
||||
EXPECT_THAT(source.sink_wants(), UnlimitedSinkWants());
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution);
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_framerate);
|
||||
|
||||
@ -4273,7 +4294,7 @@ TEST_F(VideoStreamEncoderTest,
|
||||
source.IncomingCapturedFrame(CreateFrame(1, kTooSmallWidth, kTooSmallHeight));
|
||||
WaitForEncodedFrame(1);
|
||||
video_stream_encoder_->TriggerQualityLow();
|
||||
VerifyFpsEqResolutionMax(source.sink_wants(), kFpsLimit);
|
||||
EXPECT_THAT(source.sink_wants(), FpsMatchesResolutionMax(Eq(kFpsLimit)));
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution);
|
||||
EXPECT_TRUE(stats_proxy_->GetStats().bw_limited_framerate);
|
||||
EXPECT_EQ(1, stats_proxy_->GetStats().number_of_quality_adapt_changes);
|
||||
@ -4282,7 +4303,7 @@ TEST_F(VideoStreamEncoderTest,
|
||||
source.IncomingCapturedFrame(CreateFrame(2, kTooSmallWidth, kTooSmallHeight));
|
||||
WaitForEncodedFrame(2);
|
||||
video_stream_encoder_->TriggerQualityLow();
|
||||
VerifyFpsEqResolutionMax(source.sink_wants(), kFpsLimit);
|
||||
EXPECT_THAT(source.sink_wants(), FpsMatchesResolutionMax(Eq(kFpsLimit)));
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution);
|
||||
EXPECT_TRUE(stats_proxy_->GetStats().bw_limited_framerate);
|
||||
EXPECT_EQ(1, stats_proxy_->GetStats().number_of_quality_adapt_changes);
|
||||
@ -4478,7 +4499,8 @@ TEST_F(VideoStreamEncoderTest, DoesntAdaptDownPastMinFramerate) {
|
||||
} while (video_source_.sink_wants().max_framerate_fps <
|
||||
last_wants.max_framerate_fps);
|
||||
|
||||
VerifyFpsEqResolutionMax(video_source_.sink_wants(), kMinFramerateFps);
|
||||
EXPECT_THAT(video_source_.sink_wants(),
|
||||
FpsMatchesResolutionMax(Eq(kMinFramerateFps)));
|
||||
|
||||
video_stream_encoder_->Stop();
|
||||
}
|
||||
@ -4502,7 +4524,7 @@ TEST_F(VideoStreamEncoderTest,
|
||||
timestamp_ms += kFrameIntervalMs;
|
||||
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
|
||||
WaitForEncodedFrame(kWidth, kHeight);
|
||||
VerifyFpsMaxResolutionMax(source.sink_wants());
|
||||
EXPECT_THAT(source.sink_wants(), FpsMaxResolutionMax());
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution);
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_framerate);
|
||||
EXPECT_EQ(0, stats_proxy_->GetStats().number_of_quality_adapt_changes);
|
||||
@ -4512,7 +4534,8 @@ TEST_F(VideoStreamEncoderTest,
|
||||
timestamp_ms += kFrameIntervalMs;
|
||||
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
|
||||
WaitForEncodedFrame(timestamp_ms);
|
||||
VerifyFpsMaxResolutionLt(source.sink_wants(), kWidth * kHeight);
|
||||
EXPECT_THAT(source.sink_wants(),
|
||||
FpsMaxResolutionMatches(Lt(kWidth * kHeight)));
|
||||
EXPECT_TRUE(stats_proxy_->GetStats().bw_limited_resolution);
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_framerate);
|
||||
EXPECT_EQ(1, stats_proxy_->GetStats().number_of_quality_adapt_changes);
|
||||
@ -4654,14 +4677,14 @@ TEST_F(VideoStreamEncoderTest,
|
||||
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
|
||||
WaitForEncodedFrame(kWidth, kHeight);
|
||||
VerifyFpsMaxResolutionGt(source.sink_wants(), source.last_wants());
|
||||
VerifyFpsMaxResolutionMax(source.sink_wants());
|
||||
EXPECT_THAT(source.sink_wants(), FpsMaxResolutionMax());
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution);
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_framerate);
|
||||
EXPECT_EQ(14, stats_proxy_->GetStats().number_of_quality_adapt_changes);
|
||||
|
||||
// Trigger adapt up, expect no change.
|
||||
video_stream_encoder_->TriggerQualityHigh();
|
||||
VerifyFpsMaxResolutionMax(source.sink_wants());
|
||||
EXPECT_THAT(source.sink_wants(), FpsMaxResolutionMax());
|
||||
EXPECT_EQ(14, stats_proxy_->GetStats().number_of_quality_adapt_changes);
|
||||
|
||||
video_stream_encoder_->Stop();
|
||||
@ -4685,7 +4708,7 @@ TEST_F(VideoStreamEncoderTest, AdaptWithTwoReasonsAndDifferentOrder_Framerate) {
|
||||
timestamp_ms += kFrameIntervalMs;
|
||||
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
|
||||
WaitForEncodedFrame(kWidth, kHeight);
|
||||
VerifyFpsMaxResolutionMax(source.sink_wants());
|
||||
EXPECT_THAT(source.sink_wants(), FpsMaxResolutionMax());
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution);
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_framerate);
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_resolution);
|
||||
@ -4698,7 +4721,8 @@ TEST_F(VideoStreamEncoderTest, AdaptWithTwoReasonsAndDifferentOrder_Framerate) {
|
||||
timestamp_ms += kFrameIntervalMs;
|
||||
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
|
||||
WaitForEncodedFrame(timestamp_ms);
|
||||
VerifyFpsMaxResolutionLt(source.sink_wants(), kWidth * kHeight);
|
||||
EXPECT_THAT(source.sink_wants(),
|
||||
FpsMaxResolutionMatches(Lt(kWidth * kHeight)));
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution);
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_framerate);
|
||||
EXPECT_TRUE(stats_proxy_->GetStats().cpu_limited_resolution);
|
||||
@ -4764,7 +4788,7 @@ TEST_F(VideoStreamEncoderTest, AdaptWithTwoReasonsAndDifferentOrder_Framerate) {
|
||||
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
|
||||
WaitForEncodedFrame(kWidth, kHeight);
|
||||
VerifyFpsMaxResolutionGt(source.sink_wants(), source.last_wants());
|
||||
VerifyFpsMaxResolutionMax(source.sink_wants());
|
||||
EXPECT_THAT(source.sink_wants(), FpsMaxResolutionMax());
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution);
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_framerate);
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_resolution);
|
||||
@ -4774,7 +4798,7 @@ TEST_F(VideoStreamEncoderTest, AdaptWithTwoReasonsAndDifferentOrder_Framerate) {
|
||||
|
||||
// Trigger adapt up, expect no change.
|
||||
video_stream_encoder_->TriggerQualityHigh();
|
||||
VerifyFpsMaxResolutionMax(source.sink_wants());
|
||||
EXPECT_THAT(source.sink_wants(), FpsMaxResolutionMax());
|
||||
EXPECT_EQ(4, stats_proxy_->GetStats().number_of_cpu_adapt_changes);
|
||||
EXPECT_EQ(2, stats_proxy_->GetStats().number_of_quality_adapt_changes);
|
||||
|
||||
@ -4801,7 +4825,7 @@ TEST_F(VideoStreamEncoderTest,
|
||||
timestamp_ms += kFrameIntervalMs;
|
||||
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
|
||||
WaitForEncodedFrame(kWidth, kHeight);
|
||||
VerifyFpsMaxResolutionMax(source.sink_wants());
|
||||
EXPECT_THAT(source.sink_wants(), FpsMaxResolutionMax());
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution);
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_framerate);
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_resolution);
|
||||
@ -4814,7 +4838,7 @@ TEST_F(VideoStreamEncoderTest,
|
||||
timestamp_ms += kFrameIntervalMs;
|
||||
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
|
||||
WaitForEncodedFrame(timestamp_ms);
|
||||
VerifyFpsEqResolutionMax(source.sink_wants(), kFpsLimit);
|
||||
EXPECT_THAT(source.sink_wants(), FpsMatchesResolutionMax(Eq(kFpsLimit)));
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution);
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_framerate);
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_resolution);
|
||||
@ -4853,7 +4877,7 @@ TEST_F(VideoStreamEncoderTest,
|
||||
timestamp_ms += kFrameIntervalMs;
|
||||
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
|
||||
WaitForEncodedFrame(timestamp_ms);
|
||||
VerifyFpsMaxResolutionMax(source.sink_wants());
|
||||
EXPECT_THAT(source.sink_wants(), FpsMaxResolutionMax());
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution);
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_framerate);
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().cpu_limited_resolution);
|
||||
@ -4863,7 +4887,7 @@ TEST_F(VideoStreamEncoderTest,
|
||||
|
||||
// Trigger adapt up, expect no change.
|
||||
video_stream_encoder_->TriggerQualityHigh();
|
||||
VerifyFpsMaxResolutionMax(source.sink_wants());
|
||||
EXPECT_THAT(source.sink_wants(), FpsMaxResolutionMax());
|
||||
EXPECT_EQ(2, stats_proxy_->GetStats().number_of_cpu_adapt_changes);
|
||||
EXPECT_EQ(2, stats_proxy_->GetStats().number_of_quality_adapt_changes);
|
||||
|
||||
@ -5860,7 +5884,7 @@ TEST_F(VideoStreamEncoderTest, AutomaticAnimationDetection) {
|
||||
DataRate::BitsPerSec(kTargetBitrateBps), 0, 0, 0);
|
||||
video_stream_encoder_->SetSource(&video_source_,
|
||||
webrtc::DegradationPreference::BALANCED);
|
||||
VerifyNoLimitation(video_source_.sink_wants());
|
||||
EXPECT_THAT(video_source_.sink_wants(), UnlimitedSinkWants());
|
||||
|
||||
VideoFrame frame = CreateFrame(1, kWidth, kHeight);
|
||||
frame.set_update_rect(VideoFrame::UpdateRect{0, 0, kWidth, kHeight});
|
||||
@ -5892,7 +5916,8 @@ TEST_F(VideoStreamEncoderTest, AutomaticAnimationDetection) {
|
||||
WaitForEncodedFrame(timestamp_ms);
|
||||
|
||||
// Resolution should be unlimited now.
|
||||
VerifyFpsEqResolutionMax(video_source_.sink_wants(), kFramerateFps);
|
||||
EXPECT_THAT(video_source_.sink_wants(),
|
||||
FpsMatchesResolutionMax(Eq(kFramerateFps)));
|
||||
|
||||
video_stream_encoder_->Stop();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user