VideoStreamLibrary

Struct VideoStreamLibrary 

Source
pub struct VideoStreamLibrary {
Show 80 fields pub vsl_version: Result<unsafe extern "C" fn() -> *const c_char, Error>, pub vsl_timestamp: Result<unsafe extern "C" fn() -> i64, Error>, pub vsl_host_init: Result<unsafe extern "C" fn(path: *const c_char) -> *mut VSLHost, Error>, pub vsl_host_release: Result<unsafe extern "C" fn(host: *mut VSLHost), Error>, pub vsl_host_path: Result<unsafe extern "C" fn(host: *const VSLHost) -> *const c_char, Error>, pub vsl_host_poll: Result<unsafe extern "C" fn(host: *mut VSLHost, wait: i64) -> c_int, Error>, pub vsl_host_service: Result<unsafe extern "C" fn(host: *mut VSLHost, sock: c_int) -> c_int, Error>, pub vsl_host_process: Result<unsafe extern "C" fn(host: *mut VSLHost) -> c_int, Error>, pub vsl_host_sockets: Result<unsafe extern "C" fn(host: *mut VSLHost, n_sockets: usize, sockets: *mut c_int, max_sockets: *mut usize) -> c_int, Error>, pub vsl_host_post: Result<unsafe extern "C" fn(host: *mut VSLHost, frame: *mut VSLFrame, expires: i64, duration: i64, pts: i64, dts: i64) -> c_int, Error>, pub vsl_host_drop: Result<unsafe extern "C" fn(host: *mut VSLHost, frame: *mut VSLFrame) -> c_int, Error>, pub vsl_client_init: Result<unsafe extern "C" fn(path: *const c_char, userptr: *mut c_void, reconnect: bool) -> *mut VSLClient, Error>, pub vsl_client_release: Result<unsafe extern "C" fn(client: *mut VSLClient), Error>, pub vsl_client_disconnect: Result<unsafe extern "C" fn(client: *mut VSLClient), Error>, pub vsl_client_userptr: Result<unsafe extern "C" fn(client: *mut VSLClient) -> *mut c_void, Error>, pub vsl_client_path: Result<unsafe extern "C" fn(client: *const VSLClient) -> *const c_char, Error>, pub vsl_client_set_timeout: Result<unsafe extern "C" fn(client: *mut VSLClient, timeout: f32), Error>, pub vsl_frame_register: Result<unsafe extern "C" fn(host: *mut VSLHost, serial: i64, handle: c_int, width: c_int, height: c_int, fourcc: u32, size: usize, offset: usize, expires: i64, duration: i64, pts: i64, dts: i64, cleanup: vsl_frame_cleanup, userptr: *mut c_void) -> *mut VSLFrame, Error>, pub vsl_frame_init: Result<unsafe extern "C" fn(width: u32, height: u32, stride: u32, fourcc: u32, userptr: *mut c_void, cleanup: vsl_frame_cleanup) -> *mut VSLFrame, Error>, pub vsl_frame_alloc: Result<unsafe extern "C" fn(frame: *mut VSLFrame, path: *const c_char) -> c_int, Error>, pub vsl_frame_unalloc: Result<unsafe extern "C" fn(frame: *mut VSLFrame), Error>, pub vsl_frame_attach: Result<unsafe extern "C" fn(frame: *mut VSLFrame, fd: c_int, size: usize, offset: usize) -> c_int, Error>, pub vsl_frame_path: Result<unsafe extern "C" fn(frame: *const VSLFrame) -> *const c_char, Error>, pub vsl_frame_unregister: Result<unsafe extern "C" fn(frame: *mut VSLFrame), Error>, pub vsl_frame_copy: Result<unsafe extern "C" fn(target: *mut VSLFrame, source: *mut VSLFrame, crop: *const VSLRect) -> c_int, Error>, pub vsl_frame_userptr: Result<unsafe extern "C" fn(frame: *mut VSLFrame) -> *mut c_void, Error>, pub vsl_frame_set_userptr: Result<unsafe extern "C" fn(frame: *mut VSLFrame, userptr: *mut c_void), Error>, pub vsl_frame_wait: Result<unsafe extern "C" fn(client: *mut VSLClient, until: i64) -> *mut VSLFrame, Error>, pub vsl_frame_release: Result<unsafe extern "C" fn(frame: *mut VSLFrame), Error>, pub vsl_frame_trylock: Result<unsafe extern "C" fn(frame: *mut VSLFrame) -> c_int, Error>, pub vsl_frame_unlock: Result<unsafe extern "C" fn(frame: *mut VSLFrame) -> c_int, Error>, pub vsl_frame_serial: Result<unsafe extern "C" fn(frame: *const VSLFrame) -> i64, Error>, pub vsl_frame_timestamp: Result<unsafe extern "C" fn(frame: *const VSLFrame) -> i64, Error>, pub vsl_frame_duration: Result<unsafe extern "C" fn(frame: *const VSLFrame) -> i64, Error>, pub vsl_frame_pts: Result<unsafe extern "C" fn(frame: *const VSLFrame) -> i64, Error>, pub vsl_frame_dts: Result<unsafe extern "C" fn(frame: *const VSLFrame) -> i64, Error>, pub vsl_frame_expires: Result<unsafe extern "C" fn(frame: *const VSLFrame) -> i64, Error>, pub vsl_frame_fourcc: Result<unsafe extern "C" fn(frame: *const VSLFrame) -> u32, Error>, pub vsl_frame_width: Result<unsafe extern "C" fn(frame: *const VSLFrame) -> c_int, Error>, pub vsl_frame_height: Result<unsafe extern "C" fn(frame: *const VSLFrame) -> c_int, Error>, pub vsl_frame_stride: Result<unsafe extern "C" fn(frame: *const VSLFrame) -> c_int, Error>, pub vsl_frame_size: Result<unsafe extern "C" fn(frame: *const VSLFrame) -> c_int, Error>, pub vsl_frame_handle: Result<unsafe extern "C" fn(frame: *const VSLFrame) -> c_int, Error>, pub vsl_frame_paddr: Result<unsafe extern "C" fn(frame: *mut VSLFrame) -> isize, Error>, pub vsl_frame_mmap: Result<unsafe extern "C" fn(frame: *mut VSLFrame, size: *mut usize) -> *mut c_void, Error>, pub vsl_frame_munmap: Result<unsafe extern "C" fn(frame: *mut VSLFrame), Error>, pub vsl_frame_sync: Result<unsafe extern "C" fn(frame: *const VSLFrame, enable: c_int, mode: c_int) -> c_int, Error>, pub vsl_fourcc_from_string: Result<unsafe extern "C" fn(fourcc: *const c_char) -> u32, Error>, pub vsl_encoder_create: Result<unsafe extern "C" fn(profile: VSLEncoderProfile, outputFourcc: u32, fps: c_int) -> *mut VSLEncoder, Error>, pub vsl_encoder_create_ex: Result<unsafe extern "C" fn(profile: VSLEncoderProfile, outputFourcc: u32, fps: c_int, backend: VSLCodecBackend) -> *mut VSLEncoder, Error>, pub vsl_encoder_release: Result<unsafe extern "C" fn(encoder: *mut VSLEncoder), Error>, pub vsl_encode_frame: Result<unsafe extern "C" fn(encoder: *mut VSLEncoder, source: *mut VSLFrame, destination: *mut VSLFrame, cropRegion: *const VSLRect, keyframe: *mut c_int) -> c_int, Error>, pub vsl_encoder_new_output_frame: Result<unsafe extern "C" fn(encoder: *const VSLEncoder, width: c_int, height: c_int, duration: i64, pts: i64, dts: i64) -> *mut VSLFrame, Error>, pub vsl_camera_open_device: Result<unsafe extern "C" fn(filename: *const c_char) -> *mut vsl_camera, Error>, pub vsl_camera_init_device: Result<unsafe extern "C" fn(ctx: *mut vsl_camera, width: *mut c_int, height: *mut c_int, buf_count: *mut c_int, fourcc: *mut u32) -> c_int, Error>, pub vsl_camera_mirror: Result<unsafe extern "C" fn(ctx: *const vsl_camera, mirror: bool) -> c_int, Error>, pub vsl_camera_mirror_v: Result<unsafe extern "C" fn(ctx: *const vsl_camera, mirror: bool) -> c_int, Error>, pub vsl_camera_start_capturing: Result<unsafe extern "C" fn(ctx: *mut vsl_camera) -> c_int, Error>, pub vsl_camera_get_data: Result<unsafe extern "C" fn(ctx: *mut vsl_camera) -> *mut vsl_camera_buffer, Error>, pub vsl_camera_release_buffer: Result<unsafe extern "C" fn(ctx: *mut vsl_camera, buffer: *const vsl_camera_buffer) -> c_int, Error>, pub vsl_camera_stop_capturing: Result<unsafe extern "C" fn(ctx: *const vsl_camera) -> c_int, Error>, pub vsl_camera_uninit_device: Result<unsafe extern "C" fn(ctx: *mut vsl_camera), Error>, pub vsl_camera_close_device: Result<unsafe extern "C" fn(ctx: *mut vsl_camera), Error>, pub vsl_camera_is_dmabuf_supported: Result<unsafe extern "C" fn(ctx: *const vsl_camera) -> c_int, Error>, pub vsl_camera_get_queued_buf_count: Result<unsafe extern "C" fn(ctx: *const vsl_camera) -> c_int, Error>, pub vsl_camera_buffer_mmap: Result<unsafe extern "C" fn(buffer: *mut vsl_camera_buffer) -> *mut c_void, Error>, pub vsl_camera_buffer_dma_fd: Result<unsafe extern "C" fn(buffer: *const vsl_camera_buffer) -> c_int, Error>, pub vsl_camera_buffer_phys_addr: Result<unsafe extern "C" fn(buffer: *const vsl_camera_buffer) -> u64, Error>, pub vsl_camera_buffer_length: Result<unsafe extern "C" fn(buffer: *const vsl_camera_buffer) -> u32, Error>, pub vsl_camera_buffer_fourcc: Result<unsafe extern "C" fn(buffer: *const vsl_camera_buffer) -> u32, Error>, pub vsl_camera_buffer_timestamp: Result<unsafe extern "C" fn(buffer: *const vsl_camera_buffer, seconds: *mut i64, nanoseconds: *mut i64), Error>, pub vsl_camera_enum_fmts: Result<unsafe extern "C" fn(ctx: *const vsl_camera, codes: *mut u32, size: c_int) -> c_int, Error>, pub vsl_camera_enum_mplane_fmts: Result<unsafe extern "C" fn(ctx: *const vsl_camera, codes: *mut u32, size: c_int) -> c_int, Error>, pub vsl_decoder_create: Result<unsafe extern "C" fn(codec: VSLDecoderCodec, fps: c_int) -> *mut VSLDecoder, Error>, pub vsl_decoder_create_ex: Result<unsafe extern "C" fn(codec: u32, fps: c_int, backend: VSLCodecBackend) -> *mut VSLDecoder, Error>, pub vsl_decode_frame: Result<unsafe extern "C" fn(decoder: *mut VSLDecoder, data: *const c_void, data_length: c_uint, bytes_used: *mut usize, output_frame: *mut *mut VSLFrame) -> VSLDecoderRetCode, Error>, pub vsl_decoder_width: Result<unsafe extern "C" fn(decoder: *const VSLDecoder) -> c_int, Error>, pub vsl_decoder_height: Result<unsafe extern "C" fn(decoder: *const VSLDecoder) -> c_int, Error>, pub vsl_decoder_crop: Result<unsafe extern "C" fn(decoder: *const VSLDecoder) -> VSLRect, Error>, pub vsl_decoder_release: Result<unsafe extern "C" fn(decoder: *mut VSLDecoder) -> c_int, Error>, /* private fields */
}

