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 // Called when a video frame has been captured. |capture_data| describes | 56 // Called when a video frame has been captured. |capture_data| describes |
56 // a captured frame. | 57 // a captured frame. |
57 virtual void OnCaptureCompleted( | 58 virtual void OnCaptureCompleted( |
58 scoped_refptr<CaptureData> capture_data) = 0; | 59 scoped_refptr<ScreenCaptureData> capture_data) = 0; |
59 | 60 |
60 // Called when the cursor shape has changed. | 61 // Called when the cursor shape has changed. |
61 // TODO(sergeyu): Move cursor shape capturing to a separate class. | 62 // TODO(sergeyu): Move cursor shape capturing to a separate class. |
62 virtual void OnCursorShapeChanged( | 63 virtual void OnCursorShapeChanged( |
63 scoped_ptr<MouseCursorShape> cursor_shape) = 0; | 64 scoped_ptr<MouseCursorShape> cursor_shape) = 0; |
64 | 65 |
65 protected: | 66 protected: |
66 virtual ~Delegate() {} | 67 virtual ~Delegate() {} |
67 }; | 68 }; |
68 | 69 |
69 virtual ~VideoFrameCapturer() {} | 70 virtual ~ScreenCapturer() {} |
70 | 71 |
71 // Create platform-specific capturer. | 72 // Create platform-specific capturer. |
72 static scoped_ptr<VideoFrameCapturer> Create(); | 73 static scoped_ptr<ScreenCapturer> Create(); |
73 | 74 |
74 // Create platform-specific capturer that uses shared memory buffers. | 75 // Create platform-specific capturer that uses shared memory buffers. |
75 static scoped_ptr<VideoFrameCapturer> CreateWithFactory( | 76 static scoped_ptr<ScreenCapturer> CreateWithFactory( |
76 SharedBufferFactory* shared_buffer_factory); | 77 SharedBufferFactory* shared_buffer_factory); |
77 | 78 |
78 #if defined(OS_LINUX) | 79 #if defined(OS_LINUX) |
79 // Set whether the VideoFrameCapturer should try to use X DAMAGE support if it | 80 // Set whether the ScreenCapturer should try to use X DAMAGE support if it |
80 // is available. This needs to be called before the VideoFrameCapturer is | 81 // is available. This needs to be called before the ScreenCapturer is |
81 // created. | 82 // created. |
82 // This is used by the Virtual Me2Me host, since the XDamage extension is | 83 // This is used by the Virtual Me2Me host, since the XDamage extension is |
83 // known to work reliably in this case. | 84 // known to work reliably in this case. |
84 | 85 |
85 // TODO(lambroslambrou): This currently sets a global flag, referenced during | 86 // TODO(lambroslambrou): This currently sets a global flag, referenced during |
86 // VideoFrameCapturer::Create(). This is a temporary solution, until the | 87 // ScreenCapturer::Create(). This is a temporary solution, until the |
87 // DesktopEnvironment class is refactored to allow applications to control | 88 // DesktopEnvironment class is refactored to allow applications to control |
88 // the creation of various stubs (including the VideoFrameCapturer) - see | 89 // the creation of various stubs (including the ScreenCapturer) - see |
89 // http://crbug.com/104544 | 90 // http://crbug.com/104544 |
90 static void EnableXDamage(bool enable); | 91 static void EnableXDamage(bool enable); |
91 #endif // defined(OS_LINUX) | 92 #endif // defined(OS_LINUX) |
92 | 93 |
93 // Called at the beginning of a capturing session. |delegate| must remain | 94 // Called at the beginning of a capturing session. |delegate| must remain |
94 // valid until Stop() is called. | 95 // valid until Stop() is called. |
95 virtual void Start(Delegate* delegate) = 0; | 96 virtual void Start(Delegate* delegate) = 0; |
96 | 97 |
97 // Called at the end of a capturing session. | 98 // Called at the end of a capturing session. |
98 virtual void Stop() = 0; | 99 virtual void Stop() = 0; |
99 | 100 |
100 // Invalidates the specified region. | 101 // Invalidates the specified region. |
101 virtual void InvalidateRegion(const SkRegion& invalid_region) = 0; | 102 virtual void InvalidateRegion(const SkRegion& invalid_region) = 0; |
102 | 103 |
103 // Captures the screen data associated with each of the accumulated | 104 // Captures the screen data associated with each of the accumulated |
104 // dirty region. When the capture is complete, the delegate is notified even | 105 // dirty region. When the capture is complete, the delegate is notified even |
105 // if the dirty region is empty. | 106 // if the dirty region is empty. |
106 // | 107 // |
107 // It is OK to call this method while another thread is reading | 108 // It is OK to call this method while another thread is reading |
108 // data of the previous capture. There can be at most one concurrent read | 109 // data of the previous capture. There can be at most one concurrent read |
109 // going on when this method is called. | 110 // going on when this method is called. |
110 virtual void CaptureFrame() = 0; | 111 virtual void CaptureFrame() = 0; |
111 }; | 112 }; |
112 | 113 |
113 } // namespace remoting | 114 } // namespace media |
114 | 115 |
115 #endif // REMOTING_CAPTURER_VIDEO_FRAME_CAPTURER_H_ | 116 #endif // MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURER_H_ |
OLD | NEW |