pub trait DecoderSession {
// Required methods
fn set_output_parameters(
&mut self,
buffer_count: usize,
format: Format
) -> Result<(), VideoError>;
fn decode(
&mut self,
resource_id: u32,
timestamp: u64,
resource: GuestResourceHandle,
offset: u32,
bytes_used: u32
) -> Result<(), VideoError>;
fn flush(&mut self) -> Result<(), VideoError>;
fn reset(&mut self) -> Result<(), VideoError>;
fn clear_output_buffers(&mut self) -> Result<(), VideoError>;
fn event_pipe(&self) -> &dyn AsRawDescriptor;
fn use_output_buffer(
&mut self,
picture_buffer_id: i32,
resource: GuestResource
) -> Result<(), VideoError>;
fn reuse_output_buffer(
&mut self,
picture_buffer_id: i32
) -> Result<(), VideoError>;
fn read_event(&mut self) -> Result<DecoderEvent, VideoError>;
}
Expand description
Contains the device’s state for one playback session, i.e. one stream.
Required Methods§
sourcefn set_output_parameters(
&mut self,
buffer_count: usize,
format: Format
) -> Result<(), VideoError>
fn set_output_parameters( &mut self, buffer_count: usize, format: Format ) -> Result<(), VideoError>
Tell how many output buffers will be used for this session and which format they will carry.
This method must be called after a ProvidePictureBuffers
event is emitted, and before the
first call to use_output_buffer()
.
sourcefn decode(
&mut self,
resource_id: u32,
timestamp: u64,
resource: GuestResourceHandle,
offset: u32,
bytes_used: u32
) -> Result<(), VideoError>
fn decode( &mut self, resource_id: u32, timestamp: u64, resource: GuestResourceHandle, offset: u32, bytes_used: u32 ) -> Result<(), VideoError>
Decode the compressed stream contained in [offset
..offset
+bytes_used
] of the shared
memory in the input resource
.
resource_id
is the ID of the input resource. It will be signaled using the
NotifyEndOfBitstreamBuffer
once the input resource is not used anymore.
timestamp
is a timestamp that will be copied into the frames decoded from that input
stream. Units are effectively free and provided by the input stream.
The device takes ownership of resource
and is responsible for closing it once it is not
used anymore.
The device will emit a NotifyEndOfBitstreamBuffer
event with the resource_id
value after
the input buffer has been entirely processed.
The device will emit a PictureReady
event with the timestamp
value for each picture
produced from that input buffer.
sourcefn flush(&mut self) -> Result<(), VideoError>
fn flush(&mut self) -> Result<(), VideoError>
Flush the decoder device, i.e. finish processing all queued decode requests and emit frames for them.
The device will emit a FlushCompleted
event once the flush is done.
sourcefn reset(&mut self) -> Result<(), VideoError>
fn reset(&mut self) -> Result<(), VideoError>
Reset the decoder device, i.e. cancel all pending decoding requests.
The device will emit a ResetCompleted
event once the reset is done.
sourcefn clear_output_buffers(&mut self) -> Result<(), VideoError>
fn clear_output_buffers(&mut self) -> Result<(), VideoError>
Immediately release all buffers passed using use_output_buffer()
and
reuse_output_buffer()
.
sourcefn event_pipe(&self) -> &dyn AsRawDescriptor
fn event_pipe(&self) -> &dyn AsRawDescriptor
Returns the event pipe on which the availability of events will be signaled. Note that the returned value is borrowed and only valid as long as the session is alive.
sourcefn use_output_buffer(
&mut self,
picture_buffer_id: i32,
resource: GuestResource
) -> Result<(), VideoError>
fn use_output_buffer( &mut self, picture_buffer_id: i32, resource: GuestResource ) -> Result<(), VideoError>
Ask the device to use resource
to store decoded frames according to its layout.
picture_buffer_id
is the ID of the picture that will be reproduced in PictureReady
events using this buffer.
The device takes ownership of resource
and is responsible for closing it once the buffer
is not used anymore (either when the session is closed, or a new set of buffers is provided
for the session).
The device will emit a PictureReady
event with the picture_buffer_id
field set to the
same value as the argument of the same name when a frame has been decoded into that buffer.
sourcefn reuse_output_buffer(
&mut self,
picture_buffer_id: i32
) -> Result<(), VideoError>
fn reuse_output_buffer( &mut self, picture_buffer_id: i32 ) -> Result<(), VideoError>
Ask the device to reuse an output buffer previously passed to
use_output_buffer
and that has previously been returned to the decoder
in a PictureReady
event.
The device will emit a PictureReady
event with the picture_buffer_id
field set to the same value as the argument of the same name when a
frame has been decoded into that buffer.
sourcefn read_event(&mut self) -> Result<DecoderEvent, VideoError>
fn read_event(&mut self) -> Result<DecoderEvent, VideoError>
Blocking call to read a single event from the event pipe.