OLD | NEW |
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 REMOTING_CAPTURER_VIDEO_FRAME_CAPTURER_H_ | 5 #ifndef MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURER_H_ |
6 #define REMOTING_CAPTURER_VIDEO_FRAME_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/shared_memory.h" | 10 #include "base/shared_memory.h" |
| 11 #include "media/base/media_export.h" |
11 #include "third_party/skia/include/core/SkRegion.h" | 12 #include "third_party/skia/include/core/SkRegion.h" |
12 | 13 |
13 namespace remoting { | 14 namespace media { |
14 | 15 |
15 class CaptureData; | 16 class ScreenCaptureData; |
16 struct MouseCursorShape; | 17 struct MouseCursorShape; |
17 class SharedBufferFactory; | 18 class SharedBufferFactory; |
18 | 19 |
19 // Class used to capture video frames asynchronously. | 20 // Class used to capture video frames asynchronously. |
20 // | 21 // |
21 // The full capture sequence is as follows: | 22 // The full capture sequence is as follows: |
22 // | 23 // |
23 // (1) Start | 24 // (1) Start |
24 // This is when pre-capture steps are executed, such as flagging the | 25 // This is when pre-capture steps are executed, such as flagging the |
25 // display to prevent it from sleeping during a session. | 26 // display to prevent it from sleeping during a session. |
(...skipping 13 matching lines...) Expand all Loading... |
39 // a capture to calculate the diff from the previous screen, whereas the | 40 // a capture to calculate the diff from the previous screen, whereas the |
40 // Mac version does not. | 41 // Mac version does not. |
41 // | 42 // |
42 // (4) Stop | 43 // (4) Stop |
43 // This is when post-capture steps are executed, such as releasing the | 44 // This is when post-capture steps are executed, such as releasing the |
44 // assertion that prevents the display from sleeping. | 45 // assertion that prevents the display from sleeping. |
45 // | 46 // |
46 // Implementation has to ensure the following guarantees: | 47 // Implementation has to ensure the following guarantees: |
47 // 1. Double buffering | 48 // 1. Double buffering |
48 // Since data can be read while another capture action is happening. | 49 // Since data can be read while another capture action is happening. |
49 class VideoFrameCapturer { | 50 class MEDIA_EXPORT ScreenCapturer { |
50 public: | 51 public: |
51 // Provides callbacks used by the capturer to pass captured video frames and | 52 // Provides callbacks used by the capturer to pass captured video frames and |
52 // mouse cursor shapes to the processing pipeline. | 53 // mouse cursor shapes to the processing pipeline. |
53 class Delegate { | 54 class Delegate { |
54 public: | 55 public: |
55 virtual ~Delegate() {} | 56 virtual ~Delegate() {} |
56 | 57 |
57 // Called when a video frame has been captured. |capture_data| describes | 58 // Called when a video frame has been captured. |capture_data| describes |
58 // a captured frame. | 59 // a captured frame. |
59 virtual void OnCaptureCompleted( | 60 virtual void OnCaptureCompleted( |
60 scoped_refptr<CaptureData> capture_data) = 0; | 61 scoped_refptr<ScreenCaptureData> capture_data) = 0; |
61 | 62 |
62 // Called when the cursor shape has changed. | 63 // Called when the cursor shape has changed. |
63 // TODO(sergeyu): Move cursor shape capturing to a separate class. | 64 // TODO(sergeyu): Move cursor shape capturing to a separate class. |
64 virtual void OnCursorShapeChanged( | 65 virtual void OnCursorShapeChanged( |
65 scoped_ptr<MouseCursorShape> cursor_shape) = 0; | 66 scoped_ptr<MouseCursorShape> cursor_shape) = 0; |
66 }; | 67 }; |
67 | 68 |
68 virtual ~VideoFrameCapturer() {} | 69 virtual ~ScreenCapturer() {} |
69 | 70 |
70 // Create platform-specific capturer. | 71 // Create platform-specific capturer. |
71 static scoped_ptr<VideoFrameCapturer> Create(); | 72 static scoped_ptr<ScreenCapturer> Create(); |
72 | 73 |
73 // Create platform-specific capturer that uses shared memory buffers. | 74 // Create platform-specific capturer that uses shared memory buffers. |
74 static scoped_ptr<VideoFrameCapturer> CreateWithFactory( | 75 static scoped_ptr<ScreenCapturer> CreateWithFactory( |
75 SharedBufferFactory* shared_buffer_factory); | 76 SharedBufferFactory* shared_buffer_factory); |
76 | 77 |
77 #if defined(OS_LINUX) | 78 #if defined(OS_LINUX) |
78 // Set whether the VideoFrameCapturer should try to use X DAMAGE support if it | 79 // Set whether the ScreenCapturer should try to use X DAMAGE support if it |
79 // is available. This needs to be called before the VideoFrameCapturer is | 80 // is available. This needs to be called before the ScreenCapturer is |
80 // created. | 81 // created. |
81 // This is used by the Virtual Me2Me host, since the XDamage extension is | 82 // This is used by the Virtual Me2Me host, since the XDamage extension is |
82 // known to work reliably in this case. | 83 // known to work reliably in this case. |
83 | 84 |
84 // TODO(lambroslambrou): This currently sets a global flag, referenced during | 85 // TODO(lambroslambrou): This currently sets a global flag, referenced during |
85 // VideoFrameCapturer::Create(). This is a temporary solution, until the | 86 // ScreenCapturer::Create(). This is a temporary solution, until the |
86 // DesktopEnvironment class is refactored to allow applications to control | 87 // DesktopEnvironment class is refactored to allow applications to control |
87 // the creation of various stubs (including the VideoFrameCapturer) - see | 88 // the creation of various stubs (including the ScreenCapturer) - see |
88 // http://crbug.com/104544 | 89 // http://crbug.com/104544 |
89 static void EnableXDamage(bool enable); | 90 static void EnableXDamage(bool enable); |
90 #endif // defined(OS_LINUX) | 91 #endif // defined(OS_LINUX) |
91 | 92 |
92 // Called at the beginning of a capturing session. |delegate| must remain | 93 // Called at the beginning of a capturing session. |delegate| must remain |
93 // valid until Stop() is called. | 94 // valid until Stop() is called. |
94 virtual void Start(Delegate* delegate) = 0; | 95 virtual void Start(Delegate* delegate) = 0; |
95 | 96 |
96 // Called at the end of a capturing session. | 97 // Called at the end of a capturing session. |
97 virtual void Stop() = 0; | 98 virtual void Stop() = 0; |
98 | 99 |
99 // Invalidates the specified region. | 100 // Invalidates the specified region. |
100 virtual void InvalidateRegion(const SkRegion& invalid_region) = 0; | 101 virtual void InvalidateRegion(const SkRegion& invalid_region) = 0; |
101 | 102 |
102 // Captures the screen data associated with each of the accumulated | 103 // Captures the screen data associated with each of the accumulated |
103 // dirty region. When the capture is complete, the delegate is notified even | 104 // dirty region. When the capture is complete, the delegate is notified even |
104 // if the dirty region is empty. | 105 // if the dirty region is empty. |
105 // | 106 // |
106 // It is OK to call this method while another thread is reading | 107 // It is OK to call this method while another thread is reading |
107 // data of the previous capture. There can be at most one concurrent read | 108 // data of the previous capture. There can be at most one concurrent read |
108 // going on when this method is called. | 109 // going on when this method is called. |
109 virtual void CaptureFrame() = 0; | 110 virtual void CaptureFrame() = 0; |
110 }; | 111 }; |
111 | 112 |
112 } // namespace remoting | 113 } // namespace media |
113 | 114 |
114 #endif // REMOTING_CAPTURER_VIDEO_FRAME_CAPTURER_H_ | 115 #endif // MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURER_H_ |
OLD | NEW |