[Adaptation] Make resource most limited if kLimitReached hit

This occurs when a resource causes an adaptation down but the current
adaptations can not be adapted any more. Any further adaptation will result in the status kLimitReached,
and so any resource that adapts down should also be most limited.

Bug: webrtc:11695
Change-Id: Idfdf23f482b1b4a132cec49a9be76adc0aec4361
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/181586
Commit-Queue: Evan Shrubsole <eshr@google.com>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31933}
This commit is contained in:
Evan Shrubsole
2020-08-14 10:08:54 +02:00
committed by Commit Bot
parent dd9db8c23a
commit bd4a718667
2 changed files with 32 additions and 0 deletions

View File

@ -305,6 +305,13 @@ ResourceAdaptationProcessor::OnResourceOveruse(
if (adaptation.min_pixel_limit_reached()) {
encoder_stats_observer_->OnMinPixelLimitReached();
}
if (adaptation.status() == Adaptation::Status::kLimitReached) {
// Add resource as most limited.
VideoStreamAdapter::RestrictionsWithCounters restrictions;
std::tie(std::ignore, restrictions) = FindMostLimitedResources();
UpdateResourceLimitations(reason_resource, restrictions.restrictions,
restrictions.counters);
}
if (adaptation.status() != Adaptation::Status::kValid) {
rtc::StringBuilder message;
message << "Not adapting down because VideoStreamAdapter returned "

View File

@ -709,4 +709,29 @@ TEST_F(ResourceAdaptationProcessorTest,
resource_ = nullptr;
}
TEST_F(ResourceAdaptationProcessorTest,
ResourceOverusedAtLimitReachedWillShareMostLimited) {
video_stream_adapter_->SetDegradationPreference(
DegradationPreference::MAINTAIN_FRAMERATE);
SetInputStates(true, kDefaultFrameRate, kDefaultFrameSize);
bool has_reached_min_pixels = false;
ON_CALL(frame_rate_provider_, OnMinPixelLimitReached())
.WillByDefault(testing::Assign(&has_reached_min_pixels, true));
// Adapt 10 times, which should make us hit the limit.
for (int i = 0; i < 10; ++i) {
resource_->SetUsageState(ResourceUsageState::kOveruse);
RestrictSource(restrictions_listener_.restrictions());
}
EXPECT_TRUE(has_reached_min_pixels);
auto last_update_count = restrictions_listener_.restrictions_updated_count();
other_resource_->SetUsageState(ResourceUsageState::kOveruse);
// Now both |resource_| and |other_resource_| are most limited. Underuse of
// |resource_| will not adapt up.
resource_->SetUsageState(ResourceUsageState::kUnderuse);
EXPECT_EQ(last_update_count,
restrictions_listener_.restrictions_updated_count());
}
} // namespace webrtc