pub struct Stream { /* private fields */ }Expand description
A live, async frame source opened via open.
Every backend delivers frames through the same latest-frame channel, so the
consumer just read().awaits regardless of platform. Dropping the stream
releases the device (stops the macOS AVCaptureSession, joins the V4L2 /
Media Foundation pump thread). That is the whole point: because read is a
real await, cancelling the capture future drops this and the camera turns off
promptly, with no blocking task left pinned to the runtime.
Implementations§
Source§impl Stream
impl Stream
Sourcepub async fn read(&mut self) -> Result<Option<Surface>, Error>
pub async fn read(&mut self) -> Result<Option<Surface>, Error>
Await the next frame, or None once the source ends.
None is recoverable: the source stopped for a benign reason (it
resized, the compositor renegotiated the format, the device went idle)
and reopening is expected to work. An Err is terminal for this
selection: the source is gone or was refused.
Dropping this future cancels only the pending read. Dropping the stream releases the capture source.
Sourcepub fn framerate(&self) -> Option<u32>
pub fn framerate(&self) -> Option<u32>
The negotiated frame rate, or None if the source doesn’t report one.