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