Index: media/capture/content/video_capture_oracle.cc |
diff --git a/media/capture/content/video_capture_oracle.cc b/media/capture/content/video_capture_oracle.cc |
index e8dd752e9f453062f56c411acc9fc377176098e6..a363987d51799a5512940711416a7c93f79b0808 100644 |
--- a/media/capture/content/video_capture_oracle.cc |
+++ b/media/capture/content/video_capture_oracle.cc |
@@ -14,13 +14,16 @@ |
namespace { |
-// When a non-compositor event arrives after animation has halted, this |
-// controls how much time must elapse before deciding to allow a capture. |
-const int kAnimationHaltPeriodBeforeOtherSamplingMicros = 250000; |
- |
-// When estimating frame durations, this is the hard upper-bound on the |
-// estimate. |
-const int kUpperBoundDurationEstimateMicros = 1000000; // 1 second |
+// This value controls how many redundant, timer-base captures occur when the |
+// content is static. Redundantly capturing the same frame allows iterative |
+// quality enhancement, and also allows the buffer to fill in "buffered mode". |
+// |
+// TODO(nick): Controlling this here is a hack and a layering violation, since |
+// it's a strategy specific to the WebRTC consumer, and probably just papers |
+// over some frame dropping and quality bugs. It should either be controlled at |
+// a higher level, or else redundant frame generation should be pushed down |
+// further into the WebRTC encoding stack. |
+const int kNumRedundantCapturesOfStaticContent = 200; |
// The half-life of data points provided to the accumulator used when evaluating |
// the recent utilization of the buffer pool. This value is based on a |
@@ -103,7 +106,8 @@ |
next_frame_number_(0), |
last_successfully_delivered_frame_number_(-1), |
num_frames_pending_(0), |
- smoothing_sampler_(min_capture_period), |
+ smoothing_sampler_(min_capture_period, |
+ kNumRedundantCapturesOfStaticContent), |
content_sampler_(min_capture_period), |
resolution_chooser_(max_frame_size, resolution_change_policy), |
buffer_pool_utilization_(base::TimeDelta::FromMicroseconds( |
@@ -160,21 +164,20 @@ |
break; |
} |
- case kActiveRefreshRequest: |
- case kPassiveRefreshRequest: |
+ case kTimerPoll: |
+ // While the timer is firing, only allow a sampling if there are none |
+ // currently in-progress. |
+ if (num_frames_pending_ == 0) |
+ should_sample = smoothing_sampler_.IsOverdueForSamplingAt(event_time); |
+ break; |
+ |
case kMouseCursorUpdate: |
- // Only allow non-compositor samplings when content has not recently been |
- // animating, and only if there are no samplings currently in progress. |
+ // Only allow a sampling if there are none currently in-progress. |
if (num_frames_pending_ == 0) { |
- if (!content_sampler_.HasProposal() || |
- ((event_time - last_time_animation_was_detected_).InMicroseconds() > |
- kAnimationHaltPeriodBeforeOtherSamplingMicros)) { |
- smoothing_sampler_.ConsiderPresentationEvent(event_time); |
- should_sample = smoothing_sampler_.ShouldSample(); |
- } |
+ smoothing_sampler_.ConsiderPresentationEvent(event_time); |
+ should_sample = smoothing_sampler_.ShouldSample(); |
} |
break; |
- |
case kNumEvents: |
NOTREACHED(); |
break; |
@@ -190,8 +193,8 @@ |
duration_of_next_frame_ = |
event_time - GetFrameTimestamp(next_frame_number_ - 1); |
} |
- const base::TimeDelta upper_bound = |
- base::TimeDelta::FromMilliseconds(kUpperBoundDurationEstimateMicros); |
+ const base::TimeDelta upper_bound = base::TimeDelta::FromMilliseconds( |
+ SmoothEventSampler::OVERDUE_DIRTY_THRESHOLD_MILLIS); |
duration_of_next_frame_ = |
std::max(std::min(duration_of_next_frame_, upper_bound), |
smoothing_sampler_.min_capture_period()); |
@@ -337,24 +340,6 @@ |
estimated_capable_area_.Update(area_at_full_utilization, timestamp); |
} |
-// static |
-const char* VideoCaptureOracle::EventAsString(Event event) { |
- switch (event) { |
- case kCompositorUpdate: |
- return "compositor"; |
- case kActiveRefreshRequest: |
- return "active_refresh"; |
- case kPassiveRefreshRequest: |
- return "passive_refresh"; |
- case kMouseCursorUpdate: |
- return "mouse"; |
- case kNumEvents: |
- break; |
- } |
- NOTREACHED(); |
- return "unknown"; |
-} |
- |
base::TimeTicks VideoCaptureOracle::GetFrameTimestamp(int frame_number) const { |
DCHECK(IsFrameInRecentHistory(frame_number)); |
return frame_timestamps_[frame_number % kMaxFrameTimestamps]; |