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

Side by Side Diff: media/video/capture/screen/screen_capturer.h

Issue 14305004: Simplify ScreenCapturer interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURER_H_ 5 #ifndef MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURER_H_
6 #define MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURER_H_ 6 #define MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/shared_memory.h" 11 #include "base/shared_memory.h"
12 #include "media/base/media_export.h" 12 #include "media/base/media_export.h"
13 #include "media/video/capture/screen/shared_buffer.h" 13 #include "media/video/capture/screen/shared_buffer.h"
14 #include "third_party/skia/include/core/SkRegion.h"
15 14
16 namespace media { 15 namespace media {
17 16
18 class ScreenCaptureData; 17 class ScreenCaptureData;
19 struct MouseCursorShape; 18 struct MouseCursorShape;
20 class SharedBuffer; 19 class SharedBuffer;
21 20
22 // Class used to capture video frames asynchronously. 21 // Class used to capture video frames asynchronously.
23 // 22 //
24 // The full capture sequence is as follows: 23 // The full capture sequence is as follows:
25 // 24 //
26 // (1) Start 25 // (1) Start
27 // This is when pre-capture steps are executed, such as flagging the 26 // This is when pre-capture steps are executed, such as flagging the
28 // display to prevent it from sleeping during a session. 27 // display to prevent it from sleeping during a session.
29 // 28 //
30 // (2) InvalidateRegion 29 // (2) CaptureFrame
31 // This is an optional step where regions of the screen are marked as
32 // invalid. Some platforms (Windows, for now) won't use this and will
33 // instead calculate the diff-regions later (in step (2). Other
34 // platforms (Mac) will use this to mark all the changed regions of the
35 // screen. Some limited rect-merging (e.g., to eliminate exact
36 // duplicates) may be done here.
37 //
38 // (3) CaptureFrame
39 // This is where the bits for the invalid rects are packaged up and sent 30 // This is where the bits for the invalid rects are packaged up and sent
40 // to the encoder. 31 // to the encoder.
41 // A screen capture is performed if needed. For example, Windows requires 32 // A screen capture is performed if needed. For example, Windows requires
42 // a capture to calculate the diff from the previous screen, whereas the 33 // a capture to calculate the diff from the previous screen, whereas the
43 // Mac version does not. 34 // Mac version does not.
44 // 35 //
45 // (4) Stop
46 // This is when post-capture steps are executed, such as releasing the
47 // assertion that prevents the display from sleeping.
48 //
49 // Implementation has to ensure the following guarantees: 36 // Implementation has to ensure the following guarantees:
50 // 1. Double buffering 37 // 1. Double buffering
51 // Since data can be read while another capture action is happening. 38 // Since data can be read while another capture action is happening.
52 class MEDIA_EXPORT ScreenCapturer { 39 class MEDIA_EXPORT ScreenCapturer {
53 public: 40 public:
54 // Provides callbacks used by the capturer to pass captured video frames and 41 // Provides callbacks used by the capturer to pass captured video frames and
55 // mouse cursor shapes to the processing pipeline. 42 // mouse cursor shapes to the processing pipeline.
56 class MEDIA_EXPORT Delegate { 43 class MEDIA_EXPORT Delegate {
57 public: 44 public:
58 // Creates a shared memory buffer of the given size. Returns NULL if shared 45 // Creates a shared memory buffer of the given size. Returns NULL if shared
(...skipping 26 matching lines...) Expand all
85 #if defined(OS_LINUX) 72 #if defined(OS_LINUX)
86 // Creates platform-specific capturer and instructs it whether it should use 73 // Creates platform-specific capturer and instructs it whether it should use
87 // X DAMAGE support. 74 // X DAMAGE support.
88 static scoped_ptr<ScreenCapturer> CreateWithXDamage(bool use_x_damage); 75 static scoped_ptr<ScreenCapturer> CreateWithXDamage(bool use_x_damage);
89 #endif // defined(OS_LINUX) 76 #endif // defined(OS_LINUX)
90 77
91 // Called at the beginning of a capturing session. |delegate| must remain 78 // Called at the beginning of a capturing session. |delegate| must remain
92 // valid until Stop() is called. 79 // valid until Stop() is called.
93 virtual void Start(Delegate* delegate) = 0; 80 virtual void Start(Delegate* delegate) = 0;
94 81
95 // Called at the end of a capturing session.
96 virtual void Stop() = 0;
97
98 // Invalidates the specified region.
99 virtual void InvalidateRegion(const SkRegion& invalid_region) = 0;
100
101 // Captures the screen data associated with each of the accumulated 82 // Captures the screen data associated with each of the accumulated
102 // dirty region. When the capture is complete, the delegate is notified even 83 // dirty region. When the capture is complete, the delegate is notified even
103 // if the dirty region is empty. 84 // if the dirty region is empty.
104 // 85 //
105 // It is OK to call this method while another thread is reading 86 // It is OK to call this method while another thread is reading
106 // data of the previous capture. There can be at most one concurrent read 87 // data of the previous capture. There can be at most one concurrent read
107 // going on when this method is called. 88 // going on when this method is called.
108 virtual void CaptureFrame() = 0; 89 virtual void CaptureFrame() = 0;
109 }; 90 };
110 91
111 } // namespace media 92 } // namespace media
112 93
113 #endif // MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURER_H_ 94 #endif // MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURER_H_
OLDNEW
« no previous file with comments | « media/video/capture/screen/screen_capture_device_unittest.cc ('k') | media/video/capture/screen/screen_capturer_fake.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698