use core::cell::UnsafeCell;
use core::ffi::*;
use core::marker::{PhantomData, PhantomPinned};
use core::ptr::NonNull;
#[cfg(feature = "objc2")]
use objc2::__framework_prelude::*;
use objc2_core_foundation::*;
use crate::*;
#[doc(alias = "CVPixelBufferPoolRef")]
#[repr(C)]
pub struct CVPixelBufferPool {
inner: [u8; 0],
_p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
}
cf_type!(
unsafe impl CVPixelBufferPool {}
);
#[cfg(feature = "objc2")]
cf_objc2_type!(
unsafe impl RefEncode<"__CVPixelBufferPool"> for CVPixelBufferPool {}
);
extern "C" {
pub static kCVPixelBufferPoolMinimumBufferCountKey: &'static CFString;
}
extern "C" {
pub static kCVPixelBufferPoolMaximumBufferAgeKey: &'static CFString;
}
unsafe impl ConcreteType for CVPixelBufferPool {
#[doc(alias = "CVPixelBufferPoolGetTypeID")]
#[inline]
fn type_id() -> CFTypeID {
extern "C-unwind" {
fn CVPixelBufferPoolGetTypeID() -> CFTypeID;
}
unsafe { CVPixelBufferPoolGetTypeID() }
}
}
impl CVPixelBufferPool {
#[doc(alias = "CVPixelBufferPoolCreate")]
#[cfg(feature = "CVReturn")]
#[inline]
pub unsafe fn create(
allocator: Option<&CFAllocator>,
pool_attributes: Option<&CFDictionary>,
pixel_buffer_attributes: Option<&CFDictionary>,
pool_out: NonNull<*mut CVPixelBufferPool>,
) -> CVReturn {
extern "C-unwind" {
fn CVPixelBufferPoolCreate(
allocator: Option<&CFAllocator>,
pool_attributes: Option<&CFDictionary>,
pixel_buffer_attributes: Option<&CFDictionary>,
pool_out: NonNull<*mut CVPixelBufferPool>,
) -> CVReturn;
}
unsafe {
CVPixelBufferPoolCreate(
allocator,
pool_attributes,
pixel_buffer_attributes,
pool_out,
)
}
}
#[doc(alias = "CVPixelBufferPoolGetAttributes")]
#[inline]
pub fn attributes(&self) -> Option<CFRetained<CFDictionary>> {
extern "C-unwind" {
fn CVPixelBufferPoolGetAttributes(
pool: &CVPixelBufferPool,
) -> Option<NonNull<CFDictionary>>;
}
let ret = unsafe { CVPixelBufferPoolGetAttributes(self) };
ret.map(|ret| unsafe { CFRetained::retain(ret) })
}
#[doc(alias = "CVPixelBufferPoolGetPixelBufferAttributes")]
#[inline]
pub fn pixel_buffer_attributes(&self) -> Option<CFRetained<CFDictionary>> {
extern "C-unwind" {
fn CVPixelBufferPoolGetPixelBufferAttributes(
pool: &CVPixelBufferPool,
) -> Option<NonNull<CFDictionary>>;
}
let ret = unsafe { CVPixelBufferPoolGetPixelBufferAttributes(self) };
ret.map(|ret| unsafe { CFRetained::retain(ret) })
}
#[doc(alias = "CVPixelBufferPoolCreatePixelBuffer")]
#[cfg(all(
feature = "CVBuffer",
feature = "CVImageBuffer",
feature = "CVPixelBuffer",
feature = "CVReturn"
))]
#[inline]
pub unsafe fn create_pixel_buffer(
allocator: Option<&CFAllocator>,
pixel_buffer_pool: &CVPixelBufferPool,
pixel_buffer_out: NonNull<*mut CVPixelBuffer>,
) -> CVReturn {
extern "C-unwind" {
fn CVPixelBufferPoolCreatePixelBuffer(
allocator: Option<&CFAllocator>,
pixel_buffer_pool: &CVPixelBufferPool,
pixel_buffer_out: NonNull<*mut CVPixelBuffer>,
) -> CVReturn;
}
unsafe {
CVPixelBufferPoolCreatePixelBuffer(allocator, pixel_buffer_pool, pixel_buffer_out)
}
}
#[doc(alias = "CVPixelBufferPoolCreatePixelBufferWithAuxAttributes")]
#[cfg(all(
feature = "CVBuffer",
feature = "CVImageBuffer",
feature = "CVPixelBuffer",
feature = "CVReturn"
))]
#[inline]
pub unsafe fn create_pixel_buffer_with_aux_attributes(
allocator: Option<&CFAllocator>,
pixel_buffer_pool: &CVPixelBufferPool,
aux_attributes: Option<&CFDictionary>,
pixel_buffer_out: NonNull<*mut CVPixelBuffer>,
) -> CVReturn {
extern "C-unwind" {
fn CVPixelBufferPoolCreatePixelBufferWithAuxAttributes(
allocator: Option<&CFAllocator>,
pixel_buffer_pool: &CVPixelBufferPool,
aux_attributes: Option<&CFDictionary>,
pixel_buffer_out: NonNull<*mut CVPixelBuffer>,
) -> CVReturn;
}
unsafe {
CVPixelBufferPoolCreatePixelBufferWithAuxAttributes(
allocator,
pixel_buffer_pool,
aux_attributes,
pixel_buffer_out,
)
}
}
}
extern "C" {
pub static kCVPixelBufferPoolAllocationThresholdKey: &'static CFString;
}
extern "C" {
pub static kCVPixelBufferPoolFreeBufferNotification: &'static CFString;
}
#[cfg(feature = "CVBase")]
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CVPixelBufferPoolFlushFlags(pub CVOptionFlags);
#[cfg(feature = "CVBase")]
bitflags::bitflags! {
impl CVPixelBufferPoolFlushFlags: CVOptionFlags {
#[doc(alias = "kCVPixelBufferPoolFlushExcessBuffers")]
const ExcessBuffers = 1;
}
}
#[cfg(all(feature = "CVBase", feature = "objc2"))]
unsafe impl Encode for CVPixelBufferPoolFlushFlags {
const ENCODING: Encoding = CVOptionFlags::ENCODING;
}
#[cfg(all(feature = "CVBase", feature = "objc2"))]
unsafe impl RefEncode for CVPixelBufferPoolFlushFlags {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
impl CVPixelBufferPool {
#[doc(alias = "CVPixelBufferPoolFlush")]
#[cfg(feature = "CVBase")]
#[inline]
pub fn flush(&self, options: CVPixelBufferPoolFlushFlags) {
extern "C-unwind" {
fn CVPixelBufferPoolFlush(
pool: &CVPixelBufferPool,
options: CVPixelBufferPoolFlushFlags,
);
}
unsafe { CVPixelBufferPoolFlush(self, options) }
}
}
extern "C-unwind" {
#[cfg(feature = "CVReturn")]
#[deprecated = "renamed to `CVPixelBufferPool::create`"]
pub fn CVPixelBufferPoolCreate(
allocator: Option<&CFAllocator>,
pool_attributes: Option<&CFDictionary>,
pixel_buffer_attributes: Option<&CFDictionary>,
pool_out: NonNull<*mut CVPixelBufferPool>,
) -> CVReturn;
}
#[deprecated = "renamed to `CVPixelBufferPool::attributes`"]
#[inline]
pub extern "C-unwind" fn CVPixelBufferPoolGetAttributes(
pool: &CVPixelBufferPool,
) -> Option<CFRetained<CFDictionary>> {
extern "C-unwind" {
fn CVPixelBufferPoolGetAttributes(
pool: &CVPixelBufferPool,
) -> Option<NonNull<CFDictionary>>;
}
let ret = unsafe { CVPixelBufferPoolGetAttributes(pool) };
ret.map(|ret| unsafe { CFRetained::retain(ret) })
}
#[deprecated = "renamed to `CVPixelBufferPool::pixel_buffer_attributes`"]
#[inline]
pub extern "C-unwind" fn CVPixelBufferPoolGetPixelBufferAttributes(
pool: &CVPixelBufferPool,
) -> Option<CFRetained<CFDictionary>> {
extern "C-unwind" {
fn CVPixelBufferPoolGetPixelBufferAttributes(
pool: &CVPixelBufferPool,
) -> Option<NonNull<CFDictionary>>;
}
let ret = unsafe { CVPixelBufferPoolGetPixelBufferAttributes(pool) };
ret.map(|ret| unsafe { CFRetained::retain(ret) })
}
extern "C-unwind" {
#[cfg(all(
feature = "CVBuffer",
feature = "CVImageBuffer",
feature = "CVPixelBuffer",
feature = "CVReturn"
))]
#[deprecated = "renamed to `CVPixelBufferPool::create_pixel_buffer`"]
pub fn CVPixelBufferPoolCreatePixelBuffer(
allocator: Option<&CFAllocator>,
pixel_buffer_pool: &CVPixelBufferPool,
pixel_buffer_out: NonNull<*mut CVPixelBuffer>,
) -> CVReturn;
}
extern "C-unwind" {
#[cfg(all(
feature = "CVBuffer",
feature = "CVImageBuffer",
feature = "CVPixelBuffer",
feature = "CVReturn"
))]
#[deprecated = "renamed to `CVPixelBufferPool::create_pixel_buffer_with_aux_attributes`"]
pub fn CVPixelBufferPoolCreatePixelBufferWithAuxAttributes(
allocator: Option<&CFAllocator>,
pixel_buffer_pool: &CVPixelBufferPool,
aux_attributes: Option<&CFDictionary>,
pixel_buffer_out: NonNull<*mut CVPixelBuffer>,
) -> CVReturn;
}
#[cfg(feature = "CVBase")]
#[deprecated = "renamed to `CVPixelBufferPool::flush`"]
#[inline]
pub extern "C-unwind" fn CVPixelBufferPoolFlush(
pool: &CVPixelBufferPool,
options: CVPixelBufferPoolFlushFlags,
) {
extern "C-unwind" {
fn CVPixelBufferPoolFlush(pool: &CVPixelBufferPool, options: CVPixelBufferPoolFlushFlags);
}
unsafe { CVPixelBufferPoolFlush(pool, options) }
}