aboutsummaryrefslogtreecommitdiff
path: root/call/adaptation
diff options
context:
space:
mode:
authorEvan Shrubsole <eshr@google.com>2020-07-03 13:51:48 +0200
committerCommit Bot <commit-bot@chromium.org>2020-07-03 13:10:27 +0000
commit9492d500ddbdf77da7fdb260b78202636b65b3a6 (patch)
tree4fb46fdc53a9d86e1832c10a5cf01100ea6ad98a /call/adaptation
parentdb1c81d45b22ce5d7c0c2a17d6f7a2f6f27c8d67 (diff)
downloadwebrtc-9492d500ddbdf77da7fdb260b78202636b65b3a6.tar.gz
[Adaptation] Move deg.pref. out of ResourceAdaptationProcessor
This patch creates a new class which provides the DegradationPreference thread safe to all classes that need if (BalancedConstraint and QpScalerResource). It also broadcasts to all listeners when the preferences are updated, so the ResourceAdaptationProcessor can update the video if needed. In future work, this could be used to remove the need for two task queues for the VideoStreamEncoder resources. Bug: webrtc:11700 Change-Id: I05480db8b7157b5643f6f86ec9c64850839b3e76 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/177522 Commit-Queue: Evan Shrubsole <eshr@google.com> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31623}
Diffstat (limited to 'call/adaptation')
-rw-r--r--call/adaptation/BUILD.gn4
-rw-r--r--call/adaptation/degradation_preference_listener.cc17
-rw-r--r--call/adaptation/degradation_preference_listener.h28
-rw-r--r--call/adaptation/degradation_preference_provider.cc14
-rw-r--r--call/adaptation/degradation_preference_provider.h28
-rw-r--r--call/adaptation/resource_adaptation_processor.cc46
-rw-r--r--call/adaptation/resource_adaptation_processor.h17
-rw-r--r--call/adaptation/resource_adaptation_processor_interface.h11
-rw-r--r--call/adaptation/resource_adaptation_processor_unittest.cc66
-rw-r--r--call/adaptation/video_stream_adapter.h1
10 files changed, 142 insertions, 90 deletions
diff --git a/call/adaptation/BUILD.gn b/call/adaptation/BUILD.gn
index 055fc43782..d920fd27db 100644
--- a/call/adaptation/BUILD.gn
+++ b/call/adaptation/BUILD.gn
@@ -16,6 +16,10 @@ rtc_library("resource_adaptation") {
"adaptation_listener.h",
"broadcast_resource_listener.cc",
"broadcast_resource_listener.h",
+ "degradation_preference_listener.cc",
+ "degradation_preference_listener.h",
+ "degradation_preference_provider.cc",
+ "degradation_preference_provider.h",
"encoder_settings.cc",
"encoder_settings.h",
"resource_adaptation_processor.cc",
diff --git a/call/adaptation/degradation_preference_listener.cc b/call/adaptation/degradation_preference_listener.cc
new file mode 100644
index 0000000000..3425e59aa0
--- /dev/null
+++ b/call/adaptation/degradation_preference_listener.cc
@@ -0,0 +1,17 @@
+/*
+ * Copyright 2020 The WebRTC Project Authors. All rights reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include "call/adaptation/degradation_preference_listener.h"
+
+namespace webrtc {
+
+DegradationPreferenceListener::~DegradationPreferenceListener() = default;
+
+} // namespace webrtc
diff --git a/call/adaptation/degradation_preference_listener.h b/call/adaptation/degradation_preference_listener.h
new file mode 100644
index 0000000000..d085b220e8
--- /dev/null
+++ b/call/adaptation/degradation_preference_listener.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2020 The WebRTC Project Authors. All rights reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef CALL_ADAPTATION_DEGRADATION_PREFERENCE_LISTENER_H_
+#define CALL_ADAPTATION_DEGRADATION_PREFERENCE_LISTENER_H_
+
+#include "api/rtp_parameters.h"
+
+namespace webrtc {
+
+class DegradationPreferenceListener {
+ public:
+ virtual ~DegradationPreferenceListener();
+
+ virtual void OnDegradationPreferenceUpdated(
+ DegradationPreference degradation_preference) = 0;
+};
+
+} // namespace webrtc
+
+#endif // CALL_ADAPTATION_DEGRADATION_PREFERENCE_LISTENER_H_
diff --git a/call/adaptation/degradation_preference_provider.cc b/call/adaptation/degradation_preference_provider.cc
new file mode 100644
index 0000000000..c87e49f366
--- /dev/null
+++ b/call/adaptation/degradation_preference_provider.cc
@@ -0,0 +1,14 @@
+/*
+ * Copyright 2020 The WebRTC Project Authors. All rights reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include "call/adaptation/degradation_preference_provider.h"
+
+webrtc::DegradationPreferenceProvider::~DegradationPreferenceProvider() =
+ default;
diff --git a/call/adaptation/degradation_preference_provider.h b/call/adaptation/degradation_preference_provider.h
new file mode 100644
index 0000000000..035fed1e55
--- /dev/null
+++ b/call/adaptation/degradation_preference_provider.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2020 The WebRTC Project Authors. All rights reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef CALL_ADAPTATION_DEGRADATION_PREFERENCE_PROVIDER_H_
+#define CALL_ADAPTATION_DEGRADATION_PREFERENCE_PROVIDER_H_
+
+#include "api/rtp_parameters.h"
+
+namespace webrtc {
+
+// Thread-safe retrieval of degradation preferences.
+class DegradationPreferenceProvider {
+ public:
+ virtual ~DegradationPreferenceProvider();
+
+ virtual DegradationPreference degradation_preference() const = 0;
+};
+
+} // namespace webrtc
+
+#endif // CALL_ADAPTATION_DEGRADATION_PREFERENCE_PROVIDER_H_
diff --git a/call/adaptation/resource_adaptation_processor.cc b/call/adaptation/resource_adaptation_processor.cc
index 01322b913c..3f256b15d7 100644
--- a/call/adaptation/resource_adaptation_processor.cc
+++ b/call/adaptation/resource_adaptation_processor.cc
@@ -75,9 +75,7 @@ ResourceAdaptationProcessor::ResourceAdaptationProcessor(
new rtc::RefCountedObject<ResourceListenerDelegate>(this)),
encoder_stats_observer_(encoder_stats_observer),
resources_(),
- degradation_preference_(DegradationPreference::DISABLED),
effective_degradation_preference_(DegradationPreference::DISABLED),
- is_screenshare_(false),
stream_adapter_(stream_adapter),
last_reported_source_restrictions_(),
previous_mitigation_results_(),
@@ -112,18 +110,6 @@ void ResourceAdaptationProcessor::SetResourceAdaptationQueue(
stream_adapter_->AddRestrictionsListener(this);
}
-DegradationPreference ResourceAdaptationProcessor::degradation_preference()
- const {
- RTC_DCHECK_RUN_ON(resource_adaptation_queue_);
- return degradation_preference_;
-}
-
-DegradationPreference
-ResourceAdaptationProcessor::effective_degradation_preference() const {
- RTC_DCHECK_RUN_ON(resource_adaptation_queue_);
- return effective_degradation_preference_;
-}
-
void ResourceAdaptationProcessor::AddResourceLimitationsListener(
ResourceLimitationsListener* limitations_listener) {
RTC_DCHECK_RUN_ON(resource_adaptation_queue_);
@@ -215,26 +201,20 @@ void ResourceAdaptationProcessor::RemoveAdaptationListener(
adaptation_listeners_.erase(it);
}
-void ResourceAdaptationProcessor::SetDegradationPreference(
+void ResourceAdaptationProcessor::OnDegradationPreferenceUpdated(
DegradationPreference degradation_preference) {
+ if (!resource_adaptation_queue_->IsCurrent()) {
+ resource_adaptation_queue_->PostTask(
+ ToQueuedTask([this, degradation_preference]() {
+ OnDegradationPreferenceUpdated(degradation_preference);
+ }));
+ return;
+ }
RTC_DCHECK_RUN_ON(resource_adaptation_queue_);
- degradation_preference_ = degradation_preference;
- MaybeUpdateEffectiveDegradationPreference();
-}
-
-void ResourceAdaptationProcessor::SetIsScreenshare(bool is_screenshare) {
- RTC_DCHECK_RUN_ON(resource_adaptation_queue_);
- is_screenshare_ = is_screenshare;
- MaybeUpdateEffectiveDegradationPreference();
-}
-
-void ResourceAdaptationProcessor::MaybeUpdateEffectiveDegradationPreference() {
- RTC_DCHECK_RUN_ON(resource_adaptation_queue_);
- effective_degradation_preference_ =
- (is_screenshare_ &&
- degradation_preference_ == DegradationPreference::BALANCED)
- ? DegradationPreference::MAINTAIN_RESOLUTION
- : degradation_preference_;
+ if (degradation_preference == effective_degradation_preference_) {
+ return;
+ }
+ effective_degradation_preference_ = degradation_preference;
stream_adapter_->SetDegradationPreference(effective_degradation_preference_);
}
@@ -419,7 +399,7 @@ void ResourceAdaptationProcessor::TriggerAdaptationDueToFrameDroppedDueToSize(
VideoAdaptationCounters counters_before =
stream_adapter_->adaptation_counters();
OnResourceOveruse(reason_resource);
- if (degradation_preference_ == DegradationPreference::BALANCED &&
+ if (effective_degradation_preference_ == DegradationPreference::BALANCED &&
stream_adapter_->adaptation_counters().fps_adaptations >
counters_before.fps_adaptations) {
// Oops, we adapted frame rate. Adapt again, maybe it will adapt resolution!
diff --git a/call/adaptation/resource_adaptation_processor.h b/call/adaptation/resource_adaptation_processor.h
index 66f1300d3a..098050ddf8 100644
--- a/call/adaptation/resource_adaptation_processor.h
+++ b/call/adaptation/resource_adaptation_processor.h
@@ -26,6 +26,7 @@
#include "api/video/video_stream_encoder_observer.h"
#include "call/adaptation/adaptation_constraint.h"
#include "call/adaptation/adaptation_listener.h"
+#include "call/adaptation/degradation_preference_listener.h"
#include "call/adaptation/resource_adaptation_processor_interface.h"
#include "call/adaptation/video_source_restrictions.h"
#include "call/adaptation/video_stream_adapter.h"
@@ -52,7 +53,8 @@ namespace webrtc {
// i.e. the "resource adaptation task queue".
class ResourceAdaptationProcessor : public ResourceAdaptationProcessorInterface,
public VideoSourceRestrictionsListener,
- public ResourceListener {
+ public ResourceListener,
+ public DegradationPreferenceListener {
public:
ResourceAdaptationProcessor(
VideoStreamEncoderObserver* encoder_stats_observer,
@@ -63,9 +65,6 @@ class ResourceAdaptationProcessor : public ResourceAdaptationProcessorInterface,
TaskQueueBase* resource_adaptation_queue) override;
// ResourceAdaptationProcessorInterface implementation.
- DegradationPreference degradation_preference() const override;
- DegradationPreference effective_degradation_preference() const override;
-
void AddResourceLimitationsListener(
ResourceLimitationsListener* limitations_listener) override;
void RemoveResourceLimitationsListener(
@@ -81,10 +80,6 @@ class ResourceAdaptationProcessor : public ResourceAdaptationProcessorInterface,
void RemoveAdaptationListener(
AdaptationListener* adaptation_listener) override;
- void SetDegradationPreference(
- DegradationPreference degradation_preference) override;
- void SetIsScreenshare(bool is_screenshare) override;
-
// ResourceListener implementation.
// Triggers OnResourceUnderuse() or OnResourceOveruse().
void OnResourceUsageStateMeasured(rtc::scoped_refptr<Resource> resource,
@@ -96,6 +91,9 @@ class ResourceAdaptationProcessor : public ResourceAdaptationProcessorInterface,
const VideoAdaptationCounters& adaptation_counters,
rtc::scoped_refptr<Resource> reason,
const VideoSourceRestrictions& unfiltered_restrictions) override;
+ // DegradationPreferenceListener implementation.
+ void OnDegradationPreferenceUpdated(
+ DegradationPreference degradation_preference) override;
// May trigger 1-2 adaptations. It is meant to reduce resolution but this is
// not guaranteed. It may adapt frame rate, which does not address the issue.
@@ -190,11 +188,8 @@ class ResourceAdaptationProcessor : public ResourceAdaptationProcessorInterface,
adaptation_limits_by_resources_
RTC_GUARDED_BY(resource_adaptation_queue_);
// Adaptation strategy settings.
- DegradationPreference degradation_preference_
- RTC_GUARDED_BY(resource_adaptation_queue_);
DegradationPreference effective_degradation_preference_
RTC_GUARDED_BY(resource_adaptation_queue_);
- bool is_screenshare_ RTC_GUARDED_BY(resource_adaptation_queue_);
// Responsible for generating and applying possible adaptations.
VideoStreamAdapter* const stream_adapter_
RTC_GUARDED_BY(resource_adaptation_queue_);
diff --git a/call/adaptation/resource_adaptation_processor_interface.h b/call/adaptation/resource_adaptation_processor_interface.h
index bf6b19790b..e8cca26abb 100644
--- a/call/adaptation/resource_adaptation_processor_interface.h
+++ b/call/adaptation/resource_adaptation_processor_interface.h
@@ -51,13 +51,6 @@ class ResourceAdaptationProcessorInterface {
virtual void SetResourceAdaptationQueue(
TaskQueueBase* resource_adaptation_queue) = 0;
- virtual DegradationPreference degradation_preference() const = 0;
- // Reinterprets "balanced + screenshare" as "maintain-resolution".
- // TODO(hbos): Don't do this. This is not what "balanced" means. If the
- // application wants to maintain resolution it should set that degradation
- // preference rather than depend on non-standard behaviors.
- virtual DegradationPreference effective_degradation_preference() const = 0;
-
// Starts or stops listening to resources, effectively enabling or disabling
// processing.
// TODO(https://crbug.com/webrtc/11172): Automatically register and unregister
@@ -80,10 +73,6 @@ class ResourceAdaptationProcessorInterface {
virtual void RemoveAdaptationListener(
AdaptationListener* adaptation_listener) = 0;
- virtual void SetDegradationPreference(
- DegradationPreference degradation_preference) = 0;
- virtual void SetIsScreenshare(bool is_screenshare) = 0;
-
// May trigger one or more adaptations. It is meant to reduce resolution -
// useful if a frame was dropped due to its size - however, the implementation
// may not guarantee this (see resource_adaptation_processor.h).
diff --git a/call/adaptation/resource_adaptation_processor_unittest.cc b/call/adaptation/resource_adaptation_processor_unittest.cc
index e466c471f0..4e0f88524b 100644
--- a/call/adaptation/resource_adaptation_processor_unittest.cc
+++ b/call/adaptation/resource_adaptation_processor_unittest.cc
@@ -156,10 +156,6 @@ class ResourceAdaptationProcessorTest : public ::testing::Test {
} // namespace
TEST_F(ResourceAdaptationProcessorTest, DisabledByDefault) {
- EXPECT_EQ(DegradationPreference::DISABLED,
- processor_->degradation_preference());
- EXPECT_EQ(DegradationPreference::DISABLED,
- processor_->effective_degradation_preference());
SetInputStates(true, kDefaultFrameRate, kDefaultFrameSize);
// Adaptation does not happen when disabled.
resource_->SetUsageState(ResourceUsageState::kOveruse);
@@ -167,7 +163,7 @@ TEST_F(ResourceAdaptationProcessorTest, DisabledByDefault) {
}
TEST_F(ResourceAdaptationProcessorTest, InsufficientInput) {
- processor_->SetDegradationPreference(
+ processor_->OnDegradationPreferenceUpdated(
DegradationPreference::MAINTAIN_FRAMERATE);
// Adaptation does not happen if input is insufficient.
// When frame size is missing (OnFrameSizeObserved not called yet).
@@ -187,7 +183,7 @@ TEST_F(ResourceAdaptationProcessorTest, InsufficientInput) {
// restrictions. For that, see video_stream_adapter_unittest.cc.
TEST_F(ResourceAdaptationProcessorTest,
OveruseTriggersRestrictingResolutionInMaintainFrameRate) {
- processor_->SetDegradationPreference(
+ processor_->OnDegradationPreferenceUpdated(
DegradationPreference::MAINTAIN_FRAMERATE);
SetInputStates(true, kDefaultFrameRate, kDefaultFrameSize);
resource_->SetUsageState(ResourceUsageState::kOveruse);
@@ -198,7 +194,7 @@ TEST_F(ResourceAdaptationProcessorTest,
TEST_F(ResourceAdaptationProcessorTest,
OveruseTriggersRestrictingFrameRateInMaintainResolution) {
- processor_->SetDegradationPreference(
+ processor_->OnDegradationPreferenceUpdated(
DegradationPreference::MAINTAIN_RESOLUTION);
SetInputStates(true, kDefaultFrameRate, kDefaultFrameSize);
resource_->SetUsageState(ResourceUsageState::kOveruse);
@@ -209,7 +205,7 @@ TEST_F(ResourceAdaptationProcessorTest,
TEST_F(ResourceAdaptationProcessorTest,
OveruseTriggersRestrictingFrameRateAndResolutionInBalanced) {
- processor_->SetDegradationPreference(DegradationPreference::BALANCED);
+ processor_->OnDegradationPreferenceUpdated(DegradationPreference::BALANCED);
SetInputStates(true, kDefaultFrameRate, kDefaultFrameSize);
// Adapting multiple times eventually resticts both frame rate and
// resolution. Exactly many times we need to adapt depends on
@@ -227,7 +223,7 @@ TEST_F(ResourceAdaptationProcessorTest,
}
TEST_F(ResourceAdaptationProcessorTest, AwaitingPreviousAdaptation) {
- processor_->SetDegradationPreference(
+ processor_->OnDegradationPreferenceUpdated(
DegradationPreference::MAINTAIN_FRAMERATE);
SetInputStates(true, kDefaultFrameRate, kDefaultFrameSize);
resource_->SetUsageState(ResourceUsageState::kOveruse);
@@ -239,7 +235,7 @@ TEST_F(ResourceAdaptationProcessorTest, AwaitingPreviousAdaptation) {
}
TEST_F(ResourceAdaptationProcessorTest, CannotAdaptUpWhenUnrestricted) {
- processor_->SetDegradationPreference(
+ processor_->OnDegradationPreferenceUpdated(
DegradationPreference::MAINTAIN_FRAMERATE);
SetInputStates(true, kDefaultFrameRate, kDefaultFrameSize);
resource_->SetUsageState(ResourceUsageState::kUnderuse);
@@ -247,7 +243,7 @@ TEST_F(ResourceAdaptationProcessorTest, CannotAdaptUpWhenUnrestricted) {
}
TEST_F(ResourceAdaptationProcessorTest, UnderuseTakesUsBackToUnrestricted) {
- processor_->SetDegradationPreference(
+ processor_->OnDegradationPreferenceUpdated(
DegradationPreference::MAINTAIN_FRAMERATE);
SetInputStates(true, kDefaultFrameRate, kDefaultFrameSize);
resource_->SetUsageState(ResourceUsageState::kOveruse);
@@ -259,7 +255,7 @@ TEST_F(ResourceAdaptationProcessorTest, UnderuseTakesUsBackToUnrestricted) {
}
TEST_F(ResourceAdaptationProcessorTest, ResourcesCanPreventAdaptingUp) {
- processor_->SetDegradationPreference(
+ processor_->OnDegradationPreferenceUpdated(
DegradationPreference::MAINTAIN_FRAMERATE);
SetInputStates(true, kDefaultFrameRate, kDefaultFrameSize);
// Adapt down so that we can adapt up.
@@ -274,7 +270,7 @@ TEST_F(ResourceAdaptationProcessorTest, ResourcesCanPreventAdaptingUp) {
TEST_F(ResourceAdaptationProcessorTest,
ResourcesCanNotAdaptUpIfNeverAdaptedDown) {
- processor_->SetDegradationPreference(
+ processor_->OnDegradationPreferenceUpdated(
DegradationPreference::MAINTAIN_FRAMERATE);
SetInputStates(true, kDefaultFrameRate, kDefaultFrameSize);
resource_->SetUsageState(ResourceUsageState::kOveruse);
@@ -288,7 +284,7 @@ TEST_F(ResourceAdaptationProcessorTest,
TEST_F(ResourceAdaptationProcessorTest,
ResourcesCanNotAdaptUpIfNotAdaptedDownAfterReset) {
- processor_->SetDegradationPreference(
+ processor_->OnDegradationPreferenceUpdated(
DegradationPreference::MAINTAIN_FRAMERATE);
SetInputStates(true, kDefaultFrameRate, kDefaultFrameSize);
resource_->SetUsageState(ResourceUsageState::kOveruse);
@@ -307,7 +303,7 @@ TEST_F(ResourceAdaptationProcessorTest,
}
TEST_F(ResourceAdaptationProcessorTest, OnlyMostLimitedResourceMayAdaptUp) {
- processor_->SetDegradationPreference(
+ processor_->OnDegradationPreferenceUpdated(
DegradationPreference::MAINTAIN_FRAMERATE);
SetInputStates(true, kDefaultFrameRate, kDefaultFrameSize);
resource_->SetUsageState(ResourceUsageState::kOveruse);
@@ -337,7 +333,7 @@ TEST_F(ResourceAdaptationProcessorTest, OnlyMostLimitedResourceMayAdaptUp) {
TEST_F(ResourceAdaptationProcessorTest,
MultipleResourcesCanTriggerMultipleAdaptations) {
- processor_->SetDegradationPreference(
+ processor_->OnDegradationPreferenceUpdated(
DegradationPreference::MAINTAIN_FRAMERATE);
SetInputStates(true, kDefaultFrameRate, kDefaultFrameSize);
resource_->SetUsageState(ResourceUsageState::kOveruse);
@@ -395,7 +391,7 @@ TEST_F(ResourceAdaptationProcessorTest,
TEST_F(ResourceAdaptationProcessorTest,
MostLimitedResourceAdaptationWorksAfterChangingDegradataionPreference) {
- processor_->SetDegradationPreference(
+ processor_->OnDegradationPreferenceUpdated(
DegradationPreference::MAINTAIN_FRAMERATE);
SetInputStates(true, kDefaultFrameRate, kDefaultFrameSize);
// Adapt down until we can't anymore.
@@ -411,7 +407,7 @@ TEST_F(ResourceAdaptationProcessorTest,
RestrictSource(restrictions_listener_.restrictions());
int last_total = restrictions_listener_.adaptation_counters().Total();
- processor_->SetDegradationPreference(
+ processor_->OnDegradationPreferenceUpdated(
DegradationPreference::MAINTAIN_RESOLUTION);
// resource_ can not adapt up since we have never reduced FPS.
resource_->SetUsageState(ResourceUsageState::kUnderuse);
@@ -427,7 +423,7 @@ TEST_F(ResourceAdaptationProcessorTest,
}
TEST_F(ResourceAdaptationProcessorTest, AdaptingTriggersOnAdaptationApplied) {
- processor_->SetDegradationPreference(
+ processor_->OnDegradationPreferenceUpdated(
DegradationPreference::MAINTAIN_FRAMERATE);
SetInputStates(true, kDefaultFrameRate, kDefaultFrameSize);
resource_->SetUsageState(ResourceUsageState::kOveruse);
@@ -436,7 +432,7 @@ TEST_F(ResourceAdaptationProcessorTest, AdaptingTriggersOnAdaptationApplied) {
TEST_F(ResourceAdaptationProcessorTest,
AdaptsDownWhenOtherResourceIsAlwaysUnderused) {
- processor_->SetDegradationPreference(
+ processor_->OnDegradationPreferenceUpdated(
DegradationPreference::MAINTAIN_FRAMERATE);
SetInputStates(true, kDefaultFrameRate, kDefaultFrameSize);
other_resource_->SetUsageState(ResourceUsageState::kUnderuse);
@@ -457,7 +453,7 @@ TEST_F(ResourceAdaptationProcessorTest,
TEST_F(ResourceAdaptationProcessorTest,
TriggerOveruseNotOnAdaptationTaskQueue) {
- processor_->SetDegradationPreference(
+ processor_->OnDegradationPreferenceUpdated(
DegradationPreference::MAINTAIN_FRAMERATE);
SetInputStates(true, kDefaultFrameRate, kDefaultFrameSize);
@@ -471,7 +467,7 @@ TEST_F(ResourceAdaptationProcessorTest,
TEST_F(ResourceAdaptationProcessorTest,
DestroyProcessorWhileResourceListenerDelegateHasTaskInFlight) {
- processor_->SetDegradationPreference(
+ processor_->OnDegradationPreferenceUpdated(
DegradationPreference::MAINTAIN_FRAMERATE);
SetInputStates(true, kDefaultFrameRate, kDefaultFrameSize);
@@ -495,7 +491,7 @@ TEST_F(ResourceAdaptationProcessorTest,
TEST_F(ResourceAdaptationProcessorTest,
ResourceOveruseIgnoredWhenSignalledDuringRemoval) {
- processor_->SetDegradationPreference(
+ processor_->OnDegradationPreferenceUpdated(
DegradationPreference::MAINTAIN_FRAMERATE);
SetInputStates(true, kDefaultFrameRate, kDefaultFrameSize);
@@ -524,7 +520,7 @@ TEST_F(ResourceAdaptationProcessorTest,
TEST_F(ResourceAdaptationProcessorTest,
RemovingOnlyAdaptedResourceResetsAdaptation) {
- processor_->SetDegradationPreference(
+ processor_->OnDegradationPreferenceUpdated(
DegradationPreference::MAINTAIN_FRAMERATE);
SetInputStates(true, kDefaultFrameRate, kDefaultFrameSize);
@@ -541,7 +537,7 @@ TEST_F(ResourceAdaptationProcessorTest,
TEST_F(ResourceAdaptationProcessorTest,
RemovingMostLimitedResourceSetsAdaptationToNextLimitedLevel) {
- processor_->SetDegradationPreference(DegradationPreference::BALANCED);
+ processor_->OnDegradationPreferenceUpdated(DegradationPreference::BALANCED);
SetInputStates(true, kDefaultFrameRate, kDefaultFrameSize);
other_resource_->SetUsageState(ResourceUsageState::kOveruse);
@@ -569,7 +565,7 @@ TEST_F(ResourceAdaptationProcessorTest,
TEST_F(ResourceAdaptationProcessorTest,
RemovingMostLimitedResourceSetsAdaptationIfInputStateUnchanged) {
- processor_->SetDegradationPreference(
+ processor_->OnDegradationPreferenceUpdated(
DegradationPreference::MAINTAIN_FRAMERATE);
SetInputStates(true, kDefaultFrameRate, kDefaultFrameSize);
@@ -606,7 +602,7 @@ TEST_F(ResourceAdaptationProcessorTest,
TEST_F(ResourceAdaptationProcessorTest,
RemovingResourceNotMostLimitedHasNoEffectOnLimitations) {
- processor_->SetDegradationPreference(DegradationPreference::BALANCED);
+ processor_->OnDegradationPreferenceUpdated(DegradationPreference::BALANCED);
SetInputStates(true, kDefaultFrameRate, kDefaultFrameSize);
other_resource_->SetUsageState(ResourceUsageState::kOveruse);
@@ -632,7 +628,7 @@ TEST_F(ResourceAdaptationProcessorTest,
TEST_F(ResourceAdaptationProcessorTest,
RemovingMostLimitedResourceAfterSwitchingDegradationPreferences) {
- processor_->SetDegradationPreference(
+ processor_->OnDegradationPreferenceUpdated(
DegradationPreference::MAINTAIN_FRAMERATE);
SetInputStates(true, kDefaultFrameRate, kDefaultFrameSize);
@@ -644,7 +640,7 @@ TEST_F(ResourceAdaptationProcessorTest,
VideoAdaptationCounters next_limited_counters =
restrictions_listener_.adaptation_counters();
- processor_->SetDegradationPreference(
+ processor_->OnDegradationPreferenceUpdated(
DegradationPreference::MAINTAIN_RESOLUTION);
resource_->SetUsageState(ResourceUsageState::kOveruse);
RestrictSource(restrictions_listener_.restrictions());
@@ -658,7 +654,7 @@ TEST_F(ResourceAdaptationProcessorTest,
// After switching back to MAINTAIN_FRAMERATE, the next most limited settings
// are restored.
- processor_->SetDegradationPreference(
+ processor_->OnDegradationPreferenceUpdated(
DegradationPreference::MAINTAIN_FRAMERATE);
EXPECT_EQ(next_limited_restrictions, restrictions_listener_.restrictions());
@@ -668,7 +664,7 @@ TEST_F(ResourceAdaptationProcessorTest,
TEST_F(ResourceAdaptationProcessorTest,
RemovingMostLimitedResourceSetsNextLimitationsInDisabled) {
- processor_->SetDegradationPreference(
+ processor_->OnDegradationPreferenceUpdated(
DegradationPreference::MAINTAIN_FRAMERATE);
SetInputStates(true, kDefaultFrameRate, kDefaultFrameSize);
@@ -683,7 +679,7 @@ TEST_F(ResourceAdaptationProcessorTest,
RestrictSource(restrictions_listener_.restrictions());
EXPECT_EQ(2, restrictions_listener_.adaptation_counters().Total());
- processor_->SetDegradationPreference(DegradationPreference::DISABLED);
+ processor_->OnDegradationPreferenceUpdated(DegradationPreference::DISABLED);
// Revert to |other_resource_| when removing |resource_| even though the
// current degradataion preference is disabled.
@@ -691,7 +687,7 @@ TEST_F(ResourceAdaptationProcessorTest,
// After switching back to MAINTAIN_FRAMERATE, the next most limited settings
// are restored.
- processor_->SetDegradationPreference(
+ processor_->OnDegradationPreferenceUpdated(
DegradationPreference::MAINTAIN_FRAMERATE);
EXPECT_EQ(next_limited_restrictions, restrictions_listener_.restrictions());
EXPECT_EQ(next_limited_counters,
@@ -703,7 +699,7 @@ TEST_F(ResourceAdaptationProcessorTest,
TEST_F(ResourceAdaptationProcessorTest,
RemovedResourceSignalsIgnoredByProcessor) {
- processor_->SetDegradationPreference(
+ processor_->OnDegradationPreferenceUpdated(
DegradationPreference::MAINTAIN_FRAMERATE);
SetInputStates(true, kDefaultFrameRate, kDefaultFrameSize);
@@ -717,7 +713,7 @@ TEST_F(ResourceAdaptationProcessorTest,
TEST_F(ResourceAdaptationProcessorTest,
RemovingResourceWhenMultipleMostLimtedHasNoEffect) {
- processor_->SetDegradationPreference(
+ processor_->OnDegradationPreferenceUpdated(
DegradationPreference::MAINTAIN_FRAMERATE);
SetInputStates(true, kDefaultFrameRate, kDefaultFrameSize);
diff --git a/call/adaptation/video_stream_adapter.h b/call/adaptation/video_stream_adapter.h
index 216c36c2bd..df334785ec 100644
--- a/call/adaptation/video_stream_adapter.h
+++ b/call/adaptation/video_stream_adapter.h
@@ -18,6 +18,7 @@
#include "api/adaptation/resource.h"
#include "api/rtp_parameters.h"
#include "api/video/video_adaptation_counters.h"
+#include "call/adaptation/degradation_preference_provider.h"
#include "call/adaptation/video_source_restrictions.h"
#include "call/adaptation/video_stream_input_state.h"
#include "call/adaptation/video_stream_input_state_provider.h"