pub struct NativeAudioDecoder { /* private fields */ }Expand description
Streaming FFmpeg audio decoder normalized to project-rate planar f32.
Blocks keep the stream’s channels in its own order and name the speaker
each feeds (NativeAudioDecoder::speakers). swresample turns each
decoded frame into f32 at its own rate, rematrixing only a frame whose
layout differs from the stream’s; the source timeline places it by
its timestamp and alpha2_audio::Resampler, the converter a browser host
runs as wasm, brings it to the project rate.
Implementations§
Source§impl NativeAudioDecoder
impl NativeAudioDecoder
Sourcepub fn set_decode_policy(&mut self, policy: DecodePolicy)
pub fn set_decode_policy(&mut self, policy: DecodePolicy)
Selects strict failure (default) or bounded, reported recovery.
Sourcepub fn set_decode_reporter(
&mut self,
reporter: impl Fn(DecodeDiagnostic) + Send + Sync + 'static,
)
pub fn set_decode_reporter( &mut self, reporter: impl Fn(DecodeDiagnostic) + Send + Sync + 'static, )
Receives each diagnostic before recovery continues, including before errors.
Sourcepub fn decode_diagnostics(&self) -> &DecodeDiagnostics
pub fn decode_diagnostics(&self) -> &DecodeDiagnostics
Cumulative corruption and concealment diagnostics, including seeks.
Sourcepub fn open(
path: impl AsRef<Path>,
project_sample_rate: u32,
) -> Result<Self, DecodeError>
pub fn open( path: impl AsRef<Path>, project_sample_rate: u32, ) -> Result<Self, DecodeError>
Decodes the selected audio stream through the installed FFmpeg 8 runtime.
Stream selection and decoding use the linked FFmpeg libraries through
rsmpeg; no command-line program is spawned. Sample-rate conversion is
alpha2_audio::Resampler.
§Errors
Returns a platform-neutral error for invalid rates, missing streams, unsupported layouts, codec failures, or malformed decoded audio.
Sourcepub fn set_block_frames(&mut self, frames: usize) -> Result<(), DecodeError>
pub fn set_block_frames(&mut self, frames: usize) -> Result<(), DecodeError>
Sets the maximum observable block size returned by decode_next.
§Errors
Returns DecodeError::OutOfRange for zero frames.
Sourcepub const fn channels(&self) -> usize
pub const fn channels(&self) -> usize
Channels of every block this decoder returns: the source’s, 1 to
MAX_AUDIO_CHANNELS.
Sourcepub const fn speakers(&self) -> SpeakerLayout
pub const fn speakers(&self) -> SpeakerLayout
The speaker each plane of every block feeds: the layout the stream declares, in its own order, or the default for its channel count.
Sourcepub const fn speakers_assumed(&self) -> bool
pub const fn speakers_assumed(&self) -> bool
Whether the stream declares no layout, so Self::speakers is the
default for its channel count rather than what it says.
Sourcepub fn audio_duration(&self) -> Option<MediaTime>
pub fn audio_duration(&self) -> Option<MediaTime>
Effective end of the selected audio source.
Containers commonly declare a slightly longer presentation duration than the selected stream because of codec priming and time-base rounding. Browser-authored projects use that container duration, so the adapter preserves it as the source boundary instead of rejecting the final presentation window.