Tolerate out of order samples to SendProcessingUsage2::FrameSent.
Bug: chromium:842613 Change-Id: I57e4df75dcfdfb9bf42819f31d2186e875a90a3a Reviewed-on: https://webrtc-review.googlesource.com/92880 Commit-Queue: Niels Moller <nisse@webrtc.org> Reviewed-by: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24224}
This commit is contained in:
@ -249,6 +249,14 @@ class SendProcessingUsage2 : public OveruseFrameDetector::ProcessingUsage {
|
|||||||
absl::optional<int> encode_duration_us) override {
|
absl::optional<int> encode_duration_us) override {
|
||||||
if (encode_duration_us) {
|
if (encode_duration_us) {
|
||||||
if (prev_time_us_ != -1) {
|
if (prev_time_us_ != -1) {
|
||||||
|
if (capture_time_us < prev_time_us_) {
|
||||||
|
// The weighting in AddSample assumes that samples are processed with
|
||||||
|
// non-decreasing measurement timestamps. We could implement
|
||||||
|
// appropriate weights for samples arriving late, but since it is a
|
||||||
|
// rare case, keep things simple, by just pushing those measurements a
|
||||||
|
// bit forward in time.
|
||||||
|
capture_time_us = prev_time_us_;
|
||||||
|
}
|
||||||
AddSample(1e-6 * (*encode_duration_us),
|
AddSample(1e-6 * (*encode_duration_us),
|
||||||
1e-6 * (capture_time_us - prev_time_us_));
|
1e-6 * (capture_time_us - prev_time_us_));
|
||||||
}
|
}
|
||||||
|
@ -890,4 +890,19 @@ TEST_F(OveruseFrameDetectorTest2, NoOveruseForRandomFrameIntervalWithReset) {
|
|||||||
EXPECT_LE(UsagePercent(), InitialUsage() + 5);
|
EXPECT_LE(UsagePercent(), InitialUsage() + 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(OveruseFrameDetectorTest2, ToleratesOutOfOrderFrames) {
|
||||||
|
overuse_detector_->SetOptions(options_);
|
||||||
|
// Represents a cpu utilization close to 100%. First input frame results in
|
||||||
|
// three encoded frames, and the last of those isn't finished until after the
|
||||||
|
// first encoded frame corresponding to the next input frame.
|
||||||
|
const int kEncodeTimeUs = 30 * rtc::kNumMicrosecsPerMillisec;
|
||||||
|
const int kCaptureTimesMs[] = { 33, 33, 66, 33 };
|
||||||
|
|
||||||
|
for (int capture_time_ms : kCaptureTimesMs) {
|
||||||
|
overuse_detector_->FrameSent(
|
||||||
|
0, 0, capture_time_ms * rtc::kNumMicrosecsPerMillisec, kEncodeTimeUs);
|
||||||
|
}
|
||||||
|
EXPECT_GE(UsagePercent(), InitialUsage());
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
Reference in New Issue
Block a user