sergeyu@chromium.org | 3d34f66 | 2013-06-04 18:51:23 +0000 | [diff] [blame] | 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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef MODULES_DESKTOP_CAPTURE_SHARED_DESKTOP_FRAME_H_ |
| 12 | #define MODULES_DESKTOP_CAPTURE_SHARED_DESKTOP_FRAME_H_ |
sergeyu@chromium.org | 3d34f66 | 2013-06-04 18:51:23 +0000 | [diff] [blame] | 13 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 14 | #include "modules/desktop_capture/desktop_frame.h" |
| 15 | #include "rtc_base/constructormagic.h" |
| 16 | #include "rtc_base/refcount.h" |
Niels Möller | 84255bb | 2017-10-06 13:43:23 +0200 | [diff] [blame] | 17 | #include "rtc_base/refcountedobject.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 18 | #include "rtc_base/scoped_ref_ptr.h" |
sergeyu@chromium.org | 3d34f66 | 2013-06-04 18:51:23 +0000 | [diff] [blame] | 19 | |
| 20 | namespace webrtc { |
| 21 | |
| 22 | // SharedDesktopFrame is a DesktopFrame that may have multiple instances all |
| 23 | // sharing the same buffer. |
| 24 | class SharedDesktopFrame : public DesktopFrame { |
| 25 | public: |
Sergey Ulanov | 58000a0 | 2016-10-20 09:33:52 -0700 | [diff] [blame] | 26 | ~SharedDesktopFrame() override; |
sergeyu@chromium.org | 3d34f66 | 2013-06-04 18:51:23 +0000 | [diff] [blame] | 27 | |
sergeyu | 5d91028 | 2016-06-07 16:41:58 -0700 | [diff] [blame] | 28 | static std::unique_ptr<SharedDesktopFrame> Wrap( |
| 29 | std::unique_ptr<DesktopFrame> desktop_frame); |
| 30 | |
| 31 | // Deprecated. |
| 32 | // TODO(sergeyu): remove this method. |
sergeyu@chromium.org | 3d34f66 | 2013-06-04 18:51:23 +0000 | [diff] [blame] | 33 | static SharedDesktopFrame* Wrap(DesktopFrame* desktop_frame); |
| 34 | |
Zijie He | 5acd9d0 | 2017-08-24 12:41:53 -0700 | [diff] [blame] | 35 | // Deprecated. Clients do not need to know the underlying DesktopFrame |
| 36 | // instance. |
| 37 | // TODO(zijiehe): Remove this method. |
sergeyu@chromium.org | 3d34f66 | 2013-06-04 18:51:23 +0000 | [diff] [blame] | 38 | // Returns the underlying instance of DesktopFrame. |
| 39 | DesktopFrame* GetUnderlyingFrame(); |
| 40 | |
Zijie He | 5acd9d0 | 2017-08-24 12:41:53 -0700 | [diff] [blame] | 41 | // Returns whether |this| and |other| share the underlying DesktopFrame. |
| 42 | bool ShareFrameWith(const SharedDesktopFrame& other) const; |
| 43 | |
sergeyu@chromium.org | 3d34f66 | 2013-06-04 18:51:23 +0000 | [diff] [blame] | 44 | // Creates a clone of this object. |
sergeyu | 5d91028 | 2016-06-07 16:41:58 -0700 | [diff] [blame] | 45 | std::unique_ptr<SharedDesktopFrame> Share(); |
sergeyu@chromium.org | 3d34f66 | 2013-06-04 18:51:23 +0000 | [diff] [blame] | 46 | |
| 47 | // Checks if the frame is currently shared. If it returns false it's |
| 48 | // guaranteed that there are no clones of the object. |
| 49 | bool IsShared(); |
| 50 | |
| 51 | private: |
sergeyu | 5d91028 | 2016-06-07 16:41:58 -0700 | [diff] [blame] | 52 | typedef rtc::RefCountedObject<std::unique_ptr<DesktopFrame>> Core; |
sergeyu@chromium.org | 3d34f66 | 2013-06-04 18:51:23 +0000 | [diff] [blame] | 53 | |
Peter Boström | 26b0860 | 2015-06-04 15:18:17 +0200 | [diff] [blame] | 54 | SharedDesktopFrame(rtc::scoped_refptr<Core> core); |
sergeyu@chromium.org | 3d34f66 | 2013-06-04 18:51:23 +0000 | [diff] [blame] | 55 | |
Zijie He | 5acd9d0 | 2017-08-24 12:41:53 -0700 | [diff] [blame] | 56 | const rtc::scoped_refptr<Core> core_; |
sergeyu@chromium.org | 3d34f66 | 2013-06-04 18:51:23 +0000 | [diff] [blame] | 57 | |
henrikg | 3c089d7 | 2015-09-16 05:37:44 -0700 | [diff] [blame] | 58 | RTC_DISALLOW_COPY_AND_ASSIGN(SharedDesktopFrame); |
sergeyu@chromium.org | 3d34f66 | 2013-06-04 18:51:23 +0000 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | } // namespace webrtc |
| 62 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 63 | #endif // MODULES_DESKTOP_CAPTURE_SHARED_DESKTOP_FRAME_H_ |