Skip to main content

NativeAudioDecoder

Struct NativeAudioDecoder 

Source
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

Source

pub fn set_decode_policy(&mut self, policy: DecodePolicy)

Selects strict failure (default) or bounded, reported recovery.

Source

pub fn set_decode_reporter( &mut self, reporter: impl Fn(DecodeDiagnostic) + Send + Sync + 'static, )

Receives each diagnostic before recovery continues, including before errors.

Source

pub fn decode_diagnostics(&self) -> &DecodeDiagnostics

Cumulative corruption and concealment diagnostics, including seeks.

Source

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.

Source

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.

Source

pub const fn channels(&self) -> usize

Channels of every block this decoder returns: the source’s, 1 to MAX_AUDIO_CHANNELS.

Source

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.

Source

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.

Source

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

Source§

fn streams(&self) -> &[StreamInfo]

Returns deterministic stream metadata and stream selection.
Source§

fn flush(&mut self) -> Result<(), DecodeError>

Flushes queued packets and frames without changing stream selection. Read more
Source§

fn seek( &mut self, request: DecodeRequest, cancel: &CancelToken, ) -> Result<DecodeResult, DecodeError>

Seeks and returns what is presented at the request’s time. Read more
Source§

fn decode_next( &mut self, cancel: &CancelToken, ) -> Result<DecodeEvent, DecodeError>

Advances packet draining by one observable event. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,