Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(502)

Unified Diff: content/browser/media/capture/animated_content_sampler.h

Issue 1109603003: Clean-up: Break sampler classes into their own files. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/media/capture/animated_content_sampler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/media/capture/animated_content_sampler.h
diff --git a/content/browser/media/capture/video_capture_oracle.h b/content/browser/media/capture/animated_content_sampler.h
similarity index 52%
copy from content/browser/media/capture/video_capture_oracle.h
copy to content/browser/media/capture/animated_content_sampler.h
index db98b49e571dfe89b0d6d614204aaea9127d47d4..de7b3016d84e31208456ab7699871203bc3f21b4 100644
--- a/content/browser/media/capture/video_capture_oracle.h
+++ b/content/browser/media/capture/animated_content_sampler.h
@@ -1,62 +1,18 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Copyright (c) 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CONTENT_BROWSER_MEDIA_CAPTURE_VIDEO_CAPTURE_ORACLE_H_
-#define CONTENT_BROWSER_MEDIA_CAPTURE_VIDEO_CAPTURE_ORACLE_H_
+#ifndef CONTENT_BROWSER_MEDIA_CAPTURE_ANIMATED_CONTENT_SAMPLER_H_
+#define CONTENT_BROWSER_MEDIA_CAPTURE_ANIMATED_CONTENT_SAMPLER_H_
#include <deque>
-#include "base/callback_forward.h"
-#include "base/memory/scoped_ptr.h"
#include "base/time/time.h"
#include "content/common/content_export.h"
#include "ui/gfx/geometry/rect.h"
namespace content {
-// Filters a sequence of events to achieve a target frequency.
-class CONTENT_EXPORT SmoothEventSampler {
- public:
- SmoothEventSampler(base::TimeDelta min_capture_period,
- int redundant_capture_goal);
-
- base::TimeDelta min_capture_period() const { return min_capture_period_; }
-
- // Add a new event to the event history, and consider whether it ought to be
- // sampled. The event is not recorded as a sample until RecordSample() is
- // called.
- void ConsiderPresentationEvent(base::TimeTicks event_time);
-
- // Returns true if the last event considered should be sampled.
- bool ShouldSample() const;
-
- // Operates on the last event added by ConsiderPresentationEvent(), marking
- // it as sampled. After this point we are current in the stream of events, as
- // we have sampled the most recent event.
- void RecordSample();
-
- // Returns true if, at time |event_time|, sampling should occur because too
- // much time will have passed relative to the last event and/or sample.
- bool IsOverdueForSamplingAt(base::TimeTicks event_time) const;
-
- // Returns true if ConsiderPresentationEvent() has been called since the last
- // call to RecordSample().
- bool HasUnrecordedEvent() const;
-
- private:
- const base::TimeDelta min_capture_period_;
- const int redundant_capture_goal_;
- const base::TimeDelta token_bucket_capacity_;
-
- base::TimeTicks current_event_;
- base::TimeTicks last_sample_;
- int overdue_sample_count_;
- base::TimeDelta token_bucket_;
-
- DISALLOW_COPY_AND_ASSIGN(SmoothEventSampler);
-};
-
// Analyzes a sequence of events to detect the presence of constant frame rate
// animated content. In the case where there are multiple regions of animated
// content, AnimatedContentSampler will propose sampling the one having the
@@ -166,71 +122,6 @@ class CONTENT_EXPORT AnimatedContentSampler {
base::TimeDelta borrowed_time_;
};
-// VideoCaptureOracle manages the producer-side throttling of captured frames
-// from a video capture device. It is informed of every update by the device;
-// this empowers it to look into the future and decide if a particular frame
-// ought to be captured in order to achieve its target frame rate.
-class CONTENT_EXPORT VideoCaptureOracle {
- public:
- enum Event {
- kTimerPoll,
- kCompositorUpdate,
- kNumEvents,
- };
-
- explicit VideoCaptureOracle(base::TimeDelta min_capture_period);
- virtual ~VideoCaptureOracle();
-
- // Record a event of type |event|, and decide whether the caller should do a
- // frame capture. |damage_rect| is the region of a frame about to be drawn,
- // and may be an empty Rect, if this is not known. If the caller accepts the
- // oracle's proposal, it should call RecordCapture() to indicate this.
- bool ObserveEventAndDecideCapture(Event event,
- const gfx::Rect& damage_rect,
- base::TimeTicks event_time);
-
- // Record the start of a capture. Returns a frame_number to be used with
- // CompleteCapture().
- int RecordCapture();
-
- // Notify of the completion of a capture. Returns true iff the captured frame
- // should be delivered. |frame_timestamp| is set to the timestamp that should
- // be provided to the consumer of the frame.
- bool CompleteCapture(int frame_number, base::TimeTicks* frame_timestamp);
-
- base::TimeDelta min_capture_period() const {
- return smoothing_sampler_.min_capture_period();
- }
-
- private:
- // Retrieve/Assign a frame timestamp by capture |frame_number|.
- base::TimeTicks GetFrameTimestamp(int frame_number) const;
- void SetFrameTimestamp(int frame_number, base::TimeTicks timestamp);
-
- // Incremented every time a paint or update event occurs.
- int frame_number_;
-
- // Stores the last |event_time| from the last observation/decision. Used to
- // sanity-check that event times are monotonically non-decreasing.
- base::TimeTicks last_event_time_[kNumEvents];
-
- // Stores the frame number from the last delivered frame.
- int last_delivered_frame_number_;
-
- // These track present/paint history and propose whether to sample each event
- // for capture. |smoothing_sampler_| uses a "works for all" heuristic, while
- // |content_sampler_| specifically detects animated content (e.g., video
- // playback) and decides which events to sample to "lock into" that content.
- SmoothEventSampler smoothing_sampler_;
- AnimatedContentSampler content_sampler_;
-
- // Recent history of frame timestamps proposed by VideoCaptureOracle. This is
- // a ring-buffer, and should only be accessed by the Get/SetFrameTimestamp()
- // methods.
- enum { kMaxFrameTimestamps = 16 };
- base::TimeTicks frame_timestamps_[kMaxFrameTimestamps];
-};
-
} // namespace content
-#endif // CONTENT_BROWSER_MEDIA_CAPTURE_VIDEO_CAPTURE_ORACLE_H_
+#endif // CONTENT_BROWSER_MEDIA_CAPTURE_ANIMATED_CONTENT_SAMPLER_H_
« no previous file with comments | « no previous file | content/browser/media/capture/animated_content_sampler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698