Fields§

§vsl_version: Result<unsafe extern "C" fn() -> *const c_char, Error>§vsl_timestamp: Result<unsafe extern "C" fn() -> i64, Error>§vsl_host_init: Result<unsafe extern "C" fn(path: *const c_char) -> *mut VSLHost, Error>§vsl_host_release: Result<unsafe extern "C" fn(host: *mut VSLHost), Error>§vsl_host_path: Result<unsafe extern "C" fn(host: *const VSLHost) -> *const c_char, Error>§vsl_host_poll: Result<unsafe extern "C" fn(host: *mut VSLHost, wait: i64) -> c_int, Error>§vsl_host_service: Result<unsafe extern "C" fn(host: *mut VSLHost, sock: c_int) -> c_int, Error>§vsl_host_process: Result<unsafe extern "C" fn(host: *mut VSLHost) -> c_int, Error>§vsl_host_sockets: Result<unsafe extern "C" fn(host: *mut VSLHost, n_sockets: usize, sockets: *mut c_int, max_sockets: *mut usize) -> c_int, Error>§vsl_host_post: Result<unsafe extern "C" fn(host: *mut VSLHost, frame: *mut VSLFrame, expires: i64, duration: i64, pts: i64, dts: i64) -> c_int, Error>§vsl_host_drop: Result<unsafe extern "C" fn(host: *mut VSLHost, frame: *mut VSLFrame) -> c_int, Error>§vsl_client_init: Result<unsafe extern "C" fn(path: *const c_char, userptr: *mut c_void, reconnect: bool) -> *mut VSLClient, Error>§vsl_client_release: Result<unsafe extern "C" fn(client: *mut VSLClient), Error>§vsl_client_disconnect: Result<unsafe extern "C" fn(client: *mut VSLClient), Error>§vsl_client_userptr: Result<unsafe extern "C" fn(client: *mut VSLClient) -> *mut c_void, Error>§vsl_client_path: Result<unsafe extern "C" fn(client: *const VSLClient) -> *const c_char, Error>§vsl_client_set_timeout: Result<unsafe extern "C" fn(client: *mut VSLClient, timeout: f32), Error>§vsl_frame_register: Result<unsafe extern "C" fn(host: *mut VSLHost, serial: i64, handle: c_int, width: c_int, height: c_int, fourcc: u32, size: usize, offset: usize, expires: i64, duration: i64, pts: i64, dts: i64, cleanup: vsl_frame_cleanup, userptr: *mut c_void) -> *mut VSLFrame, Error>§vsl_frame_init: Result<unsafe extern "C" fn(width: u32, height: u32, stride: u32, fourcc: u32, userptr: *mut c_void, cleanup: vsl_frame_cleanup) -> *mut VSLFrame, Error>§vsl_frame_alloc: Result<unsafe extern "C" fn(frame: *mut VSLFrame, path: *const c_char) -> c_int, Error>§vsl_frame_unalloc: Result<unsafe extern "C" fn(frame: *mut VSLFrame), Error>§vsl_frame_attach: Result<unsafe extern "C" fn(frame: *mut VSLFrame, fd: c_int, size: usize, offset: usize) -> c_int, Error>§vsl_frame_path: Result<unsafe extern "C" fn(frame: *const VSLFrame) -> *const c_char, Error>§vsl_frame_unregister: Result<unsafe extern "C" fn(frame: *mut VSLFrame), Error>§vsl_frame_copy: Result<unsafe extern "C" fn(target: *mut VSLFrame, source: *mut VSLFrame, crop: *const VSLRect) -> c_int, Error>§vsl_frame_userptr: Result<unsafe extern "C" fn(frame: *mut VSLFrame) -> *mut c_void, Error>§vsl_frame_set_userptr: Result<unsafe extern "C" fn(frame: *mut VSLFrame, userptr: *mut c_void), Error>§vsl_frame_wait: Result<unsafe extern "C" fn(client: *mut VSLClient, until: i64) -> *mut VSLFrame, Error>§vsl_frame_release: Result<unsafe extern "C" fn(frame: *mut VSLFrame), Error>§vsl_frame_trylock: Result<unsafe extern "C" fn(frame: *mut VSLFrame) -> c_int, Error>§vsl_frame_unlock: Result<unsafe extern "C" fn(frame: *mut VSLFrame) -> c_int, Error>§vsl_frame_serial: Result<unsafe extern "C" fn(frame: *const VSLFrame) -> i64, Error>§vsl_frame_timestamp: Result<unsafe extern "C" fn(frame: *const VSLFrame) -> i64, Error>§vsl_frame_duration: Result<unsafe extern "C" fn(frame: *const VSLFrame) -> i64, Error>§vsl_frame_pts: Result<unsafe extern "C" fn(frame: *const VSLFrame) -> i64, Error>§vsl_frame_dts: Result<unsafe extern "C" fn(frame: *const VSLFrame) -> i64, Error>§vsl_frame_expires: Result<unsafe extern "C" fn(frame: *const VSLFrame) -> i64, Error>§vsl_frame_fourcc: Result<unsafe extern "C" fn(frame: *const VSLFrame) -> u32, Error>§vsl_frame_width: Result<unsafe extern "C" fn(frame: *const VSLFrame) -> c_int, Error>§vsl_frame_height: Result<unsafe extern "C" fn(frame: *const VSLFrame) -> c_int, Error>§vsl_frame_stride: Result<unsafe extern "C" fn(frame: *const VSLFrame) -> c_int, Error>§vsl_frame_size: Result<unsafe extern "C" fn(frame: *const VSLFrame) -> c_int, Error>§vsl_frame_handle: Result<unsafe extern "C" fn(frame: *const VSLFrame) -> c_int, Error>§vsl_frame_paddr: Result<unsafe extern "C" fn(frame: *mut VSLFrame) -> isize, Error>§vsl_frame_mmap: Result<unsafe extern "C" fn(frame: *mut VSLFrame, size: *mut usize) -> *mut c_void, Error>§vsl_frame_munmap: Result<unsafe extern "C" fn(frame: *mut VSLFrame), Error>§vsl_frame_sync: Result<unsafe extern "C" fn(frame: *const VSLFrame, enable: c_int, mode: c_int) -> c_int, Error>§vsl_fourcc_from_string: Result<unsafe extern "C" fn(fourcc: *const c_char) -> u32, Error>§vsl_encoder_create: Result<unsafe extern "C" fn(profile: VSLEncoderProfile, outputFourcc: u32, fps: c_int) -> *mut VSLEncoder, Error>§vsl_encoder_create_ex: Result<unsafe extern "C" fn(profile: VSLEncoderProfile, outputFourcc: u32, fps: c_int, backend: VSLCodecBackend) -> *mut VSLEncoder, Error>§vsl_encoder_release: Result<unsafe extern "C" fn(encoder: *mut VSLEncoder), Error>§vsl_encode_frame: Result<unsafe extern "C" fn(encoder: *mut VSLEncoder, source: *mut VSLFrame, destination: *mut VSLFrame, cropRegion: *const VSLRect, keyframe: *mut c_int) -> c_int, Error>§vsl_encoder_new_output_frame: Result<unsafe extern "C" fn(encoder: *const VSLEncoder, width: c_int, height: c_int, duration: i64, pts: i64, dts: i64) -> *mut VSLFrame, Error>§vsl_camera_open_device: Result<unsafe extern "C" fn(filename: *const c_char) -> *mut vsl_camera, Error>§vsl_camera_init_device: Result<unsafe extern "C" fn(ctx: *mut vsl_camera, width: *mut c_int, height: *mut c_int, buf_count: *mut c_int, fourcc: *mut u32) -> c_int, Error>§vsl_camera_mirror: Result<unsafe extern "C" fn(ctx: *const vsl_camera, mirror: bool) -> c_int, Error>§vsl_camera_mirror_v: Result<unsafe extern "C" fn(ctx: *const vsl_camera, mirror: bool) -> c_int, Error>§vsl_camera_start_capturing: Result<unsafe extern "C" fn(ctx: *mut vsl_camera) -> c_int, Error>§vsl_camera_get_data: Result<unsafe extern "C" fn(ctx: *mut vsl_camera) -> *mut vsl_camera_buffer, Error>§vsl_camera_release_buffer: Result<unsafe extern "C" fn(ctx: *mut vsl_camera, buffer: *const vsl_camera_buffer) -> c_int, Error>§vsl_camera_stop_capturing: Result<unsafe extern "C" fn(ctx: *const vsl_camera) -> c_int, Error>§vsl_camera_uninit_device: Result<unsafe extern "C" fn(ctx: *mut vsl_camera), Error>§vsl_camera_close_device: Result<unsafe extern "C" fn(ctx: *mut vsl_camera), Error>§vsl_camera_is_dmabuf_supported: Result<unsafe extern "C" fn(ctx: *const vsl_camera) -> c_int, Error>§vsl_camera_get_queued_buf_count: Result<unsafe extern "C" fn(ctx: *const vsl_camera) -> c_int, Error>§vsl_camera_buffer_mmap: Result<unsafe extern "C" fn(buffer: *mut vsl_camera_buffer) -> *mut c_void, Error>§vsl_camera_buffer_dma_fd: Result<unsafe extern "C" fn(buffer: *const vsl_camera_buffer) -> c_int, Error>§vsl_camera_buffer_phys_addr: Result<unsafe extern "C" fn(buffer: *const vsl_camera_buffer) -> u64, Error>§vsl_camera_buffer_length: Result<unsafe extern "C" fn(buffer: *const vsl_camera_buffer) -> u32, Error>§vsl_camera_buffer_fourcc: Result<unsafe extern "C" fn(buffer: *const vsl_camera_buffer) -> u32, Error>§vsl_camera_buffer_timestamp: Result<unsafe extern "C" fn(buffer: *const vsl_camera_buffer, seconds: *mut i64, nanoseconds: *mut i64), Error>§vsl_camera_enum_fmts: Result<unsafe extern "C" fn(ctx: *const vsl_camera, codes: *mut u32, size: c_int) -> c_int, Error>§vsl_camera_enum_mplane_fmts: Result<unsafe extern "C" fn(ctx: *const vsl_camera, codes: *mut u32, size: c_int) -> c_int, Error>§vsl_decoder_create: Result<unsafe extern "C" fn(codec: VSLDecoderCodec, fps: c_int) -> *mut VSLDecoder, Error>§vsl_decoder_create_ex: Result<unsafe extern "C" fn(codec: u32, fps: c_int, backend: VSLCodecBackend) -> *mut VSLDecoder, Error>§vsl_decode_frame: Result<unsafe extern "C" fn(decoder: *mut VSLDecoder, data: *const c_void, data_length: c_uint, bytes_used: *mut usize, output_frame: *mut *mut VSLFrame) -> VSLDecoderRetCode, Error>§vsl_decoder_width: Result<unsafe extern "C" fn(decoder: *const VSLDecoder) -> c_int, Error>§vsl_decoder_height: Result<unsafe extern "C" fn(decoder: *const VSLDecoder) -> c_int, Error>§vsl_decoder_crop: Result<unsafe extern "C" fn(decoder: *const VSLDecoder) -> VSLRect, Error>§vsl_decoder_release: Result<unsafe extern "C" fn(decoder: *mut VSLDecoder) -> c_int, Error>

