screencapturekit/cm/
ffi.rs

1extern "C" {
2    pub fn cm_sample_buffer_get_image_buffer(
3        sample_buffer: *mut std::ffi::c_void,
4    ) -> *mut std::ffi::c_void;
5    pub fn cm_sample_buffer_get_frame_status(sample_buffer: *mut std::ffi::c_void) -> i32;
6    pub fn cm_sample_buffer_get_presentation_timestamp(
7        sample_buffer: *mut std::ffi::c_void,
8        out_value: *mut i64,
9        out_timescale: *mut i32,
10        out_flags: *mut u32,
11        out_epoch: *mut i64,
12    );
13    pub fn cm_sample_buffer_get_duration(
14        sample_buffer: *mut std::ffi::c_void,
15        out_value: *mut i64,
16        out_timescale: *mut i32,
17        out_flags: *mut u32,
18        out_epoch: *mut i64,
19    );
20    pub fn cm_sample_buffer_release(sample_buffer: *mut std::ffi::c_void);
21    pub fn cm_sample_buffer_retain(sample_buffer: *mut std::ffi::c_void);
22    pub fn cm_sample_buffer_is_valid(sample_buffer: *mut std::ffi::c_void) -> bool;
23    pub fn cm_sample_buffer_get_num_samples(sample_buffer: *mut std::ffi::c_void) -> usize;
24    pub fn cm_sample_buffer_get_audio_buffer_list(
25        sample_buffer: *mut std::ffi::c_void,
26        out_num_buffers: *mut u32,
27        out_buffers_ptr: *mut *mut std::ffi::c_void,
28        out_buffers_len: *mut usize,
29    );
30    pub fn cm_sample_buffer_get_data_buffer(
31        sample_buffer: *mut std::ffi::c_void,
32    ) -> *mut std::ffi::c_void;
33
34    pub fn cm_sample_buffer_get_decode_timestamp(
35        sample_buffer: *mut std::ffi::c_void,
36        out_value: *mut i64,
37        out_timescale: *mut i32,
38        out_flags: *mut u32,
39        out_epoch: *mut i64,
40    );
41    pub fn cm_sample_buffer_get_output_presentation_timestamp(
42        sample_buffer: *mut std::ffi::c_void,
43        out_value: *mut i64,
44        out_timescale: *mut i32,
45        out_flags: *mut u32,
46        out_epoch: *mut i64,
47    );
48    pub fn cm_sample_buffer_set_output_presentation_timestamp(
49        sample_buffer: *mut std::ffi::c_void,
50        value: i64,
51        timescale: i32,
52        flags: u32,
53        epoch: i64,
54    ) -> i32;
55    pub fn cm_sample_buffer_get_sample_size(
56        sample_buffer: *mut std::ffi::c_void,
57        sample_index: usize,
58    ) -> usize;
59    pub fn cm_sample_buffer_get_total_sample_size(sample_buffer: *mut std::ffi::c_void) -> usize;
60    pub fn cm_sample_buffer_is_ready_for_data_access(sample_buffer: *mut std::ffi::c_void) -> bool;
61    pub fn cm_sample_buffer_make_data_ready(sample_buffer: *mut std::ffi::c_void) -> i32;
62
63    // New CMSampleBuffer APIs
64    pub fn cm_sample_buffer_get_format_description(
65        sample_buffer: *mut std::ffi::c_void,
66    ) -> *mut std::ffi::c_void;
67    pub fn cm_sample_buffer_get_sample_timing_info(
68        sample_buffer: *mut std::ffi::c_void,
69        sample_index: usize,
70        out_duration_value: *mut i64,
71        out_duration_timescale: *mut i32,
72        out_duration_flags: *mut u32,
73        out_duration_epoch: *mut i64,
74        out_pts_value: *mut i64,
75        out_pts_timescale: *mut i32,
76        out_pts_flags: *mut u32,
77        out_pts_epoch: *mut i64,
78        out_dts_value: *mut i64,
79        out_dts_timescale: *mut i32,
80        out_dts_flags: *mut u32,
81        out_dts_epoch: *mut i64,
82    ) -> i32;
83    pub fn cm_sample_buffer_invalidate(sample_buffer: *mut std::ffi::c_void) -> i32;
84    pub fn cm_sample_buffer_create_copy_with_new_timing(
85        sample_buffer: *mut std::ffi::c_void,
86        num_timing_infos: usize,
87        timing_info_array: *const std::ffi::c_void,
88        sample_buffer_out: *mut *mut std::ffi::c_void,
89    ) -> i32;
90    pub fn cm_sample_buffer_copy_pcm_data_into_audio_buffer_list(
91        sample_buffer: *mut std::ffi::c_void,
92        frame_offset: i32,
93        num_frames: i32,
94        buffer_list: *mut std::ffi::c_void,
95    ) -> i32;
96
97    // CMFormatDescription APIs
98    pub fn cm_format_description_get_media_type(format_description: *mut std::ffi::c_void) -> u32;
99    pub fn cm_format_description_get_media_subtype(
100        format_description: *mut std::ffi::c_void,
101    ) -> u32;
102    pub fn cm_format_description_get_extensions(
103        format_description: *mut std::ffi::c_void,
104    ) -> *const std::ffi::c_void;
105    pub fn cm_format_description_retain(
106        format_description: *mut std::ffi::c_void,
107    ) -> *mut std::ffi::c_void;
108    pub fn cm_format_description_release(format_description: *mut std::ffi::c_void);
109
110    // Hash functions
111    pub fn cm_sample_buffer_hash(sample_buffer: *mut std::ffi::c_void) -> usize;
112    pub fn cv_pixel_buffer_hash(pixel_buffer: *mut std::ffi::c_void) -> usize;
113    pub fn cv_pixel_buffer_pool_hash(pool: *mut std::ffi::c_void) -> usize;
114    pub fn cm_block_buffer_hash(block_buffer: *mut std::ffi::c_void) -> usize;
115    pub fn cm_format_description_hash(format_description: *mut std::ffi::c_void) -> usize;
116    pub fn io_surface_hash(surface: *mut std::ffi::c_void) -> usize;
117
118    pub fn cv_pixel_buffer_get_width(pixel_buffer: *mut std::ffi::c_void) -> usize;
119    pub fn cv_pixel_buffer_get_height(pixel_buffer: *mut std::ffi::c_void) -> usize;
120    pub fn cv_pixel_buffer_get_pixel_format_type(pixel_buffer: *mut std::ffi::c_void) -> u32;
121    pub fn cv_pixel_buffer_get_bytes_per_row(pixel_buffer: *mut std::ffi::c_void) -> usize;
122    pub fn cv_pixel_buffer_lock_base_address(
123        pixel_buffer: *mut std::ffi::c_void,
124        flags: u32,
125    ) -> i32;
126    pub fn cv_pixel_buffer_unlock_base_address(
127        pixel_buffer: *mut std::ffi::c_void,
128        flags: u32,
129    ) -> i32;
130    pub fn cv_pixel_buffer_get_base_address(
131        pixel_buffer: *mut std::ffi::c_void,
132    ) -> *mut std::ffi::c_void;
133    pub fn cv_pixel_buffer_get_io_surface(
134        pixel_buffer: *mut std::ffi::c_void,
135    ) -> *mut std::ffi::c_void;
136    pub fn cv_pixel_buffer_release(pixel_buffer: *mut std::ffi::c_void);
137    pub fn cv_pixel_buffer_retain(pixel_buffer: *mut std::ffi::c_void) -> *mut std::ffi::c_void;
138    pub fn cv_pixel_buffer_create(
139        width: usize,
140        height: usize,
141        pixel_format_type: u32,
142        pixel_buffer_out: *mut *mut std::ffi::c_void,
143    ) -> i32;
144    pub fn cv_pixel_buffer_create_with_bytes(
145        width: usize,
146        height: usize,
147        pixel_format_type: u32,
148        base_address: *mut std::ffi::c_void,
149        bytes_per_row: usize,
150        pixel_buffer_out: *mut *mut std::ffi::c_void,
151    ) -> i32;
152    pub fn cv_pixel_buffer_fill_extended_pixels(pixel_buffer: *mut std::ffi::c_void) -> i32;
153
154    // New CVPixelBuffer APIs
155    pub fn cv_pixel_buffer_create_with_planar_bytes(
156        width: usize,
157        height: usize,
158        pixel_format_type: u32,
159        num_planes: usize,
160        plane_base_addresses: *const *mut std::ffi::c_void,
161        plane_widths: *const usize,
162        plane_heights: *const usize,
163        plane_bytes_per_row: *const usize,
164        pixel_buffer_out: *mut *mut std::ffi::c_void,
165    ) -> i32;
166    pub fn cv_pixel_buffer_create_with_io_surface(
167        io_surface: *mut std::ffi::c_void,
168        pixel_buffer_out: *mut *mut std::ffi::c_void,
169    ) -> i32;
170    pub fn cv_pixel_buffer_get_type_id() -> usize;
171
172    // CVPixelBufferPool APIs
173    pub fn cv_pixel_buffer_pool_create(
174        width: usize,
175        height: usize,
176        pixel_format_type: u32,
177        max_buffers: usize,
178        pool_out: *mut *mut std::ffi::c_void,
179    ) -> i32;
180    pub fn cv_pixel_buffer_pool_create_pixel_buffer(
181        pool: *mut std::ffi::c_void,
182        pixel_buffer_out: *mut *mut std::ffi::c_void,
183    ) -> i32;
184    pub fn cv_pixel_buffer_pool_flush(pool: *mut std::ffi::c_void);
185    pub fn cv_pixel_buffer_pool_get_type_id() -> usize;
186    pub fn cv_pixel_buffer_pool_retain(pool: *mut std::ffi::c_void) -> *mut std::ffi::c_void;
187    pub fn cv_pixel_buffer_pool_release(pool: *mut std::ffi::c_void);
188
189    // Additional pool APIs
190    pub fn cv_pixel_buffer_pool_get_attributes(
191        pool: *mut std::ffi::c_void,
192    ) -> *const std::ffi::c_void;
193    pub fn cv_pixel_buffer_pool_get_pixel_buffer_attributes(
194        pool: *mut std::ffi::c_void,
195    ) -> *const std::ffi::c_void;
196
197    pub fn cv_pixel_buffer_get_data_size(pixel_buffer: *mut std::ffi::c_void) -> usize;
198    pub fn cv_pixel_buffer_is_planar(pixel_buffer: *mut std::ffi::c_void) -> bool;
199    pub fn cv_pixel_buffer_get_plane_count(pixel_buffer: *mut std::ffi::c_void) -> usize;
200    pub fn cv_pixel_buffer_get_width_of_plane(
201        pixel_buffer: *mut std::ffi::c_void,
202        plane_index: usize,
203    ) -> usize;
204    pub fn cv_pixel_buffer_get_height_of_plane(
205        pixel_buffer: *mut std::ffi::c_void,
206        plane_index: usize,
207    ) -> usize;
208    pub fn cv_pixel_buffer_get_base_address_of_plane(
209        pixel_buffer: *mut std::ffi::c_void,
210        plane_index: usize,
211    ) -> *mut std::ffi::c_void;
212    pub fn cv_pixel_buffer_get_bytes_per_row_of_plane(
213        pixel_buffer: *mut std::ffi::c_void,
214        plane_index: usize,
215    ) -> usize;
216    pub fn cv_pixel_buffer_get_extended_pixels(
217        pixel_buffer: *mut std::ffi::c_void,
218        extra_columns_on_left: *mut usize,
219        extra_columns_on_right: *mut usize,
220        extra_rows_on_top: *mut usize,
221        extra_rows_on_bottom: *mut usize,
222    );
223
224    pub fn cm_sample_buffer_create_for_image_buffer(
225        image_buffer: *mut std::ffi::c_void,
226        presentation_time_value: i64,
227        presentation_time_scale: i32,
228        duration_value: i64,
229        duration_scale: i32,
230        sample_buffer_out: *mut *mut std::ffi::c_void,
231    ) -> i32;
232
233    pub fn io_surface_get_width(surface: *mut std::ffi::c_void) -> usize;
234    pub fn io_surface_get_height(surface: *mut std::ffi::c_void) -> usize;
235    pub fn io_surface_get_bytes_per_row(surface: *mut std::ffi::c_void) -> usize;
236    pub fn io_surface_release(surface: *mut std::ffi::c_void);
237    pub fn io_surface_retain(surface: *mut std::ffi::c_void) -> *mut std::ffi::c_void;
238}