zijiehe | 54fd579 | 2016-11-02 14:49:35 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016 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_DIFFER_WRAPPER_H_ |
| 12 | #define WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURER_DIFFER_WRAPPER_H_ |
| 13 | |
| 14 | #include <memory> |
| 15 | |
| 16 | #include "webrtc/modules/desktop_capture/desktop_capturer.h" |
| 17 | #include "webrtc/modules/desktop_capture/shared_desktop_frame.h" |
| 18 | |
| 19 | namespace webrtc { |
| 20 | |
| 21 | // DesktopCapturer wrapper that calculates updated_region() by comparing frames |
| 22 | // content. This class always expects the underlying DesktopCapturer |
| 23 | // implementation returns a superset of updated regions in DestkopFrame. If a |
| 24 | // DesktopCapturer implementation does not know the updated region, it should |
| 25 | // set updated_region() to full frame. |
| 26 | // |
| 27 | // This class marks entire frame as updated if the frame size or frame stride |
| 28 | // has been changed. |
| 29 | class DesktopCapturerDifferWrapper : public DesktopCapturer, |
| 30 | public DesktopCapturer::Callback { |
| 31 | public: |
| 32 | // Creates a DesktopCapturerDifferWrapper with a DesktopCapturer |
| 33 | // implementation, and takes its ownership. |
| 34 | explicit DesktopCapturerDifferWrapper( |
| 35 | std::unique_ptr<DesktopCapturer> base_capturer); |
| 36 | |
| 37 | ~DesktopCapturerDifferWrapper() override; |
| 38 | |
| 39 | // DesktopCapturer interface. |
| 40 | void Start(DesktopCapturer::Callback* callback) override; |
| 41 | void SetSharedMemoryFactory( |
| 42 | std::unique_ptr<SharedMemoryFactory> shared_memory_factory) override; |
| 43 | void CaptureFrame() override; |
| 44 | void SetExcludedWindow(WindowId window) override; |
| 45 | bool GetSourceList(SourceList* screens) override; |
| 46 | bool SelectSource(SourceId id) override; |
| 47 | bool FocusOnSelectedSource() override; |
Zijie He | 9cad501 | 2017-09-14 08:32:46 -0700 | [diff] [blame] | 48 | bool IsOccluded(const DesktopVector& pos) override; |
zijiehe | 54fd579 | 2016-11-02 14:49:35 -0700 | [diff] [blame] | 49 | |
| 50 | private: |
| 51 | // DesktopCapturer::Callback interface. |
| 52 | void OnCaptureResult(Result result, |
| 53 | std::unique_ptr<DesktopFrame> frame) override; |
| 54 | |
| 55 | const std::unique_ptr<DesktopCapturer> base_capturer_; |
| 56 | DesktopCapturer::Callback* callback_; |
| 57 | std::unique_ptr<SharedDesktopFrame> last_frame_; |
| 58 | }; |
| 59 | |
| 60 | } // namespace webrtc |
| 61 | |
| 62 | #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURER_DIFFER_WRAPPER_H_ |