Implementations§

Source§

impl VideoStreamLibrary

Source

pub unsafe fn new<P>(path: P) -> Result<Self, Error>
where P: AsFilename,

Source

pub unsafe fn from_library<L>(library: L) -> Result<Self, Error>
where L: Into<Library>,

Source

pub unsafe fn vsl_version(&self) -> *const c_char

Returns the VideoStream Library version string.

@return Version string in “MAJOR.MINOR.PATCH” format (e.g., “1.5.4”) @since 1.0

Source

pub unsafe fn vsl_timestamp(&self) -> i64

Returns the current timestamp in nanoseconds.

Uses monotonic clock (CLOCK_MONOTONIC) for consistent timing across the system. This timestamp is used for frame timing and synchronization.

@return Current time in nanoseconds since an unspecified starting point @since 1.0

Source

pub unsafe fn vsl_host_init(&self, path: *const c_char) -> *mut VSLHost

Creates a host on the requested path for inter-process frame sharing.

The host manages a UNIX domain socket at the specified path and accepts connections from clients. Frames posted to the host are broadcast to all connected clients.

@param path UNIX socket path (filesystem or abstract). If path starts with ‘/’ it creates a filesystem socket, otherwise an abstract socket. @return Pointer to VSLHost object on success, NULL on failure (sets errno) @since 1.0 @memberof VSLHost

