mirror of
https://github.com/Serial-ATA/lofty-rs
synced 2024-12-12 21:52:33 +00:00
Misc: Add tests and extension detection for MP1 and MP2
This commit is contained in:
parent
903531e07f
commit
69436e5c0a
5 changed files with 51 additions and 1 deletions
|
@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
- **FileType**: `FileType::from_ext` detects MP1/MP2 as `FileType::MP3`, allowing these files to be read with
|
||||
`read_from_path`/`Probe::open`.
|
||||
|
||||
### Fixed
|
||||
- **Tag**: The `Accessor::set_*` methods will stop falling through, and adding empty strings
|
||||
|
||||
|
|
|
@ -577,7 +577,7 @@ impl FileType {
|
|||
match ext.as_str() {
|
||||
"ape" => Some(Self::APE),
|
||||
"aiff" | "aif" | "afc" | "aifc" => Some(Self::AIFF),
|
||||
"mp3" => Some(Self::MP3),
|
||||
"mp3" | "mp2" | "mp1" => Some(Self::MP3),
|
||||
"wav" | "wave" => Some(Self::WAV),
|
||||
"wv" => Some(Self::WavPack),
|
||||
"opus" => Some(Self::Opus),
|
||||
|
|
|
@ -105,6 +105,36 @@ mod tests {
|
|||
channels: Some(2),
|
||||
};
|
||||
|
||||
const MP1_PROPERTIES: Mp3Properties = Mp3Properties {
|
||||
version: MpegVersion::V1,
|
||||
layer: Layer::Layer1,
|
||||
channel_mode: ChannelMode::Stereo,
|
||||
mode_extension: None,
|
||||
copyright: false,
|
||||
original: true,
|
||||
duration: Duration::from_millis(588), // FFmpeg reports 576, possibly an issue
|
||||
overall_bitrate: 383, // TODO: FFmpeg reports 392
|
||||
audio_bitrate: 384,
|
||||
sample_rate: 32000,
|
||||
channels: 2,
|
||||
emphasis: Emphasis::None,
|
||||
};
|
||||
|
||||
const MP2_PROPERTIES: Mp3Properties = Mp3Properties {
|
||||
version: MpegVersion::V1,
|
||||
layer: Layer::Layer2,
|
||||
channel_mode: ChannelMode::Stereo,
|
||||
mode_extension: None,
|
||||
copyright: false,
|
||||
original: true,
|
||||
duration: Duration::from_millis(1344), // TODO: FFmpeg reports 1440 here
|
||||
overall_bitrate: 411, // FFmpeg reports 384, related to above issue
|
||||
audio_bitrate: 384,
|
||||
sample_rate: 48000,
|
||||
channels: 2,
|
||||
emphasis: Emphasis::None,
|
||||
};
|
||||
|
||||
const MP3_PROPERTIES: Mp3Properties = Mp3Properties {
|
||||
version: MpegVersion::V1,
|
||||
layer: Layer::Layer3,
|
||||
|
@ -254,6 +284,22 @@ mod tests {
|
|||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mp1_properties() {
|
||||
assert_eq!(
|
||||
get_properties::<Mp3File>("tests/files/assets/minimal/full_test.mp1"),
|
||||
MP1_PROPERTIES
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mp2_properties() {
|
||||
assert_eq!(
|
||||
get_properties::<Mp3File>("tests/files/assets/minimal/full_test.mp2"),
|
||||
MP2_PROPERTIES
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mp3_properties() {
|
||||
assert_eq!(
|
||||
|
|
BIN
tests/files/assets/minimal/full_test.mp1
Normal file
BIN
tests/files/assets/minimal/full_test.mp1
Normal file
Binary file not shown.
BIN
tests/files/assets/minimal/full_test.mp2
Normal file
BIN
tests/files/assets/minimal/full_test.mp2
Normal file
Binary file not shown.
Loading…
Reference in a new issue