sergeyu@chromium.org | 85a1dab | 2013-04-29 20:10:57 +0000 | [diff] [blame] | 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 | |
sergeyu@chromium.org | 6c82a7e | 2013-06-04 18:51:23 +0000 | [diff] [blame] | 14 | #include <stddef.h> |
| 15 | |
sergeyu@chromium.org | 85a1dab | 2013-04-29 20:10:57 +0000 | [diff] [blame] | 16 | namespace webrtc { |
| 17 | |
| 18 | class DesktopFrame; |
| 19 | class DesktopRegion; |
| 20 | class SharedMemory; |
| 21 | |
| 22 | // Abstract interface for screen and window capturers. |
| 23 | class DesktopCapturer { |
| 24 | public: |
| 25 | // Interface that must be implemented by the DesktopCapturer consumers. |
| 26 | class Callback { |
| 27 | public: |
| 28 | // Creates a new shared memory buffer for a frame create by the capturer. |
| 29 | // Should return null shared memory is not used for captured frames (in that |
| 30 | // case the capturer will allocate memory on the heap). |
| 31 | virtual SharedMemory* CreateSharedMemory(size_t size) = 0; |
| 32 | |
| 33 | // Called after a frame has been captured. Handler must take ownership of |
| 34 | // |frame|. If capture has failed for any reason |frame| is set to NULL |
| 35 | // (e.g. the window has been closed). |
| 36 | virtual void OnCaptureCompleted(DesktopFrame* frame) = 0; |
| 37 | |
| 38 | protected: |
| 39 | virtual ~Callback() {} |
| 40 | }; |
| 41 | |
| 42 | virtual ~DesktopCapturer() {} |
| 43 | |
| 44 | // Called at the beginning of a capturing session. |callback| must remain |
| 45 | // valid until capturer is destroyed. |
| 46 | virtual void Start(Callback* callback) = 0; |
| 47 | |
| 48 | // Captures next frame. |region| specifies region of the capture target that |
| 49 | // should be fresh in the resulting frame. The frame may also include fresh |
| 50 | // data for areas outside |region|. In that case capturer will include these |
| 51 | // areas in updated_region() of the frame. |region| is specified relative to |
| 52 | // the top left corner of the capture target. Pending capture operations are |
| 53 | // canceled when DesktopCapturer is deleted. |
| 54 | virtual void Capture(const DesktopRegion& region) = 0; |
| 55 | }; |
| 56 | |
| 57 | } // namespace webrtc |
| 58 | |
| 59 | #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURER_H_ |
| 60 | |