Source

pub unsafe fn vsl_host_release(&self, host: *mut VSLHost)

Releases the host, disconnecting all clients and releasing any allocated memory.

Closes the UNIX socket, disconnects all clients, and frees all resources associated with the host. Any posted frames are released.

@param host The host to release @since 1.0 @memberof VSLHost

Source

pub unsafe fn vsl_host_path(&self, host: *const VSLHost) -> *const c_char

Returns the bound path of the host.

@param host The host instance @return UNIX socket path string (owned by host, do not free) @since 1.0 @memberof VSLHost

Source

pub unsafe fn vsl_host_poll(&self, host: *mut VSLHost, wait: i64) -> c_int

Polls the list of available connections for activity.

Waits for socket activity (new connections or client messages) using poll(). Should be called in a loop before vsl_host_process(). Note frames are only expired by vsl_host_process(), so the wait parameter should be no greater than the desired frame expiration time to ensure timely cleanup.

@param host The host instance @param wait Timeout in milliseconds. If >0, poll waits up to this duration. If 0, returns immediately. If <0, waits indefinitely. @return Number of sockets with activity, 0 on timeout, -1 on error (sets errno) @since 1.0 @memberof VSLHost

Source

pub unsafe fn vsl_host_service(&self, host: *mut VSLHost, sock: c_int) -> c_int

Services a single client socket.

Processes messages from a specific client socket. Does not accept new connections - use vsl_host_process() for that. Useful when you need to track errors for individual clients.

@param host The host instance @param sock The client socket file descriptor to service @return 0 on success, -1 on error (sets errno, EPIPE if client disconnected) @since 1.0 @memberof VSLHost

Source

pub unsafe fn vsl_host_process(&self, host: *mut VSLHost) -> c_int

Process host tasks: expire old frames and service one client connection.

First expires frames past their lifetime, then services the first available connection (accepting new clients or processing client messages). Should be called in a loop, typically after vsl_host_poll() indicates activity.

@param host The host instance @return 0 on success, -1 on error (sets errno, ETIMEDOUT if no activity) @since 1.0 @memberof VSLHost

Source

pub unsafe fn vsl_host_sockets( &self, host: *mut VSLHost, n_sockets: usize, sockets: *mut c_int, max_sockets: *mut usize, ) -> c_int

Request a copy of the sockets managed by the host.

Returns socket file descriptors for the host’s listening socket and all connected client sockets. The first socket is always the listening socket. The array should be refreshed frequently as sockets may become stale.

Thread-safe: allows one thread to use sockets for messaging while another polls for reads.

@param host The host instance @param n_sockets Size of the sockets array buffer @param sockets Buffer to receive socket file descriptors @param max_sockets If provided, populated with n_clients+1 (total sockets) @return 0 on success, -1 on error (sets errno to ENOBUFS if buffer too small) @since 1.0 @memberof VSLHost

Source

pub unsafe fn vsl_host_post( &self, host: *mut VSLHost, frame: *mut VSLFrame, expires: i64, duration: i64, pts: i64, dts: i64, ) -> c_int

Registers the frame with the host and publishes it to subscribers.

Transfers ownership of the frame to the host. The frame is broadcast to all connected clients and will be automatically released when it expires. Do not call vsl_frame_release() on frames posted to the host.

@param host The host instance @param frame Frame to post (ownership transferred to host) @param expires Expiration time in nanoseconds (absolute, from vsl_timestamp()) @param duration Frame duration in nanoseconds (-1 if unknown) @param pts Presentation timestamp in nanoseconds (-1 if unknown) @param dts Decode timestamp in nanoseconds (-1 if unknown) @return 0 on success, -1 on error (sets errno) @since 1.3 @memberof VSLHost

Source

pub unsafe fn vsl_host_drop( &self, host: *mut VSLHost, frame: *mut VSLFrame, ) -> c_int

Drops the frame from the host.

Removes the host association of the frame and returns ownership to the caller. Can be used to cancel a previously posted frame before it expires.

@param host The host instance @param frame Frame to drop from host @return 0 on success, -1 on error (sets errno) @since 1.3 @memberof VSLHost

Source

pub unsafe fn vsl_client_init( &self, path: *const c_char, userptr: *mut c_void, reconnect: bool, ) -> *mut VSLClient

Creates a client and connects to the host at the provided path.

Establishes a connection to a VSLHost via UNIX domain socket. The client can receive frames broadcast by the host.

@param path UNIX socket path matching the host’s path @param userptr Optional user data pointer (retrievable via vsl_client_userptr) @param reconnect If true, automatically reconnect if connection is lost @return Pointer to VSLClient object on success, NULL on failure (sets errno) @since 1.0 @memberof VSLClient

Source

pub unsafe fn vsl_client_release(&self, client: *mut VSLClient)

Releases the client, disconnecting from the host and releasing allocated memory.

Closes the socket connection, frees all resources, and invalidates any pending frames. Not thread-safe - use vsl_client_disconnect() for thread-safe disconnection before calling this.

@param client The client to release @since 1.0 @memberof VSLClient

Source

pub unsafe fn vsl_client_disconnect(&self, client: *mut VSLClient)

Disconnects from the VSLHost and stops all reconnection attempts.

Thread-safe disconnect operation. Should be called before vsl_client_release() when shutting down a client session from a different thread.

@param client The client to disconnect @since 1.1 @memberof VSLClient

Source

pub unsafe fn vsl_client_userptr(&self, client: *mut VSLClient) -> *mut c_void

Returns the optional userptr associated with this client connection.

@param client The client instance @return User pointer provided to vsl_client_init(), or NULL if none @since 1.0 @memberof VSLClient

Source

pub unsafe fn vsl_client_path(&self, client: *const VSLClient) -> *const c_char

Returns the path on which the client has connected to the host.

@param client The client instance @return UNIX socket path string (owned by client, do not free) @since 1.0 @memberof VSLClient

Source

pub unsafe fn vsl_client_set_timeout( &self, client: *mut VSLClient, timeout: f32, )

Sets the socket timeout for this client.

Configures how long socket operations wait before timing out. Affects recv() calls when waiting for frames from the host.

@param client The client instance @param timeout Timeout in seconds (e.g., 1.0 for 1 second) @since 1.0 @memberof VSLClient

Source

pub unsafe fn vsl_frame_register( &self, host: *mut VSLHost, serial: i64, handle: c_int, width: c_int, height: c_int, fourcc: u32, size: usize, offset: usize, expires: i64, duration: i64, pts: i64, dts: i64, cleanup: vsl_frame_cleanup, userptr: *mut c_void, ) -> *mut VSLFrame

Creates and posts the video frame along with optional user pointer to any arbitrary data. Typically it would be used for holding a reference to the host’s view of the frame handle.

@deprecated The vsl_frame_register function is deprecated in favour of using the @ref vsl_frame_init(), @ref vsl_frame_alloc() or @ref vsl_frame_attach(), and @ref vsl_host_post() functions which separate frame creation from posting to the host for publishing to subscribers.

@note A frame created through this function is owned by the host and should not have @ref vsl_frame_release called on it. This will be managed by the host on frame expiry.

@memberof VSLFrame

Source

pub unsafe fn vsl_frame_init( &self, width: u32, height: u32, stride: u32, fourcc: u32, userptr: *mut c_void, cleanup: vsl_frame_cleanup, ) -> *mut VSLFrame

Initializes a VSLFrame without underlying frame buffer.

Creates a frame descriptor with specified dimensions and format. To allocate backing memory, call vsl_frame_alloc(). To attach existing memory (e.g., DmaBuf from camera), call vsl_frame_attach().

@param width Frame width in pixels @param height Frame height in pixels @param stride Row stride in bytes (0 to auto-calculate from width) @param fourcc Pixel format as FOURCC code (e.g., VSL_FOURCC(‘N’,‘V’,‘1’,‘2’)) @param userptr Optional user data pointer @param cleanup Optional cleanup callback invoked on vsl_frame_release() @return Pointer to VSLFrame object, or NULL on failure @since 1.3 @memberof VSLFrame

