pub struct CVPixelBufferPool { /* private fields */ }cv only.Expand description
Opaque handle to a native CVPixelBufferPoolRef.
Implementations§
Source§impl CVPixelBufferPool
impl CVPixelBufferPool
Sourcepub unsafe fn from_raw(ptr: *mut c_void) -> Option<Self>
pub unsafe fn from_raw(ptr: *mut c_void) -> Option<Self>
Adopts a +1 retained native pool with no wrapper allocation threshold.
§Safety
A non-null ptr must be a live CVPixelBufferPoolRef carrying one
retain transferred to this wrapper. The caller must not release or
separately adopt that transferred retain.
Sourcepub unsafe fn from_raw_with_max_buffers(
ptr: *mut c_void,
max_buffers: usize,
) -> Result<Option<Self>, i32>
pub unsafe fn from_raw_with_max_buffers( ptr: *mut c_void, max_buffers: usize, ) -> Result<Option<Self>, i32>
Adopts a +1 retained native pool and applies max_buffers to wrapper allocations.
A zero threshold means unlimited. Native callers using Self::as_ptr
can bypass this wrapper policy.
§Safety
A non-null ptr must be a live CVPixelBufferPoolRef carrying one
retain transferred to this wrapper. On an error, ownership remains with
the caller.
§Errors
Returns paramErr if max_buffers cannot be represented by Core Video.
Sourcepub unsafe fn from_raw_borrowed(ptr: *mut c_void) -> Option<Self>
pub unsafe fn from_raw_borrowed(ptr: *mut c_void) -> Option<Self>
Retains a +0 borrowed native pool with no wrapper allocation threshold.
§Safety
A non-null ptr must be a live CVPixelBufferPoolRef for the duration
of the retain call.
Sourcepub unsafe fn from_raw_borrowed_with_max_buffers(
ptr: *mut c_void,
max_buffers: usize,
) -> Result<Option<Self>, i32>
pub unsafe fn from_raw_borrowed_with_max_buffers( ptr: *mut c_void, max_buffers: usize, ) -> Result<Option<Self>, i32>
Sourcepub unsafe fn from_ptr(ptr: *mut c_void) -> Self
pub unsafe fn from_ptr(ptr: *mut c_void) -> Self
Wraps a raw CVPixelBufferPoolRef by taking ownership without retaining it.
§Safety
ptr must be a non-null, live CVPixelBufferPoolRef carrying one retain
transferred to this wrapper.
Sourcepub const fn as_ptr(&self) -> *mut c_void
pub const fn as_ptr(&self) -> *mut c_void
Borrows the raw +0 native pool pointer while self remains alive.
Allocations performed directly through this pointer bypass the wrapper’s
configured Self::max_buffers threshold.
Sourcepub fn max_buffers(&self) -> usize
pub fn max_buffers(&self) -> usize
Wrapper-enforced allocation threshold, or zero when unlimited.
Sourcepub fn create(
width: usize,
height: usize,
pixel_format: u32,
max_buffers: usize,
) -> Result<Self, i32>
pub fn create( width: usize, height: usize, pixel_format: u32, max_buffers: usize, ) -> Result<Self, i32>
Create a new pixel buffer pool
§Arguments
width- Width of pixel buffers in the poolheight- Height of pixel buffers in the poolpixel_format- Pixel format typemax_buffers- Maximum number of buffers in the pool (0 for unlimited)
§Errors
Returns a Core Video error code if the pool creation fails.
Sourcepub fn create_pixel_buffer(&self) -> Result<CVPixelBuffer, i32>
pub fn create_pixel_buffer(&self) -> Result<CVPixelBuffer, i32>
Create a pixel buffer while enforcing the configured allocation threshold.
§Errors
Returns a Core Video error code if the buffer creation fails.
Sourcepub fn flush_with_flags(&self, flags: CVPixelBufferPoolFlushFlags)
pub fn flush_with_flags(&self, flags: CVPixelBufferPoolFlushFlags)
Flush unused buffers according to native Core Video flags.
Sourcepub fn flush_excess_buffers(&self)
pub fn flush_excess_buffers(&self)
Flush every unused buffer regardless of age.
Sourcepub fn create_pixel_buffer_with_aux_attributes(
&self,
aux_attributes: Option<&HashMap<String, u32>>,
) -> Result<CVPixelBuffer, i32>
pub fn create_pixel_buffer_with_aux_attributes( &self, aux_attributes: Option<&HashMap<String, u32>>, ) -> Result<CVPixelBuffer, i32>
Create a pixel buffer from the pool with per-call auxiliary attributes.
String keys become CFString keys and values become CFNumber values.
A per-call allocation threshold can tighten but not loosen the
threshold configured when the wrapper was created.
§Errors
Returns paramErr for an attribute key containing a NUL byte or an
unrepresentable threshold, otherwise returns the Core Video allocation
status.
Sourcepub fn try_create_pixel_buffer(&self) -> Result<Option<CVPixelBuffer>, i32>
pub fn try_create_pixel_buffer(&self) -> Result<Option<CVPixelBuffer>, i32>
Try to create a pixel buffer without exceeding the allocation threshold.
Only kCVReturnWouldExceedAllocationThreshold maps to Ok(None);
every other Core Video error is preserved.
§Errors
Returns any Core Video allocation error other than threshold exhaustion.
Sourcepub fn attributes(&self) -> Option<CFDictionary>
pub fn attributes(&self) -> Option<CFDictionary>
Copy the pool attributes into an independently owned dictionary.
Sourcepub fn pixel_buffer_attributes(&self) -> Option<CFDictionary>
pub fn pixel_buffer_attributes(&self) -> Option<CFDictionary>
Copy the pixel-buffer attributes into an independently owned dictionary.