pub struct VideoFrames { /* private fields */ }Expand description
Latest-frame-wins video frames.
VideoSource::frames returns it for a local
preview, and a player returns it for playback. Each clone keeps its own
cursor. A frame comes as an Arc because upstream frames are not Clone:
a GPU surface is shared, not copied.
On a fresh handle, the first next returns at once if a
picture is already there.
A handle from VideoSource::frames wants
the source’s frames until it and every clone of it are dropped.
Implementations§
Source§impl VideoFrames
impl VideoFrames
Sourcepub fn current(&self) -> Option<Arc<Frame>>
pub fn current(&self) -> Option<Arc<Frame>>
Returns the newest frame, seen or not, without moving the cursor.
For render loops that redraw every vsync.
Sourcepub async fn next(&mut self) -> Option<Arc<Frame>>
pub async fn next(&mut self) -> Option<Arc<Frame>>
Waits for a frame newer than the last this handle returned.
Frames that arrive faster than the handle reads them coalesce: only the
newest is returned. Returns None once the producer is gone and this
handle has seen its last frame.
Cancellation safe.
Sourcepub fn try_next(&mut self) -> Option<Arc<Frame>>
pub fn try_next(&mut self) -> Option<Arc<Frame>>
Returns a newer frame without waiting, if there is one.
For a render loop that draws only when the picture changed.
Sourcepub fn sent_at(&self) -> Option<Instant>
pub fn sent_at(&self) -> Option<Instant>
Returns when the last frame this handle returned entered the stream.
That frame is the one next or
try_next returned last. For a source, that is when
the application pushed the frame or the capture thread handed it over,
before any encoder saw it. For a player, it is when the picture was
presented. Returns None before the first frame.
Sourcepub fn keyframe_requested(&self) -> bool
pub fn keyframe_requested(&self) -> bool
Returns whether the producer asked for a keyframe at the last frame this handle returned.
Meant for encoders. Returns true for the first frame the handle returned
after a call to
FrameSender::request_keyframe,
even if the frame the request preceded was skipped. Each handle reports
a request once, independently of its clones and of other handles.