pub struct Decoder<S: DecoderState> { /* private fields */ }Implementations§
Source§impl Decoder<AwaitingOutputFormat>
impl Decoder<AwaitingOutputFormat>
pub fn open(path: &Path) -> Result<Self, DecoderOpenError>
pub fn set_output_format<F>( self, f: F, ) -> Result<Decoder<AwaitingOutputBuffers>>
Source§impl Decoder<AwaitingOutputBuffers>
impl Decoder<AwaitingOutputBuffers>
pub fn allocate_output_buffers_generic<OP: BufferHandles>( self, memory_type: OP::SupportedMemoryType, num_buffers: usize, ) -> Result<Decoder<ReadyToDecode<OP>>, RequestBuffersError>
pub fn allocate_output_buffers<OP: PrimitiveBufferHandles>( self, num_output: usize, ) -> Result<Decoder<ReadyToDecode<OP>>, RequestBuffersError>
Source§impl<OP: BufferHandles> Decoder<ReadyToDecode<OP>>
impl<OP: BufferHandles> Decoder<ReadyToDecode<OP>>
pub fn set_poll_counter(self, poll_wakeups_counter: Arc<AtomicUsize>) -> Self
pub fn start<P, InputDoneCb, DecoderEventCb, FormatChangedCb>(
self,
input_done_cb: InputDoneCb,
decoder_event_cb: DecoderEventCb,
set_capture_format_cb: FormatChangedCb,
) -> Result<Decoder<Decoding<OP, P, InputDoneCb, DecoderEventCb, FormatChangedCb>>, StartDecoderError>where
P: HandlesProvider,
InputDoneCb: InputDoneCallback<OP>,
DecoderEventCb: DecoderEventCallback<P>,
FormatChangedCb: FormatChangedCallback<P>,
for<'a> Queue<Capture, BuffersAllocated<P::HandleType>>: GetFreeCaptureBuffer<'a, P::HandleType> + GetCaptureBufferByIndex<'a, P::HandleType>,
Source§impl<OP, P, InputDoneCb, DecoderEventCb, FormatChangedCb> Decoder<Decoding<OP, P, InputDoneCb, DecoderEventCb, FormatChangedCb>>where
OP: BufferHandles,
P: HandlesProvider,
InputDoneCb: InputDoneCallback<OP>,
DecoderEventCb: DecoderEventCallback<P>,
FormatChangedCb: FormatChangedCallback<P>,
impl<OP, P, InputDoneCb, DecoderEventCb, FormatChangedCb> Decoder<Decoding<OP, P, InputDoneCb, DecoderEventCb, FormatChangedCb>>where
OP: BufferHandles,
P: HandlesProvider,
InputDoneCb: InputDoneCallback<OP>,
DecoderEventCb: DecoderEventCallback<P>,
FormatChangedCb: FormatChangedCallback<P>,
pub fn num_output_buffers(&self) -> usize
pub fn get_output_format<O: TryFrom<v4l2_format>>(&self) -> Result<O, GFmtError>
Sourcepub fn stop(
self,
) -> Result<Vec<<Queue<Output, BuffersAllocated<OP>> as Stream>::Canceled>, StopError>
pub fn stop( self, ) -> Result<Vec<<Queue<Output, BuffersAllocated<OP>> as Stream>::Canceled>, StopError>
Stop the decoder.
This will stop any pending operation consume the decoder, which cannot
be used anymore. To make sure all submitted encoded buffers have been
processed, call the Decoder::drain method and wait for the output buffer with
the LAST flag before calling this method.
TODO potential bug: the LAST buffer could also be the one signaling a DRC. We need another way to manage this? Probably a good idea to split into two properties of DQBuf.
Sourcepub fn drain(&self, blocking: bool) -> Result<bool, DrainError>
pub fn drain(&self, blocking: bool) -> Result<bool, DrainError>
Drain the decoder, i.e. make sure all its pending work is processed.
The blocking parameters decides whether this method is permitted to
block: if true, then all the frames corresponding to the encoded
buffers queued so far will have been emitted when this function returns.
In this case the method will always return true to signal that drain
has been completed.
If false, then the method may also return false to signal that drain
has not completed yet. When this is the case, the client must look for
a decoded frame with the LAST flag set, as this flag signals that this
frame is the last one before the drain has completed.
Note that requesting a blocking drain can be hazardous if the current thread is responsible for e.g. submitting handles for decoded frames. It is easy to put the decoding pipeline in a deadlock situation.
The client can keep submitting buffers with encoded data as the drain is
ongoing. They will be processed in order and their frames will come
after the ones still in the pipeline. For a way to cancel all the
pending jobs, see the Decoder::flush method.
Sourcepub fn flush(&self) -> Result<(), FlushError>
pub fn flush(&self) -> Result<(), FlushError>
Flush the decoder, i.e. try to cancel all pending work.
The canceled input buffers will be returned as
CompletedInputBuffer::Canceled through the input done callback.
If a Decoder::drain operation was in progress, it is also canceled.
This function is blocking. When is returns, the frame decoded callback has been called for all pre-flush frames, and the decoder can accept new content to decode.
Source§impl<'a, OP, P, InputDoneCb, DecoderEventCb, FormatChangedCb> Decoder<Decoding<OP, P, InputDoneCb, DecoderEventCb, FormatChangedCb>>where
Self: GetFreeOutputBuffer<'a, OP, GetBufferError>,
OP: BufferHandles,
P: HandlesProvider,
InputDoneCb: InputDoneCallback<OP>,
DecoderEventCb: DecoderEventCallback<P>,
FormatChangedCb: FormatChangedCallback<P>,
impl<'a, OP, P, InputDoneCb, DecoderEventCb, FormatChangedCb> Decoder<Decoding<OP, P, InputDoneCb, DecoderEventCb, FormatChangedCb>>where
Self: GetFreeOutputBuffer<'a, OP, GetBufferError>,
OP: BufferHandles,
P: HandlesProvider,
InputDoneCb: InputDoneCallback<OP>,
DecoderEventCb: DecoderEventCallback<P>,
FormatChangedCb: FormatChangedCallback<P>,
Sourcepub fn num_queued_buffers(&self) -> usize
pub fn num_queued_buffers(&self) -> usize
Returns the number of currently queued encoded buffers.
Sourcepub fn get_buffer(
&'a mut self,
) -> Result<<Self as OutputQueueableProvider<'a, OP>>::Queueable, GetBufferError>
pub fn get_buffer( &'a mut self, ) -> Result<<Self as OutputQueueableProvider<'a, OP>>::Queueable, GetBufferError>
Returns a V4L2 buffer to be filled with a frame to decode, waiting for one to be available if needed.
Contrary to Decoder::try_get_free_buffer(), this method will wait for a buffer
to be available if needed.
Sourcepub fn kick(&self) -> Result<(), DqBufError<V4l2BufferFromError>>
pub fn kick(&self) -> Result<(), DqBufError<V4l2BufferFromError>>
Kick the decoder and see if some input buffers fall as a result.
No, really. Completed input buffers are typically checked when calling
Decoder::get_buffer (which is also the time when the input done callback is
invoked), but this mechanism is not foolproof: if the client works with
a limited set of input buffers and queues them all before an output
frame can be produced, then the client has no more buffers to fill and
thus no reason to call Decoder::get_buffer, resulting in the decoding process
being blocked.
This method mitigates this problem by adding a way to check for completed input buffers and calling the input done callback without the need for new encoded content. It is suggested to call it from the thread that owns the decoder every time a decoded frame is produced. That way the client can recycle its input buffers and the decoding process does not get stuck.
Trait Implementations§
Source§impl<'a, OP, P, InputDoneCb, DecoderEventCb, FormatChangedCb> GetFreeOutputBuffer<'a, OP, GetBufferError> for Decoder<Decoding<OP, P, InputDoneCb, DecoderEventCb, FormatChangedCb>>where
Queue<Output, BuffersAllocated<OP>>: GetFreeOutputBuffer<'a, OP>,
OP: BufferHandles,
P: HandlesProvider,
InputDoneCb: InputDoneCallback<OP>,
DecoderEventCb: DecoderEventCallback<P>,
FormatChangedCb: FormatChangedCallback<P>,
Let the decoder provide the buffers from the OUTPUT queue.
impl<'a, OP, P, InputDoneCb, DecoderEventCb, FormatChangedCb> GetFreeOutputBuffer<'a, OP, GetBufferError> for Decoder<Decoding<OP, P, InputDoneCb, DecoderEventCb, FormatChangedCb>>where
Queue<Output, BuffersAllocated<OP>>: GetFreeOutputBuffer<'a, OP>,
OP: BufferHandles,
P: HandlesProvider,
InputDoneCb: InputDoneCallback<OP>,
DecoderEventCb: DecoderEventCallback<P>,
FormatChangedCb: FormatChangedCallback<P>,
Let the decoder provide the buffers from the OUTPUT queue.
Source§fn try_get_free_buffer(&'a self) -> Result<Self::Queueable, GetBufferError>
fn try_get_free_buffer(&'a self) -> Result<Self::Queueable, GetBufferError>
Returns a V4L2 buffer to be filled with a frame to decode if one is available.
This method will return None immediately if all the allocated buffers are currently queued.