ff_stream/output.rs
1//! Common interface for live stream outputs.
2
3use ff_format::{AudioFrame, VideoFrame};
4
5use crate::error::StreamError;
6
7/// Common interface for all live stream outputs.
8///
9/// Implementors: [`LiveHlsOutput`](crate::live_hls::LiveHlsOutput),
10/// [`LiveDashOutput`](crate::live_dash::LiveDashOutput),
11/// [`RtmpOutput`](crate::rtmp::RtmpOutput),
12/// [`FanoutOutput`](crate::fanout::FanoutOutput).
13pub trait StreamOutput: Send {
14 /// Push one video frame into the stream.
15 fn push_video(&mut self, frame: &VideoFrame) -> Result<(), StreamError>;
16
17 /// Push one audio frame into the stream.
18 fn push_audio(&mut self, frame: &AudioFrame) -> Result<(), StreamError>;
19
20 /// Flush all buffered data and close the output.
21 ///
22 /// Consumes the boxed value so the output cannot be used after finishing.
23 fn finish(self: Box<Self>) -> Result<(), StreamError>;
24}