Upstream version 11.40.277.0
[platform/framework/web/crosswalk.git] / src / third_party / webrtc / modules / desktop_capture / desktop_capturer.h
1 /*
2  *  Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3  *
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.
9  */
10
11 #ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURER_H_
12 #define WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURER_H_
13
14 #include <stddef.h>
15
16 #include "webrtc/modules/desktop_capture/desktop_capture_types.h"
17
18 namespace webrtc {
19
20 class DesktopFrame;
21 class DesktopRegion;
22 class SharedMemory;
23
24 // Abstract interface for screen and window capturers.
25 class DesktopCapturer {
26  public:
27   // Interface that must be implemented by the DesktopCapturer consumers.
28   class Callback {
29    public:
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;
34
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;
39
40    protected:
41     virtual ~Callback() {}
42   };
43
44   virtual ~DesktopCapturer() {}
45
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;
49
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;
57
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
60   // screen capturing.
61   virtual void SetExcludedWindow(WindowId window) {}
62 };
63
64 }  // namespace webrtc
65
66 #endif  // WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURER_H_
67