pub struct Header {
pub source: HeaderSource,
pub version: Option<Version>,
pub layer: Option<Layer>,
pub mode: Option<Mode>,
pub min_channel_count: u8,
pub max_channel_count: u8,
pub min_sample_rate_hz: u16,
pub max_sample_rate_hz: u16,
pub total_sample_count: u64,
pub total_duration: Duration,
pub avg_sample_rate_hz: Option<u16>,
pub avg_bitrate_bps: Option<u32>,
}
Expand description
Properties of an MPEG audio stream
A virtual MPEG audio header, built from both the XING header and optionally aggregated from all valid MPEG frame headers.
Fields§
§source: HeaderSource
Source of the metadata in this header
version: Option<Version>
MPEG version
The common MPEG version in all frames or None
if either unknown or inconsistent.
layer: Option<Layer>
MPEG layer
The common MPEG layer in all frames or None
if either unknown or inconsistent.
mode: Option<Mode>
MPEG mode
The common MPEG mode in all frames or None
if either unknown or inconsistent.
min_channel_count: u8
Minimum number of channels
max_channel_count: u8
Maximum number of channels
min_sample_rate_hz: u16
Minimum sample rate in Hz
max_sample_rate_hz: u16
Maximum sample rate in Hz
total_sample_count: u64
Total number of samples per channel
total_duration: Duration
Total duration
avg_sample_rate_hz: Option<u16>
Average sample rate in Hz
avg_bitrate_bps: Option<u32>
Average bitrate in bits/sec
Implementations§
Source§impl Header
impl Header
Sourcepub fn read_from_source(
source: &mut impl Read,
parse_mode: ParseMode,
) -> PositionalResult<Self>
pub fn read_from_source( source: &mut impl Read, parse_mode: ParseMode, ) -> PositionalResult<Self>
Read from a source
that implements Read
§Errors
Returns a PositionalError
on any kind of failure.
§Examples
use std::{path::Path, fs::File, io::BufReader};
use mpeg_audio_header::{Header, ParseMode};
let path = Path::new("test/source.mp3");
let file = File::open(path).unwrap();
let mut source = BufReader::new(file);
let header = Header::read_from_source(&mut source, ParseMode::IgnoreVbrHeaders).unwrap();
println!("MPEG audio header: {:?}", header);
Sourcepub fn read_from_file(
file: &File,
parse_mode: ParseMode,
) -> PositionalResult<Self>
pub fn read_from_file( file: &File, parse_mode: ParseMode, ) -> PositionalResult<Self>
Read from a file
§Errors
Returns a PositionalError
on any kind of failure.
§Examples
use std::{path::Path, fs::File};
use mpeg_audio_header::{Header, ParseMode};
let path = Path::new("test/source.mp3");
let file = File::open(path).unwrap();
let header = Header::read_from_file(&file, ParseMode::PreferVbrHeaders).unwrap();
println!("MPEG audio header: {:?}", header);
Sourcepub fn read_from_path(
path: impl AsRef<Path>,
parse_mode: ParseMode,
) -> PositionalResult<Self>
pub fn read_from_path( path: impl AsRef<Path>, parse_mode: ParseMode, ) -> PositionalResult<Self>
Read from a file path
§Errors
Returns a PositionalError
on any kind of failure.
§Examples
use std::path::Path;
use mpeg_audio_header::{Header, ParseMode};
let path = Path::new("test/source.mp3");
let header = Header::read_from_path(&path, ParseMode::PreferVbrHeaders).unwrap();
println!("MPEG audio header: {:?}", header);