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

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

Issue 1865283003: Revert of Tab/Desktop Capture: Use requests instead of timer-based refreshing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@video_refresh_from_sinks
Patch Set: Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MEDIA_CAPTURE_CONTENT_VIDEO_CAPTURE_ORACLE_H_ 5 #ifndef MEDIA_CAPTURE_CONTENT_VIDEO_CAPTURE_ORACLE_H_
6 #define MEDIA_CAPTURE_CONTENT_VIDEO_CAPTURE_ORACLE_H_ 6 #define MEDIA_CAPTURE_CONTENT_VIDEO_CAPTURE_ORACLE_H_
7 7
8 #include "base/callback_forward.h" 8 #include "base/callback_forward.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "media/base/media_export.h" 11 #include "media/base/media_export.h"
12 #include "media/capture/content/animated_content_sampler.h" 12 #include "media/capture/content/animated_content_sampler.h"
13 #include "media/capture/content/capture_resolution_chooser.h" 13 #include "media/capture/content/capture_resolution_chooser.h"
14 #include "media/capture/content/feedback_signal_accumulator.cc" 14 #include "media/capture/content/feedback_signal_accumulator.cc"
15 #include "media/capture/content/smooth_event_sampler.h" 15 #include "media/capture/content/smooth_event_sampler.h"
16 #include "ui/gfx/geometry/rect.h" 16 #include "ui/gfx/geometry/rect.h"
17 17
18 namespace media { 18 namespace media {
19 19
20 // VideoCaptureOracle manages the producer-side throttling of captured frames 20 // VideoCaptureOracle manages the producer-side throttling of captured frames
21 // from a video capture device. It is informed of every update by the device; 21 // from a video capture device. It is informed of every update by the device;
22 // this empowers it to look into the future and decide if a particular frame 22 // this empowers it to look into the future and decide if a particular frame
23 // ought to be captured in order to achieve its target frame rate. 23 // ought to be captured in order to achieve its target frame rate.
24 class MEDIA_EXPORT VideoCaptureOracle { 24 class MEDIA_EXPORT VideoCaptureOracle {
25 public: 25 public:
26 enum Event { 26 enum Event {
27 kTimerPoll,
27 kCompositorUpdate, 28 kCompositorUpdate,
28 kActiveRefreshRequest,
29 kPassiveRefreshRequest,
30 kMouseCursorUpdate, 29 kMouseCursorUpdate,
31 kNumEvents, 30 kNumEvents,
32 }; 31 };
33 32
33 enum {
34 // The recommended minimum amount of time between calls to
35 // ObserveEventAndDecideCapture() for the kTimerPoll Event type. Anything
36 // lower than this isn't harmful, just wasteful.
37 kMinTimerPollPeriodMillis = 125, // 8 FPS
38 };
39
34 VideoCaptureOracle(base::TimeDelta min_capture_period, 40 VideoCaptureOracle(base::TimeDelta min_capture_period,
35 const gfx::Size& max_frame_size, 41 const gfx::Size& max_frame_size,
36 media::ResolutionChangePolicy resolution_change_policy, 42 media::ResolutionChangePolicy resolution_change_policy,
37 bool enable_auto_throttling); 43 bool enable_auto_throttling);
38 44
39 virtual ~VideoCaptureOracle(); 45 virtual ~VideoCaptureOracle();
40 46
41 // Sets the source content size. This may not have an immediate effect on the 47 // Sets the source content size. This may not have an immediate effect on the
42 // proposed capture size, as the oracle will prevent too-frequent changes from 48 // proposed capture size, as the oracle will prevent too-frequent changes from
43 // occurring. 49 // occurring.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 // Returns the capture frame size the client should use. This is updated by 97 // Returns the capture frame size the client should use. This is updated by
92 // calls to ObserveEventAndDecideCapture(). The oracle prevents too-frequent 98 // calls to ObserveEventAndDecideCapture(). The oracle prevents too-frequent
93 // changes to the capture size, to avoid stressing the end-to-end pipeline. 99 // changes to the capture size, to avoid stressing the end-to-end pipeline.
94 gfx::Size capture_size() const { return capture_size_; } 100 gfx::Size capture_size() const { return capture_size_; }
95 101
96 // Returns the oracle's estimate of the last time animation was detected. 102 // Returns the oracle's estimate of the last time animation was detected.
97 base::TimeTicks last_time_animation_was_detected() const { 103 base::TimeTicks last_time_animation_was_detected() const {
98 return last_time_animation_was_detected_; 104 return last_time_animation_was_detected_;
99 } 105 }
100 106
101 // Returns a NUL-terminated string containing a short, human-readable form of
102 // |event|.
103 static const char* EventAsString(Event event);
104
105 private: 107 private:
106 // Retrieve/Assign a frame timestamp by capture |frame_number|. Only valid 108 // Retrieve/Assign a frame timestamp by capture |frame_number|. Only valid
107 // when IsFrameInRecentHistory(frame_number) returns true. 109 // when IsFrameInRecentHistory(frame_number) returns true.
108 base::TimeTicks GetFrameTimestamp(int frame_number) const; 110 base::TimeTicks GetFrameTimestamp(int frame_number) const;
109 void SetFrameTimestamp(int frame_number, base::TimeTicks timestamp); 111 void SetFrameTimestamp(int frame_number, base::TimeTicks timestamp);
110 112
111 // Returns true if the frame timestamp ring-buffer currently includes a 113 // Returns true if the frame timestamp ring-buffer currently includes a
112 // slot for the given |frame_number|. 114 // slot for the given |frame_number|.
113 bool IsFrameInRecentHistory(int frame_number) const; 115 bool IsFrameInRecentHistory(int frame_number) const;
114 116
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 199
198 // The timestamp of the frame where |content_sampler_| last detected 200 // The timestamp of the frame where |content_sampler_| last detected
199 // animation. This determines whether capture size increases will be 201 // animation. This determines whether capture size increases will be
200 // aggressive (because content is not animating). 202 // aggressive (because content is not animating).
201 base::TimeTicks last_time_animation_was_detected_; 203 base::TimeTicks last_time_animation_was_detected_;
202 }; 204 };
203 205
204 } // namespace media 206 } // namespace media
205 207
206 #endif // MEDIA_CAPTURE_CONTENT_VIDEO_CAPTURE_ORACLE_H_ 208 #endif // MEDIA_CAPTURE_CONTENT_VIDEO_CAPTURE_ORACLE_H_
OLDNEW
« no previous file with comments | « media/capture/content/thread_safe_capture_oracle.cc ('k') | media/capture/content/video_capture_oracle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698