From 1b546700d552caeb970a1751862b8b5a2585fe9c Mon Sep 17 00:00:00 2001 From: Serial <69764315+Serial-ATA@users.noreply.github.com> Date: Wed, 10 Aug 2022 14:13:29 -0400 Subject: [PATCH] MPEG: Change remaining references to `mp3` to `mpeg` --- CHANGELOG.md | 5 ++++- src/ape/tag/mod.rs | 2 +- src/file.rs | 2 +- src/id3/v2/tag.rs | 2 +- src/lib.rs | 4 ++-- src/{mp3 => mpeg}/constants.rs | 0 src/{mp3 => mpeg}/header.rs | 0 src/{mp3 => mpeg}/mod.rs | 4 ++-- src/{mp3 => mpeg}/properties.rs | 14 +++++++------- src/{mp3 => mpeg}/read.rs | 4 ++-- src/{mp3 => mpeg}/write.rs | 0 src/probe.rs | 4 ++-- src/properties.rs | 8 ++++---- src/tag/utils.rs | 4 ++-- tests/files/zero_sized.rs | 2 +- tests/fuzz/mpegfile_read_from.rs | 2 +- 16 files changed, 30 insertions(+), 27 deletions(-) rename src/{mp3 => mpeg}/constants.rs (100%) rename src/{mp3 => mpeg}/header.rs (100%) rename src/{mp3 => mpeg}/mod.rs (91%) rename src/{mp3 => mpeg}/properties.rs (94%) rename src/{mp3 => mpeg}/read.rs (98%) rename src/{mp3 => mpeg}/write.rs (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index f0074a2f..6094ec93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,7 +20,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - **TaggedFile**: `tag{_mut}` no longer takes a reference to `TagType` - **ID3v2**: `LanguageFrame`'s `lang` field has changed type - `String` -> `[u8; 3]` -- **MP3**: Renamed `MP3File` -> `MPEGFile` +- **MP3**: + - Renamed `lofty::mp3` -> `lofty::mpeg` + - Renamed `MP3File` -> `MPEGFile` + - Renamed `MP3Properties` -> `MPEGProperties` - **MP4**: `Atom::data` will now return all values - **Vorbis Comments**: Recognize lowercase `METADATA_BLOCK_PICTURE` as a picture ([issue](https://github.com/Serial-ATA/lofty-rs/issues/60)) diff --git a/src/ape/tag/mod.rs b/src/ape/tag/mod.rs index 9d11625b..3ab8326e 100644 --- a/src/ape/tag/mod.rs +++ b/src/ape/tag/mod.rs @@ -53,7 +53,7 @@ macro_rules! impl_accessor { /// ## Supported file types /// /// * [`FileType::APE`](crate::FileType::APE) -/// * [`FileType::MP3`](crate::FileType::MPEG) +/// * [`FileType::MPEG`](crate::FileType::MPEG) /// * [`FileType::WavPack`](crate::FileType::WavPack) /// /// ## Item storage diff --git a/src/file.rs b/src/file.rs index 4dd6ddac..2a4024c1 100644 --- a/src/file.rs +++ b/src/file.rs @@ -728,7 +728,7 @@ impl FileType { } fn quick_type_guess(buf: &[u8]) -> Option { - use crate::mp3::header::verify_frame_sync; + use crate::mpeg::header::verify_frame_sync; // Safe to index, since we return early on an empty buffer match buf[0] { diff --git a/src/id3/v2/tag.rs b/src/id3/v2/tag.rs index 4cffecbc..8264ab64 100644 --- a/src/id3/v2/tag.rs +++ b/src/id3/v2/tag.rs @@ -64,7 +64,7 @@ macro_rules! impl_accessor { /// /// ## Supported file types /// -/// * [`FileType::MP3`](crate::FileType::MPEG) +/// * [`FileType::MPEG`](crate::FileType::MPEG) /// * [`FileType::WAV`](crate::FileType::WAV) /// * [`FileType::AIFF`](crate::FileType::AIFF) /// * [`FileType::APE`](crate::FileType::APE) **(READ ONLY)** diff --git a/src/lib.rs b/src/lib.rs index 886871ba..981b6be3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -91,7 +91,7 @@ //! ```rust //! # use lofty::LoftyError; //! # fn main() -> Result<(), LoftyError> { -//! use lofty::mp3::MPEGFile; +//! use lofty::mpeg::MPEGFile; //! use lofty::{AudioFile, TagType}; //! use std::fs::File; //! @@ -184,8 +184,8 @@ pub mod flac; pub mod id3; pub mod iff; pub(crate) mod macros; -pub mod mp3; pub mod mp4; +pub mod mpeg; pub mod ogg; pub(crate) mod picture; mod probe; diff --git a/src/mp3/constants.rs b/src/mpeg/constants.rs similarity index 100% rename from src/mp3/constants.rs rename to src/mpeg/constants.rs diff --git a/src/mp3/header.rs b/src/mpeg/header.rs similarity index 100% rename from src/mp3/header.rs rename to src/mpeg/header.rs diff --git a/src/mp3/mod.rs b/src/mpeg/mod.rs similarity index 91% rename from src/mp3/mod.rs rename to src/mpeg/mod.rs index c29f71b3..b55c020a 100644 --- a/src/mp3/mod.rs +++ b/src/mpeg/mod.rs @@ -6,7 +6,7 @@ mod read; pub(crate) mod write; pub use header::{ChannelMode, Emphasis, Layer, MpegVersion}; -pub use properties::Mp3Properties; +pub use properties::MPEGProperties; #[cfg(feature = "ape")] use crate::ape::tag::ApeTag; @@ -34,5 +34,5 @@ pub struct MPEGFile { #[lofty(tag_type = "APE")] pub(crate) ape_tag: Option, /// The file's audio properties - pub(crate) properties: Mp3Properties, + pub(crate) properties: MPEGProperties, } diff --git a/src/mp3/properties.rs b/src/mpeg/properties.rs similarity index 94% rename from src/mp3/properties.rs rename to src/mpeg/properties.rs index b9a0c59a..413fbe4f 100644 --- a/src/mp3/properties.rs +++ b/src/mpeg/properties.rs @@ -1,6 +1,6 @@ use super::header::{ChannelMode, Emphasis, Header, Layer, MpegVersion, XingHeader}; use crate::error::Result; -use crate::mp3::header::{cmp_header, rev_search_for_frame_sync, HeaderCmpResult}; +use crate::mpeg::header::{cmp_header, rev_search_for_frame_sync, HeaderCmpResult}; use crate::properties::FileProperties; use std::io::{Read, Seek, SeekFrom}; @@ -10,8 +10,8 @@ use byteorder::{BigEndian, ReadBytesExt}; #[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] #[non_exhaustive] -/// An MP3 file's audio properties -pub struct Mp3Properties { +/// An MPEG file's audio properties +pub struct MPEGProperties { pub(crate) version: MpegVersion, pub(crate) layer: Layer, pub(crate) duration: Duration, @@ -26,8 +26,8 @@ pub struct Mp3Properties { pub(crate) emphasis: Emphasis, } -impl From for FileProperties { - fn from(input: Mp3Properties) -> Self { +impl From for FileProperties { + fn from(input: MPEGProperties) -> Self { Self { duration: input.duration, overall_bitrate: Some(input.overall_bitrate), @@ -39,7 +39,7 @@ impl From for FileProperties { } } -impl Mp3Properties { +impl MPEGProperties { /// Duration pub fn duration(&self) -> Duration { self.duration @@ -102,7 +102,7 @@ impl Mp3Properties { } pub(super) fn read_properties( - properties: &mut Mp3Properties, + properties: &mut MPEGProperties, reader: &mut R, first_frame: (Header, u64), mut last_frame_offset: u64, diff --git a/src/mp3/read.rs b/src/mpeg/read.rs similarity index 98% rename from src/mp3/read.rs rename to src/mpeg/read.rs index efe70a27..568e5b31 100644 --- a/src/mp3/read.rs +++ b/src/mpeg/read.rs @@ -1,5 +1,5 @@ use super::header::{cmp_header, search_for_frame_sync, Header, HeaderCmpResult, XingHeader}; -use super::{MPEGFile, Mp3Properties}; +use super::{MPEGFile, MPEGProperties}; use crate::ape::constants::APE_PREAMBLE; use crate::ape::header::read_ape_header; #[cfg(feature = "ape")] @@ -133,7 +133,7 @@ where } let last_frame_offset = reader.stream_position()?; - file.properties = Mp3Properties::default(); + file.properties = MPEGProperties::default(); if read_properties { let first_frame_header = match first_frame_header { diff --git a/src/mp3/write.rs b/src/mpeg/write.rs similarity index 100% rename from src/mp3/write.rs rename to src/mpeg/write.rs diff --git a/src/probe.rs b/src/probe.rs index 38d9c92d..3cceb14d 100644 --- a/src/probe.rs +++ b/src/probe.rs @@ -5,9 +5,9 @@ use crate::flac::FlacFile; use crate::iff::aiff::AiffFile; use crate::iff::wav::WavFile; use crate::macros::err; -use crate::mp3::header::search_for_frame_sync; -use crate::mp3::MPEGFile; use crate::mp4::Mp4File; +use crate::mpeg::header::search_for_frame_sync; +use crate::mpeg::MPEGFile; use crate::ogg::opus::OpusFile; use crate::ogg::speex::SpeexFile; use crate::ogg::vorbis::VorbisFile; diff --git a/src/properties.rs b/src/properties.rs index 5f61ca08..67ece088 100644 --- a/src/properties.rs +++ b/src/properties.rs @@ -62,8 +62,8 @@ mod tests { use crate::ape::{ApeFile, ApeProperties}; use crate::flac::FlacFile; use crate::iff::{AiffFile, WavFile, WavFormat, WavProperties}; - use crate::mp3::{ChannelMode, Emphasis, Layer, MPEGFile, Mp3Properties, MpegVersion}; use crate::mp4::{AudioObjectType, Mp4Codec, Mp4File, Mp4Properties}; + use crate::mpeg::{ChannelMode, Emphasis, Layer, MPEGFile, MPEGProperties, MpegVersion}; use crate::ogg::{ OpusFile, OpusProperties, SpeexFile, SpeexProperties, VorbisFile, VorbisProperties, }; @@ -105,7 +105,7 @@ mod tests { channels: Some(2), }; - const MP1_PROPERTIES: Mp3Properties = Mp3Properties { + const MP1_PROPERTIES: MPEGProperties = MPEGProperties { version: MpegVersion::V1, layer: Layer::Layer1, channel_mode: ChannelMode::Stereo, @@ -120,7 +120,7 @@ mod tests { emphasis: Emphasis::None, }; - const MP2_PROPERTIES: Mp3Properties = Mp3Properties { + const MP2_PROPERTIES: MPEGProperties = MPEGProperties { version: MpegVersion::V1, layer: Layer::Layer2, channel_mode: ChannelMode::Stereo, @@ -135,7 +135,7 @@ mod tests { emphasis: Emphasis::None, }; - const MP3_PROPERTIES: Mp3Properties = Mp3Properties { + const MP3_PROPERTIES: MPEGProperties = MPEGProperties { version: MpegVersion::V1, layer: Layer::Layer3, channel_mode: ChannelMode::Stereo, diff --git a/src/tag/utils.rs b/src/tag/utils.rs index dfc9216d..878bb8a3 100644 --- a/src/tag/utils.rs +++ b/src/tag/utils.rs @@ -2,7 +2,7 @@ use crate::error::Result; use crate::file::FileType; use crate::macros::err; use crate::tag::{Tag, TagType}; -use crate::{ape, iff, mp3, wavpack}; +use crate::{ape, iff, mpeg, wavpack}; #[cfg(feature = "id3v1")] use crate::id3::v1::tag::Id3v1TagRef; @@ -31,7 +31,7 @@ pub(crate) fn write_tag(tag: &Tag, file: &mut File, file_type: FileType) -> Resu FileType::FLAC | FileType::Opus | FileType::Speex | FileType::Vorbis => { crate::ogg::write::write_to(file, tag, file_type) }, - FileType::MPEG => mp3::write::write_to(file, tag), + FileType::MPEG => mpeg::write::write_to(file, tag), #[cfg(feature = "mp4_ilst")] FileType::MP4 => { crate::mp4::ilst::write::write_to(file, &mut Into::::into(tag.clone()).as_ref()) diff --git a/tests/files/zero_sized.rs b/tests/files/zero_sized.rs index b3bc31b0..223e6597 100644 --- a/tests/files/zero_sized.rs +++ b/tests/files/zero_sized.rs @@ -1,8 +1,8 @@ use lofty::ape::ApeFile; use lofty::flac::FlacFile; use lofty::iff::{AiffFile, WavFile}; -use lofty::mp3::MPEGFile; use lofty::mp4::Mp4File; +use lofty::mpeg::MPEGFile; use lofty::AudioFile; fn read_file_with_properties(path: &str) -> bool { diff --git a/tests/fuzz/mpegfile_read_from.rs b/tests/fuzz/mpegfile_read_from.rs index 69cfee62..2048526e 100644 --- a/tests/fuzz/mpegfile_read_from.rs +++ b/tests/fuzz/mpegfile_read_from.rs @@ -1,5 +1,5 @@ use crate::oom_test; -use lofty::mp3::MPEGFile; +use lofty::mpeg::MPEGFile; #[test] fn oom1() {