desktop_capturer_differ_wrapper.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. #ifndef MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURER_DIFFER_WRAPPER_H_
  11. #define MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURER_DIFFER_WRAPPER_H_
  12. #include <memory>
  13. #include "modules/desktop_capture/desktop_capture_types.h"
  14. #include "modules/desktop_capture/desktop_capturer.h"
  15. #include "modules/desktop_capture/desktop_frame.h"
  16. #include "modules/desktop_capture/desktop_geometry.h"
  17. #include "modules/desktop_capture/shared_desktop_frame.h"
  18. #include "modules/desktop_capture/shared_memory.h"
  19. #include "rtc_base/system/rtc_export.h"
  20. namespace webrtc {
  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 RTC_EXPORT DesktopCapturerDifferWrapper
  30. : public DesktopCapturer,
  31. public DesktopCapturer::Callback {
  32. public:
  33. // Creates a DesktopCapturerDifferWrapper with a DesktopCapturer
  34. // implementation, and takes its ownership.
  35. explicit DesktopCapturerDifferWrapper(
  36. std::unique_ptr<DesktopCapturer> base_capturer);
  37. ~DesktopCapturerDifferWrapper() override;
  38. // DesktopCapturer interface.
  39. void Start(DesktopCapturer::Callback* callback) override;
  40. void SetSharedMemoryFactory(
  41. std::unique_ptr<SharedMemoryFactory> shared_memory_factory) override;
  42. void CaptureFrame() override;
  43. void SetExcludedWindow(WindowId window) override;
  44. bool GetSourceList(SourceList* screens) override;
  45. bool SelectSource(SourceId id) override;
  46. bool FocusOnSelectedSource() override;
  47. bool IsOccluded(const DesktopVector& pos) override;
  48. private:
  49. // DesktopCapturer::Callback interface.
  50. void OnCaptureResult(Result result,
  51. std::unique_ptr<DesktopFrame> frame) override;
  52. const std::unique_ptr<DesktopCapturer> base_capturer_;
  53. DesktopCapturer::Callback* callback_;
  54. std::unique_ptr<SharedDesktopFrame> last_frame_;
  55. };
  56. } // namespace webrtc
  57. #endif // MODULES_DESKTOP_CAPTURE_DESKTOP_CAPTURER_DIFFER_WRAPPER_H_