objc2_core_video/generated/
CVPixelBufferPool.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6use core::ptr::NonNull;
7#[cfg(feature = "objc2")]
8use objc2::__framework_prelude::*;
9use objc2_core_foundation::*;
10
11use crate::*;
12
13/// [Apple's documentation](https://developer.apple.com/documentation/corevideo/cvpixelbufferpool?language=objc)
14#[repr(C)]
15pub struct CVPixelBufferPool {
16    inner: [u8; 0],
17    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
18}
19
20cf_type!(
21    #[encoding_name = "__CVPixelBufferPool"]
22    unsafe impl CVPixelBufferPool {}
23);
24
25extern "C" {
26    /// [Apple's documentation](https://developer.apple.com/documentation/corevideo/kcvpixelbufferpoolminimumbuffercountkey?language=objc)
27    pub static kCVPixelBufferPoolMinimumBufferCountKey: &'static CFString;
28}
29
30extern "C" {
31    /// [Apple's documentation](https://developer.apple.com/documentation/corevideo/kcvpixelbufferpoolmaximumbufferagekey?language=objc)
32    pub static kCVPixelBufferPoolMaximumBufferAgeKey: &'static CFString;
33}
34
35unsafe impl ConcreteType for CVPixelBufferPool {
36    #[doc(alias = "CVPixelBufferPoolGetTypeID")]
37    #[inline]
38    fn type_id() -> CFTypeID {
39        extern "C-unwind" {
40            fn CVPixelBufferPoolGetTypeID() -> CFTypeID;
41        }
42        unsafe { CVPixelBufferPoolGetTypeID() }
43    }
44}
45
46extern "C-unwind" {
47    /// Creates a new Pixel Buffer pool.
48    ///
49    /// Parameter `allocator`: The CFAllocatorRef to use for allocating this buffer pool.  May be NULL.
50    ///
51    /// Parameter `attributes`: A CFDictionaryRef containing the attributes to be used for creating new PixelBuffers within the pool.
52    ///
53    /// Parameter `poolOut`: The newly created pool will be placed here
54    ///
55    /// Returns: Returns kCVReturnSuccess on success
56    #[cfg(feature = "CVReturn")]
57    pub fn CVPixelBufferPoolCreate(
58        allocator: Option<&CFAllocator>,
59        pool_attributes: Option<&CFDictionary>,
60        pixel_buffer_attributes: Option<&CFDictionary>,
61        pool_out: NonNull<*mut CVPixelBufferPool>,
62    ) -> CVReturn;
63}
64
65/// Returns the pool attributes dictionary for a CVPixelBufferPool
66///
67/// Parameter `pool`: The CVPixelBufferPoolRef to retrieve the attributes from
68///
69/// Returns: Returns the pool attributes dictionary, or NULL on failure.
70#[inline]
71pub unsafe extern "C-unwind" fn CVPixelBufferPoolGetAttributes(
72    pool: &CVPixelBufferPool,
73) -> Option<CFRetained<CFDictionary>> {
74    extern "C-unwind" {
75        fn CVPixelBufferPoolGetAttributes(
76            pool: &CVPixelBufferPool,
77        ) -> Option<NonNull<CFDictionary>>;
78    }
79    let ret = unsafe { CVPixelBufferPoolGetAttributes(pool) };
80    ret.map(|ret| unsafe { CFRetained::retain(ret) })
81}
82
83/// Returns the attributes of pixel buffers that will be created from this pool.
84///
85/// This function is provided for those cases where you may need to know some information about the buffers that
86/// will be created up front.
87///
88/// Parameter `pool`: The CVPixelBufferPoolRef to retrieve the attributes from
89///
90/// Returns: Returns the pixel buffer attributes dictionary, or NULL on failure.
91#[inline]
92pub unsafe extern "C-unwind" fn CVPixelBufferPoolGetPixelBufferAttributes(
93    pool: &CVPixelBufferPool,
94) -> Option<CFRetained<CFDictionary>> {
95    extern "C-unwind" {
96        fn CVPixelBufferPoolGetPixelBufferAttributes(
97            pool: &CVPixelBufferPool,
98        ) -> Option<NonNull<CFDictionary>>;
99    }
100    let ret = unsafe { CVPixelBufferPoolGetPixelBufferAttributes(pool) };
101    ret.map(|ret| unsafe { CFRetained::retain(ret) })
102}
103
104extern "C-unwind" {
105    /// Creates a new PixelBuffer object from the pool.
106    ///
107    /// The function creates a new (attachment-free) CVPixelBuffer using the pixel buffer attributes specifed during pool creation.
108    ///
109    /// Parameter `allocator`: The CFAllocatorRef to use for creating the pixel buffer.  May be NULL.
110    ///
111    /// Parameter `pool`: The CVPixelBufferPool that should create the new CVPixelBuffer.
112    ///
113    /// Parameter `pixelBufferOut`: The newly created pixel buffer will be placed here
114    ///
115    /// Returns: Returns kCVReturnSuccess on success
116    #[cfg(all(
117        feature = "CVBuffer",
118        feature = "CVImageBuffer",
119        feature = "CVPixelBuffer",
120        feature = "CVReturn"
121    ))]
122    pub fn CVPixelBufferPoolCreatePixelBuffer(
123        allocator: Option<&CFAllocator>,
124        pixel_buffer_pool: &CVPixelBufferPool,
125        pixel_buffer_out: NonNull<*mut CVPixelBuffer>,
126    ) -> CVReturn;
127}
128
129extern "C-unwind" {
130    #[cfg(all(
131        feature = "CVBuffer",
132        feature = "CVImageBuffer",
133        feature = "CVPixelBuffer",
134        feature = "CVReturn"
135    ))]
136    pub fn CVPixelBufferPoolCreatePixelBufferWithAuxAttributes(
137        allocator: Option<&CFAllocator>,
138        pixel_buffer_pool: &CVPixelBufferPool,
139        aux_attributes: Option<&CFDictionary>,
140        pixel_buffer_out: NonNull<*mut CVPixelBuffer>,
141    ) -> CVReturn;
142}
143
144extern "C" {
145    /// [Apple's documentation](https://developer.apple.com/documentation/corevideo/kcvpixelbufferpoolallocationthresholdkey?language=objc)
146    pub static kCVPixelBufferPoolAllocationThresholdKey: &'static CFString;
147}
148
149extern "C" {
150    /// [Apple's documentation](https://developer.apple.com/documentation/corevideo/kcvpixelbufferpoolfreebuffernotification?language=objc)
151    pub static kCVPixelBufferPoolFreeBufferNotification: &'static CFString;
152}
153
154/// Flags to pass to CVPixelBufferPoolFlush()
155///
156/// This flag will cause CVPixelBufferPoolFlush to flush all unused buffers regardless of age.
157///
158/// See also [Apple's documentation](https://developer.apple.com/documentation/corevideo/cvpixelbufferpoolflushflags?language=objc)
159// NS_OPTIONS
160#[cfg(feature = "CVBase")]
161#[repr(transparent)]
162#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
163pub struct CVPixelBufferPoolFlushFlags(pub CVOptionFlags);
164#[cfg(feature = "CVBase")]
165bitflags::bitflags! {
166    impl CVPixelBufferPoolFlushFlags: CVOptionFlags {
167        #[doc(alias = "kCVPixelBufferPoolFlushExcessBuffers")]
168        const ExcessBuffers = 1;
169    }
170}
171
172#[cfg(all(feature = "CVBase", feature = "objc2"))]
173unsafe impl Encode for CVPixelBufferPoolFlushFlags {
174    const ENCODING: Encoding = CVOptionFlags::ENCODING;
175}
176
177#[cfg(all(feature = "CVBase", feature = "objc2"))]
178unsafe impl RefEncode for CVPixelBufferPoolFlushFlags {
179    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
180}
181
182extern "C-unwind" {
183    /// Frees as many buffers from the pool as possible.
184    ///
185    /// By default, this function will free all aged out buffers.  Setting the
186    /// kCVPixelBufferPoolFlushExcessBuffers flag will cause this call to free all unused
187    /// buffers regardless of age.
188    ///
189    /// Parameter `pool`: The CVPixelBufferPool to be flushed.
190    ///
191    /// Parameter `options`: Set to kCVPixelBufferPoolFlushExcessBuffers to free all unused buffers
192    /// regardless of their age.
193    #[cfg(feature = "CVBase")]
194    pub fn CVPixelBufferPoolFlush(pool: &CVPixelBufferPool, options: CVPixelBufferPoolFlushFlags);
195}