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

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: q 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"
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 // TODO(sergeyu): Move cursor shape capturing to a separate class.
alexeypa (please no reviews) 2013/04/26 21:33:58 nit: Indentation. Also add a brief explanation why
Sergey Ulanov 2013/05/07 22:25:50 Done.
41 class MEDIA_EXPORT MouseShapeObserver {
44 public: 42 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. 43 // Called when the cursor shape has changed.
59 // TODO(sergeyu): Move cursor shape capturing to a separate class.
60 virtual void OnCursorShapeChanged( 44 virtual void OnCursorShapeChanged(
61 scoped_ptr<MouseCursorShape> cursor_shape) = 0; 45 scoped_ptr<MouseCursorShape> cursor_shape) = 0;
62 46
63 protected: 47 protected:
64 virtual ~Delegate() {} 48 virtual ~MouseShapeObserver() {}
65 }; 49 };
66 50
67 virtual ~ScreenCapturer() {} 51 virtual ~ScreenCapturer() {}
68 52
69 // Creates platform-specific capturer. 53 // Creates platform-specific capturer.
70 static scoped_ptr<ScreenCapturer> Create(); 54 static scoped_ptr<ScreenCapturer> Create();
71 55
72 #if defined(OS_LINUX) 56 #if defined(OS_LINUX)
73 // Creates platform-specific capturer and instructs it whether it should use 57 // Creates platform-specific capturer and instructs it whether it should use
74 // X DAMAGE support. 58 // X DAMAGE support.
75 static scoped_ptr<ScreenCapturer> CreateWithXDamage(bool use_x_damage); 59 static scoped_ptr<ScreenCapturer> CreateWithXDamage(bool use_x_damage);
76 #elif defined(OS_WIN) 60 #elif defined(OS_WIN)
77 // Creates Windows-specific capturer and instructs it whether or not to 61 // Creates Windows-specific capturer and instructs it whether or not to
78 // disable desktop compositing. 62 // disable desktop compositing.
79 static scoped_ptr<ScreenCapturer> CreateWithDisableAero(bool disable_aero); 63 static scoped_ptr<ScreenCapturer> CreateWithDisableAero(bool disable_aero);
80 #endif 64 #endif
alexeypa (please no reviews) 2013/04/26 21:33:58 nit: add // defined(OS_WIN)
Sergey Ulanov 2013/05/07 22:25:50 Done.
81 65
82 // Called at the beginning of a capturing session. |delegate| must remain 66 // Called at the beginning of a capturing session. |mouse_shape_observer| must
83 // valid until Stop() is called. 67 // remain valid until the capturer is destroyed.
84 virtual void Start(Delegate* delegate) = 0; 68 virtual void SetMouseShapeObserver(
85 69 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 }; 70 };
95 71
96 } // namespace media 72 } // namespace media
97 73
98 #endif // MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURER_H_ 74 #endif // MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698