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

Side by Side Diff: remoting/host/video_frame_capturer.h

Issue 11470028: Move screen capturers to remoting/capturer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 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 REMOTING_HOST_VIDEO_FRAME_CAPTURER_H_
6 #define REMOTING_HOST_VIDEO_FRAME_CAPTURER_H_
7
8 #include "base/basictypes.h"
9 #include "base/callback.h"
10 #include "base/shared_memory.h"
11 #include "media/base/video_frame.h"
12 #include "third_party/skia/include/core/SkRegion.h"
13
14 namespace remoting {
15
16 namespace protocol {
17 class CursorShapeInfo;
18 }
19
20 class CaptureData;
21 class SharedBufferFactory;
22
23 // Class used to capture video frames asynchronously.
24 //
25 // The full capture sequence is as follows:
26 //
27 // (1) Start
28 // This is when pre-capture steps are executed, such as flagging the
29 // display to prevent it from sleeping during a session.
30 //
31 // (2) InvalidateRegion
32 // This is an optional step where regions of the screen are marked as
33 // invalid. Some platforms (Windows, for now) won't use this and will
34 // instead calculate the diff-regions later (in step (2). Other
35 // platforms (Mac) will use this to mark all the changed regions of the
36 // screen. Some limited rect-merging (e.g., to eliminate exact
37 // duplicates) may be done here.
38 //
39 // (3) CaptureFrame
40 // This is where the bits for the invalid rects are packaged up and sent
41 // to the encoder.
42 // A screen capture is performed if needed. For example, Windows requires
43 // a capture to calculate the diff from the previous screen, whereas the
44 // Mac version does not.
45 //
46 // (4) Stop
47 // This is when post-capture steps are executed, such as releasing the
48 // assertion that prevents the display from sleeping.
49 //
50 // Implementation has to ensure the following guarantees:
51 // 1. Double buffering
52 // Since data can be read while another capture action is happening.
53 class VideoFrameCapturer {
54 public:
55 // Provides callbacks used by the capturer to pass captured video frames and
56 // mouse cursor shapes to the processing pipeline.
57 class Delegate {
58 public:
59 virtual ~Delegate() {}
60
61 // Called when a video frame has been captured. |capture_data| describes
62 // a captured frame.
63 virtual void OnCaptureCompleted(
64 scoped_refptr<CaptureData> capture_data) = 0;
65
66 // Called when the cursor shape has changed.
67 virtual void OnCursorShapeChanged(
68 scoped_ptr<protocol::CursorShapeInfo> cursor_shape) = 0;
69 };
70
71 virtual ~VideoFrameCapturer() {}
72
73 // Create platform-specific capturer.
74 static scoped_ptr<VideoFrameCapturer> Create();
75
76 // Create platform-specific capturer that uses shared memory buffers.
77 static scoped_ptr<VideoFrameCapturer> CreateWithFactory(
78 SharedBufferFactory* shared_buffer_factory);
79
80 #if defined(OS_LINUX)
81 // Set whether the VideoFrameCapturer should try to use X DAMAGE support if it
82 // is available. This needs to be called before the VideoFrameCapturer is
83 // created.
84 // This is used by the Virtual Me2Me host, since the XDamage extension is
85 // known to work reliably in this case.
86
87 // TODO(lambroslambrou): This currently sets a global flag, referenced during
88 // VideoFrameCapturer::Create(). This is a temporary solution, until the
89 // DesktopEnvironment class is refactored to allow applications to control
90 // the creation of various stubs (including the VideoFrameCapturer) - see
91 // http://crbug.com/104544
92 static void EnableXDamage(bool enable);
93 #endif // defined(OS_LINUX)
94
95 // Called at the beginning of a capturing session. |delegate| must remain
96 // valid until Stop() is called.
97 virtual void Start(Delegate* delegate) = 0;
98
99 // Called at the end of a capturing session.
100 virtual void Stop() = 0;
101
102 // Returns the pixel format of the screen.
103 virtual media::VideoFrame::Format pixel_format() const = 0;
104
105 // Invalidates the specified region.
106 virtual void InvalidateRegion(const SkRegion& invalid_region) = 0;
107
108 // Captures the screen data associated with each of the accumulated
109 // dirty region. When the capture is complete, the delegate is notified even
110 // if the dirty region is empty.
111 //
112 // It is OK to call this method while another thread is reading
113 // data of the previous capture. There can be at most one concurrent read
114 // going on when this method is called.
115 virtual void CaptureFrame() = 0;
116
117 // Get the size of the most recently captured screen.
118 virtual const SkISize& size_most_recent() const = 0;
119 };
120
121 } // namespace remoting
122
123 #endif // REMOTING_HOST_VIDEO_FRAME_CAPTURER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698