Removes usages of repeating task without task queue argument.

This prepares from removing the overload in a followup CL.

Bug: webrtc:10365
Change-Id: I80db16e7d37944e3dc7d2799bbf45ef8f439a22c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/126860
Reviewed-by: Åsa Persson <asapersson@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27091}
This commit is contained in:
Sebastian Jansson 2019-03-11 17:26:36 +01:00
parent e7a5f7bfae
commit cda86dd483
9 changed files with 37 additions and 25 deletions

View file

@ -68,13 +68,14 @@ class QualityScaler::QpSmoother {
rtc::ExpFilter smoother_; rtc::ExpFilter smoother_;
}; };
QualityScaler::QualityScaler(rtc::TaskQueue* task_queue,
QualityScaler::QualityScaler(AdaptationObserverInterface* observer, AdaptationObserverInterface* observer,
VideoEncoder::QpThresholds thresholds) VideoEncoder::QpThresholds thresholds)
: QualityScaler(observer, thresholds, kMeasureMs) {} : QualityScaler(task_queue, observer, thresholds, kMeasureMs) {}
// Protected ctor, should not be called directly. // Protected ctor, should not be called directly.
QualityScaler::QualityScaler(AdaptationObserverInterface* observer, QualityScaler::QualityScaler(rtc::TaskQueue* task_queue,
AdaptationObserverInterface* observer,
VideoEncoder::QpThresholds thresholds, VideoEncoder::QpThresholds thresholds,
int64_t sampling_period_ms) int64_t sampling_period_ms)
: observer_(observer), : observer_(observer),
@ -95,7 +96,7 @@ QualityScaler::QualityScaler(AdaptationObserverInterface* observer,
} }
RTC_DCHECK(observer_ != nullptr); RTC_DCHECK(observer_ != nullptr);
check_qp_task_ = RepeatingTaskHandle::DelayedStart( check_qp_task_ = RepeatingTaskHandle::DelayedStart(
TimeDelta::ms(GetSamplingPeriodMs()), [this]() { task_queue->Get(), TimeDelta::ms(GetSamplingPeriodMs()), [this]() {
CheckQp(); CheckQp();
return TimeDelta::ms(GetSamplingPeriodMs()); return TimeDelta::ms(GetSamplingPeriodMs());
}); });

View file