Source

pub unsafe fn vsl_frame_alloc( &self, frame: *mut VSLFrame, path: *const c_char, ) -> c_int

Allocates the underlying memory for the frame.

Prefers DmaBuf allocation for zero-copy, falling back to POSIX shared memory if DmaBuf unavailable. If path is provided, it determines allocation type:

  • NULL: Try DmaBuf first, fallback to shared memory
  • Starts with “/dev”: Use DmaBuf heap device at this path
  • Other paths: Use shared memory at this path

Allocates height*stride bytes. For compressed formats (JPEG, H.264), the actual data size may be smaller. Use vsl_frame_copy() return value to get actual compressed size.

@param frame Frame to allocate memory for @param path Optional allocation path (NULL for auto, /dev/… for DmaBuf heap) @return 0 on success, -1 on failure (sets errno) @since 1.3 @memberof VSLFrame

Source

pub unsafe fn vsl_frame_unalloc(&self, frame: *mut VSLFrame)

Frees the allocated buffer for this frame.

Releases the underlying memory (DmaBuf or shared memory) but does not destroy the frame object. Use vsl_frame_release() to destroy the frame.

@param frame Frame whose buffer should be freed @since 1.3 @memberof VSLFrame

Source

pub unsafe fn vsl_frame_attach( &self, frame: *mut VSLFrame, fd: c_int, size: usize, offset: usize, ) -> c_int

Attach the provided file descriptor to the VSLFrame.

Associates an existing buffer (typically DmaBuf from camera or hardware accelerator) with the frame. The frame does not take ownership of the FD.

@param frame Frame to attach buffer to @param fd File descriptor (typically DmaBuf) to attach @param size Buffer size in bytes (0 to use stride*height) @param offset Byte offset to frame data start (must provide size if offset>0) @return 0 on success, -1 on failure (sets errno) @since 1.3 @memberof VSLFrame

Source

pub unsafe fn vsl_frame_path(&self, frame: *const VSLFrame) -> *const c_char

Returns the path to the underlying VSLFrame buffer.

Returns the filesystem path for shared memory buffers or DmaBuf heap devices. Not available for externally created DmaBufs (e.g., from camera driver).

@warning Not thread-safe. Use the returned string immediately.

@param frame The frame instance @return Buffer path string (owned by frame), or NULL if unavailable @since 1.3 @memberof VSLFrame

Source

pub unsafe fn vsl_frame_unregister(&self, frame: *mut VSLFrame)

Unregisters the frame, removing it from the host pool.

@deprecated Use vsl_frame_release() instead, which handles cleanup properly.

@param frame Frame to unregister @since 1.0 @memberof VSLFrame

Source

pub unsafe fn vsl_frame_copy( &self, target: *mut VSLFrame, source: *mut VSLFrame, crop: *const VSLRect, ) -> c_int

Copy the source frame into the target frame, with optional source crop.

Handles format conversion, rescaling, and cropping using hardware acceleration when available (G2D on i.MX8). Both frames can be host or client frames. Automatically locks frames during copy (safe for free-standing frames too).

Copy sequence: 1) Crop source, 2) Convert format, 3) Scale to target size.

@warning Copying to/from a posted frame may cause visual tearing.

@param target Destination frame (receives copied data) @param source Source frame to copy from @param crop Optional crop region in source coordinates (NULL for full frame) @return Number of bytes copied on success, -1 on failure (sets errno) @since 1.3 @memberof VSLFrame

Source

pub unsafe fn vsl_frame_userptr(&self, frame: *mut VSLFrame) -> *mut c_void

Returns the user pointer associated with this frame.

@param frame The frame instance @return User pointer provided to vsl_frame_init(), or NULL if none @since 1.0 @memberof VSLFrame

Source

pub unsafe fn vsl_frame_set_userptr( &self, frame: *mut VSLFrame, userptr: *mut c_void, )

Associate userptr with this frame.

Sets or updates the user data pointer for this frame.

@param frame The frame instance @param userptr User data pointer to associate with frame @since 1.0 @memberof VSLFrame

Source

pub unsafe fn vsl_frame_wait( &self, client: *mut VSLClient, until: i64, ) -> *mut VSLFrame

Waits for a frame to arrive and returns a new frame object.

Blocks until the host broadcasts a new frame. Frames with timestamp less than ‘until’ are ignored (useful for skipping old frames after a pause).

Caller must lock the frame (vsl_frame_trylock) before accessing data, then unlock and release when done.

@param client The client instance @param until Minimum timestamp in nanoseconds (0 to accept next frame) @return Pointer to VSLFrame object, or NULL on error (sets errno) @since 1.0 @memberof VSLFrame

Source

pub unsafe fn vsl_frame_release(&self, frame: *mut VSLFrame)

Releases the frame, performing required cleanup.

Unmaps memory if mapped, unlocks if locked. If frame was posted to a host, removes it. If client frame, decrements reference count. Invokes cleanup callback if registered.

@param frame Frame to release @since 1.0 @memberof VSLFrame

Source

pub unsafe fn vsl_frame_trylock(&self, frame: *mut VSLFrame) -> c_int

Attempts to lock the video frame.

Locks the frame for exclusive access (prevents host from releasing it). Must be called before accessing frame data from a client. Always succeeds for host-owned frames.

@param frame Frame to lock @return 0 on success, -1 on failure (frame expired or already unlocked) @since 1.0 @memberof VSLFrame

Source

pub unsafe fn vsl_frame_unlock(&self, frame: *mut VSLFrame) -> c_int

Attempts to unlock the video frame.

Releases the lock acquired by vsl_frame_trylock(), allowing the host to release the frame when it expires.

@param frame Frame to unlock @return 0 on success, -1 on failure (sets errno) @since 1.0 @memberof VSLFrame

Source

pub unsafe fn vsl_frame_serial(&self, frame: *const VSLFrame) -> i64

Returns the serial frame count of the video frame.

Frame serial is a monotonically increasing counter assigned by the host when frames are registered. Does not necessarily equal camera frame number.

@param frame The frame instance @return Frame serial number (starts at 1) @since 1.0 @memberof VSLFrame

Source

pub unsafe fn vsl_frame_timestamp(&self, frame: *const VSLFrame) -> i64

Returns the timestamp for this frame in nanoseconds.

Timestamp from vsl_timestamp() when frame was registered with host. Uses monotonic clock for consistent timing.

@param frame The frame instance @return Frame timestamp in nanoseconds @since 1.0 @memberof VSLFrame

Source

pub unsafe fn vsl_frame_duration(&self, frame: *const VSLFrame) -> i64

Returns the duration for this frame in nanoseconds.

Frame duration indicates how long this frame should be displayed. May be -1 if unknown or not applicable.

@param frame The frame instance @return Frame duration in nanoseconds, or -1 if unknown @since 1.0 @memberof VSLFrame

Source

pub unsafe fn vsl_frame_pts(&self, frame: *const VSLFrame) -> i64

Returns the presentation timestamp for this frame in nanoseconds.

PTS indicates when this frame should be presented/displayed in a stream. May be -1 if unknown or not applicable.

@param frame The frame instance @return Presentation timestamp in nanoseconds, or -1 if unknown @since 1.0 @memberof VSLFrame

Source

pub unsafe fn vsl_frame_dts(&self, frame: *const VSLFrame) -> i64

Returns the decode timestamp for this frame in nanoseconds.

DTS indicates when this frame should be decoded in a stream (important for B-frames in video codecs). May be -1 if unknown or not applicable.

@param frame The frame instance @return Decode timestamp in nanoseconds, or -1 if unknown @since 1.0 @memberof VSLFrame

Source

pub unsafe fn vsl_frame_expires(&self, frame: *const VSLFrame) -> i64

Returns the expiration time for this frame in nanoseconds.

Absolute timestamp (from vsl_timestamp()) when this frame will be expired by the host. Clients should lock frames before this time.

@param frame The frame instance @return Expiration timestamp in nanoseconds @since 1.0 @memberof VSLFrame

Source

