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