pub struct AudioStreamInfo { /* private fields */ }Expand description
Information about an audio stream within a media file.
This struct contains all metadata needed to understand and process an audio stream, including sample rate, channel layout, and codec information.
§Construction
Use AudioStreamInfo::builder() for fluent construction:
use ff_format::stream::AudioStreamInfo;
use ff_format::SampleFormat;
use ff_format::codec::AudioCodec;
let info = AudioStreamInfo::builder()
.index(1)
.codec(AudioCodec::Aac)
.sample_rate(48000)
.channels(2)
.build();Implementations§
Source§impl AudioStreamInfo
impl AudioStreamInfo
Sourcepub fn builder() -> AudioStreamInfoBuilder
pub fn builder() -> AudioStreamInfoBuilder
Creates a new builder for constructing AudioStreamInfo.
§Examples
use ff_format::stream::AudioStreamInfo;
use ff_format::codec::AudioCodec;
use ff_format::SampleFormat;
let info = AudioStreamInfo::builder()
.index(1)
.codec(AudioCodec::Aac)
.sample_rate(48000)
.channels(2)
.build();Sourcepub const fn codec(&self) -> AudioCodec
pub const fn codec(&self) -> AudioCodec
Returns the audio codec.
Sourcepub fn codec_name(&self) -> &str
pub fn codec_name(&self) -> &str
Returns the codec name as reported by the demuxer.
Sourcepub const fn sample_rate(&self) -> u32
pub const fn sample_rate(&self) -> u32
Returns the sample rate in Hz.
Sourcepub const fn channels(&self) -> u32
pub const fn channels(&self) -> u32
Returns the number of audio channels.
The type is u32 to match FFmpeg’s AVCodecParameters::ch_layout.nb_channels
and professional audio APIs. When passing to rodio or cpal (which require
u16), cast with info.channels() as u16 — channel counts never exceed
u16::MAX in practice.
Sourcepub const fn channel_layout(&self) -> ChannelLayout
pub const fn channel_layout(&self) -> ChannelLayout
Returns the channel layout.
Sourcepub const fn sample_format(&self) -> SampleFormat
pub const fn sample_format(&self) -> SampleFormat
Returns the sample format.
Sourcepub const fn is_surround(&self) -> bool
pub const fn is_surround(&self) -> bool
Returns true if this is a surround sound stream (more than 2 channels).
Trait Implementations§
Source§impl Clone for AudioStreamInfo
impl Clone for AudioStreamInfo
Source§fn clone(&self) -> AudioStreamInfo
fn clone(&self) -> AudioStreamInfo
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more