desktop_capturer_differ_wrapper.h (2837B)
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 MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURER_DIFFER_WRAPPER_H_ 12 #define MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURER_DIFFER_WRAPPER_H_ 13 14 #include <memory> 15 16 #include "modules/desktop_capture/desktop_capture_metadata.h" 17 #include "modules/desktop_capture/desktop_capture_types.h" 18 #include "modules/desktop_capture/desktop_capturer.h" 19 #include "modules/desktop_capture/desktop_frame.h" 20 #include "modules/desktop_capture/desktop_geometry.h" 21 #include "modules/desktop_capture/shared_desktop_frame.h" 22 #include "modules/desktop_capture/shared_memory.h" 23 #include "rtc_base/system/rtc_export.h" 24 25 namespace webrtc { 26 27 // DesktopCapturer wrapper that calculates updated_region() by comparing frames 28 // content. This class always expects the underlying DesktopCapturer 29 // implementation returns a superset of updated regions in DestkopFrame. If a 30 // DesktopCapturer implementation does not know the updated region, it should 31 // set updated_region() to full frame. 32 // 33 // This class marks entire frame as updated if the frame size or frame stride 34 // has been changed. 35 class RTC_EXPORT DesktopCapturerDifferWrapper 36 : public DesktopCapturer, 37 public DesktopCapturer::Callback { 38 public: 39 // Creates a DesktopCapturerDifferWrapper with a DesktopCapturer 40 // implementation, and takes its ownership. 41 explicit DesktopCapturerDifferWrapper( 42 std::unique_ptr<DesktopCapturer> base_capturer); 43 44 ~DesktopCapturerDifferWrapper() override; 45 46 // DesktopCapturer interface. 47 void Start(DesktopCapturer::Callback* callback) override; 48 void SetSharedMemoryFactory( 49 std::unique_ptr<SharedMemoryFactory> shared_memory_factory) override; 50 void CaptureFrame() override; 51 void SetExcludedWindow(WindowId window) override; 52 bool GetSourceList(SourceList* screens) override; 53 bool SelectSource(SourceId id) override; 54 bool FocusOnSelectedSource() override; 55 bool IsOccluded(const DesktopVector& pos) override; 56 #if defined(WEBRTC_USE_GIO) 57 DesktopCaptureMetadata GetMetadata() override; 58 #endif // defined(WEBRTC_USE_GIO) 59 private: 60 // DesktopCapturer::Callback interface. 61 void OnCaptureResult(Result result, 62 std::unique_ptr<DesktopFrame> frame) override; 63 64 const std::unique_ptr<DesktopCapturer> base_capturer_; 65 DesktopCapturer::Callback* callback_; 66 std::unique_ptr<SharedDesktopFrame> last_frame_; 67 }; 68 69 } // namespace webrtc 70 71 #endif // MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURER_DIFFER_WRAPPER_H_