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_DESKTOP_CAPTURER_H_
12 #define WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURER_H_
16 #include "webrtc/modules/desktop_capture/desktop_capture_types.h"
24 // Abstract interface for screen and window capturers.
25 class DesktopCapturer {
27 // Interface that must be implemented by the DesktopCapturer consumers.
30 // Creates a new shared memory buffer for a frame create by the capturer.
31 // Should return null shared memory is not used for captured frames (in that
32 // case the capturer will allocate memory on the heap).
33 virtual SharedMemory* CreateSharedMemory(size_t size) = 0;
35 // Called after a frame has been captured. Handler must take ownership of
36 // |frame|. If capture has failed for any reason |frame| is set to NULL
37 // (e.g. the window has been closed).
38 virtual void OnCaptureCompleted(DesktopFrame* frame) = 0;
41 virtual ~Callback() {}
44 virtual ~DesktopCapturer() {}
46 // Called at the beginning of a capturing session. |callback| must remain
47 // valid until capturer is destroyed.
48 virtual void Start(Callback* callback) = 0;
50 // Captures next frame. |region| specifies region of the capture target that
51 // should be fresh in the resulting frame. The frame may also include fresh
52 // data for areas outside |region|. In that case capturer will include these
53 // areas in updated_region() of the frame. |region| is specified relative to
54 // the top left corner of the capture target. Pending capture operations are
55 // canceled when DesktopCapturer is deleted.
56 virtual void Capture(const DesktopRegion& region) = 0;
58 // Sets the window to be excluded from the captured image in the future
59 // Capture calls. Used to exclude the screenshare notification window for
61 virtual void SetExcludedWindow(WindowId window) {}
66 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURER_H_