pub unsafe fn vsl_frame_fourcc(&self, frame: *const VSLFrame) -> u32

Returns the FOURCC code for the video frame.

FOURCC identifies the pixel format (e.g., NV12, YUY2, JPEG, H264). Use VSL_FOURCC() macro to create fourcc codes.

@param frame The frame instance @return FOURCC code as uint32_t @since 1.0 @memberof VSLFrame

Source

pub unsafe fn vsl_frame_width(&self, frame: *const VSLFrame) -> c_int

Returns the width in pixels of the video frame.

@param frame The frame instance @return Frame width in pixels @since 1.0 @memberof VSLFrame

Source

pub unsafe fn vsl_frame_height(&self, frame: *const VSLFrame) -> c_int

Returns the height in pixels of the video frame.

@param frame The frame instance @return Frame height in pixels @since 1.0 @memberof VSLFrame

Source

pub unsafe fn vsl_frame_stride(&self, frame: *const VSLFrame) -> c_int

Returns the stride in bytes of the video frame.

Stride is the number of bytes from the start of one row to the next. May be larger than width*bytes_per_pixel due to alignment requirements.

@param frame The frame instance @return Row stride in bytes @since 1.3 @memberof VSLFrame

Source

pub unsafe fn vsl_frame_size(&self, frame: *const VSLFrame) -> c_int

Returns the size in bytes of the video frame buffer.

For uncompressed formats, this is stride*height. For compressed formats (JPEG, H.264), this is the maximum buffer size, not the actual data size.

@param frame The frame instance @return Buffer size in bytes @since 1.0 @memberof VSLFrame

Source

pub unsafe fn vsl_frame_handle(&self, frame: *const VSLFrame) -> c_int

Returns the file descriptor for this frame.

Returns the DmaBuf or shared memory file descriptor used for zero-copy sharing. Returns -1 if no file descriptor is associated (e.g., CPU-only memory).

@param frame The frame instance @return File descriptor, or -1 if none @since 1.0 @memberof VSLFrame

Source

pub unsafe fn vsl_frame_paddr(&self, frame: *mut VSLFrame) -> isize

Returns the physical address of the frame.

Physical address is available for DMA-capable buffers on platforms where the kernel provides physical address translation (some i.MX platforms). Note: This function caches the physical address internally on first call.

@param frame The frame instance @return Physical address, or MMAP_FAILED ((intptr_t)-1) if DMA not supported @since 1.0 @memberof VSLFrame

Source

pub unsafe fn vsl_frame_mmap( &self, frame: *mut VSLFrame, size: *mut usize, ) -> *mut c_void

Maps the frame into the process memory space.

Creates a memory mapping for CPU access to frame data. Frame must be locked (vsl_frame_trylock) for the duration of the mapping. Call vsl_frame_munmap() when done.

@param frame The frame instance @param size Optional pointer to receive mapped size in bytes (may be NULL) @return Pointer to mapped memory, or NULL on failure @since 1.0 @memberof VSLFrame

Source

pub unsafe fn vsl_frame_munmap(&self, frame: *mut VSLFrame)

Unmaps the frame from the process memory space.

Releases the memory mapping created by vsl_frame_mmap(). Should be called when done accessing frame data.

@param frame The frame instance to unmap @since 1.0 @memberof VSLFrame

Source

pub unsafe fn vsl_frame_sync( &self, frame: *const VSLFrame, enable: c_int, mode: c_int, ) -> c_int

Cache synchronization session control for DMA-backed buffers.

Controls CPU cache coherency for DMA buffers. Automatically called by mmap/munmap, but can be used manually for in-place frame updates.

Call with enable=1 before accessing, enable=0 after modifying. Mode: DMA_BUF_SYNC_READ (CPU reads), DMA_BUF_SYNC_WRITE (CPU writes), or DMA_BUF_SYNC_RW (both).

@param frame The frame object to synchronize @param enable 1 to start sync session, 0 to end it @param mode Sync mode: DMA_BUF_SYNC_READ, DMA_BUF_SYNC_WRITE, or DMA_BUF_SYNC_RW @return 0 on success, -1 on failure (sets errno) @since 1.3 @memberof VSLFrame

Source

pub unsafe fn vsl_fourcc_from_string(&self, fourcc: *const c_char) -> u32

Returns a fourcc integer code from the string.

Converts a 4-character string to FOURCC code. Example: “NV12” -> VSL_FOURCC(‘N’,‘V’,‘1’,‘2’).

@param fourcc String containing exactly 4 characters (e.g., “NV12”, “YUY2”) @return FOURCC code as uint32_t, or 0 if invalid/unsupported @since 1.3

Source

pub unsafe fn vsl_encoder_create( &self, profile: VSLEncoderProfile, outputFourcc: u32, fps: c_int, ) -> *mut VSLEncoder

@brief Creates VSLEncoder instance

@param profile VSLEncoderProfile determining encode quality @param outputFourcc fourcc code defining the codec @param fps output stream fps @return VSLEncoder* new encoder instance

Every encoder instance must be released using vsl_encoder_release

For Hantro VC8000e encoder initialization is performed when vsl_encode_frame is called for a first time

Source

pub unsafe fn vsl_encoder_create_ex( &self, profile: VSLEncoderProfile, outputFourcc: u32, fps: c_int, backend: VSLCodecBackend, ) -> *mut VSLEncoder

@brief Creates VSLEncoder instance with explicit backend selection

Extended version of vsl_encoder_create() that allows selecting a specific codec backend. Use this when you need to force V4L2 or Hantro backend.

@param profile VSLEncoderProfile determining encode quality @param outputFourcc fourcc code defining the codec (H264 or HEVC) @param fps output stream fps @param backend Which backend to use (VSL_CODEC_BACKEND_AUTO, _V4L2, _HANTRO) @return VSLEncoder* new encoder instance, or NULL if backend unavailable

@since 2.0

Source

pub unsafe fn vsl_encoder_release(&self, encoder: *mut VSLEncoder)

@brief Destroys VSLEncoder instance

Frees all resources associated with the encoder, including hardware resources. Do not use the encoder after calling this function.

@param encoder VSLEncoder instance to destroy @since 1.3

Source

pub unsafe fn vsl_encode_frame( &self, encoder: *mut VSLEncoder, source: *mut VSLFrame, destination: *mut VSLFrame, cropRegion: *const VSLRect, keyframe: *mut c_int, ) -> c_int

@brief Encode frame

Encodes the source frame into the destination frame using hardware acceleration (Hantro VPU on i.MX8). First call initializes the encoder with the given parameters. Subsequent calls must use identical source/destination dimensions, formats, and crop region.

@param encoder VSLEncoder instance @param source Source frame (raw video data) @param destination Pre-allocated destination frame (receives encoded data) @param cropRegion Optional crop region in source coordinates (NULL for no crop) @param keyframe Optional output: set to 1 if encoded frame is IDR/keyframe, 0 otherwise. Pass NULL to ignore. @retval 0 on success @retval -1 on failure (check errno for details) @since 1.3

Source

pub unsafe fn vsl_encoder_new_output_frame( &self, encoder: *const VSLEncoder, width: c_int, height: c_int, duration: i64, pts: i64, dts: i64, ) -> *mut VSLFrame

@brief Creates a new output frame for encoder

Allocates a frame suitable for receiving encoded output from vsl_encode_frame(). The frame uses encoder-specific memory (e.g., Hantro VPU EWL memory on i.MX8) for efficient hardware encoding.

@param encoder VSLEncoder instance @param width Encoded frame width in pixels (should match encoder source) @param height Encoded frame height in pixels (should match encoder source) @param duration Frame duration in nanoseconds (passed through to output) @param pts Presentation timestamp in nanoseconds (passed through to output) @param dts Decode timestamp in nanoseconds (passed through to output) @return Pointer to VSLFrame for encoded output, or NULL on failure @since 1.3

Source

pub unsafe fn vsl_camera_open_device( &self, filename: *const c_char, ) -> *mut vsl_camera

Opens the camera device specified by filename and allocates device memory.

Opens a V4L2 video capture device (e.g., /dev/video0) and prepares it for streaming. The device is not yet configured - call vsl_camera_init_device() next.

