objc2_core_video/generated/
CVPixelBufferIOSurface.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2_core_foundation::*;
5#[cfg(feature = "objc2-io-surface")]
6#[cfg(not(target_os = "watchos"))]
7use objc2_io_surface::*;
8
9use crate::*;
10
11extern "C" {
12    /// [Apple's documentation](https://developer.apple.com/documentation/corevideo/kcvpixelbufferiosurfaceopengltexturecompatibilitykey?language=objc)
13    pub static kCVPixelBufferIOSurfaceOpenGLTextureCompatibilityKey: &'static CFString;
14}
15
16extern "C" {
17    /// [Apple's documentation](https://developer.apple.com/documentation/corevideo/kcvpixelbufferiosurfaceopenglfbocompatibilitykey?language=objc)
18    pub static kCVPixelBufferIOSurfaceOpenGLFBOCompatibilityKey: &'static CFString;
19}
20
21extern "C" {
22    /// [Apple's documentation](https://developer.apple.com/documentation/corevideo/kcvpixelbufferiosurfacecoreanimationcompatibilitykey?language=objc)
23    pub static kCVPixelBufferIOSurfaceCoreAnimationCompatibilityKey: &'static CFString;
24}
25
26extern "C" {
27    /// [Apple's documentation](https://developer.apple.com/documentation/corevideo/kcvpixelbufferiosurfaceopenglestexturecompatibilitykey?language=objc)
28    pub static kCVPixelBufferIOSurfaceOpenGLESTextureCompatibilityKey: &'static CFString;
29}
30
31extern "C" {
32    /// [Apple's documentation](https://developer.apple.com/documentation/corevideo/kcvpixelbufferiosurfaceopenglesfbocompatibilitykey?language=objc)
33    pub static kCVPixelBufferIOSurfaceOpenGLESFBOCompatibilityKey: &'static CFString;
34}
35
36/// Returns the IOSurface backing the pixel buffer, or NULL if it is not backed by an IOSurface.
37///
38/// Parameter `pixelBuffer`: Target PixelBuffer.
39#[cfg(all(
40    feature = "CVBuffer",
41    feature = "CVImageBuffer",
42    feature = "CVPixelBuffer",
43    feature = "objc2-io-surface"
44))]
45#[cfg(not(target_os = "watchos"))]
46#[inline]
47pub extern "C-unwind" fn CVPixelBufferGetIOSurface(
48    pixel_buffer: Option<&CVPixelBuffer>,
49) -> Option<CFRetained<IOSurfaceRef>> {
50    extern "C-unwind" {
51        fn CVPixelBufferGetIOSurface(
52            pixel_buffer: Option<&CVPixelBuffer>,
53        ) -> Option<NonNull<IOSurfaceRef>>;
54    }
55    let ret = unsafe { CVPixelBufferGetIOSurface(pixel_buffer) };
56    ret.map(|ret| unsafe { CFRetained::retain(ret) })
57}
58
59extern "C-unwind" {
60    /// Call to create a single CVPixelBuffer for a passed-in IOSurface.
61    ///
62    /// The CVPixelBuffer will retain the IOSurface.
63    /// IMPORTANT NOTE: If you are using IOSurface to share CVPixelBuffers between processes
64    /// and those CVPixelBuffers are allocated via a CVPixelBufferPool, it is important
65    /// that the CVPixelBufferPool does not reuse CVPixelBuffers whose IOSurfaces are still
66    /// in use in other processes.
67    /// CoreVideo and IOSurface will take care of this for if you use IOSurfaceCreateMachPort
68    /// and IOSurfaceLookupFromMachPort, but NOT if you pass IOSurfaceIDs.
69    ///
70    /// Parameter `surface`: The IOSurface to wrap.
71    ///
72    /// Parameter `pixelBufferAttributes`: A dictionary with additional attributes for a a pixel buffer. This parameter is optional. See PixelBufferAttributes for more details.
73    ///
74    /// Parameter `pixelBufferOut`: The new pixel buffer will be returned here
75    ///
76    /// Returns: returns kCVReturnSuccess on success.
77    ///
78    /// # Safety
79    ///
80    /// - `pixel_buffer_attributes` generics must be of the correct type.
81    /// - `pixel_buffer_out` must be a valid pointer.
82    #[cfg(all(
83        feature = "CVBuffer",
84        feature = "CVImageBuffer",
85        feature = "CVPixelBuffer",
86        feature = "CVReturn",
87        feature = "objc2-io-surface"
88    ))]
89    #[cfg(not(target_os = "watchos"))]
90    pub fn CVPixelBufferCreateWithIOSurface(
91        allocator: Option<&CFAllocator>,
92        surface: &IOSurfaceRef,
93        pixel_buffer_attributes: Option<&CFDictionary>,
94        pixel_buffer_out: NonNull<*mut CVPixelBuffer>,
95    ) -> CVReturn;
96}