pub struct NativeAudioDecoder { /* private fields */ }Expand description
Streaming FFmpeg audio decoder normalized to project-rate planar f32.
Blocks keep the stream’s channel order (NativeAudioDecoder::speakers). swresample converts
each frame to f32 at its own rate, rematrixing only a frame whose layout differs from the
stream’s; the source timeline places it by timestamp and alpha2_audio::Resampler (shared with
the browser host) 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 linked FFmpeg 8 libraries.
§Errors
Returns a platform-neutral error for invalid rates, missing streams, unsupported layouts, codec failures, or malformed decoded audio.
Sourcepub fn open_stream(
path: impl AsRef<Path>,
project_sample_rate: u32,
stream: Option<u32>,
) -> Result<Self, DecodeError>
pub fn open_stream( path: impl AsRef<Path>, project_sample_rate: u32, stream: Option<u32>, ) -> Result<Self, DecodeError>
Decodes audio stream stream, counted over the file’s audio streams in demuxer order
(ProbeResult::audio_stream); None decodes the selected one, as Self::open does.
§Errors
As Self::open, and Unsupported when the file has no such audio stream.
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 feeds: the stream’s declared layout, or its count’s default.
Sourcepub const fn speakers_assumed(&self) -> bool
pub const fn speakers_assumed(&self) -> bool
Whether the stream declares no layout, so Self::speakers is a default.
Sourcepub fn audio_duration(&self) -> Option<MediaTime>
pub fn audio_duration(&self) -> Option<MediaTime>
Effective end of the selected audio source.
Containers often declare a slightly longer duration than the stream (priming, time-base rounding). Projects authored in a browser use the container duration, so it is kept as the source boundary.
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