1pub const VSL_VERSION: &[u8; 6] = b"2.0.0\0";
7#[repr(C)]
8#[derive(Debug, Copy, Clone)]
9pub struct vsl_host {
10 _unused: [u8; 0],
11}
12#[doc = " @struct VSLHost\n @brief The VSLHost object manages a connection point at the user-defined path\n and allows frames to be registered for client use."]
13pub type VSLHost = vsl_host;
14#[repr(C)]
15#[derive(Debug, Copy, Clone)]
16pub struct vsl_client {
17 _unused: [u8; 0],
18}
19#[doc = " @struct VSLClient\n @brief The VSLClient object manages a single connection to a VSLHost."]
20pub type VSLClient = vsl_client;
21#[repr(C)]
22#[derive(Debug, Copy, Clone)]
23pub struct vsl_frame {
24 _unused: [u8; 0],
25}
26#[doc = " @struct VSLFrame\n @brief The VSLFrame object represents a single video frame from either the\n host or client perspective. Certain API are only available to the host or\n client."]
27pub type VSLFrame = vsl_frame;
28#[repr(C)]
29#[derive(Debug, Copy, Clone)]
30pub struct vsl_encoder {
31 _unused: [u8; 0],
32}
33#[doc = " @struct VSLEncoder\n @brief The VSLEncoder object represents encoder instance.\n"]
34pub type VSLEncoder = vsl_encoder;
35#[repr(C)]
36#[derive(Debug, Copy, Clone)]
37pub struct vsl_decoder {
38 _unused: [u8; 0],
39}
40#[doc = " @struct VSLDecoder\n @brief The VSLDecoder object represents decoder instance.\n"]
41pub type VSLDecoder = vsl_decoder;
42#[doc = " The VSLRect structure represents a rectangle region of a frame and is used to\n define cropping regions for sub-frames."]
43#[repr(C)]
44#[derive(Debug, Copy, Clone)]
45pub struct vsl_rect {
46 #[doc = " The left-most pixel offset for the rectangle."]
47 pub x: ::std::os::raw::c_int,
48 #[doc = " The top-most pixel offset for the rectangle."]
49 pub y: ::std::os::raw::c_int,
50 #[doc = " The width in pixels of the rectangle. The end position is x+width."]
51 pub width: ::std::os::raw::c_int,
52 #[doc = " The height in pixels of the rectangle. The end position is y+height."]
53 pub height: ::std::os::raw::c_int,
54}
55#[allow(clippy::unnecessary_operation, clippy::identity_op)]
56const _: () = {
57 ["Size of vsl_rect"][::std::mem::size_of::<vsl_rect>() - 16usize];
58 ["Alignment of vsl_rect"][::std::mem::align_of::<vsl_rect>() - 4usize];
59 ["Offset of field: vsl_rect::x"][::std::mem::offset_of!(vsl_rect, x) - 0usize];
60 ["Offset of field: vsl_rect::y"][::std::mem::offset_of!(vsl_rect, y) - 4usize];
61 ["Offset of field: vsl_rect::width"][::std::mem::offset_of!(vsl_rect, width) - 8usize];
62 ["Offset of field: vsl_rect::height"][::std::mem::offset_of!(vsl_rect, height) - 12usize];
63};
64#[doc = " The VSLRect structure represents a rectangle region of a frame and is used to\n define cropping regions for sub-frames."]
65pub type VSLRect = vsl_rect;
66#[doc = " Automatic bitrate selection (encoder default).\n\n Platform and version dependent. Testing shows approximately 10000 kbps\n on i.MX8M Plus. Use this for general-purpose encoding when specific\n bitrate control is not required."]
67pub const vsl_encode_profile_VSL_ENCODE_PROFILE_AUTO: vsl_encode_profile = 0;
68#[doc = " 5 Mbps target bitrate.\n\n Suitable for moderate quality 1080p video or high quality 720p."]
69pub const vsl_encode_profile_VSL_ENCODE_PROFILE_5000_KBPS: vsl_encode_profile = 1;
70#[doc = " 25 Mbps target bitrate.\n\n Suitable for high quality 1080p video or moderate quality 4K."]
71pub const vsl_encode_profile_VSL_ENCODE_PROFILE_25000_KBPS: vsl_encode_profile = 2;
72#[doc = " 50 Mbps target bitrate.\n\n Suitable for very high quality 1080p or high quality 4K video."]
73pub const vsl_encode_profile_VSL_ENCODE_PROFILE_50000_KBPS: vsl_encode_profile = 3;
74#[doc = " 100 Mbps target bitrate.\n\n Suitable for maximum quality 4K video or when preserving fine details\n is critical. May stress storage and network bandwidth."]
75pub const vsl_encode_profile_VSL_ENCODE_PROFILE_100000_KBPS: vsl_encode_profile = 4;
76#[doc = " Encoder profile defining target bitrate for video encoding.\n\n These profiles provide a convenient way to specify encoding quality/bitrate\n tradeoffs. Higher bitrates produce better quality at the cost of larger file\n sizes and potentially higher CPU/power consumption.\n\n @note The actual quality-to-bitrate ratio depends on the codec (H.264 vs\n H.265), encoder implementation, and content complexity."]
77pub type vsl_encode_profile = ::std::os::raw::c_uint;
78#[doc = " Encoder profile defining target bitrate for video encoding.\n\n These profiles provide a convenient way to specify encoding quality/bitrate\n tradeoffs. Higher bitrates produce better quality at the cost of larger file\n sizes and potentially higher CPU/power consumption.\n\n @note The actual quality-to-bitrate ratio depends on the codec (H.264 vs\n H.265), encoder implementation, and content complexity."]
79pub use self::vsl_encode_profile as VSLEncoderProfile;
80#[doc = " H.264/AVC (Advanced Video Coding) codec.\n\n Widely supported standard (ISO/IEC 14496-10, ITU-T H.264) with good\n compression and compatibility. Recommended for maximum device\n compatibility."]
81pub const VSLDecoderCodec_VSL_DEC_H264: VSLDecoderCodec = 0;
82#[doc = " H.265/HEVC (High Efficiency Video Coding) codec.\n\n Next-generation standard (ISO/IEC 23008-2, ITU-T H.265) providing\n approximately 50% better compression than H.264 at equivalent quality.\n Recommended when bandwidth/storage are constrained and decoder support\n is confirmed."]
83pub const VSLDecoderCodec_VSL_DEC_HEVC: VSLDecoderCodec = 1;
84#[doc = " Video codec type for hardware decoder.\n\n Specifies which video compression standard to use for decoding.\n Both codecs are supported via Hantro VPU hardware acceleration on i.MX8."]
85pub type VSLDecoderCodec = ::std::os::raw::c_uint;
86#[doc = " Auto-detect best available backend.\n\n Selection priority:\n 1. Check VSL_CODEC_BACKEND environment variable\n 2. Prefer V4L2 if device available and has M2M capability\n 3. Fall back to Hantro if V4L2 unavailable\n 4. Fail if no backend available"]
87pub const VSLCodecBackend_VSL_CODEC_BACKEND_AUTO: VSLCodecBackend = 0;
88#[doc = " Force Hantro/libcodec.so backend.\n\n Uses the proprietary VPU wrapper library. May be needed for:\n - Systems without V4L2 codec driver\n - Testing/debugging Hantro-specific behavior\n - Compatibility with older configurations"]
89pub const VSLCodecBackend_VSL_CODEC_BACKEND_HANTRO: VSLCodecBackend = 1;
90#[doc = " Force V4L2 kernel driver backend.\n\n Uses the vsi_v4l2 mem2mem driver. Provides:\n - 37-56x faster decode performance\n - Stable encoder (vs crashing libcodec.so)\n - Standard Linux API"]
91pub const VSLCodecBackend_VSL_CODEC_BACKEND_V4L2: VSLCodecBackend = 2;
92#[doc = " Codec backend selection for encoder/decoder.\n\n Allows selection between V4L2 kernel driver and Hantro user-space\n library (libcodec.so) backends. Use with vsl_decoder_create_ex() and\n vsl_encoder_create_ex() for explicit backend control.\n\n The VSL_CODEC_BACKEND environment variable can override the AUTO selection:\n - \"hantro\" - Force Hantro backend even if V4L2 available\n - \"v4l2\" - Force V4L2 backend (fail if unavailable)\n - \"auto\" - Auto-detect (default)\n\n @since 2.0"]
93pub type VSLCodecBackend = ::std::os::raw::c_uint;
94#[doc = " Function pointer definition which will be called as part of\n @ref vsl_frame_unregister. This is typically used to free resources\n associated with the frame on either client or host side."]
95pub type vsl_frame_cleanup = ::std::option::Option<unsafe extern "C" fn(frame: *mut VSLFrame)>;
96#[repr(C)]
97#[derive(Debug, Copy, Clone)]
98pub struct vsl_camera_buffer {
99 _unused: [u8; 0],
100}
101#[repr(C)]
102#[derive(Debug, Copy, Clone)]
103pub struct vsl_camera {
104 _unused: [u8; 0],
105}
106pub const VSLDecoderRetCode_VSL_DEC_SUCCESS: VSLDecoderRetCode = 0;
107pub const VSLDecoderRetCode_VSL_DEC_ERR: VSLDecoderRetCode = 1;
108pub const VSLDecoderRetCode_VSL_DEC_INIT_INFO: VSLDecoderRetCode = 2;
109pub const VSLDecoderRetCode_VSL_DEC_FRAME_DEC: VSLDecoderRetCode = 4;
110pub type VSLDecoderRetCode = ::std::os::raw::c_uint;
111pub struct VideoStreamLibrary {
112 __library: ::libloading::Library,
113 pub vsl_version:
114 Result<unsafe extern "C" fn() -> *const ::std::os::raw::c_char, ::libloading::Error>,
115 pub vsl_timestamp: Result<unsafe extern "C" fn() -> i64, ::libloading::Error>,
116 pub vsl_host_init: Result<
117 unsafe extern "C" fn(path: *const ::std::os::raw::c_char) -> *mut VSLHost,
118 ::libloading::Error,
119 >,
120 pub vsl_host_release: Result<unsafe extern "C" fn(host: *mut VSLHost), ::libloading::Error>,
121 pub vsl_host_path: Result<
122 unsafe extern "C" fn(host: *const VSLHost) -> *const ::std::os::raw::c_char,
123 ::libloading::Error,
124 >,
125 pub vsl_host_poll: Result<
126 unsafe extern "C" fn(host: *mut VSLHost, wait: i64) -> ::std::os::raw::c_int,
127 ::libloading::Error,
128 >,
129 pub vsl_host_service: Result<
130 unsafe extern "C" fn(
131 host: *mut VSLHost,
132 sock: ::std::os::raw::c_int,
133 ) -> ::std::os::raw::c_int,
134 ::libloading::Error,
135 >,
136 pub vsl_host_process: Result<
137 unsafe extern "C" fn(host: *mut VSLHost) -> ::std::os::raw::c_int,
138 ::libloading::Error,
139 >,
140 pub vsl_host_sockets: Result<
141 unsafe extern "C" fn(
142 host: *mut VSLHost,
143 n_sockets: usize,
144 sockets: *mut ::std::os::raw::c_int,
145 max_sockets: *mut usize,
146 ) -> ::std::os::raw::c_int,
147 ::libloading::Error,
148 >,
149 pub vsl_host_post: Result<
150 unsafe extern "C" fn(
151 host: *mut VSLHost,
152 frame: *mut VSLFrame,
153 expires: i64,
154 duration: i64,
155 pts: i64,
156 dts: i64,
157 ) -> ::std::os::raw::c_int,
158 ::libloading::Error,
159 >,
160 pub vsl_host_drop: Result<
161 unsafe extern "C" fn(host: *mut VSLHost, frame: *mut VSLFrame) -> ::std::os::raw::c_int,
162 ::libloading::Error,
163 >,
164 pub vsl_client_init: Result<
165 unsafe extern "C" fn(
166 path: *const ::std::os::raw::c_char,
167 userptr: *mut ::std::os::raw::c_void,
168 reconnect: bool,
169 ) -> *mut VSLClient,
170 ::libloading::Error,
171 >,
172 pub vsl_client_release:
173 Result<unsafe extern "C" fn(client: *mut VSLClient), ::libloading::Error>,
174 pub vsl_client_disconnect:
175 Result<unsafe extern "C" fn(client: *mut VSLClient), ::libloading::Error>,
176 pub vsl_client_userptr: Result<
177 unsafe extern "C" fn(client: *mut VSLClient) -> *mut ::std::os::raw::c_void,
178 ::libloading::Error,
179 >,
180 pub vsl_client_path: Result<
181 unsafe extern "C" fn(client: *const VSLClient) -> *const ::std::os::raw::c_char,
182 ::libloading::Error,
183 >,
184 pub vsl_client_set_timeout:
185 Result<unsafe extern "C" fn(client: *mut VSLClient, timeout: f32), ::libloading::Error>,
186 pub vsl_frame_register: Result<
187 unsafe extern "C" fn(
188 host: *mut VSLHost,
189 serial: i64,
190 handle: ::std::os::raw::c_int,
191 width: ::std::os::raw::c_int,
192 height: ::std::os::raw::c_int,
193 fourcc: u32,
194 size: usize,
195 offset: usize,
196 expires: i64,
197 duration: i64,
198 pts: i64,
199 dts: i64,
200 cleanup: vsl_frame_cleanup,
201 userptr: *mut ::std::os::raw::c_void,
202 ) -> *mut VSLFrame,
203 ::libloading::Error,
204 >,
205 pub vsl_frame_init: Result<
206 unsafe extern "C" fn(
207 width: u32,
208 height: u32,
209 stride: u32,
210 fourcc: u32,
211 userptr: *mut ::std::os::raw::c_void,
212 cleanup: vsl_frame_cleanup,
213 ) -> *mut VSLFrame,
214 ::libloading::Error,
215 >,
216 pub vsl_frame_alloc: Result<
217 unsafe extern "C" fn(
218 frame: *mut VSLFrame,
219 path: *const ::std::os::raw::c_char,
220 ) -> ::std::os::raw::c_int,
221 ::libloading::Error,
222 >,
223 pub vsl_frame_unalloc: Result<unsafe extern "C" fn(frame: *mut VSLFrame), ::libloading::Error>,
224 pub vsl_frame_attach: Result<
225 unsafe extern "C" fn(
226 frame: *mut VSLFrame,
227 fd: ::std::os::raw::c_int,
228 size: usize,
229 offset: usize,
230 ) -> ::std::os::raw::c_int,
231 ::libloading::Error,
232 >,
233 pub vsl_frame_path: Result<
234 unsafe extern "C" fn(frame: *const VSLFrame) -> *const ::std::os::raw::c_char,
235 ::libloading::Error,
236 >,
237 pub vsl_frame_unregister:
238 Result<unsafe extern "C" fn(frame: *mut VSLFrame), ::libloading::Error>,
239 pub vsl_frame_copy: Result<
240 unsafe extern "C" fn(
241 target: *mut VSLFrame,
242 source: *mut VSLFrame,
243 crop: *const VSLRect,
244 ) -> ::std::os::raw::c_int,
245 ::libloading::Error,
246 >,
247 pub vsl_frame_userptr: Result<
248 unsafe extern "C" fn(frame: *mut VSLFrame) -> *mut ::std::os::raw::c_void,
249 ::libloading::Error,
250 >,
251 pub vsl_frame_set_userptr: Result<
252 unsafe extern "C" fn(frame: *mut VSLFrame, userptr: *mut ::std::os::raw::c_void),
253 ::libloading::Error,
254 >,
255 pub vsl_frame_wait: Result<
256 unsafe extern "C" fn(client: *mut VSLClient, until: i64) -> *mut VSLFrame,
257 ::libloading::Error,
258 >,
259 pub vsl_frame_release: Result<unsafe extern "C" fn(frame: *mut VSLFrame), ::libloading::Error>,
260 pub vsl_frame_trylock: Result<
261 unsafe extern "C" fn(frame: *mut VSLFrame) -> ::std::os::raw::c_int,
262 ::libloading::Error,
263 >,
264 pub vsl_frame_unlock: Result<
265 unsafe extern "C" fn(frame: *mut VSLFrame) -> ::std::os::raw::c_int,
266 ::libloading::Error,
267 >,
268 pub vsl_frame_serial:
269 Result<unsafe extern "C" fn(frame: *const VSLFrame) -> i64, ::libloading::Error>,
270 pub vsl_frame_timestamp:
271 Result<unsafe extern "C" fn(frame: *const VSLFrame) -> i64, ::libloading::Error>,
272 pub vsl_frame_duration:
273 Result<unsafe extern "C" fn(frame: *const VSLFrame) -> i64, ::libloading::Error>,
274 pub vsl_frame_pts:
275 Result<unsafe extern "C" fn(frame: *const VSLFrame) -> i64, ::libloading::Error>,
276 pub vsl_frame_dts:
277 Result<unsafe extern "C" fn(frame: *const VSLFrame) -> i64, ::libloading::Error>,
278 pub vsl_frame_expires:
279 Result<unsafe extern "C" fn(frame: *const VSLFrame) -> i64, ::libloading::Error>,
280 pub vsl_frame_fourcc:
281 Result<unsafe extern "C" fn(frame: *const VSLFrame) -> u32, ::libloading::Error>,
282 pub vsl_frame_width: Result<
283 unsafe extern "C" fn(frame: *const VSLFrame) -> ::std::os::raw::c_int,
284 ::libloading::Error,
285 >,
286 pub vsl_frame_height: Result<
287 unsafe extern "C" fn(frame: *const VSLFrame) -> ::std::os::raw::c_int,
288 ::libloading::Error,
289 >,
290 pub vsl_frame_stride: Result<
291 unsafe extern "C" fn(frame: *const VSLFrame) -> ::std::os::raw::c_int,
292 ::libloading::Error,
293 >,
294 pub vsl_frame_size: Result<
295 unsafe extern "C" fn(frame: *const VSLFrame) -> ::std::os::raw::c_int,
296 ::libloading::Error,
297 >,
298 pub vsl_frame_handle: Result<
299 unsafe extern "C" fn(frame: *const VSLFrame) -> ::std::os::raw::c_int,
300 ::libloading::Error,
301 >,
302 pub vsl_frame_paddr:
303 Result<unsafe extern "C" fn(frame: *mut VSLFrame) -> isize, ::libloading::Error>,
304 pub vsl_frame_mmap: Result<
305 unsafe extern "C" fn(frame: *mut VSLFrame, size: *mut usize) -> *mut ::std::os::raw::c_void,
306 ::libloading::Error,
307 >,
308 pub vsl_frame_munmap: Result<unsafe extern "C" fn(frame: *mut VSLFrame), ::libloading::Error>,
309 pub vsl_frame_sync: Result<
310 unsafe extern "C" fn(
311 frame: *const VSLFrame,
312 enable: ::std::os::raw::c_int,
313 mode: ::std::os::raw::c_int,
314 ) -> ::std::os::raw::c_int,
315 ::libloading::Error,
316 >,
317 pub vsl_fourcc_from_string: Result<
318 unsafe extern "C" fn(fourcc: *const ::std::os::raw::c_char) -> u32,
319 ::libloading::Error,
320 >,
321 pub vsl_encoder_create: Result<
322 unsafe extern "C" fn(
323 profile: VSLEncoderProfile,
324 outputFourcc: u32,
325 fps: ::std::os::raw::c_int,
326 ) -> *mut VSLEncoder,
327 ::libloading::Error,
328 >,
329 pub vsl_encoder_create_ex: Result<
330 unsafe extern "C" fn(
331 profile: VSLEncoderProfile,
332 outputFourcc: u32,
333 fps: ::std::os::raw::c_int,
334 backend: VSLCodecBackend,
335 ) -> *mut VSLEncoder,
336 ::libloading::Error,
337 >,
338 pub vsl_encoder_release:
339 Result<unsafe extern "C" fn(encoder: *mut VSLEncoder), ::libloading::Error>,
340 pub vsl_encode_frame: Result<
341 unsafe extern "C" fn(
342 encoder: *mut VSLEncoder,
343 source: *mut VSLFrame,
344 destination: *mut VSLFrame,
345 cropRegion: *const VSLRect,
346 keyframe: *mut ::std::os::raw::c_int,
347 ) -> ::std::os::raw::c_int,
348 ::libloading::Error,
349 >,
350 pub vsl_encoder_new_output_frame: Result<
351 unsafe extern "C" fn(
352 encoder: *const VSLEncoder,
353 width: ::std::os::raw::c_int,
354 height: ::std::os::raw::c_int,
355 duration: i64,
356 pts: i64,
357 dts: i64,
358 ) -> *mut VSLFrame,
359 ::libloading::Error,
360 >,
361 pub vsl_camera_open_device: Result<
362 unsafe extern "C" fn(filename: *const ::std::os::raw::c_char) -> *mut vsl_camera,
363 ::libloading::Error,
364 >,
365 pub vsl_camera_init_device: Result<
366 unsafe extern "C" fn(
367 ctx: *mut vsl_camera,
368 width: *mut ::std::os::raw::c_int,
369 height: *mut ::std::os::raw::c_int,
370 buf_count: *mut ::std::os::raw::c_int,
371 fourcc: *mut u32,
372 ) -> ::std::os::raw::c_int,
373 ::libloading::Error,
374 >,
375 pub vsl_camera_mirror: Result<
376 unsafe extern "C" fn(ctx: *const vsl_camera, mirror: bool) -> ::std::os::raw::c_int,
377 ::libloading::Error,
378 >,
379 pub vsl_camera_mirror_v: Result<
380 unsafe extern "C" fn(ctx: *const vsl_camera, mirror: bool) -> ::std::os::raw::c_int,
381 ::libloading::Error,
382 >,
383 pub vsl_camera_start_capturing: Result<
384 unsafe extern "C" fn(ctx: *mut vsl_camera) -> ::std::os::raw::c_int,
385 ::libloading::Error,
386 >,
387 pub vsl_camera_get_data: Result<
388 unsafe extern "C" fn(ctx: *mut vsl_camera) -> *mut vsl_camera_buffer,
389 ::libloading::Error,
390 >,
391 pub vsl_camera_release_buffer: Result<
392 unsafe extern "C" fn(
393 ctx: *mut vsl_camera,
394 buffer: *const vsl_camera_buffer,
395 ) -> ::std::os::raw::c_int,
396 ::libloading::Error,
397 >,
398 pub vsl_camera_stop_capturing: Result<
399 unsafe extern "C" fn(ctx: *const vsl_camera) -> ::std::os::raw::c_int,
400 ::libloading::Error,
401 >,
402 pub vsl_camera_uninit_device:
403 Result<unsafe extern "C" fn(ctx: *mut vsl_camera), ::libloading::Error>,
404 pub vsl_camera_close_device:
405 Result<unsafe extern "C" fn(ctx: *mut vsl_camera), ::libloading::Error>,
406 pub vsl_camera_is_dmabuf_supported: Result<
407 unsafe extern "C" fn(ctx: *const vsl_camera) -> ::std::os::raw::c_int,
408 ::libloading::Error,
409 >,
410 pub vsl_camera_get_queued_buf_count: Result<
411 unsafe extern "C" fn(ctx: *const vsl_camera) -> ::std::os::raw::c_int,
412 ::libloading::Error,
413 >,
414 pub vsl_camera_buffer_mmap: Result<
415 unsafe extern "C" fn(buffer: *mut vsl_camera_buffer) -> *mut ::std::os::raw::c_void,
416 ::libloading::Error,
417 >,
418 pub vsl_camera_buffer_dma_fd: Result<
419 unsafe extern "C" fn(buffer: *const vsl_camera_buffer) -> ::std::os::raw::c_int,
420 ::libloading::Error,
421 >,
422 pub vsl_camera_buffer_phys_addr:
423 Result<unsafe extern "C" fn(buffer: *const vsl_camera_buffer) -> u64, ::libloading::Error>,
424 pub vsl_camera_buffer_length:
425 Result<unsafe extern "C" fn(buffer: *const vsl_camera_buffer) -> u32, ::libloading::Error>,
426 pub vsl_camera_buffer_fourcc:
427 Result<unsafe extern "C" fn(buffer: *const vsl_camera_buffer) -> u32, ::libloading::Error>,
428 pub vsl_camera_buffer_timestamp: Result<
429 unsafe extern "C" fn(
430 buffer: *const vsl_camera_buffer,
431 seconds: *mut i64,
432 nanoseconds: *mut i64,
433 ),
434 ::libloading::Error,
435 >,
436 pub vsl_camera_enum_fmts: Result<
437 unsafe extern "C" fn(
438 ctx: *const vsl_camera,
439 codes: *mut u32,
440 size: ::std::os::raw::c_int,
441 ) -> ::std::os::raw::c_int,
442 ::libloading::Error,
443 >,
444 pub vsl_camera_enum_mplane_fmts: Result<
445 unsafe extern "C" fn(
446 ctx: *const vsl_camera,
447 codes: *mut u32,
448 size: ::std::os::raw::c_int,
449 ) -> ::std::os::raw::c_int,
450 ::libloading::Error,
451 >,
452 pub vsl_decoder_create: Result<
453 unsafe extern "C" fn(codec: VSLDecoderCodec, fps: ::std::os::raw::c_int) -> *mut VSLDecoder,
454 ::libloading::Error,
455 >,
456 pub vsl_decoder_create_ex: Result<
457 unsafe extern "C" fn(
458 codec: u32,
459 fps: ::std::os::raw::c_int,
460 backend: VSLCodecBackend,
461 ) -> *mut VSLDecoder,
462 ::libloading::Error,
463 >,
464 pub vsl_decode_frame: Result<
465 unsafe extern "C" fn(
466 decoder: *mut VSLDecoder,
467 data: *const ::std::os::raw::c_void,
468 data_length: ::std::os::raw::c_uint,
469 bytes_used: *mut usize,
470 output_frame: *mut *mut VSLFrame,
471 ) -> VSLDecoderRetCode,
472 ::libloading::Error,
473 >,
474 pub vsl_decoder_width: Result<
475 unsafe extern "C" fn(decoder: *const VSLDecoder) -> ::std::os::raw::c_int,
476 ::libloading::Error,
477 >,
478 pub vsl_decoder_height: Result<
479 unsafe extern "C" fn(decoder: *const VSLDecoder) -> ::std::os::raw::c_int,
480 ::libloading::Error,
481 >,
482 pub vsl_decoder_crop:
483 Result<unsafe extern "C" fn(decoder: *const VSLDecoder) -> VSLRect, ::libloading::Error>,
484 pub vsl_decoder_release: Result<
485 unsafe extern "C" fn(decoder: *mut VSLDecoder) -> ::std::os::raw::c_int,
486 ::libloading::Error,
487 >,
488}
489impl VideoStreamLibrary {
490 pub unsafe fn new<P>(path: P) -> Result<Self, ::libloading::Error>
491 where
492 P: ::libloading::AsFilename,
493 {
494 let library = ::libloading::Library::new(path)?;
495 Self::from_library(library)
496 }
497 pub unsafe fn from_library<L>(library: L) -> Result<Self, ::libloading::Error>
498 where
499 L: Into<::libloading::Library>,
500 {
501 let __library = library.into();
502 let vsl_version = __library.get(b"vsl_version\0").map(|sym| *sym);
503 let vsl_timestamp = __library.get(b"vsl_timestamp\0").map(|sym| *sym);
504 let vsl_host_init = __library.get(b"vsl_host_init\0").map(|sym| *sym);
505 let vsl_host_release = __library.get(b"vsl_host_release\0").map(|sym| *sym);
506 let vsl_host_path = __library.get(b"vsl_host_path\0").map(|sym| *sym);
507 let vsl_host_poll = __library.get(b"vsl_host_poll\0").map(|sym| *sym);
508 let vsl_host_service = __library.get(b"vsl_host_service\0").map(|sym| *sym);
509 let vsl_host_process = __library.get(b"vsl_host_process\0").map(|sym| *sym);
510 let vsl_host_sockets = __library.get(b"vsl_host_sockets\0").map(|sym| *sym);
511 let vsl_host_post = __library.get(b"vsl_host_post\0").map(|sym| *sym);
512 let vsl_host_drop = __library.get(b"vsl_host_drop\0").map(|sym| *sym);
513 let vsl_client_init = __library.get(b"vsl_client_init\0").map(|sym| *sym);
514 let vsl_client_release = __library.get(b"vsl_client_release\0").map(|sym| *sym);
515 let vsl_client_disconnect = __library.get(b"vsl_client_disconnect\0").map(|sym| *sym);
516 let vsl_client_userptr = __library.get(b"vsl_client_userptr\0").map(|sym| *sym);
517 let vsl_client_path = __library.get(b"vsl_client_path\0").map(|sym| *sym);
518 let vsl_client_set_timeout = __library.get(b"vsl_client_set_timeout\0").map(|sym| *sym);
519 let vsl_frame_register = __library.get(b"vsl_frame_register\0").map(|sym| *sym);
520 let vsl_frame_init = __library.get(b"vsl_frame_init\0").map(|sym| *sym);
521 let vsl_frame_alloc = __library.get(b"vsl_frame_alloc\0").map(|sym| *sym);
522 let vsl_frame_unalloc = __library.get(b"vsl_frame_unalloc\0").map(|sym| *sym);
523 let vsl_frame_attach = __library.get(b"vsl_frame_attach\0").map(|sym| *sym);
524 let vsl_frame_path = __library.get(b"vsl_frame_path\0").map(|sym| *sym);
525 let vsl_frame_unregister = __library.get(b"vsl_frame_unregister\0").map(|sym| *sym);
526 let vsl_frame_copy = __library.get(b"vsl_frame_copy\0").map(|sym| *sym);
527 let vsl_frame_userptr = __library.get(b"vsl_frame_userptr\0").map(|sym| *sym);
528 let vsl_frame_set_userptr = __library.get(b"vsl_frame_set_userptr\0").map(|sym| *sym);
529 let vsl_frame_wait = __library.get(b"vsl_frame_wait\0").map(|sym| *sym);
530 let vsl_frame_release = __library.get(b"vsl_frame_release\0").map(|sym| *sym);
531 let vsl_frame_trylock = __library.get(b"vsl_frame_trylock\0").map(|sym| *sym);
532 let vsl_frame_unlock = __library.get(b"vsl_frame_unlock\0").map(|sym| *sym);
533 let vsl_frame_serial = __library.get(b"vsl_frame_serial\0").map(|sym| *sym);
534 let vsl_frame_timestamp = __library.get(b"vsl_frame_timestamp\0").map(|sym| *sym);
535 let vsl_frame_duration = __library.get(b"vsl_frame_duration\0").map(|sym| *sym);
536 let vsl_frame_pts = __library.get(b"vsl_frame_pts\0").map(|sym| *sym);
537 let vsl_frame_dts = __library.get(b"vsl_frame_dts\0").map(|sym| *sym);
538 let vsl_frame_expires = __library.get(b"vsl_frame_expires\0").map(|sym| *sym);
539 let vsl_frame_fourcc = __library.get(b"vsl_frame_fourcc\0").map(|sym| *sym);
540 let vsl_frame_width = __library.get(b"vsl_frame_width\0").map(|sym| *sym);
541 let vsl_frame_height = __library.get(b"vsl_frame_height\0").map(|sym| *sym);
542 let vsl_frame_stride = __library.get(b"vsl_frame_stride\0").map(|sym| *sym);
543 let vsl_frame_size = __library.get(b"vsl_frame_size\0").map(|sym| *sym);
544 let vsl_frame_handle = __library.get(b"vsl_frame_handle\0").map(|sym| *sym);
545 let vsl_frame_paddr = __library.get(b"vsl_frame_paddr\0").map(|sym| *sym);
546 let vsl_frame_mmap = __library.get(b"vsl_frame_mmap\0").map(|sym| *sym);
547 let vsl_frame_munmap = __library.get(b"vsl_frame_munmap\0").map(|sym| *sym);
548 let vsl_frame_sync = __library.get(b"vsl_frame_sync\0").map(|sym| *sym);
549 let vsl_fourcc_from_string = __library.get(b"vsl_fourcc_from_string\0").map(|sym| *sym);
550 let vsl_encoder_create = __library.get(b"vsl_encoder_create\0").map(|sym| *sym);
551 let vsl_encoder_create_ex = __library.get(b"vsl_encoder_create_ex\0").map(|sym| *sym);
552 let vsl_encoder_release = __library.get(b"vsl_encoder_release\0").map(|sym| *sym);
553 let vsl_encode_frame = __library.get(b"vsl_encode_frame\0").map(|sym| *sym);
554 let vsl_encoder_new_output_frame = __library
555 .get(b"vsl_encoder_new_output_frame\0")
556 .map(|sym| *sym);
557 let vsl_camera_open_device = __library.get(b"vsl_camera_open_device\0").map(|sym| *sym);
558 let vsl_camera_init_device = __library.get(b"vsl_camera_init_device\0").map(|sym| *sym);
559 let vsl_camera_mirror = __library.get(b"vsl_camera_mirror\0").map(|sym| *sym);
560 let vsl_camera_mirror_v = __library.get(b"vsl_camera_mirror_v\0").map(|sym| *sym);
561 let vsl_camera_start_capturing = __library
562 .get(b"vsl_camera_start_capturing\0")
563 .map(|sym| *sym);
564 let vsl_camera_get_data = __library.get(b"vsl_camera_get_data\0").map(|sym| *sym);
565 let vsl_camera_release_buffer = __library
566 .get(b"vsl_camera_release_buffer\0")
567 .map(|sym| *sym);
568 let vsl_camera_stop_capturing = __library
569 .get(b"vsl_camera_stop_capturing\0")
570 .map(|sym| *sym);
571 let vsl_camera_uninit_device = __library.get(b"vsl_camera_uninit_device\0").map(|sym| *sym);
572 let vsl_camera_close_device = __library.get(b"vsl_camera_close_device\0").map(|sym| *sym);
573 let vsl_camera_is_dmabuf_supported = __library
574 .get(b"vsl_camera_is_dmabuf_supported\0")
575 .map(|sym| *sym);
576 let vsl_camera_get_queued_buf_count = __library
577 .get(b"vsl_camera_get_queued_buf_count\0")
578 .map(|sym| *sym);
579 let vsl_camera_buffer_mmap = __library.get(b"vsl_camera_buffer_mmap\0").map(|sym| *sym);
580 let vsl_camera_buffer_dma_fd = __library.get(b"vsl_camera_buffer_dma_fd\0").map(|sym| *sym);
581 let vsl_camera_buffer_phys_addr = __library
582 .get(b"vsl_camera_buffer_phys_addr\0")
583 .map(|sym| *sym);
584 let vsl_camera_buffer_length = __library.get(b"vsl_camera_buffer_length\0").map(|sym| *sym);
585 let vsl_camera_buffer_fourcc = __library.get(b"vsl_camera_buffer_fourcc\0").map(|sym| *sym);
586 let vsl_camera_buffer_timestamp = __library
587 .get(b"vsl_camera_buffer_timestamp\0")
588 .map(|sym| *sym);
589 let vsl_camera_enum_fmts = __library.get(b"vsl_camera_enum_fmts\0").map(|sym| *sym);
590 let vsl_camera_enum_mplane_fmts = __library
591 .get(b"vsl_camera_enum_mplane_fmts\0")
592 .map(|sym| *sym);
593 let vsl_decoder_create = __library.get(b"vsl_decoder_create\0").map(|sym| *sym);
594 let vsl_decoder_create_ex = __library.get(b"vsl_decoder_create_ex\0").map(|sym| *sym);
595 let vsl_decode_frame = __library.get(b"vsl_decode_frame\0").map(|sym| *sym);
596 let vsl_decoder_width = __library.get(b"vsl_decoder_width\0").map(|sym| *sym);
597 let vsl_decoder_height = __library.get(b"vsl_decoder_height\0").map(|sym| *sym);
598 let vsl_decoder_crop = __library.get(b"vsl_decoder_crop\0").map(|sym| *sym);
599 let vsl_decoder_release = __library.get(b"vsl_decoder_release\0").map(|sym| *sym);
600 Ok(VideoStreamLibrary {
601 __library,
602 vsl_version,
603 vsl_timestamp,
604 vsl_host_init,
605 vsl_host_release,
606 vsl_host_path,
607 vsl_host_poll,
608 vsl_host_service,
609 vsl_host_process,
610 vsl_host_sockets,
611 vsl_host_post,
612 vsl_host_drop,
613 vsl_client_init,
614 vsl_client_release,
615 vsl_client_disconnect,
616 vsl_client_userptr,
617 vsl_client_path,
618 vsl_client_set_timeout,
619 vsl_frame_register,
620 vsl_frame_init,
621 vsl_frame_alloc,
622 vsl_frame_unalloc,
623 vsl_frame_attach,
624 vsl_frame_path,
625 vsl_frame_unregister,
626 vsl_frame_copy,
627 vsl_frame_userptr,
628 vsl_frame_set_userptr,
629 vsl_frame_wait,
630 vsl_frame_release,
631 vsl_frame_trylock,
632 vsl_frame_unlock,
633 vsl_frame_serial,
634 vsl_frame_timestamp,
635 vsl_frame_duration,
636 vsl_frame_pts,
637 vsl_frame_dts,
638 vsl_frame_expires,
639 vsl_frame_fourcc,
640 vsl_frame_width,
641 vsl_frame_height,
642 vsl_frame_stride,
643 vsl_frame_size,
644 vsl_frame_handle,
645 vsl_frame_paddr,
646 vsl_frame_mmap,
647 vsl_frame_munmap,
648 vsl_frame_sync,
649 vsl_fourcc_from_string,
650 vsl_encoder_create,
651 vsl_encoder_create_ex,
652 vsl_encoder_release,
653 vsl_encode_frame,
654 vsl_encoder_new_output_frame,
655 vsl_camera_open_device,
656 vsl_camera_init_device,
657 vsl_camera_mirror,
658 vsl_camera_mirror_v,
659 vsl_camera_start_capturing,
660 vsl_camera_get_data,
661 vsl_camera_release_buffer,
662 vsl_camera_stop_capturing,
663 vsl_camera_uninit_device,
664 vsl_camera_close_device,
665 vsl_camera_is_dmabuf_supported,
666 vsl_camera_get_queued_buf_count,
667 vsl_camera_buffer_mmap,
668 vsl_camera_buffer_dma_fd,
669 vsl_camera_buffer_phys_addr,
670 vsl_camera_buffer_length,
671 vsl_camera_buffer_fourcc,
672 vsl_camera_buffer_timestamp,
673 vsl_camera_enum_fmts,
674 vsl_camera_enum_mplane_fmts,
675 vsl_decoder_create,
676 vsl_decoder_create_ex,
677 vsl_decode_frame,
678 vsl_decoder_width,
679 vsl_decoder_height,
680 vsl_decoder_crop,
681 vsl_decoder_release,
682 })
683 }
684 #[doc = " Returns the VideoStream Library version string.\n\n @return Version string in \"MAJOR.MINOR.PATCH\" format (e.g., \"1.5.4\")\n @since 1.0"]
685 pub unsafe fn vsl_version(&self) -> *const ::std::os::raw::c_char {
686 (self
687 .vsl_version
688 .as_ref()
689 .expect("Expected function, got error."))()
690 }
691 #[doc = " Returns the current timestamp in nanoseconds.\n\n Uses monotonic clock (CLOCK_MONOTONIC) for consistent timing across the\n system. This timestamp is used for frame timing and synchronization.\n\n @return Current time in nanoseconds since an unspecified starting point\n @since 1.0"]
692 pub unsafe fn vsl_timestamp(&self) -> i64 {
693 (self
694 .vsl_timestamp
695 .as_ref()
696 .expect("Expected function, got error."))()
697 }
698 #[doc = " Creates a host on the requested path for inter-process frame sharing.\n\n The host manages a UNIX domain socket at the specified path and accepts\n connections from clients. Frames posted to the host are broadcast to all\n connected clients.\n\n @param path UNIX socket path (filesystem or abstract). If path starts with\n '/' it creates a filesystem socket, otherwise an abstract socket.\n @return Pointer to VSLHost object on success, NULL on failure (sets errno)\n @since 1.0\n @memberof VSLHost"]
699 pub unsafe fn vsl_host_init(&self, path: *const ::std::os::raw::c_char) -> *mut VSLHost {
700 (self
701 .vsl_host_init
702 .as_ref()
703 .expect("Expected function, got error."))(path)
704 }
705 #[doc = " Releases the host, disconnecting all clients and releasing any allocated\n memory.\n\n Closes the UNIX socket, disconnects all clients, and frees all resources\n associated with the host. Any posted frames are released.\n\n @param host The host to release\n @since 1.0\n @memberof VSLHost"]
706 pub unsafe fn vsl_host_release(&self, host: *mut VSLHost) {
707 (self
708 .vsl_host_release
709 .as_ref()
710 .expect("Expected function, got error."))(host)
711 }
712 #[doc = " Returns the bound path of the host.\n\n @param host The host instance\n @return UNIX socket path string (owned by host, do not free)\n @since 1.0\n @memberof VSLHost"]
713 pub unsafe fn vsl_host_path(&self, host: *const VSLHost) -> *const ::std::os::raw::c_char {
714 (self
715 .vsl_host_path
716 .as_ref()
717 .expect("Expected function, got error."))(host)
718 }
719 #[doc = " Polls the list of available connections for activity.\n\n Waits for socket activity (new connections or client messages) using poll().\n Should be called in a loop before vsl_host_process(). Note frames are only\n expired by vsl_host_process(), so the wait parameter should be no greater\n than the desired frame expiration time to ensure timely cleanup.\n\n @param host The host instance\n @param wait Timeout in milliseconds. If >0, poll waits up to this duration.\n If 0, returns immediately. If <0, waits indefinitely.\n @return Number of sockets with activity, 0 on timeout, -1 on error (sets\n errno)\n @since 1.0\n @memberof VSLHost"]
720 pub unsafe fn vsl_host_poll(&self, host: *mut VSLHost, wait: i64) -> ::std::os::raw::c_int {
721 (self
722 .vsl_host_poll
723 .as_ref()
724 .expect("Expected function, got error."))(host, wait)
725 }
726 #[doc = " Services a single client socket.\n\n Processes messages from a specific client socket. Does not accept new\n connections - use vsl_host_process() for that. Useful when you need to\n track errors for individual clients.\n\n @param host The host instance\n @param sock The client socket file descriptor to service\n @return 0 on success, -1 on error (sets errno, EPIPE if client disconnected)\n @since 1.0\n @memberof VSLHost"]
727 pub unsafe fn vsl_host_service(
728 &self,
729 host: *mut VSLHost,
730 sock: ::std::os::raw::c_int,
731 ) -> ::std::os::raw::c_int {
732 (self
733 .vsl_host_service
734 .as_ref()
735 .expect("Expected function, got error."))(host, sock)
736 }
737 #[doc = " Process host tasks: expire old frames and service one client connection.\n\n First expires frames past their lifetime, then services the first available\n connection (accepting new clients or processing client messages). Should be\n called in a loop, typically after vsl_host_poll() indicates activity.\n\n @param host The host instance\n @return 0 on success, -1 on error (sets errno, ETIMEDOUT if no activity)\n @since 1.0\n @memberof VSLHost"]
738 pub unsafe fn vsl_host_process(&self, host: *mut VSLHost) -> ::std::os::raw::c_int {
739 (self
740 .vsl_host_process
741 .as_ref()
742 .expect("Expected function, got error."))(host)
743 }
744 #[doc = " Request a copy of the sockets managed by the host.\n\n Returns socket file descriptors for the host's listening socket and all\n connected client sockets. The first socket is always the listening socket.\n The array should be refreshed frequently as sockets may become stale.\n\n Thread-safe: allows one thread to use sockets for messaging while another\n polls for reads.\n\n @param host The host instance\n @param n_sockets Size of the sockets array buffer\n @param sockets Buffer to receive socket file descriptors\n @param max_sockets If provided, populated with n_clients+1 (total sockets)\n @return 0 on success, -1 on error (sets errno to ENOBUFS if buffer too small)\n @since 1.0\n @memberof VSLHost"]
745 pub unsafe fn vsl_host_sockets(
746 &self,
747 host: *mut VSLHost,
748 n_sockets: usize,
749 sockets: *mut ::std::os::raw::c_int,
750 max_sockets: *mut usize,
751 ) -> ::std::os::raw::c_int {
752 (self
753 .vsl_host_sockets
754 .as_ref()
755 .expect("Expected function, got error."))(host, n_sockets, sockets, max_sockets)
756 }
757 #[doc = " Registers the frame with the host and publishes it to subscribers.\n\n Transfers ownership of the frame to the host. The frame is broadcast to all\n connected clients and will be automatically released when it expires. Do not\n call vsl_frame_release() on frames posted to the host.\n\n @param host The host instance\n @param frame Frame to post (ownership transferred to host)\n @param expires Expiration time in nanoseconds (absolute, from\n vsl_timestamp())\n @param duration Frame duration in nanoseconds (-1 if unknown)\n @param pts Presentation timestamp in nanoseconds (-1 if unknown)\n @param dts Decode timestamp in nanoseconds (-1 if unknown)\n @return 0 on success, -1 on error (sets errno)\n @since 1.3\n @memberof VSLHost"]
758 pub unsafe fn vsl_host_post(
759 &self,
760 host: *mut VSLHost,
761 frame: *mut VSLFrame,
762 expires: i64,
763 duration: i64,
764 pts: i64,
765 dts: i64,
766 ) -> ::std::os::raw::c_int {
767 (self
768 .vsl_host_post
769 .as_ref()
770 .expect("Expected function, got error."))(
771 host, frame, expires, duration, pts, dts
772 )
773 }
774 #[doc = " Drops the frame from the host.\n\n Removes the host association of the frame and returns ownership to the\n caller. Can be used to cancel a previously posted frame before it expires.\n\n @param host The host instance\n @param frame Frame to drop from host\n @return 0 on success, -1 on error (sets errno)\n @since 1.3\n @memberof VSLHost"]
775 pub unsafe fn vsl_host_drop(
776 &self,
777 host: *mut VSLHost,
778 frame: *mut VSLFrame,
779 ) -> ::std::os::raw::c_int {
780 (self
781 .vsl_host_drop
782 .as_ref()
783 .expect("Expected function, got error."))(host, frame)
784 }
785 #[doc = " Creates a client and connects to the host at the provided path.\n\n Establishes a connection to a VSLHost via UNIX domain socket. The client\n can receive frames broadcast by the host.\n\n @param path UNIX socket path matching the host's path\n @param userptr Optional user data pointer (retrievable via\n vsl_client_userptr)\n @param reconnect If true, automatically reconnect if connection is lost\n @return Pointer to VSLClient object on success, NULL on failure (sets errno)\n @since 1.0\n @memberof VSLClient"]
786 pub unsafe fn vsl_client_init(
787 &self,
788 path: *const ::std::os::raw::c_char,
789 userptr: *mut ::std::os::raw::c_void,
790 reconnect: bool,
791 ) -> *mut VSLClient {
792 (self
793 .vsl_client_init
794 .as_ref()
795 .expect("Expected function, got error."))(path, userptr, reconnect)
796 }
797 #[doc = " Releases the client, disconnecting from the host and releasing allocated\n memory.\n\n Closes the socket connection, frees all resources, and invalidates any\n pending frames. Not thread-safe - use vsl_client_disconnect() for\n thread-safe disconnection before calling this.\n\n @param client The client to release\n @since 1.0\n @memberof VSLClient"]
798 pub unsafe fn vsl_client_release(&self, client: *mut VSLClient) {
799 (self
800 .vsl_client_release
801 .as_ref()
802 .expect("Expected function, got error."))(client)
803 }
804 #[doc = " Disconnects from the VSLHost and stops all reconnection attempts.\n\n Thread-safe disconnect operation. Should be called before\n vsl_client_release() when shutting down a client session from a different\n thread.\n\n @param client The client to disconnect\n @since 1.1\n @memberof VSLClient"]
805 pub unsafe fn vsl_client_disconnect(&self, client: *mut VSLClient) {
806 (self
807 .vsl_client_disconnect
808 .as_ref()
809 .expect("Expected function, got error."))(client)
810 }
811 #[doc = " Returns the optional userptr associated with this client connection.\n\n @param client The client instance\n @return User pointer provided to vsl_client_init(), or NULL if none\n @since 1.0\n @memberof VSLClient"]
812 pub unsafe fn vsl_client_userptr(&self, client: *mut VSLClient) -> *mut ::std::os::raw::c_void {
813 (self
814 .vsl_client_userptr
815 .as_ref()
816 .expect("Expected function, got error."))(client)
817 }
818 #[doc = " Returns the path on which the client has connected to the host.\n\n @param client The client instance\n @return UNIX socket path string (owned by client, do not free)\n @since 1.0\n @memberof VSLClient"]
819 pub unsafe fn vsl_client_path(
820 &self,
821 client: *const VSLClient,
822 ) -> *const ::std::os::raw::c_char {
823 (self
824 .vsl_client_path
825 .as_ref()
826 .expect("Expected function, got error."))(client)
827 }
828 #[doc = " Sets the socket timeout for this client.\n\n Configures how long socket operations wait before timing out. Affects\n recv() calls when waiting for frames from the host.\n\n @param client The client instance\n @param timeout Timeout in seconds (e.g., 1.0 for 1 second)\n @since 1.0\n @memberof VSLClient"]
829 pub unsafe fn vsl_client_set_timeout(&self, client: *mut VSLClient, timeout: f32) {
830 (self
831 .vsl_client_set_timeout
832 .as_ref()
833 .expect("Expected function, got error."))(client, timeout)
834 }
835 #[doc = " Creates and posts the video frame along with optional user pointer to any\n arbitrary data. Typically it would be used for holding a reference to\n the host's view of the frame handle.\n\n @deprecated The vsl_frame_register function is deprecated in favour of using\n the @ref vsl_frame_init(), @ref vsl_frame_alloc() or @ref vsl_frame_attach(),\n and @ref vsl_host_post() functions which separate frame creation from posting\n to the host for publishing to subscribers.\n\n @note A frame created through this function is owned by the host and should\n not have @ref vsl_frame_release called on it. This will be managed by the\n host on frame expiry.\n\n @memberof VSLFrame"]
836 pub unsafe fn vsl_frame_register(
837 &self,
838 host: *mut VSLHost,
839 serial: i64,
840 handle: ::std::os::raw::c_int,
841 width: ::std::os::raw::c_int,
842 height: ::std::os::raw::c_int,
843 fourcc: u32,
844 size: usize,
845 offset: usize,
846 expires: i64,
847 duration: i64,
848 pts: i64,
849 dts: i64,
850 cleanup: vsl_frame_cleanup,
851 userptr: *mut ::std::os::raw::c_void,
852 ) -> *mut VSLFrame {
853 (self
854 .vsl_frame_register
855 .as_ref()
856 .expect("Expected function, got error."))(
857 host, serial, handle, width, height, fourcc, size, offset, expires, duration, pts, dts,
858 cleanup, userptr,
859 )
860 }
861 #[doc = " Initializes a VSLFrame without underlying frame buffer.\n\n Creates a frame descriptor with specified dimensions and format. To allocate\n backing memory, call vsl_frame_alloc(). To attach existing memory (e.g.,\n DmaBuf from camera), call vsl_frame_attach().\n\n @param width Frame width in pixels\n @param height Frame height in pixels\n @param stride Row stride in bytes (0 to auto-calculate from width)\n @param fourcc Pixel format as FOURCC code (e.g., VSL_FOURCC('N','V','1','2'))\n @param userptr Optional user data pointer\n @param cleanup Optional cleanup callback invoked on vsl_frame_release()\n @return Pointer to VSLFrame object, or NULL on failure\n @since 1.3\n @memberof VSLFrame"]
862 pub unsafe fn vsl_frame_init(
863 &self,
864 width: u32,
865 height: u32,
866 stride: u32,
867 fourcc: u32,
868 userptr: *mut ::std::os::raw::c_void,
869 cleanup: vsl_frame_cleanup,
870 ) -> *mut VSLFrame {
871 (self
872 .vsl_frame_init
873 .as_ref()
874 .expect("Expected function, got error."))(
875 width, height, stride, fourcc, userptr, cleanup,
876 )
877 }
878 #[doc = " Allocates the underlying memory for the frame.\n\n Prefers DmaBuf allocation for zero-copy, falling back to POSIX shared memory\n if DmaBuf unavailable. If path is provided, it determines allocation type:\n - NULL: Try DmaBuf first, fallback to shared memory\n - Starts with \"/dev\": Use DmaBuf heap device at this path\n - Other paths: Use shared memory at this path\n\n Allocates height*stride bytes. For compressed formats (JPEG, H.264), the\n actual data size may be smaller. Use vsl_frame_copy() return value to get\n actual compressed size.\n\n @param frame Frame to allocate memory for\n @param path Optional allocation path (NULL for auto, /dev/... for DmaBuf\n heap)\n @return 0 on success, -1 on failure (sets errno)\n @since 1.3\n @memberof VSLFrame"]
879 pub unsafe fn vsl_frame_alloc(
880 &self,
881 frame: *mut VSLFrame,
882 path: *const ::std::os::raw::c_char,
883 ) -> ::std::os::raw::c_int {
884 (self
885 .vsl_frame_alloc
886 .as_ref()
887 .expect("Expected function, got error."))(frame, path)
888 }
889 #[doc = " Frees the allocated buffer for this frame.\n\n Releases the underlying memory (DmaBuf or shared memory) but does not\n destroy the frame object. Use vsl_frame_release() to destroy the frame.\n\n @param frame Frame whose buffer should be freed\n @since 1.3\n @memberof VSLFrame"]
890 pub unsafe fn vsl_frame_unalloc(&self, frame: *mut VSLFrame) {
891 (self
892 .vsl_frame_unalloc
893 .as_ref()
894 .expect("Expected function, got error."))(frame)
895 }
896 #[doc = " Attach the provided file descriptor to the VSLFrame.\n\n Associates an existing buffer (typically DmaBuf from camera or hardware\n accelerator) with the frame. The frame does not take ownership of the FD.\n\n @param frame Frame to attach buffer to\n @param fd File descriptor (typically DmaBuf) to attach\n @param size Buffer size in bytes (0 to use stride*height)\n @param offset Byte offset to frame data start (must provide size if offset>0)\n @return 0 on success, -1 on failure (sets errno)\n @since 1.3\n @memberof VSLFrame"]
897 pub unsafe fn vsl_frame_attach(
898 &self,
899 frame: *mut VSLFrame,
900 fd: ::std::os::raw::c_int,
901 size: usize,
902 offset: usize,
903 ) -> ::std::os::raw::c_int {
904 (self
905 .vsl_frame_attach
906 .as_ref()
907 .expect("Expected function, got error."))(frame, fd, size, offset)
908 }
909 #[doc = " Returns the path to the underlying VSLFrame buffer.\n\n Returns the filesystem path for shared memory buffers or DmaBuf heap devices.\n Not available for externally created DmaBufs (e.g., from camera driver).\n\n @warning Not thread-safe. Use the returned string immediately.\n\n @param frame The frame instance\n @return Buffer path string (owned by frame), or NULL if unavailable\n @since 1.3\n @memberof VSLFrame"]
910 pub unsafe fn vsl_frame_path(&self, frame: *const VSLFrame) -> *const ::std::os::raw::c_char {
911 (self
912 .vsl_frame_path
913 .as_ref()
914 .expect("Expected function, got error."))(frame)
915 }
916 #[doc = " Unregisters the frame, removing it from the host pool.\n\n @deprecated Use vsl_frame_release() instead, which handles cleanup properly.\n\n @param frame Frame to unregister\n @since 1.0\n @memberof VSLFrame"]
917 pub unsafe fn vsl_frame_unregister(&self, frame: *mut VSLFrame) {
918 (self
919 .vsl_frame_unregister
920 .as_ref()
921 .expect("Expected function, got error."))(frame)
922 }
923 #[doc = " Copy the source frame into the target frame, with optional source crop.\n\n Handles format conversion, rescaling, and cropping using hardware\n acceleration when available (G2D on i.MX8). Both frames can be host or client\n frames. Automatically locks frames during copy (safe for free-standing frames\n too).\n\n Copy sequence: 1) Crop source, 2) Convert format, 3) Scale to target size.\n\n @warning Copying to/from a posted frame may cause visual tearing.\n\n @param target Destination frame (receives copied data)\n @param source Source frame to copy from\n @param crop Optional crop region in source coordinates (NULL for full frame)\n @return Number of bytes copied on success, -1 on failure (sets errno)\n @since 1.3\n @memberof VSLFrame"]
924 pub unsafe fn vsl_frame_copy(
925 &self,
926 target: *mut VSLFrame,
927 source: *mut VSLFrame,
928 crop: *const VSLRect,
929 ) -> ::std::os::raw::c_int {
930 (self
931 .vsl_frame_copy
932 .as_ref()
933 .expect("Expected function, got error."))(target, source, crop)
934 }
935 #[doc = " Returns the user pointer associated with this frame.\n\n @param frame The frame instance\n @return User pointer provided to vsl_frame_init(), or NULL if none\n @since 1.0\n @memberof VSLFrame"]
936 pub unsafe fn vsl_frame_userptr(&self, frame: *mut VSLFrame) -> *mut ::std::os::raw::c_void {
937 (self
938 .vsl_frame_userptr
939 .as_ref()
940 .expect("Expected function, got error."))(frame)
941 }
942 #[doc = " Associate userptr with this frame.\n\n Sets or updates the user data pointer for this frame.\n\n @param frame The frame instance\n @param userptr User data pointer to associate with frame\n @since 1.0\n @memberof VSLFrame"]
943 pub unsafe fn vsl_frame_set_userptr(
944 &self,
945 frame: *mut VSLFrame,
946 userptr: *mut ::std::os::raw::c_void,
947 ) {
948 (self
949 .vsl_frame_set_userptr
950 .as_ref()
951 .expect("Expected function, got error."))(frame, userptr)
952 }
953 #[doc = " Waits for a frame to arrive and returns a new frame object.\n\n Blocks until the host broadcasts a new frame. Frames with timestamp less\n than 'until' are ignored (useful for skipping old frames after a pause).\n\n Caller must lock the frame (vsl_frame_trylock) before accessing data,\n then unlock and release when done.\n\n @param client The client instance\n @param until Minimum timestamp in nanoseconds (0 to accept next frame)\n @return Pointer to VSLFrame object, or NULL on error (sets errno)\n @since 1.0\n @memberof VSLFrame"]
954 pub unsafe fn vsl_frame_wait(&self, client: *mut VSLClient, until: i64) -> *mut VSLFrame {
955 (self
956 .vsl_frame_wait
957 .as_ref()
958 .expect("Expected function, got error."))(client, until)
959 }
960 #[doc = " Releases the frame, performing required cleanup.\n\n Unmaps memory if mapped, unlocks if locked. If frame was posted to a host,\n removes it. If client frame, decrements reference count. Invokes cleanup\n callback if registered.\n\n @param frame Frame to release\n @since 1.0\n @memberof VSLFrame"]
961 pub unsafe fn vsl_frame_release(&self, frame: *mut VSLFrame) {
962 (self
963 .vsl_frame_release
964 .as_ref()
965 .expect("Expected function, got error."))(frame)
966 }
967 #[doc = " Attempts to lock the video frame.\n\n Locks the frame for exclusive access (prevents host from releasing it).\n Must be called before accessing frame data from a client. Always succeeds\n for host-owned frames.\n\n @param frame Frame to lock\n @return 0 on success, -1 on failure (frame expired or already unlocked)\n @since 1.0\n @memberof VSLFrame"]
968 pub unsafe fn vsl_frame_trylock(&self, frame: *mut VSLFrame) -> ::std::os::raw::c_int {
969 (self
970 .vsl_frame_trylock
971 .as_ref()
972 .expect("Expected function, got error."))(frame)
973 }
974 #[doc = " Attempts to unlock the video frame.\n\n Releases the lock acquired by vsl_frame_trylock(), allowing the host to\n release the frame when it expires.\n\n @param frame Frame to unlock\n @return 0 on success, -1 on failure (sets errno)\n @since 1.0\n @memberof VSLFrame"]
975 pub unsafe fn vsl_frame_unlock(&self, frame: *mut VSLFrame) -> ::std::os::raw::c_int {
976 (self
977 .vsl_frame_unlock
978 .as_ref()
979 .expect("Expected function, got error."))(frame)
980 }
981 #[doc = " Returns the serial frame count of the video frame.\n\n Frame serial is a monotonically increasing counter assigned by the host\n when frames are registered. Does not necessarily equal camera frame number.\n\n @param frame The frame instance\n @return Frame serial number (starts at 1)\n @since 1.0\n @memberof VSLFrame"]
982 pub unsafe fn vsl_frame_serial(&self, frame: *const VSLFrame) -> i64 {
983 (self
984 .vsl_frame_serial
985 .as_ref()
986 .expect("Expected function, got error."))(frame)
987 }
988 #[doc = " Returns the timestamp for this frame in nanoseconds.\n\n Timestamp from vsl_timestamp() when frame was registered with host.\n Uses monotonic clock for consistent timing.\n\n @param frame The frame instance\n @return Frame timestamp in nanoseconds\n @since 1.0\n @memberof VSLFrame"]
989 pub unsafe fn vsl_frame_timestamp(&self, frame: *const VSLFrame) -> i64 {
990 (self
991 .vsl_frame_timestamp
992 .as_ref()
993 .expect("Expected function, got error."))(frame)
994 }
995 #[doc = " Returns the duration for this frame in nanoseconds.\n\n Frame duration indicates how long this frame should be displayed.\n May be -1 if unknown or not applicable.\n\n @param frame The frame instance\n @return Frame duration in nanoseconds, or -1 if unknown\n @since 1.0\n @memberof VSLFrame"]
996 pub unsafe fn vsl_frame_duration(&self, frame: *const VSLFrame) -> i64 {
997 (self
998 .vsl_frame_duration
999 .as_ref()
1000 .expect("Expected function, got error."))(frame)
1001 }
1002 #[doc = " Returns the presentation timestamp for this frame in nanoseconds.\n\n PTS indicates when this frame should be presented/displayed in a stream.\n May be -1 if unknown or not applicable.\n\n @param frame The frame instance\n @return Presentation timestamp in nanoseconds, or -1 if unknown\n @since 1.0\n @memberof VSLFrame"]
1003 pub unsafe fn vsl_frame_pts(&self, frame: *const VSLFrame) -> i64 {
1004 (self
1005 .vsl_frame_pts
1006 .as_ref()
1007 .expect("Expected function, got error."))(frame)
1008 }
1009 #[doc = " Returns the decode timestamp for this frame in nanoseconds.\n\n DTS indicates when this frame should be decoded in a stream (important for\n B-frames in video codecs). May be -1 if unknown or not applicable.\n\n @param frame The frame instance\n @return Decode timestamp in nanoseconds, or -1 if unknown\n @since 1.0\n @memberof VSLFrame"]
1010 pub unsafe fn vsl_frame_dts(&self, frame: *const VSLFrame) -> i64 {
1011 (self
1012 .vsl_frame_dts
1013 .as_ref()
1014 .expect("Expected function, got error."))(frame)
1015 }
1016 #[doc = " Returns the expiration time for this frame in nanoseconds.\n\n Absolute timestamp (from vsl_timestamp()) when this frame will be expired\n by the host. Clients should lock frames before this time.\n\n @param frame The frame instance\n @return Expiration timestamp in nanoseconds\n @since 1.0\n @memberof VSLFrame"]
1017 pub unsafe fn vsl_frame_expires(&self, frame: *const VSLFrame) -> i64 {
1018 (self
1019 .vsl_frame_expires
1020 .as_ref()
1021 .expect("Expected function, got error."))(frame)
1022 }
1023 #[doc = " Returns the FOURCC code for the video frame.\n\n FOURCC identifies the pixel format (e.g., NV12, YUY2, JPEG, H264).\n Use VSL_FOURCC() macro to create fourcc codes.\n\n @param frame The frame instance\n @return FOURCC code as uint32_t\n @since 1.0\n @memberof VSLFrame"]
1024 pub unsafe fn vsl_frame_fourcc(&self, frame: *const VSLFrame) -> u32 {
1025 (self
1026 .vsl_frame_fourcc
1027 .as_ref()
1028 .expect("Expected function, got error."))(frame)
1029 }
1030 #[doc = " Returns the width in pixels of the video frame.\n\n @param frame The frame instance\n @return Frame width in pixels\n @since 1.0\n @memberof VSLFrame"]
1031 pub unsafe fn vsl_frame_width(&self, frame: *const VSLFrame) -> ::std::os::raw::c_int {
1032 (self
1033 .vsl_frame_width
1034 .as_ref()
1035 .expect("Expected function, got error."))(frame)
1036 }
1037 #[doc = " Returns the height in pixels of the video frame.\n\n @param frame The frame instance\n @return Frame height in pixels\n @since 1.0\n @memberof VSLFrame"]
1038 pub unsafe fn vsl_frame_height(&self, frame: *const VSLFrame) -> ::std::os::raw::c_int {
1039 (self
1040 .vsl_frame_height
1041 .as_ref()
1042 .expect("Expected function, got error."))(frame)
1043 }
1044 #[doc = " Returns the stride in bytes of the video frame.\n\n Stride is the number of bytes from the start of one row to the next.\n May be larger than width*bytes_per_pixel due to alignment requirements.\n\n @param frame The frame instance\n @return Row stride in bytes\n @since 1.3\n @memberof VSLFrame"]
1045 pub unsafe fn vsl_frame_stride(&self, frame: *const VSLFrame) -> ::std::os::raw::c_int {
1046 (self
1047 .vsl_frame_stride
1048 .as_ref()
1049 .expect("Expected function, got error."))(frame)
1050 }
1051 #[doc = " Returns the size in bytes of the video frame buffer.\n\n For uncompressed formats, this is stride*height. For compressed formats\n (JPEG, H.264), this is the maximum buffer size, not the actual data size.\n\n @param frame The frame instance\n @return Buffer size in bytes\n @since 1.0\n @memberof VSLFrame"]
1052 pub unsafe fn vsl_frame_size(&self, frame: *const VSLFrame) -> ::std::os::raw::c_int {
1053 (self
1054 .vsl_frame_size
1055 .as_ref()
1056 .expect("Expected function, got error."))(frame)
1057 }
1058 #[doc = " Returns the file descriptor for this frame.\n\n Returns the DmaBuf or shared memory file descriptor used for zero-copy\n sharing. Returns -1 if no file descriptor is associated (e.g., CPU-only\n memory).\n\n @param frame The frame instance\n @return File descriptor, or -1 if none\n @since 1.0\n @memberof VSLFrame"]
1059 pub unsafe fn vsl_frame_handle(&self, frame: *const VSLFrame) -> ::std::os::raw::c_int {
1060 (self
1061 .vsl_frame_handle
1062 .as_ref()
1063 .expect("Expected function, got error."))(frame)
1064 }
1065 #[doc = " Returns the physical address of the frame.\n\n Physical address is available for DMA-capable buffers on platforms where\n the kernel provides physical address translation (some i.MX platforms).\n Note: This function caches the physical address internally on first call.\n\n @param frame The frame instance\n @return Physical address, or MMAP_FAILED ((intptr_t)-1) if DMA not supported\n @since 1.0\n @memberof VSLFrame"]
1066 pub unsafe fn vsl_frame_paddr(&self, frame: *mut VSLFrame) -> isize {
1067 (self
1068 .vsl_frame_paddr
1069 .as_ref()
1070 .expect("Expected function, got error."))(frame)
1071 }
1072 #[doc = " Maps the frame into the process memory space.\n\n Creates a memory mapping for CPU access to frame data. Frame must be locked\n (vsl_frame_trylock) for the duration of the mapping. Call vsl_frame_munmap()\n when done.\n\n @param frame The frame instance\n @param size Optional pointer to receive mapped size in bytes (may be NULL)\n @return Pointer to mapped memory, or NULL on failure\n @since 1.0\n @memberof VSLFrame"]
1073 pub unsafe fn vsl_frame_mmap(
1074 &self,
1075 frame: *mut VSLFrame,
1076 size: *mut usize,
1077 ) -> *mut ::std::os::raw::c_void {
1078 (self
1079 .vsl_frame_mmap
1080 .as_ref()
1081 .expect("Expected function, got error."))(frame, size)
1082 }
1083 #[doc = " Unmaps the frame from the process memory space.\n\n Releases the memory mapping created by vsl_frame_mmap(). Should be called\n when done accessing frame data.\n\n @param frame The frame instance to unmap\n @since 1.0\n @memberof VSLFrame"]
1084 pub unsafe fn vsl_frame_munmap(&self, frame: *mut VSLFrame) {
1085 (self
1086 .vsl_frame_munmap
1087 .as_ref()
1088 .expect("Expected function, got error."))(frame)
1089 }
1090 #[doc = " Cache synchronization session control for DMA-backed buffers.\n\n Controls CPU cache coherency for DMA buffers. Automatically called by\n mmap/munmap, but can be used manually for in-place frame updates.\n\n Call with enable=1 before accessing, enable=0 after modifying.\n Mode: DMA_BUF_SYNC_READ (CPU reads), DMA_BUF_SYNC_WRITE (CPU writes),\n or DMA_BUF_SYNC_RW (both).\n\n @param frame The frame object to synchronize\n @param enable 1 to start sync session, 0 to end it\n @param mode Sync mode: DMA_BUF_SYNC_READ, DMA_BUF_SYNC_WRITE, or\n DMA_BUF_SYNC_RW\n @return 0 on success, -1 on failure (sets errno)\n @since 1.3\n @memberof VSLFrame"]
1091 pub unsafe fn vsl_frame_sync(
1092 &self,
1093 frame: *const VSLFrame,
1094 enable: ::std::os::raw::c_int,
1095 mode: ::std::os::raw::c_int,
1096 ) -> ::std::os::raw::c_int {
1097 (self
1098 .vsl_frame_sync
1099 .as_ref()
1100 .expect("Expected function, got error."))(frame, enable, mode)
1101 }
1102 #[doc = " Returns a fourcc integer code from the string.\n\n Converts a 4-character string to FOURCC code. Example: \"NV12\" ->\n VSL_FOURCC('N','V','1','2').\n\n @param fourcc String containing exactly 4 characters (e.g., \"NV12\", \"YUY2\")\n @return FOURCC code as uint32_t, or 0 if invalid/unsupported\n @since 1.3"]
1103 pub unsafe fn vsl_fourcc_from_string(&self, fourcc: *const ::std::os::raw::c_char) -> u32 {
1104 (self
1105 .vsl_fourcc_from_string
1106 .as_ref()
1107 .expect("Expected function, got error."))(fourcc)
1108 }
1109 #[doc = " @brief Creates VSLEncoder instance\n\n @param profile VSLEncoderProfile determining encode quality\n @param outputFourcc fourcc code defining the codec\n @param fps output stream fps\n @return VSLEncoder* new encoder instance\n\n Every encoder instance must be released using vsl_encoder_release\n\n For Hantro VC8000e encoder initialization is performed when vsl_encode_frame\n is called for a first time"]
1110 pub unsafe fn vsl_encoder_create(
1111 &self,
1112 profile: VSLEncoderProfile,
1113 outputFourcc: u32,
1114 fps: ::std::os::raw::c_int,
1115 ) -> *mut VSLEncoder {
1116 (self
1117 .vsl_encoder_create
1118 .as_ref()
1119 .expect("Expected function, got error."))(profile, outputFourcc, fps)
1120 }
1121 #[doc = " @brief Creates VSLEncoder instance with explicit backend selection\n\n Extended version of vsl_encoder_create() that allows selecting a specific\n codec backend. Use this when you need to force V4L2 or Hantro backend.\n\n @param profile VSLEncoderProfile determining encode quality\n @param outputFourcc fourcc code defining the codec (H264 or HEVC)\n @param fps output stream fps\n @param backend Which backend to use (VSL_CODEC_BACKEND_AUTO, _V4L2, _HANTRO)\n @return VSLEncoder* new encoder instance, or NULL if backend unavailable\n\n @since 2.0"]
1122 pub unsafe fn vsl_encoder_create_ex(
1123 &self,
1124 profile: VSLEncoderProfile,
1125 outputFourcc: u32,
1126 fps: ::std::os::raw::c_int,
1127 backend: VSLCodecBackend,
1128 ) -> *mut VSLEncoder {
1129 (self
1130 .vsl_encoder_create_ex
1131 .as_ref()
1132 .expect("Expected function, got error."))(profile, outputFourcc, fps, backend)
1133 }
1134 #[doc = " @brief Destroys VSLEncoder instance\n\n Frees all resources associated with the encoder, including hardware\n resources. Do not use the encoder after calling this function.\n\n @param encoder VSLEncoder instance to destroy\n @since 1.3"]
1135 pub unsafe fn vsl_encoder_release(&self, encoder: *mut VSLEncoder) {
1136 (self
1137 .vsl_encoder_release
1138 .as_ref()
1139 .expect("Expected function, got error."))(encoder)
1140 }
1141 #[doc = " @brief Encode frame\n\n Encodes the source frame into the destination frame using hardware\n acceleration (Hantro VPU on i.MX8). First call initializes the encoder with\n the given parameters. Subsequent calls must use identical source/destination\n dimensions, formats, and crop region.\n\n @param encoder VSLEncoder instance\n @param source Source frame (raw video data)\n @param destination Pre-allocated destination frame (receives encoded data)\n @param cropRegion Optional crop region in source coordinates (NULL for no\n crop)\n @param keyframe Optional output: set to 1 if encoded frame is IDR/keyframe,\n 0 otherwise. Pass NULL to ignore.\n @retval 0 on success\n @retval -1 on failure (check errno for details)\n @since 1.3"]
1142 pub unsafe fn vsl_encode_frame(
1143 &self,
1144 encoder: *mut VSLEncoder,
1145 source: *mut VSLFrame,
1146 destination: *mut VSLFrame,
1147 cropRegion: *const VSLRect,
1148 keyframe: *mut ::std::os::raw::c_int,
1149 ) -> ::std::os::raw::c_int {
1150 (self
1151 .vsl_encode_frame
1152 .as_ref()
1153 .expect("Expected function, got error."))(
1154 encoder,
1155 source,
1156 destination,
1157 cropRegion,
1158 keyframe,
1159 )
1160 }
1161 #[doc = " @brief Creates a new output frame for encoder\n\n Allocates a frame suitable for receiving encoded output from\n vsl_encode_frame(). The frame uses encoder-specific memory (e.g., Hantro VPU\n EWL memory on i.MX8) for efficient hardware encoding.\n\n @param encoder VSLEncoder instance\n @param width Encoded frame width in pixels (should match encoder source)\n @param height Encoded frame height in pixels (should match encoder source)\n @param duration Frame duration in nanoseconds (passed through to output)\n @param pts Presentation timestamp in nanoseconds (passed through to output)\n @param dts Decode timestamp in nanoseconds (passed through to output)\n @return Pointer to VSLFrame for encoded output, or NULL on failure\n @since 1.3"]
1162 pub unsafe fn vsl_encoder_new_output_frame(
1163 &self,
1164 encoder: *const VSLEncoder,
1165 width: ::std::os::raw::c_int,
1166 height: ::std::os::raw::c_int,
1167 duration: i64,
1168 pts: i64,
1169 dts: i64,
1170 ) -> *mut VSLFrame {
1171 (self
1172 .vsl_encoder_new_output_frame
1173 .as_ref()
1174 .expect("Expected function, got error."))(
1175 encoder, width, height, duration, pts, dts
1176 )
1177 }
1178 #[doc = " Opens the camera device specified by filename and allocates device memory.\n\n Opens a V4L2 video capture device (e.g., /dev/video0) and prepares it for\n streaming. The device is not yet configured - call vsl_camera_init_device()\n next.\n\n @param filename V4L2 device path (e.g., \"/dev/video0\")\n @return Pointer to vsl_camera context on success, NULL on failure\n @since 1.3\n @memberof VSLCamera"]
1179 pub unsafe fn vsl_camera_open_device(
1180 &self,
1181 filename: *const ::std::os::raw::c_char,
1182 ) -> *mut vsl_camera {
1183 (self
1184 .vsl_camera_open_device
1185 .as_ref()
1186 .expect("Expected function, got error."))(filename)
1187 }
1188 #[doc = " Initializes the camera device for streaming and allocates camera buffers.\n\n Negotiates format with the V4L2 driver. On entry, width/height/fourcc contain\n desired values (0 for driver default). On success, they're updated with\n actual negotiated values. Allocates buf_count buffers (updated with actual\n count).\n\n Must be called after vsl_camera_open_device() and before\n vsl_camera_start_capturing().\n\n @param ctx Camera context from vsl_camera_open_device()\n @param width Pointer to desired/actual width in pixels (0 for default)\n @param height Pointer to desired/actual height in pixels (0 for default)\n @param buf_count Pointer to desired/actual buffer count (0 for default)\n @param fourcc Pointer to desired/actual fourcc format (0 for default)\n @return 0 on success, -1 on error\n @since 1.3\n @memberof VSLCamera"]
1189 pub unsafe fn vsl_camera_init_device(
1190 &self,
1191 ctx: *mut vsl_camera,
1192 width: *mut ::std::os::raw::c_int,
1193 height: *mut ::std::os::raw::c_int,
1194 buf_count: *mut ::std::os::raw::c_int,
1195 fourcc: *mut u32,
1196 ) -> ::std::os::raw::c_int {
1197 (self
1198 .vsl_camera_init_device
1199 .as_ref()
1200 .expect("Expected function, got error."))(ctx, width, height, buf_count, fourcc)
1201 }
1202 #[doc = " Requests the camera to mirror the image left-to-right.\n\n Uses V4L2_CID_HFLIP control to flip the image horizontally.\n Not all cameras support this feature.\n\n @param ctx Camera context\n @param mirror true to enable horizontal flip, false to disable\n @return 0 on success, -1 if driver refused the request\n @since 1.3\n @memberof VSLCamera"]
1203 pub unsafe fn vsl_camera_mirror(
1204 &self,
1205 ctx: *const vsl_camera,
1206 mirror: bool,
1207 ) -> ::std::os::raw::c_int {
1208 (self
1209 .vsl_camera_mirror
1210 .as_ref()
1211 .expect("Expected function, got error."))(ctx, mirror)
1212 }
1213 #[doc = " Requests the camera to mirror the image top-to-bottom.\n\n Uses V4L2_CID_VFLIP control to flip the image vertically.\n Not all cameras support this feature.\n\n @param ctx Camera context\n @param mirror true to enable vertical flip, false to disable\n @return 0 on success, -1 if driver refused the request\n @since 1.3\n @memberof VSLCamera"]
1214 pub unsafe fn vsl_camera_mirror_v(
1215 &self,
1216 ctx: *const vsl_camera,
1217 mirror: bool,
1218 ) -> ::std::os::raw::c_int {
1219 (self
1220 .vsl_camera_mirror_v
1221 .as_ref()
1222 .expect("Expected function, got error."))(ctx, mirror)
1223 }
1224 #[doc = " Starts the camera stream.\n\n Begins V4L2 streaming (VIDIOC_STREAMON). Frames can now be captured with\n vsl_camera_get_data(). Must be called after vsl_camera_init_device().\n\n @param ctx Camera context\n @return 0 on success, -1 on error\n @since 1.3\n @memberof VSLCamera"]
1225 pub unsafe fn vsl_camera_start_capturing(&self, ctx: *mut vsl_camera) -> ::std::os::raw::c_int {
1226 (self
1227 .vsl_camera_start_capturing
1228 .as_ref()
1229 .expect("Expected function, got error."))(ctx)
1230 }
1231 #[doc = " Attempts to read a frame from the camera.\n\n Dequeues a filled buffer from the camera driver (VIDIOC_DQBUF). Blocks until\n a frame is available. Must be called after vsl_camera_start_capturing().\n\n After processing, call vsl_camera_release_buffer() to return the buffer to\n the driver's queue for reuse.\n\n @param ctx Camera context\n @return Pointer to camera buffer, or NULL on timeout/error\n @since 1.3\n @memberof VSLCamera"]
1232 pub unsafe fn vsl_camera_get_data(&self, ctx: *mut vsl_camera) -> *mut vsl_camera_buffer {
1233 (self
1234 .vsl_camera_get_data
1235 .as_ref()
1236 .expect("Expected function, got error."))(ctx)
1237 }
1238 #[doc = " Enqueues a buffer to be reused for frame capture.\n\n Returns the buffer to the camera driver's queue (VIDIOC_QBUF) so it can be\n filled with new frame data. Must be called after processing each buffer from\n vsl_camera_get_data().\n\n @param ctx Camera context\n @param buffer Buffer to release (from vsl_camera_get_data)\n @return 0 on success, -1 on error\n @since 1.3\n @memberof VSLCamera"]
1239 pub unsafe fn vsl_camera_release_buffer(
1240 &self,
1241 ctx: *mut vsl_camera,
1242 buffer: *const vsl_camera_buffer,
1243 ) -> ::std::os::raw::c_int {
1244 (self
1245 .vsl_camera_release_buffer
1246 .as_ref()
1247 .expect("Expected function, got error."))(ctx, buffer)
1248 }
1249 #[doc = " Stops the camera stream.\n\n Stops V4L2 streaming (VIDIOC_STREAMOFF). No more frames will be captured.\n Call before vsl_camera_uninit_device() and vsl_camera_close_device().\n\n @param ctx Camera context\n @return 0 on success, -1 on error\n @since 1.3\n @memberof VSLCamera"]
1250 pub unsafe fn vsl_camera_stop_capturing(
1251 &self,
1252 ctx: *const vsl_camera,
1253 ) -> ::std::os::raw::c_int {
1254 (self
1255 .vsl_camera_stop_capturing
1256 .as_ref()
1257 .expect("Expected function, got error."))(ctx)
1258 }
1259 #[doc = " Uninitializes the camera buffers and frees the buffer memory.\n\n Releases all allocated camera buffers. Ensure the device is not streaming\n (call vsl_camera_stop_capturing() first).\n\n @param ctx Camera context\n @since 1.3\n @memberof VSLCamera"]
1260 pub unsafe fn vsl_camera_uninit_device(&self, ctx: *mut vsl_camera) {
1261 (self
1262 .vsl_camera_uninit_device
1263 .as_ref()
1264 .expect("Expected function, got error."))(ctx)
1265 }
1266 #[doc = " Closes the camera device and frees the device memory.\n\n Closes the V4L2 device file descriptor and releases all resources.\n Ensure the device is not streaming (call vsl_camera_stop_capturing() and\n vsl_camera_uninit_device() first).\n\n @param ctx Camera context to close\n @since 1.3\n @memberof VSLCamera"]
1267 pub unsafe fn vsl_camera_close_device(&self, ctx: *mut vsl_camera) {
1268 (self
1269 .vsl_camera_close_device
1270 .as_ref()
1271 .expect("Expected function, got error."))(ctx)
1272 }
1273 #[doc = " Checks if DmaBuf export is supported on the camera.\n\n DmaBuf support allows zero-copy frame sharing with hardware accelerators\n (VPU, NPU, GPU). Requires V4L2 driver support for VIDIOC_EXPBUF.\n\n Must be called after vsl_camera_init_device().\n\n @param ctx Camera context\n @return 1 if DmaBuf supported, 0 if not supported\n @since 1.3\n @memberof VSLCamera"]
1274 pub unsafe fn vsl_camera_is_dmabuf_supported(
1275 &self,
1276 ctx: *const vsl_camera,
1277 ) -> ::std::os::raw::c_int {
1278 (self
1279 .vsl_camera_is_dmabuf_supported
1280 .as_ref()
1281 .expect("Expected function, got error."))(ctx)
1282 }
1283 #[doc = " Returns the number of buffers queued in the camera driver.\n\n Queued buffers are available for the driver to fill with new frames.\n If count reaches 0, vsl_camera_get_data() will block/timeout waiting for\n buffers to be released via vsl_camera_release_buffer().\n\n @param ctx Camera context\n @return Number of queued buffers\n @since 1.3\n @memberof VSLCamera"]
1284 pub unsafe fn vsl_camera_get_queued_buf_count(
1285 &self,
1286 ctx: *const vsl_camera,
1287 ) -> ::std::os::raw::c_int {
1288 (self
1289 .vsl_camera_get_queued_buf_count
1290 .as_ref()
1291 .expect("Expected function, got error."))(ctx)
1292 }
1293 #[doc = " Returns the mmap memory pointer of the camera buffer.\n\n Provides CPU access to the camera buffer's memory. The buffer is already\n mapped by the camera driver.\n\n @param buffer Camera buffer from vsl_camera_get_data()\n @return Pointer to mapped memory\n @since 1.3\n @memberof VSLCamera"]
1294 pub unsafe fn vsl_camera_buffer_mmap(
1295 &self,
1296 buffer: *mut vsl_camera_buffer,
1297 ) -> *mut ::std::os::raw::c_void {
1298 (self
1299 .vsl_camera_buffer_mmap
1300 .as_ref()
1301 .expect("Expected function, got error."))(buffer)
1302 }
1303 #[doc = " Returns the DmaBuf file descriptor of the camera buffer.\n\n Returns the DmaBuf FD for zero-copy sharing with hardware accelerators.\n Only available if vsl_camera_is_dmabuf_supported() returns true.\n\n @param buffer Camera buffer from vsl_camera_get_data()\n @return DmaBuf file descriptor, or -1 if DmaBuf not supported\n @since 1.3\n @memberof VSLCamera"]
1304 pub unsafe fn vsl_camera_buffer_dma_fd(
1305 &self,
1306 buffer: *const vsl_camera_buffer,
1307 ) -> ::std::os::raw::c_int {
1308 (self
1309 .vsl_camera_buffer_dma_fd
1310 .as_ref()
1311 .expect("Expected function, got error."))(buffer)
1312 }
1313 #[doc = " Returns the physical address of the camera buffer.\n\n Physical address is available on some platforms (certain i.MX drivers) for\n DMA operations. Not commonly used - prefer DmaBuf FD for portability.\n\n @param buffer Camera buffer from vsl_camera_get_data()\n @return Physical address, or 0 if not supported\n @since 1.3\n @memberof VSLCamera"]
1314 pub unsafe fn vsl_camera_buffer_phys_addr(&self, buffer: *const vsl_camera_buffer) -> u64 {
1315 (self
1316 .vsl_camera_buffer_phys_addr
1317 .as_ref()
1318 .expect("Expected function, got error."))(buffer)
1319 }
1320 #[doc = " Returns the length of the camera buffer in bytes.\n\n Buffer size as reported by the V4L2 driver. For multi-planar formats,\n this is the total size across all planes.\n\n @param buffer Camera buffer from vsl_camera_get_data()\n @return Buffer length in bytes\n @since 1.3\n @memberof VSLCamera"]
1321 pub unsafe fn vsl_camera_buffer_length(&self, buffer: *const vsl_camera_buffer) -> u32 {
1322 (self
1323 .vsl_camera_buffer_length
1324 .as_ref()
1325 .expect("Expected function, got error."))(buffer)
1326 }
1327 #[doc = " Returns the fourcc code of the camera buffer.\n\n Pixel format as negotiated with the driver during vsl_camera_init_device().\n\n @param buffer Camera buffer from vsl_camera_get_data()\n @return FOURCC code\n @since 1.3\n @memberof VSLCamera"]
1328 pub unsafe fn vsl_camera_buffer_fourcc(&self, buffer: *const vsl_camera_buffer) -> u32 {
1329 (self
1330 .vsl_camera_buffer_fourcc
1331 .as_ref()
1332 .expect("Expected function, got error."))(buffer)
1333 }
1334 #[doc = " Reads the timestamp of the camera buffer.\n\n Retrieves the capture timestamp from the V4L2 buffer. Time is relative to\n CLOCK_MONOTONIC when the frame was captured by the camera driver.\n\n @param buffer Camera buffer from vsl_camera_get_data()\n @param seconds Output pointer for timestamp seconds\n @param nanoseconds Output pointer for sub-second nanoseconds\n @since 1.3"]
1335 pub unsafe fn vsl_camera_buffer_timestamp(
1336 &self,
1337 buffer: *const vsl_camera_buffer,
1338 seconds: *mut i64,
1339 nanoseconds: *mut i64,
1340 ) {
1341 (self
1342 .vsl_camera_buffer_timestamp
1343 .as_ref()
1344 .expect("Expected function, got error."))(buffer, seconds, nanoseconds)
1345 }
1346 #[doc = " Lists the supported single-planar formats of the camera.\n\n Queries V4L2 device for available single-planar pixel formats. Call before\n vsl_camera_init_device() to determine what formats to request.\n\n @param ctx Camera context from vsl_camera_open_device()\n @param codes Array to receive fourcc codes\n @param size Size of codes array\n @return Number of formats written to codes array, or -1 on error\n @since 1.3"]
1347 pub unsafe fn vsl_camera_enum_fmts(
1348 &self,
1349 ctx: *const vsl_camera,
1350 codes: *mut u32,
1351 size: ::std::os::raw::c_int,
1352 ) -> ::std::os::raw::c_int {
1353 (self
1354 .vsl_camera_enum_fmts
1355 .as_ref()
1356 .expect("Expected function, got error."))(ctx, codes, size)
1357 }
1358 #[doc = " Lists the supported multi-planar formats of the camera.\n\n Queries V4L2 device for available multi-planar pixel formats (e.g., NV12,\n NV21 with separate Y and UV planes). Call before vsl_camera_init_device().\n\n @param ctx Camera context from vsl_camera_open_device()\n @param codes Array to receive fourcc codes\n @param size Size of codes array\n @return Number of formats written to codes array, or -1 on error\n @since 1.3"]
1359 pub unsafe fn vsl_camera_enum_mplane_fmts(
1360 &self,
1361 ctx: *const vsl_camera,
1362 codes: *mut u32,
1363 size: ::std::os::raw::c_int,
1364 ) -> ::std::os::raw::c_int {
1365 (self
1366 .vsl_camera_enum_mplane_fmts
1367 .as_ref()
1368 .expect("Expected function, got error."))(ctx, codes, size)
1369 }
1370 #[doc = " @brief Creates VSLDecoder instance\n\n Creates a hardware video decoder for H.264/H.265 using the best available\n backend (V4L2 preferred, Hantro fallback). The decoder is initialized on the\n first call to vsl_decode_frame().\n\n @param codec Codec type: VSL_DEC_H264 or VSL_DEC_HEVC\n @param fps Expected frame rate (used for buffer management)\n @return Pointer to VSLDecoder instance, or NULL on failure\n @since 1.4"]
1371 pub unsafe fn vsl_decoder_create(
1372 &self,
1373 codec: VSLDecoderCodec,
1374 fps: ::std::os::raw::c_int,
1375 ) -> *mut VSLDecoder {
1376 (self
1377 .vsl_decoder_create
1378 .as_ref()
1379 .expect("Expected function, got error."))(codec, fps)
1380 }
1381 #[doc = " @brief Creates VSLDecoder instance with explicit backend selection\n\n Creates a hardware video decoder with explicit backend selection. Use this\n when you need to force a specific backend instead of auto-detection.\n\n @param codec Codec fourcc: VSL_FOURCC('H','2','6','4') or\n VSL_FOURCC('H','E','V','C')\n @param fps Expected frame rate (used for buffer management)\n @param backend Backend to use (AUTO, HANTRO, or V4L2)\n @return Pointer to VSLDecoder instance, or NULL on failure\n @since 2.0"]
1382 pub unsafe fn vsl_decoder_create_ex(
1383 &self,
1384 codec: u32,
1385 fps: ::std::os::raw::c_int,
1386 backend: VSLCodecBackend,
1387 ) -> *mut VSLDecoder {
1388 (self
1389 .vsl_decoder_create_ex
1390 .as_ref()
1391 .expect("Expected function, got error."))(codec, fps, backend)
1392 }
1393 #[doc = " @brief Decode compressed video frame\n\n Decodes H.264/H.265 data into a raw frame using hardware acceleration.\n First call initializes the decoder. May require multiple calls to decode\n one frame (returns VSL_DEC_INIT_INFO or VSL_DEC_FRAME_DEC).\n\n @param decoder VSLDecoder instance from vsl_decoder_create()\n @param data Pointer to compressed video data\n @param data_length Length of compressed data in bytes\n @param bytes_used Output: number of bytes consumed from data\n @param output_frame Output: decoded frame (NULL if frame not yet complete)\n @return VSL_DEC_SUCCESS (frame decoded), VSL_DEC_INIT_INFO (need more calls),\n VSL_DEC_FRAME_DEC (frame in progress), or VSL_DEC_ERR (error)\n @since 1.4"]
1394 pub unsafe fn vsl_decode_frame(
1395 &self,
1396 decoder: *mut VSLDecoder,
1397 data: *const ::std::os::raw::c_void,
1398 data_length: ::std::os::raw::c_uint,
1399 bytes_used: *mut usize,
1400 output_frame: *mut *mut VSLFrame,
1401 ) -> VSLDecoderRetCode {
1402 (self
1403 .vsl_decode_frame
1404 .as_ref()
1405 .expect("Expected function, got error."))(
1406 decoder,
1407 data,
1408 data_length,
1409 bytes_used,
1410 output_frame,
1411 )
1412 }
1413 #[doc = " @brief Returns the decoded frame width\n\n Returns the width of decoded frames as determined from the stream headers.\n Only valid after decoder initialization (after first vsl_decode_frame()).\n\n @param decoder VSLDecoder instance\n @return Frame width in pixels\n @since 1.4"]
1414 pub unsafe fn vsl_decoder_width(&self, decoder: *const VSLDecoder) -> ::std::os::raw::c_int {
1415 (self
1416 .vsl_decoder_width
1417 .as_ref()
1418 .expect("Expected function, got error."))(decoder)
1419 }
1420 #[doc = " @brief Returns the decoded frame height\n\n Returns the height of decoded frames as determined from the stream headers.\n Only valid after decoder initialization (after first vsl_decode_frame()).\n\n @param decoder VSLDecoder instance\n @return Frame height in pixels\n @since 1.4"]
1421 pub unsafe fn vsl_decoder_height(&self, decoder: *const VSLDecoder) -> ::std::os::raw::c_int {
1422 (self
1423 .vsl_decoder_height
1424 .as_ref()
1425 .expect("Expected function, got error."))(decoder)
1426 }
1427 #[doc = " @brief Returns the decoder crop rectangle\n\n Returns the active video area within decoded frames, as specified in stream\n headers. Some encoded streams have padding that should be cropped.\n\n @param decoder VSLDecoder instance\n @return VSLRect with crop region (x, y, width, height)\n @since 1.4"]
1428 pub unsafe fn vsl_decoder_crop(&self, decoder: *const VSLDecoder) -> VSLRect {
1429 (self
1430 .vsl_decoder_crop
1431 .as_ref()
1432 .expect("Expected function, got error."))(decoder)
1433 }
1434 #[doc = " @brief Destroys VSLDecoder instance\n\n Frees all resources associated with the decoder, including hardware\n resources. Do not use the decoder after calling this function.\n\n @param decoder VSLDecoder instance to destroy\n @return 0 on success, -1 on error\n @since 1.4"]
1435 pub unsafe fn vsl_decoder_release(&self, decoder: *mut VSLDecoder) -> ::std::os::raw::c_int {
1436 (self
1437 .vsl_decoder_release
1438 .as_ref()
1439 .expect("Expected function, got error."))(decoder)
1440 }
1441
1442 pub fn is_encoder_available(&self) -> bool {
1446 self.vsl_encoder_create.is_ok()
1447 && self.vsl_encoder_release.is_ok()
1448 && self.vsl_encode_frame.is_ok()
1449 && self.vsl_encoder_new_output_frame.is_ok()
1450 }
1451
1452 pub fn is_decoder_available(&self) -> bool {
1454 self.vsl_decoder_create.is_ok() && self.vsl_decoder_release.is_ok()
1455 }
1456
1457 pub fn is_decoder_create_ex_available(&self) -> bool {
1459 self.vsl_decoder_create_ex.is_ok()
1460 }
1461
1462 pub fn is_encoder_create_ex_available(&self) -> bool {
1464 self.vsl_encoder_create_ex.is_ok()
1465 }
1466
1467 pub fn is_backend_selection_available(&self) -> bool {
1469 self.vsl_decoder_create_ex.is_ok()
1470 }
1471
1472 pub unsafe fn try_vsl_encoder_create(
1474 &self,
1475 profile: VSLEncoderProfile,
1476 outputFourcc: u32,
1477 fps: ::std::os::raw::c_int,
1478 ) -> Option<*mut VSLEncoder> {
1479 self.vsl_encoder_create
1480 .as_ref()
1481 .ok()
1482 .map(|f| f(profile, outputFourcc, fps))
1483 }
1484
1485 pub unsafe fn try_vsl_encoder_create_ex(
1487 &self,
1488 profile: VSLEncoderProfile,
1489 outputFourcc: u32,
1490 fps: ::std::os::raw::c_int,
1491 backend: VSLCodecBackend,
1492 ) -> Option<*mut VSLEncoder> {
1493 self.vsl_encoder_create_ex
1494 .as_ref()
1495 .ok()
1496 .map(|f| f(profile, outputFourcc, fps, backend))
1497 }
1498
1499 pub unsafe fn try_vsl_encoder_release(&self, encoder: *mut VSLEncoder) -> bool {
1501 if let Ok(f) = self.vsl_encoder_release.as_ref() {
1502 f(encoder);
1503 true
1504 } else {
1505 false
1506 }
1507 }
1508
1509 pub unsafe fn try_vsl_encode_frame(
1511 &self,
1512 encoder: *mut VSLEncoder,
1513 source: *mut VSLFrame,
1514 destination: *mut VSLFrame,
1515 cropRegion: *const VSLRect,
1516 keyframe: *mut ::std::os::raw::c_int,
1517 ) -> Option<::std::os::raw::c_int> {
1518 self.vsl_encode_frame
1519 .as_ref()
1520 .ok()
1521 .map(|f| f(encoder, source, destination, cropRegion, keyframe))
1522 }
1523
1524 pub unsafe fn try_vsl_encoder_new_output_frame(
1526 &self,
1527 encoder: *const VSLEncoder,
1528 width: ::std::os::raw::c_int,
1529 height: ::std::os::raw::c_int,
1530 duration: i64,
1531 pts: i64,
1532 dts: i64,
1533 ) -> Option<*mut VSLFrame> {
1534 self.vsl_encoder_new_output_frame
1535 .as_ref()
1536 .ok()
1537 .map(|f| f(encoder, width, height, duration, pts, dts))
1538 }
1539
1540 pub unsafe fn try_vsl_decoder_create(
1542 &self,
1543 codec: VSLDecoderCodec,
1544 fps: ::std::os::raw::c_int,
1545 ) -> Option<*mut VSLDecoder> {
1546 self.vsl_decoder_create
1547 .as_ref()
1548 .ok()
1549 .map(|f| f(codec, fps))
1550 }
1551
1552 pub unsafe fn try_vsl_decoder_create_ex(
1554 &self,
1555 codec: u32,
1556 fps: ::std::os::raw::c_int,
1557 backend: VSLCodecBackend,
1558 ) -> Option<*mut VSLDecoder> {
1559 self.vsl_decoder_create_ex
1560 .as_ref()
1561 .ok()
1562 .map(|f| f(codec, fps, backend))
1563 }
1564
1565 pub unsafe fn try_vsl_decoder_width(
1567 &self,
1568 decoder: *mut VSLDecoder,
1569 ) -> Option<::std::os::raw::c_int> {
1570 self.vsl_decoder_width.as_ref().ok().map(|f| f(decoder))
1571 }
1572
1573 pub unsafe fn try_vsl_decoder_height(
1575 &self,
1576 decoder: *mut VSLDecoder,
1577 ) -> Option<::std::os::raw::c_int> {
1578 self.vsl_decoder_height.as_ref().ok().map(|f| f(decoder))
1579 }
1580
1581 pub unsafe fn try_vsl_decoder_crop(&self, decoder: *mut VSLDecoder) -> Option<vsl_rect> {
1583 self.vsl_decoder_crop.as_ref().ok().map(|f| f(decoder))
1584 }
1585
1586 pub unsafe fn try_vsl_decode_frame(
1588 &self,
1589 decoder: *mut VSLDecoder,
1590 data: *const ::std::os::raw::c_void,
1591 len: u32,
1592 bytes_used: *mut usize,
1593 output_frame: *mut *mut vsl_frame,
1594 ) -> Option<u32> {
1595 self.vsl_decode_frame
1596 .as_ref()
1597 .ok()
1598 .map(|f| f(decoder, data, len, bytes_used, output_frame))
1599 }
1600
1601 pub unsafe fn try_vsl_decoder_release(&self, decoder: *mut VSLDecoder) -> Option<()> {
1603 self.vsl_decoder_release.as_ref().ok().map(|f| {
1604 f(decoder);
1605 })
1606 }
1607}