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

Side by Side Diff: media/capture/content/smooth_event_sampler.h

Issue 2143903003: [WIP] Move media/capture to device/capture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef MEDIA_CAPTURE_CONTENT_SMOOTH_EVENT_SAMPLER_H_
6 #define MEDIA_CAPTURE_CONTENT_SMOOTH_EVENT_SAMPLER_H_
7
8 #include "base/macros.h"
9 #include "base/time/time.h"
10 #include "media/capture/capture_export.h"
11
12 namespace media {
13
14 // Filters a sequence of events to achieve a target frequency.
15 class CAPTURE_EXPORT SmoothEventSampler {
16 public:
17 explicit SmoothEventSampler(base::TimeDelta min_capture_period);
18
19 // Get/Set minimum capture period. When setting a new value, the state of the
20 // sampler is retained so that sampling will continue smoothly.
21 base::TimeDelta min_capture_period() const { return min_capture_period_; }
22 void SetMinCapturePeriod(base::TimeDelta p);
23
24 // Add a new event to the event history, and consider whether it ought to be
25 // sampled. The event is not recorded as a sample until RecordSample() is
26 // called.
27 void ConsiderPresentationEvent(base::TimeTicks event_time);
28
29 // Returns true if the last event considered should be sampled.
30 bool ShouldSample() const;
31
32 // Operates on the last event added by ConsiderPresentationEvent(), marking
33 // it as sampled. After this point we are current in the stream of events, as
34 // we have sampled the most recent event.
35 void RecordSample();
36
37 // Returns true if ConsiderPresentationEvent() has been called since the last
38 // call to RecordSample().
39 bool HasUnrecordedEvent() const;
40
41 private:
42 base::TimeDelta min_capture_period_;
43 base::TimeDelta token_bucket_capacity_;
44
45 base::TimeTicks current_event_;
46 base::TimeTicks last_sample_;
47 base::TimeDelta token_bucket_;
48
49 DISALLOW_COPY_AND_ASSIGN(SmoothEventSampler);
50 };
51
52 } // namespace media
53
54 #endif // MEDIA_CAPTURE_CONTENT_SMOOTH_EVENT_SAMPLER_H_
OLDNEW
« no previous file with comments | « media/capture/content/screen_capture_device_core.cc ('k') | media/capture/content/smooth_event_sampler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698