| 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> | |
| 16 | 15 |
| 17 #include <memory> | 16 #include <memory> |
| 18 #include <string> | |
| 19 #include <vector> | |
| 20 | 17 |
| 21 #include "webrtc/modules/desktop_capture/desktop_frame.h" | 18 #include "webrtc/modules/desktop_capture/desktop_frame.h" |
| 22 #include "webrtc/modules/desktop_capture/desktop_capture_types.h" | 19 #include "webrtc/modules/desktop_capture/desktop_capture_types.h" |
| 23 #include "webrtc/modules/desktop_capture/shared_memory.h" | 20 #include "webrtc/modules/desktop_capture/shared_memory.h" |
| 24 | 21 |
| 25 namespace webrtc { | 22 namespace webrtc { |
| 26 | 23 |
| 27 class DesktopCaptureOptions; | |
| 28 class DesktopFrame; | 24 class DesktopFrame; |
| 29 | 25 |
| 30 // Abstract interface for screen and window capturers. | 26 // Abstract interface for screen and window capturers. |
| 31 class DesktopCapturer { | 27 class DesktopCapturer { |
| 32 public: | 28 public: |
| 33 enum class Result { | 29 enum class Result { |
| 34 // The frame was captured successfully. | 30 // The frame was captured successfully. |
| 35 SUCCESS, | 31 SUCCESS, |
| 36 | 32 |
| 37 // There was a temporary error. The caller should continue calling | 33 // There was a temporary error. The caller should continue calling |
| (...skipping 12 matching lines...) Expand all Loading... |
| 50 public: | 46 public: |
| 51 // Called after a frame has been captured. |frame| is not nullptr if and | 47 // Called after a frame has been captured. |frame| is not nullptr if and |
| 52 // only if |result| is SUCCESS. | 48 // only if |result| is SUCCESS. |
| 53 virtual void OnCaptureResult(Result result, | 49 virtual void OnCaptureResult(Result result, |
| 54 std::unique_ptr<DesktopFrame> frame) = 0; | 50 std::unique_ptr<DesktopFrame> frame) = 0; |
| 55 | 51 |
| 56 protected: | 52 protected: |
| 57 virtual ~Callback() {} | 53 virtual ~Callback() {} |
| 58 }; | 54 }; |
| 59 | 55 |
| 60 typedef intptr_t SourceId; | 56 virtual ~DesktopCapturer() {} |
| 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(); | |
| 74 | 57 |
| 75 // Called at the beginning of a capturing session. |callback| must remain | 58 // Called at the beginning of a capturing session. |callback| must remain |
| 76 // valid until capturer is destroyed. | 59 // valid until capturer is destroyed. |
| 77 virtual void Start(Callback* callback) = 0; | 60 virtual void Start(Callback* callback) = 0; |
| 78 | 61 |
| 79 // Sets SharedMemoryFactory that will be used to create buffers for the | 62 // Sets SharedMemoryFactory that will be used to create buffers for the |
| 80 // captured frames. The factory can be invoked on a thread other than the one | 63 // captured frames. The factory can be invoked on a thread other than the one |
| 81 // where CaptureFrame() is called. It will be destroyed on the same thread. | 64 // where CaptureFrame() is called. It will be destroyed on the same thread. |
| 82 // Shared memory is currently supported only by some DesktopCapturer | 65 // Shared memory is currently supported only by some DesktopCapturer |
| 83 // implementations. | 66 // implementations. |
| 84 virtual void SetSharedMemoryFactory( | 67 virtual void SetSharedMemoryFactory( |
| 85 std::unique_ptr<SharedMemoryFactory> shared_memory_factory); | 68 std::unique_ptr<SharedMemoryFactory> shared_memory_factory) {} |
| 86 | 69 |
| 87 // Captures next frame, and involve callback provided by Start() function. | 70 // Captures next frame, and involve callback provided by Start() function. |
| 88 // Pending capture requests are canceled when DesktopCapturer is deleted. | 71 // Pending capture requests are canceled when DesktopCapturer is deleted. |
| 89 virtual void CaptureFrame() = 0; | 72 virtual void CaptureFrame() = 0; |
| 90 | 73 |
| 91 // Sets the window to be excluded from the captured image in the future | 74 // Sets the window to be excluded from the captured image in the future |
| 92 // Capture calls. Used to exclude the screenshare notification window for | 75 // Capture calls. Used to exclude the screenshare notification window for |
| 93 // screen capturing. | 76 // screen capturing. |
| 94 virtual void SetExcludedWindow(WindowId window); | 77 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(); | |
| 113 }; | 78 }; |
| 114 | 79 |
| 115 } // namespace webrtc | 80 } // namespace webrtc |
| 116 | 81 |
| 117 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURER_H_ | 82 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURER_H_ |
| 118 | 83 |
| OLD | NEW |