Trait Decoder
pub trait Decoder: Send + Sync {
// Required methods
fn try_new(
params: &CodecParameters,
options: &DecoderOptions,
) -> Result<Self, Error> ⓘ
where Self: Sized;
fn supported_codecs() -> &'static [CodecDescriptor] ⓘ
where Self: Sized;
fn reset(&mut self);
fn codec_params(&self) -> &CodecParameters;
fn decode(&mut self, packet: &Packet) -> Result<AudioBufferRef<'_>, Error> ⓘ;
fn finalize(&mut self) -> FinalizeResult;
fn last_decoded(&self) -> AudioBufferRef<'_>;
}
dep_symphonia
only.Expand description
A Decoder
implements a codec’s decode algorithm. It consumes Packet
s and produces
AudioBuffer
s.
Required Methods§
fn try_new(
params: &CodecParameters,
options: &DecoderOptions,
) -> Result<Self, Error> ⓘwhere
Self: Sized,
fn try_new(
params: &CodecParameters,
options: &DecoderOptions,
) -> Result<Self, Error> ⓘwhere
Self: Sized,
Attempts to instantiates a Decoder
using the provided CodecParameters
.
fn supported_codecs() -> &'static [CodecDescriptor] ⓘwhere
Self: Sized,
fn supported_codecs() -> &'static [CodecDescriptor] ⓘwhere
Self: Sized,
Gets a list of codec descriptors for the codecs supported by this Decoder.
fn reset(&mut self)
fn reset(&mut self)
Reset the Decoder
.
A decoder must be reset when the next packet is discontinuous with respect to the last decoded packet. Most notably, this occurs after a seek.
For codecs that do a lot of pre-computation, reset should only reset the absolute minimum amount of state.
fn codec_params(&self) -> &CodecParameters
fn codec_params(&self) -> &CodecParameters
Gets a reference to an updated set of CodecParameters
based on the parameters the
Decoder
was instantiated with.
fn decode(&mut self, packet: &Packet) -> Result<AudioBufferRef<'_>, Error> ⓘ
fn decode(&mut self, packet: &Packet) -> Result<AudioBufferRef<'_>, Error> ⓘ
Decodes a Packet
of audio data and returns a copy-on-write generic (untyped) audio buffer
of the decoded audio.
If a DecodeError
or IoError
is returned, the packet is undecodeable and should be
discarded. Decoding may be continued with the next packet. If ResetRequired
is returned,
consumers of the decoded audio data should expect the duration and SignalSpec
of the
decoded audio buffer to change. All other errors are unrecoverable.
Implementors of decoders must clear
the internal buffer if an error occurs.
fn finalize(&mut self) -> FinalizeResult
fn finalize(&mut self) -> FinalizeResult
Optionally, obtain post-decode information such as the verification status.
fn last_decoded(&self) -> AudioBufferRef<'_>
fn last_decoded(&self) -> AudioBufferRef<'_>
Allows read access to the internal audio buffer.
After a successful call to decode
, this will contain the audio content of the last decoded
Packet
. If the last call to decode
resulted in an error, then implementors must ensure
the returned audio buffer has zero length.