pub trait Encoder: Send {
// Required methods
fn send_frame(&mut self, frame: Option<&Frame>) -> Result<()>;
fn receive_packet(&mut self) -> Result<Packet>;
fn flush(&mut self);
}Expand description
Encoder trait — the main abstraction for all encoders.
Follows FFmpeg’s send/receive model:
send_frame()— feed raw datareceive_packet()— pull compressed dataflush()— signal end-of-stream
Required Methods§
Sourcefn send_frame(&mut self, frame: Option<&Frame>) -> Result<()>
fn send_frame(&mut self, frame: Option<&Frame>) -> Result<()>
Send a raw frame to the encoder.
Pass None to signal end-of-stream (drain mode).
Sourcefn receive_packet(&mut self) -> Result<Packet>
fn receive_packet(&mut self) -> Result<Packet>
Receive an encoded packet from the encoder.
Returns Error::Again when more input is needed.
Returns Error::Eof when all data has been drained.