Index: content/browser/media/capture/video_capture_oracle.cc |
diff --git a/content/browser/media/capture/video_capture_oracle.cc b/content/browser/media/capture/video_capture_oracle.cc |
index 9157d8ce002f34997ccb0918ec7fc9aff323fe32..0632ef1313c1b9ad7d3e2e67096cb1a323b98861 100644 |
--- a/content/browser/media/capture/video_capture_oracle.cc |
+++ b/content/browser/media/capture/video_capture_oracle.cc |
@@ -38,7 +38,8 @@ double FractionFromExpectedFrameRate(base::TimeDelta delta, int frame_rate) { |
VideoCaptureOracle::VideoCaptureOracle(base::TimeDelta min_capture_period) |
: next_frame_number_(0), |
- last_delivered_frame_number_(-1), |
+ last_successfully_delivered_frame_number_(-1), |
+ num_frames_pending_(0), |
smoothing_sampler_(min_capture_period, |
kNumRedundantCapturesOfStaticContent), |
content_sampler_(min_capture_period) { |
@@ -80,7 +81,7 @@ bool VideoCaptureOracle::ObserveEventAndDecideCapture( |
case kTimerPoll: |
// While the timer is firing, only allow a sampling if there are none |
// currently in-progress. |
- if (last_delivered_frame_number_ == (next_frame_number_ - 1)) { |
+ if (num_frames_pending_ == 0) { |
should_sample = smoothing_sampler_.IsOverdueForSamplingAt(event_time); |
if (should_sample) |
duration_of_next_frame_ = smoothing_sampler_.min_capture_period(); |
@@ -98,28 +99,32 @@ bool VideoCaptureOracle::ObserveEventAndDecideCapture( |
int VideoCaptureOracle::RecordCapture() { |
smoothing_sampler_.RecordSample(); |
content_sampler_.RecordSample(GetFrameTimestamp(next_frame_number_)); |
+ num_frames_pending_++; |
return next_frame_number_++; |
} |
bool VideoCaptureOracle::CompleteCapture(int frame_number, |
bool capture_was_successful, |
base::TimeTicks* frame_timestamp) { |
- // Drop frame if previous frame number is higher. |
- if (last_delivered_frame_number_ > frame_number) { |
+ num_frames_pending_--; |
+ |
+ // Drop frame if previously delivered frame number is higher. |
+ if (last_successfully_delivered_frame_number_ > frame_number) { |
LOG_IF(WARNING, capture_was_successful) |
<< "Out of order frame delivery detected (have #" << frame_number |
- << ", last was #" << last_delivered_frame_number_ |
+ << ", last was #" << last_successfully_delivered_frame_number_ |
<< "). Dropping frame."; |
return false; |
} |
- DCHECK_NE(last_delivered_frame_number_, frame_number); |
- last_delivered_frame_number_ = frame_number; |
if (!capture_was_successful) { |
VLOG(2) << "Capture of frame #" << frame_number << " was not successful."; |
return false; |
} |
+ DCHECK_NE(last_successfully_delivered_frame_number_, frame_number); |
+ last_successfully_delivered_frame_number_ = frame_number; |
+ |
*frame_timestamp = GetFrameTimestamp(frame_number); |
// If enabled, log a measurement of how this frame timestamp has incremented |