mp3_metadata/types.rs
1use std::time::Duration;
2
3use crate::enums::{ChannelType, Copyright, Emphasis, Genre, Layer, Status, Version, CRC};
4
5#[derive(Debug, Default, Eq, PartialEq)]
6pub struct Frame {
7 pub size: u32,
8 pub version: Version,
9 pub layer: Layer,
10 pub crc: CRC,
11 pub bitrate: u16,
12 pub sampling_freq: u16,
13 pub padding: bool,
14 pub private_bit: bool,
15 pub chan_type: ChannelType,
16 pub intensity_stereo: bool,
17 pub ms_stereo: bool,
18 pub copyright: Copyright,
19 pub status: Status,
20 pub emphasis: Emphasis,
21 pub duration: Option<Duration>,
22 pub position: Duration,
23 pub offset: u32,
24}
25
26#[derive(Debug, Eq, PartialEq)]
27pub struct MP3Metadata {
28 pub duration: Duration,
29 pub frames: Vec<Frame>,
30 pub tag: Option<AudioTag>,
31 pub optional_info: Vec<OptionalAudioTags>,
32}
33
34#[derive(Debug, Default, Eq, PartialEq)]
35pub struct AudioTag {
36 pub title: String,
37 pub artist: String,
38 pub album: String,
39 pub year: u16,
40 pub comment: String,
41 pub genre: Genre,
42}
43
44#[derive(Debug, Default, Eq, PartialEq)]
45pub struct Url(pub String);
46
47// TODO: Add picture support
48/// id3.org/id3v2.3.0#Declared_ID3v2_frames#Text_information_frames_-_details
49#[derive(Debug, Default, Eq, PartialEq)]
50pub struct OptionalAudioTags {
51 /// Corresponds to the nth frames `MP3Metadata.frame`.
52 pub position: u32,
53 pub major_version: u8,
54 pub minor_version: u8,
55 /// The 'Album/Movie/Show title' frame is intended for the title of the
56 /// recording(/source of sound) which the audio in the file is taken from.
57 pub album_movie_show: Option<String>,
58 /// The 'BPM' frame contains the number of beats per minute in the mainpart
59 /// of the audio. The BPM is an integer and represented as a numerical string.
60 pub bpm: Option<String>,
61 /// The 'Composer(s)' frame is intended for the name of the composer(s).
62 pub composers: Vec<String>,
63 /// The 'Content type', which previously was stored as a one byte numeric value
64 /// only, is now a numeric string. You may use one or several of the types as
65 /// ID3v1.1 did or, since the category list would be impossible to maintain with
66 /// accurate and up to date categories, define your own.
67 ///
68 /// References to the ID3v1 genres can be made by, as first byte, enter "("
69 /// followed by a number from the genres list (appendix A) and ended with a ")"
70 /// character. This is optionally followed by a refinement, e.g. "(21)" or
71 /// "(4)Eurodisco". Several references can be made in the same frame, e.g.
72 /// "(51)(39)". If the refinement should begin with a "(" character it should be
73 /// replaced with "((", e.g. "((I can figure out any genre)" or "(55)((I think...)".
74 /// The following new content types is defined in ID3v2 and is implemented in the
75 /// same way as the numerig content types, e.g. "(RX)".
76 pub content_type: Vec<Genre>,
77 /// The 'Copyright message' frame, which must begin with a year and a space character
78 /// (making five characters), is intended for the copyright holder of the original
79 /// sound, not the audio file itself. The absence of this frame means only that the
80 /// copyright information is unavailable or has been removed, and must not be
81 /// interpreted to mean that the sound is public domain. Every time this field is
82 /// displayed the field must be preceded with "Copyright © ".
83 pub copyright: Option<String>,
84 /// The 'Date' frame is a numeric string in the DDMM format containing the date for
85 /// the recording. This field is always four characters long.
86 pub date: Option<String>,
87 /// The 'Playlist delay' defines the numbers of milliseconds of silence between
88 /// every song in a playlist. The player should use the "ETC" frame, if present,
89 /// to skip initial silence and silence at the end of the audio to match the
90 /// 'Playlist delay' time. The time is represented as a numeric string.
91 pub playlist_delay: Option<String>,
92 /// The 'Encoded by' frame contains the name of the person or organisation that
93 /// encoded the audio file. This field may contain a copyright message, if the
94 /// audio file also is copyrighted by the encoder.
95 pub encoded_by: Option<String>,
96 /// The 'Lyricist(s)/Text writer(s)' frame is intended for the writer(s) of the text
97 /// or lyrics in the recording.
98 pub text_writers: Vec<String>,
99 /// The 'File type' frame indicates which type of audio this tag defines. The
100 /// following type and refinements are defined:
101 ///
102 /// * MPG MPEG Audio
103 /// * /1 MPEG 1/2 layer I
104 /// * /2 MPEG 1/2 layer II
105 /// * /3 MPEG 1/2 layer III
106 /// * /2.5 MPEG 2.5
107 /// * /AAC Advanced audio compression
108 /// * VQF Transform-domain Weighted Interleave Vector Quantization
109 /// * PCM Pulse Code Modulated audio
110 ///
111 /// but other types may be used, not for these types though. This is used in a
112 /// similar way to the predefined types in the "TMED" frame, but without
113 /// parentheses. If this frame is not present audio type is assumed to be "MPG".
114 pub file_type: Option<String>,
115 /// The 'Time' frame is a numeric string in the HHMM format containing the time
116 /// for the recording. This field is always four characters long.
117 pub time: Option<String>,
118 /// The 'Content group description' frame is used if the sound belongs to a larger
119 /// category of sounds/music. For example, classical music is often sorted in
120 /// different musical sections (e.g. "Piano Concerto", "Weather - Hurricane").
121 pub content_group_description: Option<String>,
122 /// The 'Subtitle/Description refinement' frame is used for information directly
123 /// related to the contents title (e.g. "Op. 16" or "Performed live at Wembley").
124 pub subtitle_refinement_description: Option<String>,
125 /// The 'Title/Songname/Content description' frame is the actual name of the
126 /// piece (e.g. "Adagio", "Hurricane Donna").
127 pub title: Option<String>,
128 /// The 'Initial key' frame contains the musical key in which the sound starts. It is
129 /// represented as a string with a maximum length of three characters. The ground
130 /// keys are represented with "A","B","C","D","E", "F" and "G" and halfkeys
131 /// represented with "b" and "#". Minor is represented as "m". Example "Cbm". Off
132 /// key is represented with an "o" only.
133 pub initial_key: Option<String>,
134 /// The 'Language(s)' frame should contain the languages of the text or lyrics spoken
135 /// or sung in the audio. The language is represented with three characters according
136 /// to ISO-639-2. If more than one language is used in the text their language codes
137 /// should follow according to their usage.
138 pub language: Option<String>,
139 /// The 'Length' frame contains the length of the audiofile in milliseconds,
140 /// represented as a numeric string.
141 pub length: Option<String>,
142 /// The 'Media type' frame describes from which media the sound originated. This may
143 /// be a text string or a reference to the predefined media types found in the list
144 /// below. References are made within "(" and ")" and are optionally followed by a
145 /// text refinement, e.g. "(MC) with four channels". If a text refinement should
146 /// begin with a "(" character it should be replaced with "((" in the same way as in
147 /// the "TCO" frame. Predefined refinements is appended after the media type, e.g.
148 /// "(CD/A)" or "(VID/PAL/VHS)".
149 ///
150 /// DIG Other digital media
151 /// /A Analog transfer from media
152 /// ///
153 /// ANA Other analog media
154 /// /WAC Wax cylinder
155 /// /8CA 8-track tape cassette
156 ///
157 /// CD CD
158 /// /A Analog transfer from media
159 /// /DD DDD
160 /// /AD ADD
161 /// /AA AAD
162 ///
163 /// LD Laserdisc
164 /// /A Analog transfer from media
165 ///
166 /// TT Turntable records
167 /// /33 33.33 rpm
168 /// /45 45 rpm
169 /// /71 71.29 rpm
170 /// /76 76.59 rpm
171 /// /78 78.26 rpm
172 /// /80 80 rpm
173 ///
174 /// MD MiniDisc
175 /// /A Analog transfer from media
176 ///
177 /// DAT DAT
178 /// /A Analog transfer from media
179 /// /1 standard, 48 kHz/16 bits, linear
180 /// /2 mode 2, 32 kHz/16 bits, linear
181 /// /3 mode 3, 32 kHz/12 bits, nonlinear, low speed
182 /// /4 mode 4, 32 kHz/12 bits, 4 channels
183 /// /5 mode 5, 44.1 kHz/16 bits, linear
184 /// /6 mode 6, 44.1 kHz/16 bits, 'wide track' play
185 ///
186 /// DCC DCC
187 /// /A Analog transfer from media
188 ///
189 /// DVD DVD
190 /// /A Analog transfer from media
191 ///
192 /// TV Television
193 /// /PAL PAL
194 /// /NTSC NTSC
195 /// /SECAM SECAM
196 ///
197 /// VID Video
198 /// /PAL PAL
199 /// /NTSC NTSC
200 /// /SECAM SECAM
201 /// /VHS VHS
202 /// /SVHS S-VHS
203 /// /BETA BETAMAX
204 ///
205 /// RAD Radio
206 /// /FM FM
207 /// /AM AM
208 /// /LW LW
209 /// /MW MW
210 ///
211 /// TEL Telephone
212 /// /I ISDN
213 ///
214 /// MC MC (normal cassette)
215 /// /4 4.75 cm/s (normal speed for a two sided cassette)
216 /// /9 9.5 cm/s
217 /// /I Type I cassette (ferric/normal)
218 /// /II Type II cassette (chrome)
219 /// /III Type III cassette (ferric chrome)
220 /// /IV Type IV cassette (metal)
221 ///
222 /// REE Reel
223 /// /9 9.5 cm/s
224 /// /19 19 cm/s
225 /// /38 38 cm/s
226 /// /76 76 cm/s
227 /// /I Type I cassette (ferric/normal)
228 /// /II Type II cassette (chrome)
229 /// /III Type III cassette (ferric chrome)
230 /// /IV Type IV cassette (metal)
231 pub media_type: Option<String>,
232 /// The 'Original album/movie/show title' frame is intended for the title of the
233 /// original recording (or source of sound), if for example the music in the file
234 /// should be a cover of a previously released song.
235 pub original_album_move_show_title: Option<String>,
236 /// The 'Original filename' frame contains the preferred filename for the file,
237 /// since some media doesn't allow the desired length of the filename. The
238 /// filename is case sensitive and includes its suffix.
239 pub original_filename: Option<String>,
240 /// The 'Original lyricist(s)/text writer(s)' frame is intended for the text
241 /// writer(s) of the original recording, if for example the music in the file should
242 /// be a cover of a previously released song.
243 pub original_text_writers: Vec<String>,
244 /// The 'Original artist(s)/performer(s)' frame is intended for the performer(s) of
245 /// the original recording, if for example the music in the file should be a cover
246 /// of a previously released song.
247 pub original_artists: Vec<String>,
248 /// The 'Original release year' frame is intended for the year when the original
249 /// recording, if for example the music in the file should be a cover of a
250 /// previously released song, was released. The field is formatted as in the
251 /// `year` field.
252 pub original_release_year: Option<String>,
253 /// The 'File owner/licensee' frame contains the name of the owner or licensee
254 /// of the file and it's contents.
255 pub file_owner: Option<String>,
256 /// The 'Lead artist(s)/Lead performer(s)/Soloist(s)/Performing group' is used
257 /// for the main artist(s).
258 pub performers: Vec<String>,
259 /// The 'Band/Orchestra/Accompaniment' frame is used for additional information
260 /// about the performers in the recording.
261 pub band: Option<String>,
262 /// The 'Conductor' frame is used for the name of the conductor.
263 pub conductor: Option<String>,
264 /// The 'Interpreted, remixed, or otherwise modified by' frame contains more
265 /// information about the people behind a remix and similar interpretations of
266 /// another existing piece.
267 pub interpreted: Option<String>,
268 /// The 'Part of a set' frame is a numeric string that describes which part of a
269 /// set the audio came from. This frame is used if the source described in the
270 /// "TALB" frame is divided into several mediums, e.g. a double CD. The value may
271 /// be extended with a "/" character and a numeric string containing the total
272 /// number of parts in the set. E.g. "1/2".
273 pub part_of_a_set: Option<String>,
274 /// The 'Publisher' frame simply contains the name of the label or publisher.
275 pub publisher: Option<String>,
276 /// The 'Track number/Position in set' frame is a numeric string containing the
277 /// order number of the audio-file on its original recording. This may be extended
278 /// with a "/" character and a numeric string containing the total numer of
279 /// tracks/elements on the original recording. E.g. "4/9".
280 pub track_number: Option<String>,
281 /// The 'Recording dates' frame is a intended to be used as complement to the
282 /// "TYER", "TDAT" and "TIME" frames. E.g. "4th-7th June, 12th June" in
283 /// combination with the "TYER" frame.
284 pub recording_dates: Option<String>,
285 /// The 'Internet radio station name' frame contains the name of the internet
286 /// radio station from which the audio is streamed.
287 pub internet_radio_station_name: Option<String>,
288 /// The 'Internet radio station owner' frame contains the name of the owner of
289 /// the internet radio station from which the audio is streamed.
290 pub internet_radio_station_owner: Option<String>,
291 /// The 'Size' frame contains the size of the audiofile in bytes, excluding the
292 /// ID3v2 tag, represented as a numeric string.
293 pub size: Option<String>,
294 /// The 'ISRC' frame should contain the International Standard Recording Code
295 /// (ISRC) (12 characters).
296 pub international_standard_recording_code: Option<String>,
297 /// The 'Software/Hardware and settings used for encoding' frame includes the
298 /// used audio encoder and its settings when the file was encoded. Hardware
299 /// refers to hardware encoders, not the computer on which a program was run.
300 pub soft_hard_setting: Option<String>,
301 /// The 'Year' frame is a numeric string with a year of the recording. This
302 /// frames is always four characters long (until the year 10000).
303 pub year: Option<String>,
304 /// Since there might be a lot of people contributing to an audio file in
305 /// various ways, such as musicians and technicians, the 'Text information
306 /// frames' are often insufficient to list everyone involved in a project.
307 /// The 'Involved people list' is a frame containing the names of those
308 /// involved, and how they were involved. The body simply contains a terminated
309 /// string with the involvement directly followed by a terminated string with
310 /// the involvee followed by a new involvement and so on.
311 pub involved_people: Option<String>,
312
313 /// The 'Commercial information' frame is a URL pointing at a webpage with
314 /// information such as where the album can be bought. There may be more than
315 /// one "WCOM" frame in a tag, but not with the same content.
316 pub commercial_info_url: Vec<Url>,
317 /// The 'Copyright/Legal information' frame is a URL pointing at a webpage
318 /// where the terms of use and ownership of the file is described.
319 pub copyright_info_url: Option<Url>,
320 /// The 'Official audio file webpage' frame is a URL pointing at a file specific
321 /// webpage.
322 pub official_webpage: Option<Url>,
323 /// The 'Official artist/performer webpage' frame is a URL pointing at the
324 /// artists official webpage. There may be more than one "WOAR" frame in a tag
325 /// if the audio contains more than one performer, but not with the same content.
326 pub official_artist_webpage: Vec<Url>,
327 /// The 'Official audio source webpage' frame is a URL pointing at the official
328 /// webpage for the source of the audio file, e.g. a movie.
329 pub official_audio_source_webpage: Option<Url>,
330 /// The 'Official internet radio station homepage' contains a URL pointing at the
331 /// homepage of the internet radio station.
332 pub official_internet_radio_webpage: Option<Url>,
333 /// The 'Payment' frame is a URL pointing at a webpage that will handle the
334 /// process of paying for this file.
335 pub payment_url: Option<Url>,
336 /// The 'Publishers official webpage' frame is a URL pointing at the official
337 /// wepage for the publisher.
338 pub publishers_official_webpage: Option<Url>,
339}