objc2_core_video/generated/
CVPixelBufferPool.rs1use 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#[doc(alias = "CVPixelBufferPoolRef")]
15#[repr(C)]
16pub struct CVPixelBufferPool {
17 inner: [u8; 0],
18 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
19}
20
21cf_type!(
22 unsafe impl CVPixelBufferPool {}
23);
24#[cfg(feature = "objc2")]
25cf_objc2_type!(
26 unsafe impl RefEncode<"__CVPixelBufferPool"> for CVPixelBufferPool {}
27);
28
29extern "C" {
30 pub static kCVPixelBufferPoolMinimumBufferCountKey: &'static CFString;
32}
33
34extern "C" {
35 pub static kCVPixelBufferPoolMaximumBufferAgeKey: &'static CFString;
37}
38
39unsafe impl ConcreteType for CVPixelBufferPool {
40 #[doc(alias = "CVPixelBufferPoolGetTypeID")]
41 #[inline]
42 fn type_id() -> CFTypeID {
43 extern "C-unwind" {
44 fn CVPixelBufferPoolGetTypeID() -> CFTypeID;
45 }
46 unsafe { CVPixelBufferPoolGetTypeID() }
47 }
48}
49
50impl CVPixelBufferPool {
51 #[doc(alias = "CVPixelBufferPoolCreate")]
67 #[cfg(feature = "CVReturn")]
68 #[inline]
69 pub unsafe fn create(
70 allocator: Option<&CFAllocator>,
71 pool_attributes: Option<&CFDictionary>,
72 pixel_buffer_attributes: Option<&CFDictionary>,
73 pool_out: NonNull<*mut CVPixelBufferPool>,
74 ) -> CVReturn {
75 extern "C-unwind" {
76 fn CVPixelBufferPoolCreate(
77 allocator: Option<&CFAllocator>,
78 pool_attributes: Option<&CFDictionary>,
79 pixel_buffer_attributes: Option<&CFDictionary>,
80 pool_out: NonNull<*mut CVPixelBufferPool>,
81 ) -> CVReturn;
82 }
83 unsafe {
84 CVPixelBufferPoolCreate(
85 allocator,
86 pool_attributes,
87 pixel_buffer_attributes,
88 pool_out,
89 )
90 }
91 }
92
93 #[doc(alias = "CVPixelBufferPoolGetAttributes")]
99 #[inline]
100 pub fn attributes(&self) -> Option<CFRetained<CFDictionary>> {
101 extern "C-unwind" {
102 fn CVPixelBufferPoolGetAttributes(
103 pool: &CVPixelBufferPool,
104 ) -> Option<NonNull<CFDictionary>>;
105 }
106 let ret = unsafe { CVPixelBufferPoolGetAttributes(self) };
107 ret.map(|ret| unsafe { CFRetained::retain(ret) })
108 }
109
110 #[doc(alias = "CVPixelBufferPoolGetPixelBufferAttributes")]
119 #[inline]
120 pub fn pixel_buffer_attributes(&self) -> Option<CFRetained<CFDictionary>> {
121 extern "C-unwind" {
122 fn CVPixelBufferPoolGetPixelBufferAttributes(
123 pool: &CVPixelBufferPool,
124 ) -> Option<NonNull<CFDictionary>>;
125 }
126 let ret = unsafe { CVPixelBufferPoolGetPixelBufferAttributes(self) };
127 ret.map(|ret| unsafe { CFRetained::retain(ret) })
128 }
129
130 #[doc(alias = "CVPixelBufferPoolCreatePixelBuffer")]
146 #[cfg(all(
147 feature = "CVBuffer",
148 feature = "CVImageBuffer",
149 feature = "CVPixelBuffer",
150 feature = "CVReturn"
151 ))]
152 #[inline]
153 pub unsafe fn create_pixel_buffer(
154 allocator: Option<&CFAllocator>,
155 pixel_buffer_pool: &CVPixelBufferPool,
156 pixel_buffer_out: NonNull<*mut CVPixelBuffer>,
157 ) -> CVReturn {
158 extern "C-unwind" {
159 fn CVPixelBufferPoolCreatePixelBuffer(
160 allocator: Option<&CFAllocator>,
161 pixel_buffer_pool: &CVPixelBufferPool,
162 pixel_buffer_out: NonNull<*mut CVPixelBuffer>,
163 ) -> CVReturn;
164 }
165 unsafe {
166 CVPixelBufferPoolCreatePixelBuffer(allocator, pixel_buffer_pool, pixel_buffer_out)
167 }
168 }
169
170 #[doc(alias = "CVPixelBufferPoolCreatePixelBufferWithAuxAttributes")]
175 #[cfg(all(
176 feature = "CVBuffer",
177 feature = "CVImageBuffer",
178 feature = "CVPixelBuffer",
179 feature = "CVReturn"
180 ))]
181 #[inline]
182 pub unsafe fn create_pixel_buffer_with_aux_attributes(
183 allocator: Option<&CFAllocator>,
184 pixel_buffer_pool: &CVPixelBufferPool,
185 aux_attributes: Option<&CFDictionary>,
186 pixel_buffer_out: NonNull<*mut CVPixelBuffer>,
187 ) -> CVReturn {
188 extern "C-unwind" {
189 fn CVPixelBufferPoolCreatePixelBufferWithAuxAttributes(
190 allocator: Option<&CFAllocator>,
191 pixel_buffer_pool: &CVPixelBufferPool,
192 aux_attributes: Option<&CFDictionary>,
193 pixel_buffer_out: NonNull<*mut CVPixelBuffer>,
194 ) -> CVReturn;
195 }
196 unsafe {
197 CVPixelBufferPoolCreatePixelBufferWithAuxAttributes(
198 allocator,
199 pixel_buffer_pool,
200 aux_attributes,
201 pixel_buffer_out,
202 )
203 }
204 }
205}
206
207extern "C" {
208 pub static kCVPixelBufferPoolAllocationThresholdKey: &'static CFString;
210}
211
212extern "C" {
213 pub static kCVPixelBufferPoolFreeBufferNotification: &'static CFString;
215}
216
217#[cfg(feature = "CVBase")]
224#[repr(transparent)]
225#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
226pub struct CVPixelBufferPoolFlushFlags(pub CVOptionFlags);
227#[cfg(feature = "CVBase")]
228bitflags::bitflags! {
229 impl CVPixelBufferPoolFlushFlags: CVOptionFlags {
230 #[doc(alias = "kCVPixelBufferPoolFlushExcessBuffers")]
231 const ExcessBuffers = 1;
232 }
233}
234
235#[cfg(all(feature = "CVBase", feature = "objc2"))]
236unsafe impl Encode for CVPixelBufferPoolFlushFlags {
237 const ENCODING: Encoding = CVOptionFlags::ENCODING;
238}
239
240#[cfg(all(feature = "CVBase", feature = "objc2"))]
241unsafe impl RefEncode for CVPixelBufferPoolFlushFlags {
242 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
243}
244
245impl CVPixelBufferPool {
246 #[doc(alias = "CVPixelBufferPoolFlush")]
257 #[cfg(feature = "CVBase")]
258 #[inline]
259 pub fn flush(&self, options: CVPixelBufferPoolFlushFlags) {
260 extern "C-unwind" {
261 fn CVPixelBufferPoolFlush(
262 pool: &CVPixelBufferPool,
263 options: CVPixelBufferPoolFlushFlags,
264 );
265 }
266 unsafe { CVPixelBufferPoolFlush(self, options) }
267 }
268}
269
270extern "C-unwind" {
271 #[cfg(feature = "CVReturn")]
272 #[deprecated = "renamed to `CVPixelBufferPool::create`"]
273 pub fn CVPixelBufferPoolCreate(
274 allocator: Option<&CFAllocator>,
275 pool_attributes: Option<&CFDictionary>,
276 pixel_buffer_attributes: Option<&CFDictionary>,
277 pool_out: NonNull<*mut CVPixelBufferPool>,
278 ) -> CVReturn;
279}
280
281#[deprecated = "renamed to `CVPixelBufferPool::attributes`"]
282#[inline]
283pub extern "C-unwind" fn CVPixelBufferPoolGetAttributes(
284 pool: &CVPixelBufferPool,
285) -> Option<CFRetained<CFDictionary>> {
286 extern "C-unwind" {
287 fn CVPixelBufferPoolGetAttributes(
288 pool: &CVPixelBufferPool,
289 ) -> Option<NonNull<CFDictionary>>;
290 }
291 let ret = unsafe { CVPixelBufferPoolGetAttributes(pool) };
292 ret.map(|ret| unsafe { CFRetained::retain(ret) })
293}
294
295#[deprecated = "renamed to `CVPixelBufferPool::pixel_buffer_attributes`"]
296#[inline]
297pub extern "C-unwind" fn CVPixelBufferPoolGetPixelBufferAttributes(
298 pool: &CVPixelBufferPool,
299) -> Option<CFRetained<CFDictionary>> {
300 extern "C-unwind" {
301 fn CVPixelBufferPoolGetPixelBufferAttributes(
302 pool: &CVPixelBufferPool,
303 ) -> Option<NonNull<CFDictionary>>;
304 }
305 let ret = unsafe { CVPixelBufferPoolGetPixelBufferAttributes(pool) };
306 ret.map(|ret| unsafe { CFRetained::retain(ret) })
307}
308
309extern "C-unwind" {
310 #[cfg(all(
311 feature = "CVBuffer",
312 feature = "CVImageBuffer",
313 feature = "CVPixelBuffer",
314 feature = "CVReturn"
315 ))]
316 #[deprecated = "renamed to `CVPixelBufferPool::create_pixel_buffer`"]
317 pub fn CVPixelBufferPoolCreatePixelBuffer(
318 allocator: Option<&CFAllocator>,
319 pixel_buffer_pool: &CVPixelBufferPool,
320 pixel_buffer_out: NonNull<*mut CVPixelBuffer>,
321 ) -> CVReturn;
322}
323
324extern "C-unwind" {
325 #[cfg(all(
326 feature = "CVBuffer",
327 feature = "CVImageBuffer",
328 feature = "CVPixelBuffer",
329 feature = "CVReturn"
330 ))]
331 #[deprecated = "renamed to `CVPixelBufferPool::create_pixel_buffer_with_aux_attributes`"]
332 pub fn CVPixelBufferPoolCreatePixelBufferWithAuxAttributes(
333 allocator: Option<&CFAllocator>,
334 pixel_buffer_pool: &CVPixelBufferPool,
335 aux_attributes: Option<&CFDictionary>,
336 pixel_buffer_out: NonNull<*mut CVPixelBuffer>,
337 ) -> CVReturn;
338}
339
340#[cfg(feature = "CVBase")]
341#[deprecated = "renamed to `CVPixelBufferPool::flush`"]
342#[inline]
343pub extern "C-unwind" fn CVPixelBufferPoolFlush(
344 pool: &CVPixelBufferPool,
345 options: CVPixelBufferPoolFlushFlags,
346) {
347 extern "C-unwind" {
348 fn CVPixelBufferPoolFlush(pool: &CVPixelBufferPool, options: CVPixelBufferPoolFlushFlags);
349 }
350 unsafe { CVPixelBufferPoolFlush(pool, options) }
351}