1 /*
2  *  Copyright (c) 2018 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_MAC_DESKTOP_FRAME_IOSURFACE_H_
12 #define MODULES_DESKTOP_CAPTURE_MAC_DESKTOP_FRAME_IOSURFACE_H_
13 
14 #include <CoreGraphics/CoreGraphics.h>
15 #include <IOSurface/IOSurface.h>
16 
17 #include <memory>
18 
19 #include "modules/desktop_capture/desktop_frame.h"
20 #include "sdk/objc/helpers/scoped_cftyperef.h"
21 
22 namespace webrtc {
23 
24 class DesktopFrameIOSurface final : public DesktopFrame {
25  public:
26   // Lock an IOSurfaceRef containing a snapshot of a display. Return NULL if
27   // failed to lock.
28   static std::unique_ptr<DesktopFrameIOSurface> Wrap(
29       rtc::ScopedCFTypeRef<IOSurfaceRef> io_surface);
30 
31   ~DesktopFrameIOSurface() override;
32 
33  private:
34   // This constructor expects |io_surface| to hold a non-null IOSurfaceRef.
35   explicit DesktopFrameIOSurface(rtc::ScopedCFTypeRef<IOSurfaceRef> io_surface);
36 
37   const rtc::ScopedCFTypeRef<IOSurfaceRef> io_surface_;
38 
39   RTC_DISALLOW_COPY_AND_ASSIGN(DesktopFrameIOSurface);
40 };
41 
42 }  // namespace webrtc
43 
44 #endif  // MODULES_DESKTOP_CAPTURE_MAC_DESKTOP_FRAME_IOSURFACE_H_
45