| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURER_H_ | 11 #ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURER_H_ |
| 12 #define WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURER_H_ | 12 #define WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURER_H_ |
| 13 | 13 |
| 14 #include <stddef.h> | 14 #include <stddef.h> |
| 15 | 15 |
| 16 #include <memory> | 16 #include <memory> |
| 17 | 17 |
| 18 #include "webrtc/modules/desktop_capture/desktop_frame.h" | |
| 19 #include "webrtc/modules/desktop_capture/desktop_capture_types.h" | 18 #include "webrtc/modules/desktop_capture/desktop_capture_types.h" |
| 20 #include "webrtc/modules/desktop_capture/shared_memory.h" | 19 #include "webrtc/modules/desktop_capture/shared_memory.h" |
| 21 | 20 |
| 22 namespace webrtc { | 21 namespace webrtc { |
| 23 | 22 |
| 24 class DesktopFrame; | 23 class DesktopFrame; |
| 24 class DesktopRegion; |
| 25 | 25 |
| 26 // Abstract interface for screen and window capturers. | 26 // Abstract interface for screen and window capturers. |
| 27 class DesktopCapturer { | 27 class DesktopCapturer { |
| 28 public: | 28 public: |
| 29 enum class Result { | |
| 30 // The frame was captured successfully. | |
| 31 SUCCESS, | |
| 32 | |
| 33 // There was a temporary error. The caller should continue calling | |
| 34 // Capture(), in the expectation that it will eventually recover. | |
| 35 ERROR_TEMPORARY, | |
| 36 | |
| 37 // Capture has failed and will keep failing if the caller tries calling | |
| 38 // Capture() again. | |
| 39 ERROR_PERMANENT, | |
| 40 }; | |
| 41 | |
| 42 // Interface that must be implemented by the DesktopCapturer consumers. | 29 // Interface that must be implemented by the DesktopCapturer consumers. |
| 43 class Callback { | 30 class Callback { |
| 44 public: | 31 public: |
| 45 // Called after a frame has been captured. |frame| is not nullptr if and | 32 // Called after a frame has been captured. Handler must take ownership of |
| 46 // only if |result| is SUCCESS. | 33 // |frame|. If capture has failed for any reason |frame| is set to NULL |
| 47 virtual void OnCaptureResult(Result result, | 34 // (e.g. the window has been closed). |
| 48 std::unique_ptr<DesktopFrame> frame) { | 35 virtual void OnCaptureCompleted(DesktopFrame* frame) = 0; |
| 49 OnCaptureCompleted(frame.release()); | |
| 50 } | |
| 51 | |
| 52 // Deprecated version of the method above that uses raw pointer instead of | |
| 53 // std::unique_ptr<>. | |
| 54 // TODO(sergeyu): Remove this method and make OnCaptureResult() pure | |
| 55 // virtual. crbug.com/webrtc/5950 | |
| 56 virtual void OnCaptureCompleted(DesktopFrame* frame) { delete frame; }; | |
| 57 | 36 |
| 58 protected: | 37 protected: |
| 59 virtual ~Callback() {} | 38 virtual ~Callback() {} |
| 60 }; | 39 }; |
| 61 | 40 |
| 62 virtual ~DesktopCapturer() {} | 41 virtual ~DesktopCapturer() {} |
| 63 | 42 |
| 64 // Called at the beginning of a capturing session. |callback| must remain | 43 // Called at the beginning of a capturing session. |callback| must remain |
| 65 // valid until capturer is destroyed. | 44 // valid until capturer is destroyed. |
| 66 virtual void Start(Callback* callback) = 0; | 45 virtual void Start(Callback* callback) = 0; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 83 // Sets the window to be excluded from the captured image in the future | 62 // Sets the window to be excluded from the captured image in the future |
| 84 // Capture calls. Used to exclude the screenshare notification window for | 63 // Capture calls. Used to exclude the screenshare notification window for |
| 85 // screen capturing. | 64 // screen capturing. |
| 86 virtual void SetExcludedWindow(WindowId window) {} | 65 virtual void SetExcludedWindow(WindowId window) {} |
| 87 }; | 66 }; |
| 88 | 67 |
| 89 } // namespace webrtc | 68 } // namespace webrtc |
| 90 | 69 |
| 91 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURER_H_ | 70 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURER_H_ |
| 92 | 71 |
| OLD | NEW |