pub struct CameraCapture { /* private fields */ }Expand description
Stateful camera capture session over SDL’s camera backend.
poll acquires the newest queued frame, uploads it into an owned RGBA8
texture, and returns it as a VideoFrame; the SDL surface is released
immediately, so no ring-slot release contract exists on this route. The
returned frame’s presentation timestamp is the camera’s hardware capture
timestamp in microseconds and its duration follows the negotiated frame
rate.
Implementations§
Source§impl CameraCapture
impl CameraCapture
Sourcepub fn open(runtime: &Runtime, config: &CameraCaptureConfig) -> Result<Self>
pub fn open(runtime: &Runtime, config: &CameraCaptureConfig) -> Result<Self>
Open the selected camera and negotiate the closest supported format.
The session requests RGBA32 output so no pixel conversion happens
outside SDL. On platforms with a camera permission gate the camera opens
before approval; poll reports ErrorKind::MissingCapability when the
user denies access and None while approval is pending.
§Errors
Returns an error for a zero extent, when no camera device matches
device_index, or when SDL cannot open or describe the device.
Sourcepub fn poll(&mut self) -> Result<Option<VideoFrame>>
pub fn poll(&mut self) -> Result<Option<VideoFrame>>
Acquire and upload the newest queued camera frame.
Returns Ok(None) when the camera has not produced another frame yet —
this is also the steady state while a platform permission request is
pending. Callers drive this in their own pacing loop; poll never
blocks.
§Errors
Returns an error after close, when camera access was denied, for an unexpected frame layout, or when the texture upload fails.
Sourcepub fn close(&mut self)
pub fn close(&mut self)
Close the session and release the camera.
Frames already returned remain owned by their callers; SDL surfaces are
released eagerly at poll time so nothing is deferred to close.
Sourcepub const fn is_streaming(&self) -> bool
pub const fn is_streaming(&self) -> bool
Return whether the session still owns an open camera.
Sourcepub fn frame_rate(&self) -> f64
pub fn frame_rate(&self) -> f64
Return the negotiated frame rate, or 0.0 when the device reported none.