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

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

Issue 13983010: Use webrtc::DesktopCapturer for screen capturer implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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"
12 #include "media/base/media_export.h" 11 #include "media/base/media_export.h"
13 #include "media/video/capture/screen/shared_buffer.h" 12 #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h"
14 13
15 namespace media { 14 namespace media {
16 15
17 class ScreenCaptureData;
18 struct MouseCursorShape; 16 struct MouseCursorShape;
19 class SharedBuffer;
20 17
21 // Class used to capture video frames asynchronously. 18 // Class used to capture video frames asynchronously.
22 // 19 //
23 // The full capture sequence is as follows: 20 // The full capture sequence is as follows:
24 // 21 //
25 // (1) Start 22 // (1) Start
26 // This is when pre-capture steps are executed, such as flagging the 23 // This is when pre-capture steps are executed, such as flagging the
27 // display to prevent it from sleeping during a session. 24 // display to prevent it from sleeping during a session.
28 // 25 //
29 // (2) CaptureFrame 26 // (2) CaptureFrame
30 // This is where the bits for the invalid rects are packaged up and sent 27 // This is where the bits for the invalid rects are packaged up and sent
31 // to the encoder. 28 // to the encoder.
32 // A screen capture is performed if needed. For example, Windows requires 29 // A screen capture is performed if needed. For example, Windows requires
33 // a capture to calculate the diff from the previous screen, whereas the 30 // a capture to calculate the diff from the previous screen, whereas the
34 // Mac version does not. 31 // Mac version does not.
35 // 32 //
36 // Implementation has to ensure the following guarantees: 33 // Implementation has to ensure the following guarantees:
37 // 1. Double buffering 34 // 1. Double buffering
38 // Since data can be read while another capture action is happening. 35 // Since data can be read while another capture action is happening.
39 class MEDIA_EXPORT ScreenCapturer { 36 class MEDIA_EXPORT ScreenCapturer : public webrtc::DesktopCapturer {
40 public: 37 public:
41 // Provides callbacks used by the capturer to pass captured video frames and 38 // Provides callbacks used by the capturer to pass captured video frames and
42 // mouse cursor shapes to the processing pipeline. 39 // mouse cursor shapes to the processing pipeline.
43 class MEDIA_EXPORT Delegate { 40 //
41 // TODO(sergeyu): Move cursor shape capturing to a separate class because it's
42 // unrelated.
43 class MEDIA_EXPORT MouseShapeObserver {
44 public: 44 public:
45 // Creates a shared memory buffer of the given size. Returns NULL if shared
46 // buffers are not supported.
47 virtual scoped_refptr<SharedBuffer> CreateSharedBuffer(uint32 size);
48
49 // Notifies the delegate that the buffer is no longer used and can be
50 // released.
51 virtual void ReleaseSharedBuffer(scoped_refptr<SharedBuffer> buffer);
52
53 // Called when a video frame has been captured. |capture_data| describes
54 // a captured frame.
55 virtual void OnCaptureCompleted(
56 scoped_refptr<ScreenCaptureData> capture_data) = 0;
57
58 // Called when the cursor shape has changed. 45 // Called when the cursor shape has changed.
59 // TODO(sergeyu): Move cursor shape capturing to a separate class.
60 virtual void OnCursorShapeChanged( 46 virtual void OnCursorShapeChanged(
61 scoped_ptr<MouseCursorShape> cursor_shape) = 0; 47 scoped_ptr<MouseCursorShape> cursor_shape) = 0;
62 48
63 protected: 49 protected:
64 virtual ~Delegate() {} 50 virtual ~MouseShapeObserver() {}
65 }; 51 };
66 52
67 virtual ~ScreenCapturer() {} 53 virtual ~ScreenCapturer() {}
68 54
69 // Creates platform-specific capturer. 55 // Creates platform-specific capturer.
70 static scoped_ptr<ScreenCapturer> Create(); 56 static scoped_ptr<ScreenCapturer> Create();
71 57
72 #if defined(OS_LINUX) 58 #if defined(OS_LINUX)
73 // Creates platform-specific capturer and instructs it whether it should use 59 // Creates platform-specific capturer and instructs it whether it should use
74 // X DAMAGE support. 60 // X DAMAGE support.
75 static scoped_ptr<ScreenCapturer> CreateWithXDamage(bool use_x_damage); 61 static scoped_ptr<ScreenCapturer> CreateWithXDamage(bool use_x_damage);
76 #elif defined(OS_WIN) 62 #elif defined(OS_WIN)
77 // Creates Windows-specific capturer and instructs it whether or not to 63 // Creates Windows-specific capturer and instructs it whether or not to
78 // disable desktop compositing. 64 // disable desktop compositing.
79 static scoped_ptr<ScreenCapturer> CreateWithDisableAero(bool disable_aero); 65 static scoped_ptr<ScreenCapturer> CreateWithDisableAero(bool disable_aero);
80 #endif 66 #endif // defined(OS_WIN)
81 67
82 // Called at the beginning of a capturing session. |delegate| must remain 68 // Called at the beginning of a capturing session. |mouse_shape_observer| must
83 // valid until Stop() is called. 69 // remain valid until the capturer is destroyed.
84 virtual void Start(Delegate* delegate) = 0; 70 virtual void SetMouseShapeObserver(
85 71 MouseShapeObserver* mouse_shape_observer) = 0;
86 // Captures the screen data associated with each of the accumulated
87 // dirty region. When the capture is complete, the delegate is notified even
88 // if the dirty region is empty.
89 //
90 // It is OK to call this method while another thread is reading
91 // data of the previous capture. There can be at most one concurrent read
92 // going on when this method is called.
93 virtual void CaptureFrame() = 0;
94 }; 72 };
95 73
96 } // namespace media 74 } // namespace media
97 75
98 #endif // MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURER_H_ 76 #endif // MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698