This CL changes EncodeUsageResource and QualityScalerResource from private inner classes of OveruseFrameDetectorResourceAdaptationModule to standalone classes, moving them into separate files. This CL does not intend to change any lines of code, only move them. Except for removing an unused method quality_scaler(). Bug: webrtc:11222 Change-Id: I86bf7eb78c80031888c403ac43c2bdf9b24eaea6 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168198 Reviewed-by: Evan Shrubsole <eshr@google.com> Reviewed-by: Erik Språng <sprang@webrtc.org> Commit-Queue: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30472}
77 lines
2.4 KiB
C++
77 lines
2.4 KiB
C++
/*
|
|
* 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 "video/quality_scaler_resource.h"
|
|
|
|
#include <utility>
|
|
|
|
namespace webrtc {
|
|
|
|
QualityScalerResource::QualityScalerResource() : quality_scaler_(nullptr) {}
|
|
|
|
bool QualityScalerResource::is_started() const {
|
|
return quality_scaler_.get();
|
|
}
|
|
|
|
void QualityScalerResource::StartCheckForOveruse(
|
|
VideoEncoder::QpThresholds qp_thresholds) {
|
|
RTC_DCHECK(!is_started());
|
|
quality_scaler_ =
|
|
std::make_unique<QualityScaler>(this, std::move(qp_thresholds));
|
|
}
|
|
|
|
void QualityScalerResource::StopCheckForOveruse() {
|
|
quality_scaler_.reset();
|
|
}
|
|
|
|
void QualityScalerResource::SetQpThresholds(
|
|
VideoEncoder::QpThresholds qp_thresholds) {
|
|
RTC_DCHECK(is_started());
|
|
quality_scaler_->SetQpThresholds(std::move(qp_thresholds));
|
|
}
|
|
|
|
bool QualityScalerResource::QpFastFilterLow() {
|
|
RTC_DCHECK(is_started());
|
|
return quality_scaler_->QpFastFilterLow();
|
|
}
|
|
|
|
void QualityScalerResource::OnEncodeCompleted(const EncodedImage& encoded_image,
|
|
int64_t time_sent_in_us) {
|
|
if (quality_scaler_ && encoded_image.qp_ >= 0)
|
|
quality_scaler_->ReportQp(encoded_image.qp_, time_sent_in_us);
|
|
}
|
|
|
|
void QualityScalerResource::OnFrameDropped(
|
|
EncodedImageCallback::DropReason reason) {
|
|
if (!quality_scaler_)
|
|
return;
|
|
switch (reason) {
|
|
case EncodedImageCallback::DropReason::kDroppedByMediaOptimizations:
|
|
quality_scaler_->ReportDroppedFrameByMediaOpt();
|
|
break;
|
|
case EncodedImageCallback::DropReason::kDroppedByEncoder:
|
|
quality_scaler_->ReportDroppedFrameByEncoder();
|
|
break;
|
|
}
|
|
}
|
|
|
|
void QualityScalerResource::AdaptUp(AdaptReason reason) {
|
|
RTC_DCHECK_EQ(reason, AdaptReason::kQuality);
|
|
OnResourceUsageStateMeasured(ResourceUsageState::kUnderuse);
|
|
}
|
|
|
|
bool QualityScalerResource::AdaptDown(AdaptReason reason) {
|
|
RTC_DCHECK_EQ(reason, AdaptReason::kQuality);
|
|
return OnResourceUsageStateMeasured(ResourceUsageState::kOveruse) !=
|
|
ResourceListenerResponse::kQualityScalerShouldIncreaseFrequency;
|
|
}
|
|
|
|
} // namespace webrtc
|