@ -19,6 +19,7 @@
#include "rtc_base/experiments/quality_scaling_experiment.h" #include "rtc_base/experiments/quality_scaling_experiment.h"
#include "rtc_base/numerics/moving_average.h" #include "rtc_base/numerics/moving_average.h"
#include "rtc_base/sequenced_task_checker.h" #include "rtc_base/sequenced_task_checker.h"
#include "rtc_base/task_queue.h"
#include "rtc_base/task_utils/repeating_task.h" #include "rtc_base/task_utils/repeating_task.h"
namespace webrtc { namespace webrtc {
@ -48,7 +49,8 @@ class QualityScaler {
// Construct a QualityScaler with given |thresholds| and |observer|. // Construct a QualityScaler with given |thresholds| and |observer|.
// This starts the quality scaler periodically checking what the average QP // This starts the quality scaler periodically checking what the average QP
// has been recently. // has been recently.
QualityScaler(AdaptationObserverInterface* observer, QualityScaler(rtc::TaskQueue* task_queue,
AdaptationObserverInterface* observer,
VideoEncoder::QpThresholds thresholds); VideoEncoder::QpThresholds thresholds);
virtual ~QualityScaler(); virtual ~QualityScaler();
// Should be called each time a frame is dropped at encoding. // Should be called each time a frame is dropped at encoding.
@ -59,7 +61,8 @@ class QualityScaler {
// The following members declared protected for testing purposes. // The following members declared protected for testing purposes.
protected: protected:
QualityScaler(AdaptationObserverInterface* observer, QualityScaler(rtc::TaskQueue* task_queue,
AdaptationObserverInterface* observer,
VideoEncoder::QpThresholds thresholds, VideoEncoder::QpThresholds thresholds,
int64_t sampling_period_ms); int64_t sampling_period_ms);

View file

@ -59,9 +59,10 @@ class MockAdaptationObserver : public AdaptationObserverInterface {
// Pass a lower sampling period to speed up the tests. // Pass a lower sampling period to speed up the tests.
class QualityScalerUnderTest : public QualityScaler { class QualityScalerUnderTest : public QualityScaler {
public: public:
explicit QualityScalerUnderTest(AdaptationObserverInterface* observer, explicit QualityScalerUnderTest(rtc::TaskQueue* task_queue,
AdaptationObserverInterface* observer,
VideoEncoder::QpThresholds thresholds) VideoEncoder::QpThresholds thresholds)
: QualityScaler(observer, thresholds, 5) {} : QualityScaler(task_queue, observer, thresholds, 5) {}
}; };
class QualityScalerTest : public ::testing::Test, class QualityScalerTest : public ::testing::Test,
@ -81,7 +82,8 @@ class QualityScalerTest : public ::testing::Test,
observer_(new MockAdaptationObserver()) { observer_(new MockAdaptationObserver()) {
DO_SYNC(q_, { DO_SYNC(q_, {
qs_ = std::unique_ptr<QualityScaler>(new QualityScalerUnderTest( qs_ = std::unique_ptr<QualityScaler>(new QualityScalerUnderTest(
observer_.get(), VideoEncoder::QpThresholds(kLowQp, kHighQp))); q_.get(), observer_.get(),
VideoEncoder::QpThresholds(kLowQp, kHighQp)));
}); });
} }

View file

@ -227,11 +227,12 @@ void PeerConnectionE2EQualityTest::Run(
task_queue_.PostTask([&stats_poller, this]() { task_queue_.PostTask([&stats_poller, this]() {
RTC_DCHECK_RUN_ON(&task_queue_); RTC_DCHECK_RUN_ON(&task_queue_);
stats_polling_task_ = RepeatingTaskHandle::Start([this, &stats_poller]() { stats_polling_task_ =
RTC_DCHECK_RUN_ON(&task_queue_); RepeatingTaskHandle::Start(task_queue_.Get(), [this, &stats_poller]() {
stats_poller.PollStatsAndNotifyObservers(); RTC_DCHECK_RUN_ON(&task_queue_);
return kStatsUpdateInterval; stats_poller.PollStatsAndNotifyObservers();
}); return kStatsUpdateInterval;
});
}); });
rtc::Event done; rtc::Event done;

View file

@ -538,6 +538,7 @@ OveruseFrameDetector::OveruseFrameDetector(
OveruseFrameDetector::~OveruseFrameDetector() {} OveruseFrameDetector::~OveruseFrameDetector() {}
void OveruseFrameDetector::StartCheckForOveruse( void OveruseFrameDetector::StartCheckForOveruse(
rtc::TaskQueue* task_queue,
const CpuOveruseOptions& options, const CpuOveruseOptions& options,
AdaptationObserverInterface* overuse_observer) { AdaptationObserverInterface* overuse_observer) {
RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_); RTC_DCHECK_CALLED_SEQUENTIALLY(&task_checker_);
@ -546,7 +547,8 @@ void OveruseFrameDetector::StartCheckForOveruse(
SetOptions(options); SetOptions(options);
check_overuse_task_ = RepeatingTaskHandle::DelayedStart( check_overuse_task_ = RepeatingTaskHandle::DelayedStart(
TimeDelta::ms(kTimeToFirstCheckForOveruseMs), [this, overuse_observer] { task_queue->Get(), TimeDelta::ms(kTimeToFirstCheckForOveruseMs),
[this, overuse_observer] {
CheckForOveruse(overuse_observer); CheckForOveruse(overuse_observer);
return TimeDelta::ms(kCheckForOveruseIntervalMs); return TimeDelta::ms(kCheckForOveruseIntervalMs);
}); });

View file

@ -57,7 +57,8 @@ class OveruseFrameDetector {
virtual ~OveruseFrameDetector(); virtual ~OveruseFrameDetector();
// Start to periodically check for overuse. // Start to periodically check for overuse.
void StartCheckForOveruse(const CpuOveruseOptions& options, void StartCheckForOveruse(rtc::TaskQueue* task_queue,
const CpuOveruseOptions& options,
AdaptationObserverInterface* overuse_observer); AdaptationObserverInterface* overuse_observer);
// StopCheckForOveruse must be called before destruction if // StopCheckForOveruse must be called before destruction if

View file

@ -428,8 +428,8 @@ TEST_F(OveruseFrameDetectorTest, RunOnTqNormalUsage) {
rtc::TaskQueue queue("OveruseFrameDetectorTestQueue"); rtc::TaskQueue queue("OveruseFrameDetectorTestQueue");
rtc::Event event; rtc::Event event;
queue.PostTask([this, &event] { queue.PostTask([this, &event, &queue] {
overuse_detector_->StartCheckForOveruse(options_, observer_); overuse_detector_->StartCheckForOveruse(&queue, options_, observer_);
event.Set(); event.Set();
}); });
event.Wait(rtc::Event::kForever); event.Wait(rtc::Event::kForever);
@ -908,8 +908,8 @@ TEST_F(OveruseFrameDetectorTest2, RunOnTqNormalUsage) {
rtc::TaskQueue queue("OveruseFrameDetectorTestQueue"); rtc::TaskQueue queue("OveruseFrameDetectorTestQueue");
rtc::Event event; rtc::Event event;
queue.PostTask([this, &event] { queue.PostTask([this, &event, &queue] {
overuse_detector_->StartCheckForOveruse(options_, observer_); overuse_detector_->StartCheckForOveruse(&queue, options_, observer_);
event.Set(); event.Set();
}); });
event.Wait(rtc::Event::kForever); event.Wait(rtc::Event::kForever);

View file

@ -390,8 +390,8 @@ void VideoSendStreamImpl::StartupVideoSendStream() {
activity_ = false; activity_ = false;
timed_out_ = false; timed_out_ = false;
check_encoder_activity_task_ = check_encoder_activity_task_ = RepeatingTaskHandle::DelayedStart(
RepeatingTaskHandle::DelayedStart(kEncoderTimeOut, [this] { worker_queue_->Get(), kEncoderTimeOut, [this] {
RTC_DCHECK_RUN_ON(worker_queue_); RTC_DCHECK_RUN_ON(worker_queue_);
if (!activity_) { if (!activity_) {
if (!timed_out_) { if (!timed_out_) {

View file

@ -741,6 +741,7 @@ void VideoStreamEncoder::ReconfigureEncoder() {
if (pending_encoder_creation_) { if (pending_encoder_creation_) {
overuse_detector_->StopCheckForOveruse(); overuse_detector_->StopCheckForOveruse();
overuse_detector_->StartCheckForOveruse( overuse_detector_->StartCheckForOveruse(
&encoder_queue_,
GetCpuOveruseOptions( GetCpuOveruseOptions(
settings_, encoder_->GetEncoderInfo().is_hardware_accelerated), settings_, encoder_->GetEncoderInfo().is_hardware_accelerated),
this); this);
@ -829,8 +830,9 @@ void VideoStreamEncoder::ConfigureQualityScaler(
// upcast. // upcast.
AdaptationObserverInterface* observer = this; AdaptationObserverInterface* observer = this;
quality_scaler_ = absl::make_unique<QualityScaler>( quality_scaler_ = absl::make_unique<QualityScaler>(
observer, experimental_thresholds ? *experimental_thresholds &encoder_queue_, observer,
: *(scaling_settings.thresholds)); experimental_thresholds ? *experimental_thresholds
: *(scaling_settings.thresholds));
has_seen_first_significant_bwe_change_ = false; has_seen_first_significant_bwe_change_ = false;
initial_framedrop_ = 0; initial_framedrop_ = 0;
} }