Chromium Code Reviews| 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 // Title of the window or screen in UTF-8 encoding, maybe empty. This field | |
|
Sergey Ulanov
2016/10/28 23:08:15
nit: empty line here
Hzj_jie
2016/10/29 00:04:56
Done.
| |
| 66 // should not be used to identify a source. | |
| 67 std::string title; | |
| 68 }; | |
| 69 | |
| 70 typedef std::vector<Source> SourceList; | |
| 71 | |
| 72 virtual ~DesktopCapturer(); | |
| 57 | 73 |
| 58 // Called at the beginning of a capturing session. |callback| must remain | 74 // Called at the beginning of a capturing session. |callback| must remain |
| 59 // valid until capturer is destroyed. | 75 // valid until capturer is destroyed. |
| 60 virtual void Start(Callback* callback) = 0; | 76 virtual void Start(Callback* callback) = 0; |
| 61 | 77 |
| 62 // Sets SharedMemoryFactory that will be used to create buffers for the | 78 // 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 | 79 // 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. | 80 // where CaptureFrame() is called. It will be destroyed on the same thread. |
| 65 // Shared memory is currently supported only by some DesktopCapturer | 81 // Shared memory is currently supported only by some DesktopCapturer |
| 66 // implementations. | 82 // implementations. |
| 67 virtual void SetSharedMemoryFactory( | 83 virtual void SetSharedMemoryFactory( |
| 68 std::unique_ptr<SharedMemoryFactory> shared_memory_factory) {} | 84 std::unique_ptr<SharedMemoryFactory> shared_memory_factory); |
| 69 | 85 |
| 70 // Captures next frame, and involve callback provided by Start() function. | 86 // Captures next frame, and involve callback provided by Start() function. |
| 71 // Pending capture requests are canceled when DesktopCapturer is deleted. | 87 // Pending capture requests are canceled when DesktopCapturer is deleted. |
| 72 virtual void CaptureFrame() = 0; | 88 virtual void CaptureFrame() = 0; |
| 73 | 89 |
| 74 // Sets the window to be excluded from the captured image in the future | 90 // Sets the window to be excluded from the captured image in the future |
| 75 // Capture calls. Used to exclude the screenshare notification window for | 91 // Capture calls. Used to exclude the screenshare notification window for |
| 76 // screen capturing. | 92 // screen capturing. |
| 77 virtual void SetExcludedWindow(WindowId window) {} | 93 virtual void SetExcludedWindow(WindowId window); |
| 94 | |
| 95 // TODO(zijiehe): Following functions should be pure virtual. The default | |
| 96 // implementations are for backward compatibility only. Remove default | |
| 97 // implementations once all DesktopCapturer implementations in Chromium have | |
| 98 // implemented these functions. | |
| 99 | |
| 100 // Gets a list of sources current capturer supports. Returns false in case of | |
| 101 // a failure. | |
| 102 virtual bool GetSourceList(SourceList* sources); | |
| 103 | |
| 104 // Selects a source to be captured. Returns false in case of a failure (e.g. | |
| 105 // if there is no source with the specified type and id.) | |
| 106 virtual bool SelectSource(SourceId id); | |
| 107 | |
| 108 // Brings the selected source to the front and sets the input focus on it. | |
| 109 // Returns false in case of a failure or no source has been selected or the | |
| 110 // implementation does not support this functionality. | |
| 111 virtual bool FocusOnSelectedSource(); | |
| 78 }; | 112 }; |
| 79 | 113 |
| 80 } // namespace webrtc | 114 } // namespace webrtc |
| 81 | 115 |
| 82 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURER_H_ | 116 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURER_H_ |
| 83 | 117 |
| OLD | NEW |