Refactor out VideoStreamEncoder's overuse logic to separate module.

This CL puts the VideoStreamEncoder's current adaptation logic inside
the new class OveruseFrameDetectorResourceAdaptationModule. The
intention is not to change any behavior, only to move code.

Future CLs should step by step decrease the coupling between
OveruseFrameDetectorResourceAdaptationModule, VideoStreamEncoder and
the VideoStreamEncoder's QualityScaler by introducing more abstract
interfaces. This is not done in this CL because it is large enough as
it is, but the long term goal is to make it possible to replace the
existing overuse module with a different implementation.

This CL relies on existing tests exercising the VideoStreamEncoder, but
part of making overuse logic modular should include testing each module
separately as well as continued integration testing of the
VideoStreamEncoder.

Bug: webrtc:11222
Change-Id: I316a174adfd00d60cdd224a23a5f616efd235d13
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/161953
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Reviewed-by: Evan Shrubsole <eshr@google.com>
Cr-Commit-Position: refs/heads/master@{#30163}
This commit is contained in:
Henrik Boström
2020-01-07 10:11:17 +01:00
committed by Commit Bot
parent 29e14e6aae
commit b08882b625
6 changed files with 1257 additions and 844 deletions

View File

@ -155,17 +155,20 @@ class VideoStreamEncoderUnderTest : public VideoStreamEncoder {
new CpuOveruseDetectorProxy(stats_proxy)),
task_queue_factory) {}
void PostTaskAndWait(bool down, AdaptReason reason) {
void PostTaskAndWait(bool down,
AdaptationObserverInterface::AdaptReason reason) {
PostTaskAndWait(down, reason, /*expected_results=*/true);
}
void PostTaskAndWait(bool down, AdaptReason reason, bool expected_results) {
void PostTaskAndWait(bool down,
AdaptationObserverInterface::AdaptReason reason,
bool expected_results) {
rtc::Event event;
encoder_queue()->PostTask([this, &event, reason, down, expected_results] {
if (down)
EXPECT_EQ(expected_results, AdaptDown(reason));
EXPECT_EQ(expected_results, TriggerAdaptDown(reason));
else
AdaptUp(reason);
TriggerAdaptUp(reason);
event.Set();
});
ASSERT_TRUE(event.Wait(5000));
@ -180,24 +183,29 @@ class VideoStreamEncoderUnderTest : public VideoStreamEncoder {
}
void TriggerCpuOveruse() {
PostTaskAndWait(/*down=*/true, AdaptReason::kCpu);
PostTaskAndWait(/*down=*/true,
AdaptationObserverInterface::AdaptReason::kCpu);
}
void TriggerCpuNormalUsage() {
PostTaskAndWait(/*down=*/false, AdaptReason::kCpu);
PostTaskAndWait(/*down=*/false,
AdaptationObserverInterface::AdaptReason::kCpu);
}
void TriggerQualityLow() {
PostTaskAndWait(/*down=*/true, AdaptReason::kQuality);
PostTaskAndWait(/*down=*/true,
AdaptationObserverInterface::AdaptReason::kQuality);
}
void TriggerQualityLowExpectFalse() {
PostTaskAndWait(/*down=*/true, AdaptReason::kQuality,
PostTaskAndWait(/*down=*/true,
AdaptationObserverInterface::AdaptReason::kQuality,
/*expected_results=*/false);
}
void TriggerQualityHigh() {
PostTaskAndWait(/*down=*/false, AdaptReason::kQuality);
PostTaskAndWait(/*down=*/false,
AdaptationObserverInterface::AdaptReason::kQuality);
}
CpuOveruseDetectorProxy* overuse_detector_proxy_;