Skip to main content

latest_camera_frame_bgra

Function latest_camera_frame_bgra 

Source
pub fn latest_camera_frame_bgra(
    recording_state: State<'_, RecordingState>,
) -> Response
Expand description

Return the latest BGRA frame from the camera capture slot (M-PIX.8). Used by <CameraPreview />’s 15fps poll to paint the live webcam into the canvas. Returns raw bytes via tauri::ipc::Response so the JS side receives an ArrayBuffer directly (no JSON-array serialization overhead).

Empty Response when no frame is available yet — the JS side skips painting on this tick.

Reads the same CameraFrameSlot the encoder feed thread reads from. The capture worker writes latest-frame-wins, so both consumers see the most recent frame; neither blocks the other (the preview’s take() clears the slot, but the next capture tick re-fills within ~33 ms at 30 fps).