| 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 #include <stdint.h> |
| 15 | 16 |
| 16 #include <memory> | 17 #include <memory> |
| 18 #include <string> |
| 19 #include <vector> |
| 17 | 20 |
| 18 #include "webrtc/modules/desktop_capture/desktop_frame.h" | 21 #include "webrtc/modules/desktop_capture/desktop_frame.h" |
| 19 #include "webrtc/modules/desktop_capture/desktop_capture_types.h" | 22 #include "webrtc/modules/desktop_capture/desktop_capture_types.h" |
| 20 #include "webrtc/modules/desktop_capture/shared_memory.h" | 23 #include "webrtc/modules/desktop_capture/shared_memory.h" |
| 21 | 24 |
| 22 namespace webrtc { | 25 namespace webrtc { |
| 23 | 26 |
| 27 class DesktopCaptureOptions; |
| 24 class DesktopFrame; | 28 class DesktopFrame; |
| 25 | 29 |
| 26 // Abstract interface for screen and window capturers. | 30 // Abstract interface for screen and window capturers. |
| 27 class DesktopCapturer { | 31 class DesktopCapturer { |
| 28 public: | 32 public: |
| 29 enum class Result { | 33 enum class Result { |
| 30 // The frame was captured successfully. | 34 // The frame was captured successfully. |
| 31 SUCCESS, | 35 SUCCESS, |
| 32 | 36 |
| 33 // There was a temporary error. The caller should continue calling | 37 // There was a temporary error. The caller should continue calling |
| (...skipping 12 matching lines...) Expand all Loading... |
| 46 public: | 50 public: |
| 47 // Called after a frame has been captured. |frame| is not nullptr if and | 51 // Called after a frame has been captured. |frame| is not nullptr if and |
| 48 // only if |result| is SUCCESS. | 52 // only if |result| is SUCCESS. |
| 49 virtual void OnCaptureResult(Result result, | 53 virtual void OnCaptureResult(Result result, |
| 50 std::unique_ptr<DesktopFrame> frame) = 0; | 54 std::unique_ptr<DesktopFrame> frame) = 0; |
| 51 | 55 |
| 52 protected: | 56 protected: |
| 53 virtual ~Callback() {} | 57 virtual ~Callback() {} |
| 54 }; | 58 }; |
| 55 | 59 |
| 56 virtual ~DesktopCapturer() {} | 60 typedef intptr_t SourceId; |
| 61 |
| 62 struct Source { |
| 63 // The unique id to represent a Source of current DesktopCapturer. |
| 64 SourceId id; |
| 65 |
| 66 // Title of the window or screen in UTF-8 encoding, maybe empty. This field |
| 67 // should not be used to identify a source. |
| 68 std::string title; |
| 69 }; |
| 70 |
| 71 typedef std::vector<Source> SourceList; |
| 72 |
| 73 virtual ~DesktopCapturer(); |
| 57 | 74 |
| 58 // Called at the beginning of a capturing session. |callback| must remain | 75 // Called at the beginning of a capturing session. |callback| must remain |
| 59 // valid until capturer is destroyed. | 76 // valid until capturer is destroyed. |
| 60 virtual void Start(Callback* callback) = 0; | 77 virtual void Start(Callback* callback) = 0; |
| 61 | 78 |
| 62 // Sets SharedMemoryFactory that will be used to create buffers for the | 79 // Sets SharedMemoryFactory that will be used to create buffers for the |
| 63 // captured frames. The factory can be invoked on a thread other than the one | 80 // captured frames. The factory can be invoked on a thread other than the one |
| 64 // where CaptureFrame() is called. It will be destroyed on the same thread. | 81 // where CaptureFrame() is called. It will be destroyed on the same thread. |
| 65 // Shared memory is currently supported only by some DesktopCapturer | 82 // Shared memory is currently supported only by some DesktopCapturer |
| 66 // implementations. | 83 // implementations. |
| 67 virtual void SetSharedMemoryFactory( | 84 virtual void SetSharedMemoryFactory( |
| 68 std::unique_ptr<SharedMemoryFactory> shared_memory_factory) {} | 85 std::unique_ptr<SharedMemoryFactory> shared_memory_factory); |
| 69 | 86 |
| 70 // Captures next frame, and involve callback provided by Start() function. | 87 // Captures next frame, and involve callback provided by Start() function. |
| 71 // Pending capture requests are canceled when DesktopCapturer is deleted. | 88 // Pending capture requests are canceled when DesktopCapturer is deleted. |
| 72 virtual void CaptureFrame() = 0; | 89 virtual void CaptureFrame() = 0; |
| 73 | 90 |
| 74 // Sets the window to be excluded from the captured image in the future | 91 // Sets the window to be excluded from the captured image in the future |
| 75 // Capture calls. Used to exclude the screenshare notification window for | 92 // Capture calls. Used to exclude the screenshare notification window for |
| 76 // screen capturing. | 93 // screen capturing. |
| 77 virtual void SetExcludedWindow(WindowId window) {} | 94 virtual void SetExcludedWindow(WindowId window); |
| 95 |
| 96 // TODO(zijiehe): Following functions should be pure virtual. The default |
| 97 // implementations are for backward compatibility only. Remove default |
| 98 // implementations once all DesktopCapturer implementations in Chromium have |
| 99 // implemented these functions. |
| 100 |
| 101 // Gets a list of sources current capturer supports. Returns false in case of |
| 102 // a failure. |
| 103 virtual bool GetSourceList(SourceList* sources); |
| 104 |
| 105 // Selects a source to be captured. Returns false in case of a failure (e.g. |
| 106 // if there is no source with the specified type and id.) |
| 107 virtual bool SelectSource(SourceId id); |
| 108 |
| 109 // Brings the selected source to the front and sets the input focus on it. |
| 110 // Returns false in case of a failure or no source has been selected or the |
| 111 // implementation does not support this functionality. |
| 112 virtual bool FocusOnSelectedSource(); |
| 78 }; | 113 }; |
| 79 | 114 |
| 80 } // namespace webrtc | 115 } // namespace webrtc |
| 81 | 116 |
| 82 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURER_H_ | 117 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURER_H_ |
| 83 | 118 |
| OLD | NEW |