Struct ffmpeg::avcodec::AvCodecContext
source · pub struct AvCodecContext(*mut AVCodecContext);Expand description
A codec context from which decoding can be performed.
Tuple Fields§
§0: *mut AVCodecContextImplementations§
source§impl AvCodecContext
impl AvCodecContext
sourcefn init(&mut self, codec: *const AVCodec) -> Result<(), AvCodecOpenError>
fn init(&mut self, codec: *const AVCodec) -> Result<(), AvCodecOpenError>
Internal helper for DecoderContextBuilder to initialize the context.
sourcepub fn try_send_packet(
&mut self,
packet: &AvPacket<'_>,
) -> Result<bool, AvError>
pub fn try_send_packet( &mut self, packet: &AvPacket<'_>, ) -> Result<bool, AvError>
Send a packet to be decoded by the codec.
Returns true if the packet has been accepted and will be decoded, false if the codec can
not accept frames at the moment - in this case try_receive_frame must be called before
the packet can be submitted again.
Error codes are the same as those returned by avcodec_send_packet with the exception of
EAGAIN which is converted into Ok(false) as it is not actually an error.
sourcepub fn try_receive_frame(
&mut self,
frame: &mut AvFrame,
) -> Result<TryReceiveResult, AvError>
pub fn try_receive_frame( &mut self, frame: &mut AvFrame, ) -> Result<TryReceiveResult, AvError>
Attempt to write a decoded frame in frame if the codec has enough data to do so.
Returned Received if frame has been filled with the next decoded frame, TryAgain if
no frame could be returned at that time (in which case try_send_packet should be called to
submit more input to decode), or FlushCompleted to signal that a previous flush triggered
by calling the flush method has completed.
Error codes are the same as those returned by avcodec_receive_frame with the exception of
EAGAIN and EOF which are handled as TryAgain and FlushCompleted respectively.
sourcepub fn try_send_frame(&mut self, frame: &AvFrame) -> Result<bool, AvError>
pub fn try_send_frame(&mut self, frame: &AvFrame) -> Result<bool, AvError>
Send a frame to be encoded by the codec.
Returns true if the frame has been accepted and will be encoded, false if the codec can
not accept input at the moment - in this case try_receive_frame must be called before
the frame can be submitted again.
Error codes are the same as those returned by avcodec_send_frame with the exception of
EAGAIN which is converted into Ok(false) as it is not actually an error.
sourcepub fn try_receive_packet(
&mut self,
packet: &mut AvPacket<'_>,
) -> Result<TryReceiveResult, AvError>
pub fn try_receive_packet( &mut self, packet: &mut AvPacket<'_>, ) -> Result<TryReceiveResult, AvError>
Attempt to write an encoded frame in packet if the codec has enough data to do so.
Returned Received if packet has been filled with encoded data, TryAgain if
no packet could be returned at that time (in which case try_send_frame should be called to
submit more input to decode), or FlushCompleted to signal that a previous flush triggered
by calling the flush method has completed.
Error codes are the same as those returned by avcodec_receive_packet with the exception of
EAGAIN and EOF which are handled as TryAgain and FlushCompleted respectively.
sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Reset the internal codec state/flush internal buffers. Should be called e.g. when seeking or switching to a different stream.
sourcepub fn flush_decoder(&mut self) -> Result<(), AvError>
pub fn flush_decoder(&mut self) -> Result<(), AvError>
Ask the context to start flushing, i.e. to process all pending input packets and produce frames for them.
The flush process is complete when try_receive_frame returns FlushCompleted,
sourcepub fn flush_encoder(&mut self) -> Result<(), AvError>
pub fn flush_encoder(&mut self) -> Result<(), AvError>
Ask the context to start flushing, i.e. to process all pending input frames and produce packets for them.
The flush process is complete when try_receive_packet returns FlushCompleted,
sourcepub fn set_time_base(&mut self, time_base: AVRational)
pub fn set_time_base(&mut self, time_base: AVRational)
Set the time base for this context.
sourcepub fn set_bit_rate(&mut self, bit_rate: u64)
pub fn set_bit_rate(&mut self, bit_rate: u64)
Set the bit rate for this context.
sourcepub fn set_max_bit_rate(&mut self, bit_rate: u64)
pub fn set_max_bit_rate(&mut self, bit_rate: u64)
Set the max bit rate (rc_max_rate) for this context.