Remove unused overuse detection metric (capture jitter).

BUG=
R=pbos@webrtc.org, stefan@webrtc.org

Review URL: https://codereview.webrtc.org/1250593002 .

Cr-Commit-Position: refs/heads/master@{#9881}
This commit is contained in:
Åsa Persson 2015-09-08 10:52:42 +02:00
parent 3dfe5d3d41
commit 746210f46d
3 changed files with 62 additions and 289 deletions

View File

@ -24,16 +24,9 @@
namespace webrtc {
// TODO(mflodman) Test different values for all of these to trigger correctly,
// avoid fluctuations etc.
namespace {
const int64_t kProcessIntervalMs = 5000;
// Weight factor to apply to the standard deviation.
const float kWeightFactor = 0.997f;
// Weight factor to apply to the average.
const float kWeightFactorMean = 0.98f;
// Delay between consecutive rampups. (Used for quick recovery.)
const int kQuickRampUpDelayMs = 10 * 1000;
// Delay between rampup attempts. Initially uses standard, scales up to max.
@ -51,63 +44,6 @@ const float kMaxExp = 7.0f;
} // namespace
// TODO(asapersson): Remove this class. Not used.
Statistics::Statistics(const CpuOveruseOptions& options)
: sum_(0.0),
count_(0),
options_(options),
filtered_samples_(new rtc::ExpFilter(kWeightFactorMean)),
filtered_variance_(new rtc::ExpFilter(kWeightFactor)) {
Reset();
}
void Statistics::Reset() {
sum_ = 0.0;
count_ = 0;
filtered_variance_->Reset(kWeightFactor);
filtered_variance_->Apply(1.0f, InitialVariance());
}
void Statistics::AddSample(float sample_ms) {
sum_ += sample_ms;
++count_;
if (count_ < static_cast<uint32_t>(options_.min_frame_samples)) {
// Initialize filtered samples.
filtered_samples_->Reset(kWeightFactorMean);
filtered_samples_->Apply(1.0f, InitialMean());
return;
}
float exp = sample_ms / kSampleDiffMs;
exp = std::min(exp, kMaxExp);
filtered_samples_->Apply(exp, sample_ms);
filtered_variance_->Apply(exp, (sample_ms - filtered_samples_->filtered()) *
(sample_ms - filtered_samples_->filtered()));
}
float Statistics::InitialMean() const {
if (count_ == 0)
return 0.0;
return sum_ / count_;
}
float Statistics::InitialVariance() const {
// Start in between the underuse and overuse threshold.
float average_stddev = (options_.low_capture_jitter_threshold_ms +
options_.high_capture_jitter_threshold_ms) / 2.0f;
return average_stddev * average_stddev;
}
float Statistics::Mean() const { return filtered_samples_->filtered(); }
float Statistics::StdDev() const {
return sqrt(std::max(filtered_variance_->filtered(), 0.0f));
}
uint64_t Statistics::Count() const { return count_; }
// Class for calculating the average encode time.
class OveruseFrameDetector::EncodeTimeAvg {
public:
@ -265,7 +201,6 @@ OveruseFrameDetector::OveruseFrameDetector(
clock_(clock),
next_process_time_(clock_->TimeInMilliseconds()),
num_process_times_(0),
capture_deltas_(options),
last_capture_time_(0),
last_overuse_time_(0),
checks_above_threshold_(0),
@ -301,7 +236,6 @@ int OveruseFrameDetector::FramesInQueue() const {
}
void OveruseFrameDetector::UpdateCpuOveruseMetrics() {
metrics_.capture_jitter_ms = static_cast<int>(capture_deltas_.StdDev() + 0.5);
metrics_.avg_encode_time_ms = encode_time_->Value();
metrics_.encode_usage_percent = usage_->Value();
@ -329,7 +263,6 @@ bool OveruseFrameDetector::FrameTimeoutDetected(int64_t now) const {
void OveruseFrameDetector::ResetAll(int num_pixels) {
num_pixels_ = num_pixels;
capture_deltas_.Reset();
usage_->Reset();
frame_queue_->Reset();
last_capture_time_ = 0;
@ -347,16 +280,14 @@ void OveruseFrameDetector::FrameCaptured(int width,
ResetAll(width * height);
}
if (last_capture_time_ != 0) {
capture_deltas_.AddSample(now - last_capture_time_);
if (last_capture_time_ != 0)
usage_->AddCaptureSample(now - last_capture_time_);
}
last_capture_time_ = now;
if (options_.enable_extended_processing_usage) {
frame_queue_->Start(capture_time_ms, now);
}
UpdateCpuOveruseMetrics();
}
void OveruseFrameDetector::FrameEncoded(int encode_time_ms) {
@ -449,9 +380,7 @@ int32_t OveruseFrameDetector::Process() {
int rampup_delay =
in_quick_rampup_ ? kQuickRampUpDelayMs : current_rampup_delay_ms_;
LOG(LS_VERBOSE) << " Frame stats: capture avg: " << capture_deltas_.Mean()
<< " capture stddev " << capture_deltas_.StdDev()
<< " encode usage " << usage_->Value()
LOG(LS_VERBOSE) << " Frame stats: encode usage: " << usage_->Value()
<< " overuse detections " << num_overuse_detections_
<< " rampup delay " << rampup_delay;
@ -460,12 +389,8 @@ int32_t OveruseFrameDetector::Process() {
bool OveruseFrameDetector::IsOverusing() {
bool overusing = false;
if (options_.enable_capture_jitter_method) {
overusing = capture_deltas_.StdDev() >=
options_.high_capture_jitter_threshold_ms;
} else if (options_.enable_encode_usage_method) {
if (options_.enable_encode_usage_method)
overusing = usage_->Value() >= options_.high_encode_usage_threshold_percent;
}
if (overusing) {
++checks_above_threshold_;
@ -481,12 +406,9 @@ bool OveruseFrameDetector::IsUnderusing(int64_t time_now) {
return false;
bool underusing = false;
if (options_.enable_capture_jitter_method) {
underusing = capture_deltas_.StdDev() <
options_.low_capture_jitter_threshold_ms;
} else if (options_.enable_encode_usage_method) {
if (options_.enable_encode_usage_method)
underusing = usage_->Value() < options_.low_encode_usage_threshold_percent;
}
return underusing;
}
} // namespace webrtc

View File

@ -38,35 +38,19 @@ class CpuOveruseObserver {
struct CpuOveruseOptions {
CpuOveruseOptions()
: enable_capture_jitter_method(false),
low_capture_jitter_threshold_ms(20.0f),
high_capture_jitter_threshold_ms(30.0f),
enable_encode_usage_method(true),
: enable_encode_usage_method(true),
low_encode_usage_threshold_percent(55),
high_encode_usage_threshold_percent(85),
low_encode_time_rsd_threshold(-1),
high_encode_time_rsd_threshold(-1),
enable_extended_processing_usage(true),
frame_timeout_interval_ms(1500),
min_frame_samples(120),
min_process_count(3),
high_threshold_consecutive_count(2) {}
// Method based on inter-arrival jitter of captured frames.
bool enable_capture_jitter_method;
float low_capture_jitter_threshold_ms; // Threshold for triggering underuse.
float high_capture_jitter_threshold_ms; // Threshold for triggering overuse.
// Method based on encode time of frames.
bool enable_encode_usage_method;
int low_encode_usage_threshold_percent; // Threshold for triggering underuse.
int high_encode_usage_threshold_percent; // Threshold for triggering overuse.
// TODO(asapersson): Remove options, not used.
int low_encode_time_rsd_threshold; // Additional threshold for triggering
// underuse (used in addition to
// threshold above if configured).
int high_encode_time_rsd_threshold; // Additional threshold for triggering
// overuse (used in addition to
// threshold above if configured).
bool enable_extended_processing_usage; // Include a larger time span (in
// addition to encode time) for
// measuring the processing time of a
@ -80,36 +64,13 @@ struct CpuOveruseOptions {
int high_threshold_consecutive_count; // The number of consecutive checks
// above the high threshold before
// triggering an overuse.
bool Equals(const CpuOveruseOptions& o) const {
return enable_capture_jitter_method == o.enable_capture_jitter_method &&
low_capture_jitter_threshold_ms == o.low_capture_jitter_threshold_ms &&
high_capture_jitter_threshold_ms ==
o.high_capture_jitter_threshold_ms &&
enable_encode_usage_method == o.enable_encode_usage_method &&
low_encode_usage_threshold_percent ==
o.low_encode_usage_threshold_percent &&
high_encode_usage_threshold_percent ==
o.high_encode_usage_threshold_percent &&
low_encode_time_rsd_threshold == o.low_encode_time_rsd_threshold &&
high_encode_time_rsd_threshold == o.high_encode_time_rsd_threshold &&
enable_extended_processing_usage ==
o.enable_extended_processing_usage &&
frame_timeout_interval_ms == o.frame_timeout_interval_ms &&
min_frame_samples == o.min_frame_samples &&
min_process_count == o.min_process_count &&
high_threshold_consecutive_count == o.high_threshold_consecutive_count;
}
};
struct CpuOveruseMetrics {
CpuOveruseMetrics()
: capture_jitter_ms(-1),
avg_encode_time_ms(-1),
: avg_encode_time_ms(-1),
encode_usage_percent(-1) {}
int capture_jitter_ms; // The current estimated jitter in ms based on
// incoming captured frames.
int avg_encode_time_ms; // The average encode time in ms.
int encode_usage_percent; // The average encode time divided by the average
// time difference between incoming captured frames.
@ -121,30 +82,9 @@ class CpuOveruseMetricsObserver {
virtual void CpuOveruseMetricsUpdated(const CpuOveruseMetrics& metrics) = 0;
};
// TODO(pbos): Move this somewhere appropriate.
class Statistics {
public:
explicit Statistics(const CpuOveruseOptions& options);
void AddSample(float sample_ms);
void Reset();
float Mean() const;
float StdDev() const;
uint64_t Count() const;
private:
float InitialMean() const;
float InitialVariance() const;
float sum_;
uint64_t count_;
const CpuOveruseOptions options_;
rtc::scoped_ptr<rtc::ExpFilter> filtered_samples_;
rtc::scoped_ptr<rtc::ExpFilter> filtered_variance_;
};
// Use to detect system overuse based on jitter in incoming frames.
// Use to detect system overuse based on the send-side processing time of
// incoming frames.
class OveruseFrameDetector : public Module {
public:
OveruseFrameDetector(Clock* clock,
@ -212,7 +152,6 @@ class OveruseFrameDetector : public Module {
int64_t next_process_time_; // Only accessed on the processing thread.
int64_t num_process_times_ GUARDED_BY(crit_);
Statistics capture_deltas_ GUARDED_BY(crit_);
int64_t last_capture_time_ GUARDED_BY(crit_);
// These six members are only accessed on the processing thread.

View File

@ -22,6 +22,7 @@ namespace {
const int kHeight = 480;
const int kFrameInterval33ms = 33;
const int kProcessIntervalMs = 5000;
const int kProcessTime5ms = 5;
} // namespace
class MockCpuOveruseObserver : public CpuOveruseObserver {
@ -53,8 +54,6 @@ class OveruseFrameDetectorTest : public ::testing::Test,
virtual void SetUp() {
clock_.reset(new SimulatedClock(1234));
observer_.reset(new MockCpuOveruseObserver());
options_.low_capture_jitter_threshold_ms = 10.0f;
options_.high_capture_jitter_threshold_ms = 15.0f;
options_.min_process_count = 0;
ReinitializeOveruseDetector();
}
@ -68,25 +67,11 @@ class OveruseFrameDetectorTest : public ::testing::Test,
metrics_ = metrics;
}
int InitialJitter() {
return ((options_.low_capture_jitter_threshold_ms +
options_.high_capture_jitter_threshold_ms) / 2.0f) + 0.5;
}
int InitialUsage() {
return ((options_.low_encode_usage_threshold_percent +
options_.high_encode_usage_threshold_percent) / 2.0f) + 0.5;
}
void InsertFramesWithInterval(
size_t num_frames, int interval_ms, int width, int height) {
while (num_frames-- > 0) {
clock_->AdvanceTimeMilliseconds(interval_ms);
overuse_detector_->FrameCaptured(width, height,
clock_->TimeInMilliseconds());
}
}
void InsertAndSendFramesWithInterval(
int num_frames, int interval_ms, int width, int height, int delay_ms) {
while (num_frames-- > 0) {
@ -100,19 +85,6 @@ class OveruseFrameDetectorTest : public ::testing::Test,
}
void TriggerOveruse(int num_times) {
for (int i = 0; i < num_times; ++i) {
InsertFramesWithInterval(200, kFrameInterval33ms, kWidth, kHeight);
InsertFramesWithInterval(50, 110, kWidth, kHeight);
overuse_detector_->Process();
}
}
void TriggerUnderuse() {
InsertFramesWithInterval(900, kFrameInterval33ms, kWidth, kHeight);
overuse_detector_->Process();
}
void TriggerOveruseWithProcessingUsage(int num_times) {
const int kDelayMs = 32;
for (int i = 0; i < num_times; ++i) {
InsertAndSendFramesWithInterval(
@ -121,7 +93,7 @@ class OveruseFrameDetectorTest : public ::testing::Test,
}
}
void TriggerUnderuseWithProcessingUsage() {
void TriggerUnderuse() {
const int kDelayMs1 = 5;
const int kDelayMs2 = 6;
InsertAndSendFramesWithInterval(
@ -131,8 +103,6 @@ class OveruseFrameDetectorTest : public ::testing::Test,
overuse_detector_->Process();
}
int CaptureJitterMs() { return metrics_.capture_jitter_ms; }
int AvgEncodeTimeMs() { return metrics_.avg_encode_time_ms; }
int UsagePercent() { return metrics_.encode_usage_percent; }
@ -144,35 +114,31 @@ class OveruseFrameDetectorTest : public ::testing::Test,
CpuOveruseMetrics metrics_;
};
// enable_capture_jitter_method = true;
// CaptureJitterMs() > high_capture_jitter_threshold_ms => overuse.
// CaptureJitterMs() < low_capture_jitter_threshold_ms => underuse.
// enable_encode_usage_method = true;
// enable_extended_processing_usage = false;
// UsagePercent() > high_encode_usage_threshold_percent => overuse.
// UsagePercent() < low_encode_usage_threshold_percent => underuse.
TEST_F(OveruseFrameDetectorTest, TriggerOveruse) {
options_.enable_capture_jitter_method = true;
options_.enable_encode_usage_method = false;
options_.enable_extended_processing_usage = false;
ReinitializeOveruseDetector();
// capture_jitter > high => overuse
// usage > high => overuse
EXPECT_CALL(*(observer_.get()), OveruseDetected()).Times(1);
TriggerOveruse(options_.high_threshold_consecutive_count);
}
TEST_F(OveruseFrameDetectorTest, OveruseAndRecover) {
options_.enable_capture_jitter_method = true;
options_.enable_encode_usage_method = false;
options_.enable_extended_processing_usage = false;
ReinitializeOveruseDetector();
// capture_jitter > high => overuse
// usage > high => overuse
EXPECT_CALL(*(observer_.get()), OveruseDetected()).Times(1);
TriggerOveruse(options_.high_threshold_consecutive_count);
// capture_jitter < low => underuse
// usage < low => underuse
EXPECT_CALL(*(observer_.get()), NormalUsage()).Times(testing::AtLeast(1));
TriggerUnderuse();
}
TEST_F(OveruseFrameDetectorTest, OveruseAndRecoverWithNoObserver) {
options_.enable_capture_jitter_method = true;
options_.enable_encode_usage_method = false;
options_.enable_extended_processing_usage = false;
overuse_detector_.reset(
new OveruseFrameDetector(clock_.get(), options_, nullptr, this));
@ -183,7 +149,6 @@ TEST_F(OveruseFrameDetectorTest, OveruseAndRecoverWithNoObserver) {
}
TEST_F(OveruseFrameDetectorTest, OveruseAndRecoverWithMethodDisabled) {
options_.enable_capture_jitter_method = false;
options_.enable_encode_usage_method = false;
options_.enable_extended_processing_usage = false;
ReinitializeOveruseDetector();
@ -194,8 +159,6 @@ TEST_F(OveruseFrameDetectorTest, OveruseAndRecoverWithMethodDisabled) {
}
TEST_F(OveruseFrameDetectorTest, DoubleOveruseAndRecover) {
options_.enable_capture_jitter_method = true;
options_.enable_encode_usage_method = false;
options_.enable_extended_processing_usage = false;
ReinitializeOveruseDetector();
EXPECT_CALL(*(observer_.get()), OveruseDetected()).Times(2);
@ -206,14 +169,13 @@ TEST_F(OveruseFrameDetectorTest, DoubleOveruseAndRecover) {
}
TEST_F(OveruseFrameDetectorTest, TriggerUnderuseWithMinProcessCount) {
options_.enable_capture_jitter_method = true;
options_.enable_encode_usage_method = false;
options_.enable_extended_processing_usage = false;
options_.min_process_count = 1;
CpuOveruseObserverImpl overuse_observer;
overuse_detector_.reset(new OveruseFrameDetector(clock_.get(), options_,
&overuse_observer, this));
InsertFramesWithInterval(1200, kFrameInterval33ms, kWidth, kHeight);
InsertAndSendFramesWithInterval(
1200, kFrameInterval33ms, kWidth, kHeight, kProcessTime5ms);
overuse_detector_->Process();
EXPECT_EQ(0, overuse_observer.normaluse_);
clock_->AdvanceTimeMilliseconds(kProcessIntervalMs);
@ -222,8 +184,6 @@ TEST_F(OveruseFrameDetectorTest, TriggerUnderuseWithMinProcessCount) {
}
TEST_F(OveruseFrameDetectorTest, ConstantOveruseGivesNoNormalUsage) {
options_.enable_capture_jitter_method = true;
options_.enable_encode_usage_method = false;
options_.enable_extended_processing_usage = false;
ReinitializeOveruseDetector();
EXPECT_CALL(*(observer_.get()), NormalUsage()).Times(0);
@ -235,8 +195,6 @@ TEST_F(OveruseFrameDetectorTest, ConstantOveruseGivesNoNormalUsage) {
TEST_F(OveruseFrameDetectorTest, ConsecutiveCountTriggersOveruse) {
EXPECT_CALL(*(observer_.get()), OveruseDetected()).Times(1);
options_.enable_capture_jitter_method = true;
options_.enable_encode_usage_method = false;
options_.enable_extended_processing_usage = false;
options_.high_threshold_consecutive_count = 2;
ReinitializeOveruseDetector();
@ -245,47 +203,57 @@ TEST_F(OveruseFrameDetectorTest, ConsecutiveCountTriggersOveruse) {
TEST_F(OveruseFrameDetectorTest, IncorrectConsecutiveCountTriggersNoOveruse) {
EXPECT_CALL(*(observer_.get()), OveruseDetected()).Times(0);
options_.enable_capture_jitter_method = true;
options_.enable_encode_usage_method = false;
options_.enable_extended_processing_usage = false;
options_.high_threshold_consecutive_count = 2;
ReinitializeOveruseDetector();
TriggerOveruse(1);
}
TEST_F(OveruseFrameDetectorTest, CaptureJitter) {
EXPECT_EQ(InitialJitter(), CaptureJitterMs());
InsertFramesWithInterval(1000, kFrameInterval33ms, kWidth, kHeight);
EXPECT_NE(InitialJitter(), CaptureJitterMs());
TEST_F(OveruseFrameDetectorTest, ProcessingUsage) {
InsertAndSendFramesWithInterval(
1000, kFrameInterval33ms, kWidth, kHeight, kProcessTime5ms);
EXPECT_EQ(kProcessTime5ms * 100 / kFrameInterval33ms, UsagePercent());
}
TEST_F(OveruseFrameDetectorTest, CaptureJitterResetAfterResolutionChange) {
EXPECT_EQ(InitialJitter(), CaptureJitterMs());
InsertFramesWithInterval(1000, kFrameInterval33ms, kWidth, kHeight);
EXPECT_NE(InitialJitter(), CaptureJitterMs());
TEST_F(OveruseFrameDetectorTest, ResetAfterResolutionChange) {
EXPECT_EQ(InitialUsage(), UsagePercent());
InsertAndSendFramesWithInterval(
1000, kFrameInterval33ms, kWidth, kHeight, kProcessTime5ms);
EXPECT_NE(InitialUsage(), UsagePercent());
// Verify reset.
InsertFramesWithInterval(1, kFrameInterval33ms, kWidth, kHeight + 1);
EXPECT_EQ(InitialJitter(), CaptureJitterMs());
InsertAndSendFramesWithInterval(
1, kFrameInterval33ms, kWidth, kHeight + 1, kProcessTime5ms);
EXPECT_EQ(InitialUsage(), UsagePercent());
}
TEST_F(OveruseFrameDetectorTest, CaptureJitterResetAfterFrameTimeout) {
EXPECT_EQ(InitialJitter(), CaptureJitterMs());
InsertFramesWithInterval(1000, kFrameInterval33ms, kWidth, kHeight);
EXPECT_NE(InitialJitter(), CaptureJitterMs());
InsertFramesWithInterval(
1, options_.frame_timeout_interval_ms, kWidth, kHeight);
EXPECT_NE(InitialJitter(), CaptureJitterMs());
TEST_F(OveruseFrameDetectorTest, ResetAfterFrameTimeout) {
EXPECT_EQ(InitialUsage(), UsagePercent());
InsertAndSendFramesWithInterval(
1000, kFrameInterval33ms, kWidth, kHeight, kProcessTime5ms);
EXPECT_NE(InitialUsage(), UsagePercent());
InsertAndSendFramesWithInterval(
2, options_.frame_timeout_interval_ms, kWidth, kHeight, kProcessTime5ms);
EXPECT_NE(InitialUsage(), UsagePercent());
// Verify reset.
InsertFramesWithInterval(
1, options_.frame_timeout_interval_ms + 1, kWidth, kHeight);
EXPECT_EQ(InitialJitter(), CaptureJitterMs());
InsertAndSendFramesWithInterval(
2, options_.frame_timeout_interval_ms + 1, kWidth, kHeight,
kProcessTime5ms);
EXPECT_EQ(InitialUsage(), UsagePercent());
}
TEST_F(OveruseFrameDetectorTest, MinFrameSamplesBeforeUpdatingCaptureJitter) {
TEST_F(OveruseFrameDetectorTest, MinFrameSamplesBeforeUpdating) {
options_.min_frame_samples = 40;
ReinitializeOveruseDetector();
InsertFramesWithInterval(40, kFrameInterval33ms, kWidth, kHeight);
EXPECT_EQ(InitialJitter(), CaptureJitterMs());
InsertAndSendFramesWithInterval(
40, kFrameInterval33ms, kWidth, kHeight, kProcessTime5ms);
EXPECT_EQ(InitialUsage(), UsagePercent());
InsertAndSendFramesWithInterval(
1, kFrameInterval33ms, kWidth, kHeight, kProcessTime5ms);
EXPECT_NE(InitialUsage(), UsagePercent());
}
TEST_F(OveruseFrameDetectorTest, InitialProcessingUsage) {
EXPECT_EQ(InitialUsage(), UsagePercent());
}
TEST_F(OveruseFrameDetectorTest, FrameDelay_OneFrameDisabled) {
@ -398,96 +366,40 @@ TEST_F(OveruseFrameDetectorTest, EncodedFrame) {
EXPECT_EQ(2, AvgEncodeTimeMs());
}
TEST_F(OveruseFrameDetectorTest, InitialProcessingUsage) {
EXPECT_EQ(InitialUsage(), UsagePercent());
}
TEST_F(OveruseFrameDetectorTest, ProcessingUsage) {
const int kProcessingTimeMs = 5;
InsertAndSendFramesWithInterval(
1000, kFrameInterval33ms, kWidth, kHeight, kProcessingTimeMs);
EXPECT_EQ(kProcessingTimeMs * 100 / kFrameInterval33ms, UsagePercent());
}
// enable_encode_usage_method = true;
// UsagePercent() > high_encode_usage_threshold_percent => overuse.
// UsagePercent() < low_encode_usage_threshold_percent => underuse.
TEST_F(OveruseFrameDetectorTest, TriggerOveruseWithProcessingUsage) {
options_.enable_capture_jitter_method = false;
options_.enable_encode_usage_method = true;
options_.enable_extended_processing_usage = false;
ReinitializeOveruseDetector();
// usage > high => overuse
EXPECT_CALL(*(observer_.get()), OveruseDetected()).Times(1);
TriggerOveruseWithProcessingUsage(options_.high_threshold_consecutive_count);
}
TEST_F(OveruseFrameDetectorTest, OveruseAndRecoverWithProcessingUsage) {
options_.enable_capture_jitter_method = false;
options_.enable_encode_usage_method = true;
options_.enable_extended_processing_usage = false;
ReinitializeOveruseDetector();
// usage > high => overuse
EXPECT_CALL(*(observer_.get()), OveruseDetected()).Times(1);
TriggerOveruseWithProcessingUsage(options_.high_threshold_consecutive_count);
// usage < low => underuse
EXPECT_CALL(*(observer_.get()), NormalUsage()).Times(testing::AtLeast(1));
TriggerUnderuseWithProcessingUsage();
}
TEST_F(OveruseFrameDetectorTest,
OveruseAndRecoverWithProcessingUsageMethodDisabled) {
options_.enable_capture_jitter_method = false;
options_.enable_encode_usage_method = false;
options_.enable_extended_processing_usage = false;
ReinitializeOveruseDetector();
// usage > high => overuse
EXPECT_CALL(*(observer_.get()), OveruseDetected()).Times(0);
TriggerOveruseWithProcessingUsage(options_.high_threshold_consecutive_count);
// usage < low => underuse
EXPECT_CALL(*(observer_.get()), NormalUsage()).Times(0);
TriggerUnderuseWithProcessingUsage();
}
// enable_extended_processing_usage = true;
// enable_encode_usage_method = true;
// UsagePercent() > high_encode_usage_threshold_percent => overuse.
// UsagePercent() < low_encode_usage_threshold_percent => underuse.
TEST_F(OveruseFrameDetectorTest, TriggerOveruseWithExtendedProcessingUsage) {
options_.enable_capture_jitter_method = false;
options_.enable_encode_usage_method = true;
options_.enable_extended_processing_usage = true;
ReinitializeOveruseDetector();
// usage > high => overuse
EXPECT_CALL(*(observer_.get()), OveruseDetected()).Times(1);
TriggerOveruseWithProcessingUsage(options_.high_threshold_consecutive_count);
TriggerOveruse(options_.high_threshold_consecutive_count);
}
TEST_F(OveruseFrameDetectorTest, OveruseAndRecoverWithExtendedProcessingUsage) {
options_.enable_capture_jitter_method = false;
options_.enable_encode_usage_method = true;
options_.enable_extended_processing_usage = true;
ReinitializeOveruseDetector();
// usage > high => overuse
EXPECT_CALL(*(observer_.get()), OveruseDetected()).Times(1);
TriggerOveruseWithProcessingUsage(options_.high_threshold_consecutive_count);
TriggerOveruse(options_.high_threshold_consecutive_count);
// usage < low => underuse
EXPECT_CALL(*(observer_.get()), NormalUsage()).Times(testing::AtLeast(1));
TriggerUnderuseWithProcessingUsage();
TriggerUnderuse();
}
TEST_F(OveruseFrameDetectorTest,
OveruseAndRecoverWithExtendedProcessingUsageMethodDisabled) {
options_.enable_capture_jitter_method = false;
options_.enable_encode_usage_method = false;
options_.enable_extended_processing_usage = true;
ReinitializeOveruseDetector();
// usage > high => overuse
EXPECT_CALL(*(observer_.get()), OveruseDetected()).Times(0);
TriggerOveruseWithProcessingUsage(options_.high_threshold_consecutive_count);
TriggerOveruse(options_.high_threshold_consecutive_count);
// usage < low => underuse
EXPECT_CALL(*(observer_.get()), NormalUsage()).Times(0);
TriggerUnderuseWithProcessingUsage();
TriggerUnderuse();
}
} // namespace webrtc