screencapturekit/cv/
ffi.rs

1//! Raw FFI bindings for Core Video types.
2//!
3//! These are low-level bindings and are not intended for direct use.
4#![allow(missing_docs)]
5
6extern "C" {
7    // Hash functions
8    pub fn cv_pixel_buffer_hash(pixel_buffer: *mut std::ffi::c_void) -> usize;
9    pub fn cv_pixel_buffer_pool_hash(pool: *mut std::ffi::c_void) -> usize;
10
11    pub fn cv_pixel_buffer_get_width(pixel_buffer: *mut std::ffi::c_void) -> usize;
12    pub fn cv_pixel_buffer_get_height(pixel_buffer: *mut std::ffi::c_void) -> usize;
13    pub fn cv_pixel_buffer_get_pixel_format_type(pixel_buffer: *mut std::ffi::c_void) -> u32;
14    pub fn cv_pixel_buffer_get_bytes_per_row(pixel_buffer: *mut std::ffi::c_void) -> usize;
15    pub fn cv_pixel_buffer_lock_base_address(
16        pixel_buffer: *mut std::ffi::c_void,
17        flags: u32,
18    ) -> i32;
19    pub fn cv_pixel_buffer_unlock_base_address(
20        pixel_buffer: *mut std::ffi::c_void,
21        flags: u32,
22    ) -> i32;
23    pub fn cv_pixel_buffer_get_base_address(
24        pixel_buffer: *mut std::ffi::c_void,
25    ) -> *mut std::ffi::c_void;
26    pub fn cv_pixel_buffer_get_io_surface(
27        pixel_buffer: *mut std::ffi::c_void,
28    ) -> *mut std::ffi::c_void;
29    pub fn cv_pixel_buffer_release(pixel_buffer: *mut std::ffi::c_void);
30    pub fn cv_pixel_buffer_retain(pixel_buffer: *mut std::ffi::c_void) -> *mut std::ffi::c_void;
31    pub fn cv_pixel_buffer_create(
32        width: usize,
33        height: usize,
34        pixel_format_type: u32,
35        pixel_buffer_out: *mut *mut std::ffi::c_void,
36    ) -> i32;
37    pub fn cv_pixel_buffer_create_with_bytes(
38        width: usize,
39        height: usize,
40        pixel_format_type: u32,
41        base_address: *mut std::ffi::c_void,
42        bytes_per_row: usize,
43        pixel_buffer_out: *mut *mut std::ffi::c_void,
44    ) -> i32;
45    pub fn cv_pixel_buffer_fill_extended_pixels(pixel_buffer: *mut std::ffi::c_void) -> i32;
46
47    // Planar APIs
48    pub fn cv_pixel_buffer_create_with_planar_bytes(
49        width: usize,
50        height: usize,
51        pixel_format_type: u32,
52        num_planes: usize,
53        plane_base_addresses: *const *mut std::ffi::c_void,
54        plane_widths: *const usize,
55        plane_heights: *const usize,
56        plane_bytes_per_row: *const usize,
57        pixel_buffer_out: *mut *mut std::ffi::c_void,
58    ) -> i32;
59    pub fn cv_pixel_buffer_create_with_io_surface(
60        io_surface: *mut std::ffi::c_void,
61        pixel_buffer_out: *mut *mut std::ffi::c_void,
62    ) -> i32;
63    pub fn cv_pixel_buffer_get_type_id() -> usize;
64
65    // CVPixelBufferPool APIs
66    pub fn cv_pixel_buffer_pool_create(
67        width: usize,
68        height: usize,
69        pixel_format_type: u32,
70        max_buffers: usize,
71        pool_out: *mut *mut std::ffi::c_void,
72    ) -> i32;
73    pub fn cv_pixel_buffer_pool_create_pixel_buffer(
74        pool: *mut std::ffi::c_void,
75        pixel_buffer_out: *mut *mut std::ffi::c_void,
76    ) -> i32;
77    pub fn cv_pixel_buffer_pool_flush(pool: *mut std::ffi::c_void);
78    pub fn cv_pixel_buffer_pool_get_type_id() -> usize;
79    pub fn cv_pixel_buffer_pool_retain(pool: *mut std::ffi::c_void) -> *mut std::ffi::c_void;
80    pub fn cv_pixel_buffer_pool_release(pool: *mut std::ffi::c_void);
81
82    // Additional pool APIs
83    pub fn cv_pixel_buffer_pool_get_attributes(
84        pool: *mut std::ffi::c_void,
85    ) -> *const std::ffi::c_void;
86    pub fn cv_pixel_buffer_pool_get_pixel_buffer_attributes(
87        pool: *mut std::ffi::c_void,
88    ) -> *const std::ffi::c_void;
89
90    pub fn cv_pixel_buffer_get_data_size(pixel_buffer: *mut std::ffi::c_void) -> usize;
91    pub fn cv_pixel_buffer_is_planar(pixel_buffer: *mut std::ffi::c_void) -> bool;
92    pub fn cv_pixel_buffer_get_plane_count(pixel_buffer: *mut std::ffi::c_void) -> usize;
93    pub fn cv_pixel_buffer_get_width_of_plane(
94        pixel_buffer: *mut std::ffi::c_void,
95        plane_index: usize,
96    ) -> usize;
97    pub fn cv_pixel_buffer_get_height_of_plane(
98        pixel_buffer: *mut std::ffi::c_void,
99        plane_index: usize,
100    ) -> usize;
101    pub fn cv_pixel_buffer_get_base_address_of_plane(
102        pixel_buffer: *mut std::ffi::c_void,
103        plane_index: usize,
104    ) -> *mut std::ffi::c_void;
105    pub fn cv_pixel_buffer_get_bytes_per_row_of_plane(
106        pixel_buffer: *mut std::ffi::c_void,
107        plane_index: usize,
108    ) -> usize;
109    pub fn cv_pixel_buffer_get_extended_pixels(
110        pixel_buffer: *mut std::ffi::c_void,
111        extra_columns_on_left: *mut usize,
112        extra_columns_on_right: *mut usize,
113        extra_rows_on_top: *mut usize,
114        extra_rows_on_bottom: *mut usize,
115    );
116}