Skip to content

Commit

Permalink
[Adaptation] Make QuailtyScalerResourse to report underuse if quality…
Browse files Browse the repository at this point in the history
… scaling is off

Bug: chromium:1080789
Change-Id: I3aefb746fd6f4adae4b32db322af6b787e8ede1d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174804
Commit-Queue: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Evan Shrubsole <eshr@google.com>
Cr-Commit-Position: refs/heads/master@{#31213}
  • Loading branch information
Ilya Nikolaevskiy authored and Commit Bot committed May 11, 2020
1 parent a270250 commit 8e321cd
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
22 changes: 22 additions & 0 deletions call/adaptation/resource_adaptation_processor_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -325,4 +325,26 @@ TEST_F(ResourceAdaptationProcessorTest,
EXPECT_FALSE(resource_.usage_state().has_value());
}

TEST_F(ResourceAdaptationProcessorTest,
AdaptsDownWhenOtherResourceIsAlwaysUnderused) {
processor_.SetDegradationPreference(
DegradationPreference::MAINTAIN_FRAMERATE);
processor_.StartResourceAdaptation();
SetInputStates(true, kDefaultFrameRate, kDefaultFrameSize);
other_resource_.set_usage_state(ResourceUsageState::kUnderuse);
// Does not trigger adapataion because there's no restriction.
EXPECT_EQ(0, processor_listener_.adaptation_counters().Total());

RestrictSource(processor_listener_.restrictions());
resource_.set_usage_state(ResourceUsageState::kOveruse);
// Adapts down even if other resource asked for adapting up.
EXPECT_EQ(1, processor_listener_.adaptation_counters().Total());

RestrictSource(processor_listener_.restrictions());
other_resource_.set_usage_state(ResourceUsageState::kUnderuse);
// Doesn't adapt up because adaptation is due to another resource.
EXPECT_EQ(1, processor_listener_.adaptation_counters().Total());
RestrictSource(processor_listener_.restrictions());
}

} // namespace webrtc
10 changes: 9 additions & 1 deletion video/adaptation/quality_scaler_resource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,16 @@ bool QualityScalerResource::QpFastFilterLow() {

void QualityScalerResource::OnEncodeCompleted(const EncodedImage& encoded_image,
int64_t time_sent_in_us) {
if (quality_scaler_ && encoded_image.qp_ >= 0)
if (quality_scaler_ && encoded_image.qp_ >= 0) {
quality_scaler_->ReportQp(encoded_image.qp_, time_sent_in_us);
} else if (!quality_scaler_) {
// TODO(webrtc:11553): this is a workaround to ensure that all quality
// scaler imposed limitations are removed once qualty scaler is disabled
// mid call.
// Instead it should be done at a higher layer in the same way for all
// resources.
OnResourceUsageStateMeasured(ResourceUsageState::kUnderuse);
}
}

void QualityScalerResource::OnFrameDropped(
Expand Down

0 comments on commit 8e321cd

Please sign in to comment.