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(
source: impl Into<SourceLocation>,
project_sample_rate: u32,
) -> Result<Self, DecodeError>
pub fn open( source: impl Into<SourceLocation>, 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(
source: impl Into<SourceLocation>,
project_sample_rate: u32,
stream: Option<u32>,
) -> Result<Self, DecodeError>
pub fn open_stream( source: impl Into<SourceLocation>, 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>
Source§impl WindowedAudioDecoder for NativeAudioDecoder
Available on crate feature timeline only.The desktop decoder behind the host’s audio windows.
impl WindowedAudioDecoder for NativeAudioDecoder
timeline only.The desktop decoder behind the host’s audio windows.
Auto Trait Implementations§
impl !RefUnwindSafe for NativeAudioDecoder
impl !Sync for NativeAudioDecoder
impl !UnwindSafe for NativeAudioDecoder
impl Forget for NativeAudioDecoder
impl Freeze for NativeAudioDecoderwhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
*const ArcInner<RemoteObject> is !null: Freeze,
PhantomData<ArcInner<RemoteObject>>: Freeze,
*const AVFormatContext is !null: Freeze,
*const AVIOContext is !null: Freeze,
*const Opaque is !null: Freeze,
PhantomData<Opaque>: Freeze,
*const ArcInner<Mutex<Option<Error>>> is !null: Freeze,
PhantomData<ArcInner<Mutex<Option<Error>>>>: Freeze,
*const ArcInner<InputInterrupt> is !null: Freeze,
PhantomData<ArcInner<InputInterrupt>>: Freeze,
PhantomData<StreamInfo>: Freeze,
*const AVCodecContext is !null: Freeze,
*const SwrContext is !null: Freeze,
*const AVChannelLayout is !null: Freeze,
PhantomData<Segment>: Freeze,
PhantomData<VecDeque<f32>>: Freeze,
*const dyn Fn(DecodeDiagnostic) + Sync + Send is !null: Freeze,
PhantomData<dyn Fn(DecodeDiagnostic) + Sync + Send>: Freeze,
PhantomData<CorruptPacket>: Freeze,
PhantomData<ConcealedAudioGap>: Freeze,
PhantomData<DroppedAudioOverlap>: Freeze,
PhantomData<VideoRecoveryGap>: Freeze,
PhantomData<Result<Option<AVPacket>, RsmpegError>>: Freeze,
impl Move for NativeAudioDecoder
impl Send for NativeAudioDecoderwhere
RawVecInner: Send,
Arc<RemoteObject>: Send,
AVFormatContextInput: Send,
AVIOContext: Send,
BoxRaw<Opaque>: Send,
Arc<Mutex<Option<Error>>>: Send,
Arc<InputInterrupt>: Send,
AVCodecContext: Send,
SwrContext: Send,
AVChannelLayout: Send,
BoxRaw<dyn Fn(DecodeDiagnostic) + Sync + Send>: Send,
&'static str: Send,
AVPacket: Send,
impl Unpin for NativeAudioDecoderwhere
*const u8 is !null: Unpin,
Arc<RemoteObject>: Unpin,
*const AVFormatContext is !null: Unpin,
*const AVIOContext is !null: Unpin,
Box<Opaque>: Unpin,
Arc<Mutex<Option<Error>>>: Unpin,
Arc<InputInterrupt>: Unpin,
*const AVCodecContext is !null: Unpin,
*const SwrContext is !null: Unpin,
*const AVChannelLayout is !null: Unpin,
Box<dyn Fn(DecodeDiagnostic) + Sync + Send>: Unpin,
&'static str: Unpin,
*const AVPacket is !null: Unpin,
impl UnsafeUnpin for NativeAudioDecoderwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
*const ArcInner<RemoteObject> is !null: UnsafeUnpin,
PhantomData<ArcInner<RemoteObject>>: UnsafeUnpin,
*const AVFormatContext is !null: UnsafeUnpin,
*const AVIOContext is !null: UnsafeUnpin,
*const Opaque is !null: UnsafeUnpin,
PhantomData<Opaque>: UnsafeUnpin,
*const ArcInner<Mutex<Option<Error>>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Mutex<Option<Error>>>>: UnsafeUnpin,
*const ArcInner<InputInterrupt> is !null: UnsafeUnpin,
PhantomData<ArcInner<InputInterrupt>>: UnsafeUnpin,
PhantomData<StreamInfo>: UnsafeUnpin,
*const AVCodecContext is !null: UnsafeUnpin,
*const SwrContext is !null: UnsafeUnpin,
*const AVChannelLayout is !null: UnsafeUnpin,
PhantomData<Segment>: UnsafeUnpin,
PhantomData<VecDeque<f32>>: UnsafeUnpin,
*const dyn Fn(DecodeDiagnostic) + Sync + Send is !null: UnsafeUnpin,
PhantomData<dyn Fn(DecodeDiagnostic) + Sync + Send>: UnsafeUnpin,
PhantomData<CorruptPacket>: UnsafeUnpin,
PhantomData<ConcealedAudioGap>: UnsafeUnpin,
PhantomData<DroppedAudioOverlap>: UnsafeUnpin,
PhantomData<VideoRecoveryGap>: UnsafeUnpin,
PhantomData<Result<Option<AVPacket>, RsmpegError>>: UnsafeUnpin,
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