pub struct VideoDecoder { /* private fields */ }Expand description
Implementations§
Source§impl VideoDecoder
impl VideoDecoder
Sourcepub fn new(config: DecoderConfig) -> Result<Self>
pub fn new(config: DecoderConfig) -> Result<Self>
Opens a decoder for config.
On Linux the first V4L2 memory-to-memory device that decodes the
codec to NV12 is used. Setting EDGEFIRST_CODEC_V4L2_DECODER to a
device node uses that node only.
§Errors
CodecError::InvalidConfig when a provided pool is empty or not in
DMA-BUF memory, and CodecError::NoDevice when there is no decoder.
Sourcepub fn decode(
&mut self,
access_unit: &[u8],
pts: u64,
) -> Result<Vec<DecodeEvent>>
pub fn decode( &mut self, access_unit: &[u8], pts: u64, ) -> Result<Vec<DecodeEvent>>
Decodes one access unit (see access_units), whose picture is
tagged with pts.
Returns, in order, every event ready by the time the device has taken
the access unit; it may be empty, and frames may belong to earlier
access units, since devices hold pictures back for reordering. The
first access unit yields DecodeEvent::Reconfigured once the
headers are parsed.
§Errors
CodecError::PoolExhausted when the caller holds the frames in
every output buffer, so the device cannot decode further; drop frames
and decode the same access unit again. CodecError::Timeout when
the device makes no progress otherwise. CodecError::InvalidInput
when the access unit is empty or larger than the device’s bitstream
buffers. Events that became ready before an error are returned by
the next call.
Sourcepub fn flush(&mut self) -> Result<Vec<DecodeEvent>>
pub fn flush(&mut self) -> Result<Vec<DecodeEvent>>
Drains the decoder: returns every event not yet returned, in order.
The decoder accepts new access units afterwards, starting a new sequence: the next access unit must be decodable on its own, an IDR picture with its SPS and PPS, as at the start of a stream or after a seek.
§Errors
CodecError::PoolExhausted when the caller holds the frames in
every output buffer the drain needs; drop frames and flush again.
CodecError::Timeout when the device does not finish draining.
Sourcepub fn stream_info(&self) -> Option<&StreamInfo>
pub fn stream_info(&self) -> Option<&StreamInfo>
The current stream’s geometry, once known.