pub trait VideoEncoder<Handle> {
// Required methods
fn tune(&mut self, tunings: Tunings) -> EncodeResult<()>;
fn encode(
&mut self,
meta: FrameMetadata,
handle: Handle,
) -> Result<(), EncodeError>;
fn drain(&mut self) -> EncodeResult<()>;
fn poll(&mut self) -> EncodeResult<Option<CodedBitstreamBuffer>>;
}
Expand description
Generic video encoder interface.
Required Methods§
Sourcefn tune(&mut self, tunings: Tunings) -> EncodeResult<()>
fn tune(&mut self, tunings: Tunings) -> EncodeResult<()>
Changes dynamic parameters (aka Tunings
) of the encoded stream. The change may not be
effective right away. Depending on the used prediction structure, the Predictor
may
choose to delay the change until entire or a some part of the structure had been encoded.
Note: Currently changing the variant of RateControl
is not supported.
Sourcefn encode(
&mut self,
meta: FrameMetadata,
handle: Handle,
) -> Result<(), EncodeError>
fn encode( &mut self, meta: FrameMetadata, handle: Handle, ) -> Result<(), EncodeError>
Enqueues the frame for encoding. The implementation will drop the handle after it is no longer be needed. The encoder is not required to immediately start processing the frame and yield output bitstream. It is allowed to hold frames until certain conditions are met eg. for specified prediction structures or referencing in order to further optimize the compression rate of the bitstream.
Sourcefn drain(&mut self) -> EncodeResult<()>
fn drain(&mut self) -> EncodeResult<()>
Drains the encoder. This means that encoder is required to finish processing of all the
frames in the internal queue and yield output bitstream by the end of the call. The output
bitstream then can be polled using Self::poll
function.
Drain does not enforce the flush of the internal state, ie. the enqueued frame handles do not have to be returned to user (dropped) and key frame is not enforced on the next frame.
Sourcefn poll(&mut self) -> EncodeResult<Option<CodedBitstreamBuffer>>
fn poll(&mut self) -> EncodeResult<Option<CodedBitstreamBuffer>>
Polls on the encoder for the available output bitstream with compressed frames that where
submitted with Self::encode
.
The call may also trigger a further processing aside of returning output. Therefore it recommended that this function is called frequently.