@param filename V4L2 device path (e.g., “/dev/video0”) @return Pointer to vsl_camera context on success, NULL on failure @since 1.3 @memberof VSLCamera

Source

pub unsafe fn vsl_camera_init_device( &self, ctx: *mut vsl_camera, width: *mut c_int, height: *mut c_int, buf_count: *mut c_int, fourcc: *mut u32, ) -> c_int

Initializes the camera device for streaming and allocates camera buffers.

Negotiates format with the V4L2 driver. On entry, width/height/fourcc contain desired values (0 for driver default). On success, they’re updated with actual negotiated values. Allocates buf_count buffers (updated with actual count).

Must be called after vsl_camera_open_device() and before vsl_camera_start_capturing().

@param ctx Camera context from vsl_camera_open_device() @param width Pointer to desired/actual width in pixels (0 for default) @param height Pointer to desired/actual height in pixels (0 for default) @param buf_count Pointer to desired/actual buffer count (0 for default) @param fourcc Pointer to desired/actual fourcc format (0 for default) @return 0 on success, -1 on error @since 1.3 @memberof VSLCamera

Source

pub unsafe fn vsl_camera_mirror( &self, ctx: *const vsl_camera, mirror: bool, ) -> c_int

Requests the camera to mirror the image left-to-right.

Uses V4L2_CID_HFLIP control to flip the image horizontally. Not all cameras support this feature.

@param ctx Camera context @param mirror true to enable horizontal flip, false to disable @return 0 on success, -1 if driver refused the request @since 1.3 @memberof VSLCamera

Source

pub unsafe fn vsl_camera_mirror_v( &self, ctx: *const vsl_camera, mirror: bool, ) -> c_int

Requests the camera to mirror the image top-to-bottom.

Uses V4L2_CID_VFLIP control to flip the image vertically. Not all cameras support this feature.

@param ctx Camera context @param mirror true to enable vertical flip, false to disable @return 0 on success, -1 if driver refused the request @since 1.3 @memberof VSLCamera

Source

pub unsafe fn vsl_camera_start_capturing(&self, ctx: *mut vsl_camera) -> c_int

Starts the camera stream.

Begins V4L2 streaming (VIDIOC_STREAMON). Frames can now be captured with vsl_camera_get_data(). Must be called after vsl_camera_init_device().

@param ctx Camera context @return 0 on success, -1 on error @since 1.3 @memberof VSLCamera

Source

pub unsafe fn vsl_camera_get_data( &self, ctx: *mut vsl_camera, ) -> *mut vsl_camera_buffer

Attempts to read a frame from the camera.

Dequeues a filled buffer from the camera driver (VIDIOC_DQBUF). Blocks until a frame is available. Must be called after vsl_camera_start_capturing().

After processing, call vsl_camera_release_buffer() to return the buffer to the driver’s queue for reuse.

@param ctx Camera context @return Pointer to camera buffer, or NULL on timeout/error @since 1.3 @memberof VSLCamera

Source

pub unsafe fn vsl_camera_release_buffer( &self, ctx: *mut vsl_camera, buffer: *const vsl_camera_buffer, ) -> c_int

Enqueues a buffer to be reused for frame capture.

Returns the buffer to the camera driver’s queue (VIDIOC_QBUF) so it can be filled with new frame data. Must be called after processing each buffer from vsl_camera_get_data().

@param ctx Camera context @param buffer Buffer to release (from vsl_camera_get_data) @return 0 on success, -1 on error @since 1.3 @memberof VSLCamera

Source

pub unsafe fn vsl_camera_stop_capturing(&self, ctx: *const vsl_camera) -> c_int

Stops the camera stream.

Stops V4L2 streaming (VIDIOC_STREAMOFF). No more frames will be captured. Call before vsl_camera_uninit_device() and vsl_camera_close_device().

@param ctx Camera context @return 0 on success, -1 on error @since 1.3 @memberof VSLCamera

Source

pub unsafe fn vsl_camera_uninit_device(&self, ctx: *mut vsl_camera)

Uninitializes the camera buffers and frees the buffer memory.

Releases all allocated camera buffers. Ensure the device is not streaming (call vsl_camera_stop_capturing() first).

@param ctx Camera context @since 1.3 @memberof VSLCamera

Source

pub unsafe fn vsl_camera_close_device(&self, ctx: *mut vsl_camera)

Closes the camera device and frees the device memory.

Closes the V4L2 device file descriptor and releases all resources. Ensure the device is not streaming (call vsl_camera_stop_capturing() and vsl_camera_uninit_device() first).

@param ctx Camera context to close @since 1.3 @memberof VSLCamera

Source

pub unsafe fn vsl_camera_is_dmabuf_supported( &self, ctx: *const vsl_camera, ) -> c_int

Checks if DmaBuf export is supported on the camera.

DmaBuf support allows zero-copy frame sharing with hardware accelerators (VPU, NPU, GPU). Requires V4L2 driver support for VIDIOC_EXPBUF.

Must be called after vsl_camera_init_device().

@param ctx Camera context @return 1 if DmaBuf supported, 0 if not supported @since 1.3 @memberof VSLCamera

Source

pub unsafe fn vsl_camera_get_queued_buf_count( &self, ctx: *const vsl_camera, ) -> c_int

Returns the number of buffers queued in the camera driver.

Queued buffers are available for the driver to fill with new frames. If count reaches 0, vsl_camera_get_data() will block/timeout waiting for buffers to be released via vsl_camera_release_buffer().

@param ctx Camera context @return Number of queued buffers @since 1.3 @memberof VSLCamera

Source

pub unsafe fn vsl_camera_buffer_mmap( &self, buffer: *mut vsl_camera_buffer, ) -> *mut c_void

Returns the mmap memory pointer of the camera buffer.

Provides CPU access to the camera buffer’s memory. The buffer is already mapped by the camera driver.

@param buffer Camera buffer from vsl_camera_get_data() @return Pointer to mapped memory @since 1.3 @memberof VSLCamera

Source

pub unsafe fn vsl_camera_buffer_dma_fd( &self, buffer: *const vsl_camera_buffer, ) -> c_int

Returns the DmaBuf file descriptor of the camera buffer.

Returns the DmaBuf FD for zero-copy sharing with hardware accelerators. Only available if vsl_camera_is_dmabuf_supported() returns true.

@param buffer Camera buffer from vsl_camera_get_data() @return DmaBuf file descriptor, or -1 if DmaBuf not supported @since 1.3 @memberof VSLCamera

Source

pub unsafe fn vsl_camera_buffer_phys_addr( &self, buffer: *const vsl_camera_buffer, ) -> u64

Returns the physical address of the camera buffer.

Physical address is available on some platforms (certain i.MX drivers) for DMA operations. Not commonly used - prefer DmaBuf FD for portability.

@param buffer Camera buffer from vsl_camera_get_data() @return Physical address, or 0 if not supported @since 1.3 @memberof VSLCamera

Source

pub unsafe fn vsl_camera_buffer_length( &self, buffer: *const vsl_camera_buffer, ) -> u32

Returns the length of the camera buffer in bytes.

Buffer size as reported by the V4L2 driver. For multi-planar formats, this is the total size across all planes.

@param buffer Camera buffer from vsl_camera_get_data() @return Buffer length in bytes @since 1.3 @memberof VSLCamera

Source

pub unsafe fn vsl_camera_buffer_fourcc( &self, buffer: *const vsl_camera_buffer, ) -> u32

Returns the fourcc code of the camera buffer.

Pixel format as negotiated with the driver during vsl_camera_init_device().

@param buffer Camera buffer from vsl_camera_get_data() @return FOURCC code @since 1.3 @memberof VSLCamera

Source

pub unsafe fn vsl_camera_buffer_timestamp( &self, buffer: *const vsl_camera_buffer, seconds: *mut i64, nanoseconds: *mut i64, )

Reads the timestamp of the camera buffer.

Retrieves the capture timestamp from the V4L2 buffer. Time is relative to CLOCK_MONOTONIC when the frame was captured by the camera driver.

