[Adaptation] Don't toggle EncoderUsageResource on/off

Instead it should be ensured that it is started with the correct config.
This removes confusion regarding a resource state. If the resource
check is stopped then the adaptations for that resource should be
removed, and there is no way to determine that if we have one method for
stop for both reconfigure and shutdown.

Bug: webrtc:11843
Change-Id: I491f2fd1f4f803a4610124c7b0026ad75ab4a9cc
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/181368
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Evan Shrubsole <eshr@google.com>
Cr-Commit-Position: refs/heads/master@{#31913}
This commit is contained in:
Evan Shrubsole 2020-08-11 15:13:03 +02:00 committed by Commit Bot
parent c45b65a951
commit 552eed534c
3 changed files with 6 additions and 7 deletions

View File

@ -336,10 +336,12 @@ VideoStreamEncoderResourceManager::degradation_preference() const {
return degradation_preference_;
}
void VideoStreamEncoderResourceManager::StartEncodeUsageResource() {
void VideoStreamEncoderResourceManager::EnsureEncodeUsageResourceStarted() {
RTC_DCHECK_RUN_ON(encoder_queue_);
RTC_DCHECK(!encode_usage_resource_->is_started());
RTC_DCHECK(encoder_settings_.has_value());
if (encode_usage_resource_->is_started()) {
encode_usage_resource_->StopCheckForOveruse();
}
encode_usage_resource_->StartCheckForOveruse(GetCpuOveruseOptions());
}

View File

@ -89,9 +89,7 @@ class VideoStreamEncoderResourceManager
void SetDegradationPreferences(DegradationPreference degradation_preference);
DegradationPreference degradation_preference() const;
// Starts the encode usage resource. The quality scaler resource is
// automatically started on being configured.
void StartEncodeUsageResource();
void EnsureEncodeUsageResourceStarted();
// Stops the encode usage and quality scaler resources if not already stopped.
void StopManagedResources();

View File

@ -841,8 +841,7 @@ void VideoStreamEncoder::ReconfigureEncoder() {
// We may be able to change this to "EnsureStarted()" if it took care of
// reconfiguring the QualityScaler as well. (ConfigureQualityScaler() is
// invoked later in this method.)
stream_resource_manager_.StopManagedResources();
stream_resource_manager_.StartEncodeUsageResource();
stream_resource_manager_.EnsureEncodeUsageResourceStarted();
pending_encoder_creation_ = false;
}