[Adaptation] Make ResourceUsageState nullable, remove kStable.

This CL is part of the Call-Level Adaptation Processing design doc:
https://docs.google.com/document/d/1ZyC26yOCknrrcYa839ZWLxD6o6Gig5A3lVTh4E41074/edit?usp=sharing

The ResourceUsageState was written as: {kOveruse, kStable, kUnderuse}.
The assumption was that if a resource neither wanted to adapt up or
down it would report kStable. But with the addition of
Resource::IsAdaptationUpAllowed() (prior CL) the notion of being
"stable" was already captured outside of ResourceUsageState.
Furthermore, kStable failed to capture what IsAdaptationUpAllowed() did
not: whether we can go up depends on the resulting resolution or frame
rate (restrictions_after). Perhaps we can go up a little, but not a lot.

This CL also adds Resource::ClearUsageState(). After applying an
adaptation, all usage states become invalidated (new measurements are
needed to know if we are still over- or underusing). This was always
the case, but prior to this CL this was not accurately reflected in the
Resource::usage_state() in-between measurements.

Bug: webrtc:11172
Change-Id: I140ff3114025b7732e530564690783e168d2509b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/173088
Reviewed-by: Evan Shrubsole <eshr@google.com>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31110}
This commit is contained in:
Henrik Boström
2020-04-20 12:04:12 +02:00
committed by Commit Bot
parent 4c3a7dbe14
commit dc4f75f7ee
7 changed files with 55 additions and 71 deletions

View File

@ -159,12 +159,9 @@ class VideoStreamEncoderUnderTest : public VideoStreamEncoder {
overuse_detector_proxy_ =
new CpuOveruseDetectorProxy(stats_proxy)),
task_queue_factory),
fake_cpu_resource_(
std::make_unique<FakeResource>(ResourceUsageState::kStable,
"FakeResource[CPU]")),
fake_cpu_resource_(std::make_unique<FakeResource>("FakeResource[CPU]")),
fake_quality_resource_(
std::make_unique<FakeResource>(ResourceUsageState::kStable,
"FakeResource[QP]")) {
std::make_unique<FakeResource>("FakeResource[QP]")) {
InjectAdaptationResource(fake_quality_resource_.get(),
VideoAdaptationReason::kQuality);
InjectAdaptationResource(fake_cpu_resource_.get(),