@param buffer Camera buffer from vsl_camera_get_data() @param seconds Output pointer for timestamp seconds @param nanoseconds Output pointer for sub-second nanoseconds @since 1.3

Source

pub unsafe fn vsl_camera_enum_fmts( &self, ctx: *const vsl_camera, codes: *mut u32, size: c_int, ) -> c_int

Lists the supported single-planar formats of the camera.

Queries V4L2 device for available single-planar pixel formats. Call before vsl_camera_init_device() to determine what formats to request.

@param ctx Camera context from vsl_camera_open_device() @param codes Array to receive fourcc codes @param size Size of codes array @return Number of formats written to codes array, or -1 on error @since 1.3

Source

pub unsafe fn vsl_camera_enum_mplane_fmts( &self, ctx: *const vsl_camera, codes: *mut u32, size: c_int, ) -> c_int

Lists the supported multi-planar formats of the camera.

Queries V4L2 device for available multi-planar pixel formats (e.g., NV12, NV21 with separate Y and UV planes). Call before vsl_camera_init_device().

@param ctx Camera context from vsl_camera_open_device() @param codes Array to receive fourcc codes @param size Size of codes array @return Number of formats written to codes array, or -1 on error @since 1.3

Source

pub unsafe fn vsl_decoder_create( &self, codec: VSLDecoderCodec, fps: c_int, ) -> *mut VSLDecoder

@brief Creates VSLDecoder instance

Creates a hardware video decoder for H.264/H.265 using the best available backend (V4L2 preferred, Hantro fallback). The decoder is initialized on the first call to vsl_decode_frame().

@param codec Codec type: VSL_DEC_H264 or VSL_DEC_HEVC @param fps Expected frame rate (used for buffer management) @return Pointer to VSLDecoder instance, or NULL on failure @since 1.4

Source

pub unsafe fn vsl_decoder_create_ex( &self, codec: u32, fps: c_int, backend: VSLCodecBackend, ) -> *mut VSLDecoder

@brief Creates VSLDecoder instance with explicit backend selection

Creates a hardware video decoder with explicit backend selection. Use this when you need to force a specific backend instead of auto-detection.

@param codec Codec fourcc: VSL_FOURCC(‘H’,‘2’,‘6’,‘4’) or VSL_FOURCC(‘H’,‘E’,‘V’,‘C’) @param fps Expected frame rate (used for buffer management) @param backend Backend to use (AUTO, HANTRO, or V4L2) @return Pointer to VSLDecoder instance, or NULL on failure @since 2.0

Source

pub unsafe fn vsl_decode_frame( &self, decoder: *mut VSLDecoder, data: *const c_void, data_length: c_uint, bytes_used: *mut usize, output_frame: *mut *mut VSLFrame, ) -> VSLDecoderRetCode

@brief Decode compressed video frame

Decodes H.264/H.265 data into a raw frame using hardware acceleration. First call initializes the decoder. May require multiple calls to decode one frame (returns VSL_DEC_INIT_INFO or VSL_DEC_FRAME_DEC).

@param decoder VSLDecoder instance from vsl_decoder_create() @param data Pointer to compressed video data @param data_length Length of compressed data in bytes @param bytes_used Output: number of bytes consumed from data @param output_frame Output: decoded frame (NULL if frame not yet complete) @return VSL_DEC_SUCCESS (frame decoded), VSL_DEC_INIT_INFO (need more calls), VSL_DEC_FRAME_DEC (frame in progress), or VSL_DEC_ERR (error) @since 1.4

Source

pub unsafe fn vsl_decoder_width(&self, decoder: *const VSLDecoder) -> c_int

@brief Returns the decoded frame width

Returns the width of decoded frames as determined from the stream headers. Only valid after decoder initialization (after first vsl_decode_frame()).

@param decoder VSLDecoder instance @return Frame width in pixels @since 1.4

Source

pub unsafe fn vsl_decoder_height(&self, decoder: *const VSLDecoder) -> c_int

@brief Returns the decoded frame height

Returns the height of decoded frames as determined from the stream headers. Only valid after decoder initialization (after first vsl_decode_frame()).

@param decoder VSLDecoder instance @return Frame height in pixels @since 1.4

Source

pub unsafe fn vsl_decoder_crop(&self, decoder: *const VSLDecoder) -> VSLRect

@brief Returns the decoder crop rectangle

Returns the active video area within decoded frames, as specified in stream headers. Some encoded streams have padding that should be cropped.

@param decoder VSLDecoder instance @return VSLRect with crop region (x, y, width, height) @since 1.4

Source

pub unsafe fn vsl_decoder_release(&self, decoder: *mut VSLDecoder) -> c_int

@brief Destroys VSLDecoder instance

Frees all resources associated with the decoder, including hardware resources. Do not use the decoder after calling this function.

@param decoder VSLDecoder instance to destroy @return 0 on success, -1 on error @since 1.4

Source

pub fn is_encoder_available(&self) -> bool

Check if encoder functions are available in the loaded library.

Source

pub fn is_decoder_available(&self) -> bool

Check if decoder functions are available in the loaded library.

Source

pub fn is_decoder_create_ex_available(&self) -> bool

Check if vsl_decoder_create_ex is available (requires VideoStream 2.0+).

Source

pub fn is_encoder_create_ex_available(&self) -> bool

Check if vsl_encoder_create_ex is available (requires VideoStream 2.0+).

Source

pub fn is_backend_selection_available(&self) -> bool

Check if backend selection is available for decoders.

Source

pub unsafe fn try_vsl_encoder_create( &self, profile: VSLEncoderProfile, outputFourcc: u32, fps: c_int, ) -> Option<*mut VSLEncoder>

Try to create an encoder, returning None if the symbol is not available.

Source

pub unsafe fn try_vsl_encoder_create_ex( &self, profile: VSLEncoderProfile, outputFourcc: u32, fps: c_int, backend: VSLCodecBackend, ) -> Option<*mut VSLEncoder>

Try to create an encoder with backend selection, returning None if unavailable.

Source

pub unsafe fn try_vsl_encoder_release(&self, encoder: *mut VSLEncoder) -> bool

Try to release an encoder, returning false if the symbol is not available.

Source

pub unsafe fn try_vsl_encode_frame( &self, encoder: *mut VSLEncoder, source: *mut VSLFrame, destination: *mut VSLFrame, cropRegion: *const VSLRect, keyframe: *mut c_int, ) -> Option<c_int>

Try to encode a frame, returning None if the symbol is not available.

Source

pub unsafe fn try_vsl_encoder_new_output_frame( &self, encoder: *const VSLEncoder, width: c_int, height: c_int, duration: i64, pts: i64, dts: i64, ) -> Option<*mut VSLFrame>

Try to create an encoder output frame, returning None if unavailable.

Source

pub unsafe fn try_vsl_decoder_create( &self, codec: VSLDecoderCodec, fps: c_int, ) -> Option<*mut VSLDecoder>

Try to create a decoder, returning None if the symbol is not available.

Source

pub unsafe fn try_vsl_decoder_create_ex( &self, codec: u32, fps: c_int, backend: VSLCodecBackend, ) -> Option<*mut VSLDecoder>

Try to create a decoder with backend selection, returning None if unavailable.

Source

pub unsafe fn try_vsl_decoder_width( &self, decoder: *mut VSLDecoder, ) -> Option<c_int>

Try to get decoder width, returning None if unavailable.

Source

pub unsafe fn try_vsl_decoder_height( &self, decoder: *mut VSLDecoder, ) -> Option<c_int>

Try to get decoder height, returning None if unavailable.

Source

pub unsafe fn try_vsl_decoder_crop( &self, decoder: *mut VSLDecoder, ) -> Option<vsl_rect>

Try to get decoder crop region, returning None if unavailable.

Source

pub unsafe fn try_vsl_decode_frame( &self, decoder: *mut VSLDecoder, data: *const c_void, len: u32, bytes_used: *mut usize, output_frame: *mut *mut vsl_frame, ) -> Option<u32>

Try to decode a frame, returning None if unavailable.

Source

pub unsafe fn try_vsl_decoder_release( &self, decoder: *mut VSLDecoder, ) -> Option<()>

Try to release a decoder, returning None if unavailable.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.