shared_desktop_frame.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright (c) 2013 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_SHARED_DESKTOP_FRAME_H_
  11. #define MODULES_DESKTOP_CAPTURE_SHARED_DESKTOP_FRAME_H_
  12. #include <memory>
  13. #include "api/scoped_refptr.h"
  14. #include "modules/desktop_capture/desktop_frame.h"
  15. #include "rtc_base/constructor_magic.h"
  16. #include "rtc_base/ref_counted_object.h"
  17. #include "rtc_base/system/rtc_export.h"
  18. namespace webrtc {
  19. // SharedDesktopFrame is a DesktopFrame that may have multiple instances all
  20. // sharing the same buffer.
  21. class RTC_EXPORT SharedDesktopFrame : public DesktopFrame {
  22. public:
  23. ~SharedDesktopFrame() override;
  24. static std::unique_ptr<SharedDesktopFrame> Wrap(
  25. std::unique_ptr<DesktopFrame> desktop_frame);
  26. // Deprecated.
  27. // TODO(sergeyu): remove this method.
  28. static SharedDesktopFrame* Wrap(DesktopFrame* desktop_frame);
  29. // Deprecated. Clients do not need to know the underlying DesktopFrame
  30. // instance.
  31. // TODO(zijiehe): Remove this method.
  32. // Returns the underlying instance of DesktopFrame.
  33. DesktopFrame* GetUnderlyingFrame();
  34. // Returns whether |this| and |other| share the underlying DesktopFrame.
  35. bool ShareFrameWith(const SharedDesktopFrame& other) const;
  36. // Creates a clone of this object.
  37. std::unique_ptr<SharedDesktopFrame> Share();
  38. // Checks if the frame is currently shared. If it returns false it's
  39. // guaranteed that there are no clones of the object.
  40. bool IsShared();
  41. private:
  42. typedef rtc::RefCountedObject<std::unique_ptr<DesktopFrame>> Core;
  43. SharedDesktopFrame(rtc::scoped_refptr<Core> core);
  44. const rtc::scoped_refptr<Core> core_;
  45. RTC_DISALLOW_COPY_AND_ASSIGN(SharedDesktopFrame);
  46. };
  47. } // namespace webrtc
  48. #endif // MODULES_DESKTOP_CAPTURE_SHARED_DESKTOP_FRAME_H_