xref: /aosp_15_r20/external/webrtc/modules/desktop_capture/mac/desktop_frame_iosurface.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
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   DesktopFrameIOSurface(const DesktopFrameIOSurface&) = delete;
34   DesktopFrameIOSurface& operator=(const DesktopFrameIOSurface&) = delete;
35 
36  private:
37   // This constructor expects `io_surface` to hold a non-null IOSurfaceRef.
38   explicit DesktopFrameIOSurface(rtc::ScopedCFTypeRef<IOSurfaceRef> io_surface);
39 
40   const rtc::ScopedCFTypeRef<IOSurfaceRef> io_surface_;
41 };
42 
43 }  // namespace webrtc
44 
45 #endif  // MODULES_DESKTOP_CAPTURE_MAC_DESKTOP_FRAME_IOSURFACE_H_
46