2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
11 #ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_SCREEN_CAPTURER_H_
12 #define WEBRTC_MODULES_DESKTOP_CAPTURE_SCREEN_CAPTURER_H_
16 #include "webrtc/modules/desktop_capture/desktop_capture_types.h"
17 #include "webrtc/modules/desktop_capture/desktop_capturer.h"
18 #include "webrtc/system_wrappers/interface/scoped_ptr.h"
19 #include "webrtc/typedefs.h"
23 class DesktopCaptureOptions;
25 // Class used to capture video frames asynchronously.
27 // The full capture sequence is as follows:
30 // This is when pre-capture steps are executed, such as flagging the
31 // display to prevent it from sleeping during a session.
34 // This is where the bits for the invalid rects are packaged up and sent
36 // A screen capture is performed if needed. For example, Windows requires
37 // a capture to calculate the diff from the previous screen, whereas the
38 // Mac version does not.
40 // Implementation has to ensure the following guarantees:
41 // 1. Double buffering
42 // Since data can be read while another capture action is happening.
43 class ScreenCapturer : public DesktopCapturer {
45 // Use a struct to represent a screen although it has only an id for now,
46 // because we may want to add more fields (e.g. description) in the future.
50 typedef std::vector<Screen> ScreenList;
52 // TODO(sergeyu): Remove this class once all dependencies are removed from
54 class MouseShapeObserver {
57 virtual ~ScreenCapturer() {}
59 // Creates platform-specific capturer.
61 // TODO(sergeyu): Remove all Create() methods except the first one.
63 static ScreenCapturer* Create(const DesktopCaptureOptions& options);
64 static ScreenCapturer* Create();
66 #if defined(WEBRTC_LINUX)
67 // Creates platform-specific capturer and instructs it whether it should use
69 static ScreenCapturer* CreateWithXDamage(bool use_x_damage);
70 #elif defined(WEBRTC_WIN)
71 // Creates Windows-specific capturer and instructs it whether or not to
72 // disable desktop compositing.
73 static ScreenCapturer* CreateWithDisableAero(bool disable_aero);
74 #endif // defined(WEBRTC_WIN)
76 // TODO(sergeyu): Remove this method once all dependencies are removed from
78 virtual void SetMouseShapeObserver(
79 MouseShapeObserver* mouse_shape_observer) {};
81 // Get the list of screens (not containing kFullDesktopScreenId). Returns
82 // false in case of a failure.
83 virtual bool GetScreenList(ScreenList* screens) = 0;
85 // Select the screen to be captured. Returns false in case of a failure (e.g.
86 // if there is no screen with the specified id). If this is never called, the
87 // full desktop is captured.
88 virtual bool SelectScreen(ScreenId id) = 0;
93 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_SCREEN_CAPTURER_H_