Struct FrameSender
pub struct FrameSender<T> { /* private fields */ }Expand description
The push end of a source.
VideoSource::push and
AudioSource::push return one, and
VideoSource::spawn hands one to its closure.
Pushing never blocks. A video frame replaces a pending one. PCM beyond the
buffer drops the oldest frames, and the broadcast reading it counts them in
its stats.
The source ends when every sender is dropped. Cheap to clone.
Implementations§
§impl<T> FrameSender<T>where
T: 'static,
impl<T> FrameSender<T>where
T: 'static,
pub fn push(&self, frame: T) -> Result<(), SourceClosed>
pub fn push(&self, frame: T) -> Result<(), SourceClosed>
Pushes one frame.
§Errors
Returns SourceClosed once every handle to the source has been dropped.
A producing loop should stop then.
pub fn demand(&self) -> Receiver<bool>
pub fn demand(&self) -> Receiver<bool>
Returns whether any broadcast wants frames.
It is true while a broadcast this source feeds encodes it, which for
video means while somebody watches. A video source is also wanted
while a handle from VideoSource::frames
lives. A camera the application drives itself can idle while it is
false.
pub async fn closed(&self)
pub async fn closed(&self)
Waits until the source is gone.
Cancellation safe.
§impl FrameSender<Frame>
impl FrameSender<Frame>
pub fn request_keyframe(&self)
pub fn request_keyframe(&self)
Asks every encoder of the source for a keyframe at the next frame pushed.
Each rendition’s encoder cuts on the first frame it encodes after the
request, which is the next frame pushed or a newer one if the encoder
skipped it. Several requests before one frame cut once. A source
derived from this one, such as
VideoSource::scaled, passes the
request on.
Whether the encoder’s keyframe interval restarts at a requested
keyframe depends on the backend; a producer that places every keyframe
itself sets a join longer than the spacing of its requests. A backend
that cannot cut ignores the request, and so does a source that nothing
encodes.
Trait Implementations§
§impl<T> Clone for FrameSender<T>
impl<T> Clone for FrameSender<T>
§fn clone(&self) -> FrameSender<T>
fn clone(&self) -> FrameSender<T>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more