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.
Trait Implementations§
Source§impl Decoder for NativeAudioDecoder
impl Decoder for NativeAudioDecoder
Source§fn streams(&self) -> &[StreamInfo]
fn streams(&self) -> &[StreamInfo]
Source§fn flush(&mut self) -> Result<(), DecodeError>
fn flush(&mut self) -> Result<(), DecodeError>
Source§fn seek(
&mut self,
request: DecodeRequest,
cancel: &CancelToken,
) -> Result<DecodeResult, DecodeError>
fn seek( &mut self, request: DecodeRequest, cancel: &CancelToken, ) -> Result<DecodeResult, DecodeError>
Source§fn decode_next(
&mut self,
cancel: &CancelToken,
) -> Result<DecodeEvent, DecodeError>
fn decode_next( &mut self, cancel: &CancelToken, ) -> Result<DecodeEvent, DecodeError>
Auto Trait Implementations§
impl !RefUnwindSafe for NativeAudioDecoder
impl !Sync for NativeAudioDecoder
impl !UnwindSafe for NativeAudioDecoder
impl Freeze for NativeAudioDecoder
impl Send for NativeAudioDecoder
impl Unpin for NativeAudioDecoder
impl UnsafeUnpin for NativeAudioDecoder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more