| 1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> |
| 2 |
<HTML> |
| 3 |
<HEAD> |
| 4 |
<TITLE>ID3v2.3 Programming Guidelines</TITLE> |
| 5 |
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> |
| 6 |
<META NAME="GENERATOR" CONTENT="Mozilla/3.04Gold (WinNT; I) [Netscape]"> |
| 7 |
<link href="id3lib.css" rel="stylesheet" type="text/css"> |
| 8 |
</HEAD> |
| 9 |
<BODY> |
| 10 |
|
| 11 |
<h1>ID3v2.3 Programming Guidelines</h1> |
| 12 |
|
| 13 |
<center><IMG SRC="id3v2.gif" HEIGHT=50 WIDTH=52></centeR> |
| 14 |
|
| 15 |
<P>Applies to: ID3v2.3<BR> |
| 16 |
Old versions: <A HREF="id3g-2.htm">ID3v2.2 Guidelines</A> (ID3v2.2 is obsolete |
| 17 |
and should not be used for new tags.)</P> |
| 18 |
|
| 19 |
<H2>Table of Contents</H2> |
| 20 |
|
| 21 |
<P>1. <A HREF="#Intro">Introduction</A> <BR> |
| 22 |
1.1. <A HREF="#Usage">Use of this document</A> <BR> |
| 23 |
2. <A HREF="#id3v23new">What's new</A> in ID3v2.3? <BR> |
| 24 |
3. Programming Considerations <BR> |
| 25 |
3.1 <A HREF="#padding">Padding</A> <BR> |
| 26 |
3.2 <A HREF="#ROmedia">Read-only media</A> <BR> |
| 27 |
3.3 <A HREF="#SmallFrames">"Insignificant" |
| 28 |
frames</A> <BR> |
| 29 |
3.4 <A HREF="#iformat">Preferred image formats</A> |
| 30 |
<BR> |
| 31 |
3.5 <A HREF="#manytags">Multiple tags</A> <BR> |
| 32 |
3.6 <A HREF="#unsync">Unsynchronization</A> <BR> |
| 33 |
4. Pitfalls & General Advice <BR> |
| 34 |
4.1 <A HREF="#rtfm">RTFM</A> and yes, the details |
| 35 |
matter! <BR> |
| 36 |
4.2 <A HREF="#cB4e">Compression before encryption</A> |
| 37 |
<BR> |
| 38 |
4.3 <A HREF="#userErr">Validating user input</A> |
| 39 |
<BR> |
| 40 |
5. <A HREF="#Credit">Credits</A> <BR> |
| 41 |
6. <A HREF="#Refs">References</A> <BR> |
| 42 |
7. <A HREF="#copyright">Copyright & Legal Notices</A> </P> |
| 43 |
|
| 44 |
<P> |
| 45 |
<HR></P> |
| 46 |
|
| 47 |
<H2><A NAME="Intro"></A>Introduction</H2> |
| 48 |
|
| 49 |
<P>There are many people who enjoy .MP3 compressed music. The MP3 specification |
| 50 |
only defined the storage of musical data and did not provide the storage |
| 51 |
of metadata related to the musical composition; e.g., title, composer and |
| 52 |
artist, publisher, etc. The ID3 tag standard was created to remedy this |
| 53 |
need... </P> |
| 54 |
|
| 55 |
<P><B>Rationale:</B> Specifications are like grammar: they provide the |
| 56 |
rules of formatting data but few clues as to how to speak concisely and |
| 57 |
efficiently. The goal of this document is to answer the "Should I |
| 58 |
do..." and "Would doing X make it easier/faster/smaller..." |
| 59 |
type questions. </P> |
| 60 |
|
| 61 |
<P><B>Audience:</B> This document is geared toward programmers dealing |
| 62 |
directly with ID3v2.3 tags. There is a heavy slant towards writing tags |
| 63 |
correctly since decoding is relatively straightforward. You should familiarize |
| 64 |
yourself with the <A HREF="http://www.id3.org/develop.html">ID3v2 and related |
| 65 |
standards</A> since this document refers to and uses the terminology from |
| 66 |
those documents.</P> |
| 67 |
|
| 68 |
<P><B>Coverage:</B> Although ID3v2 tags were created for use with |
| 69 |
MPEG Layer-3 audio streams, flexibility was a goal from the start. |
| 70 |
Even though much of this document refers to .MP3 files, the principles |
| 71 |
are generally applicable to other formats.</P> |
| 72 |
|
| 73 |
<P> |
| 74 |
<HR WIDTH="85%"></P> |
| 75 |
|
| 76 |
<H2><A NAME="Usage"></A>Use of this document</H2> |
| 77 |
|
| 78 |
<P>These are merely Guidelines and as such they are not part of the ID3v2 |
| 79 |
standard. </P> |
| 80 |
|
| 81 |
<OL> |
| 82 |
<LI>If anything in this document contradicts the published ID3v2 standard, |
| 83 |
then the standard shall prevail. The ID3v2 standard always has the final |
| 84 |
word. |
| 85 |
|
| 86 |
<LI>These Guidelines are not binding on anyone (whereas the standard <I>is</I> |
| 87 |
binding, for obvious reasons.) This means you, as a programmer, should |
| 88 |
never assume anyone else will abide by these guidelines. A protocol designer |
| 89 |
once said: |
| 90 |
|
| 91 |
<OL> |
| 92 |
<P><I>"Be flexible in what you accept, but strict in what you write."</I> |
| 93 |
</P> |
| 94 |
</OL> |
| 95 |
|
| 96 |
<LI>Use your judgement and common sense.</LI> |
| 97 |
</OL> |
| 98 |
|
| 99 |
<P> |
| 100 |
<HR WIDTH="85%"></P> |
| 101 |
|
| 102 |
<H2><A NAME="id3v23new"></A>What's new in ID3v2.3?</H2> |
| 103 |
|
| 104 |
<P>For starters, the naming convention changed. "ID3v2" now refers |
| 105 |
to the family of frame-based tagging methods which utilize the 10-byte |
| 106 |
header beginning with "ID3" followed by version information. |
| 107 |
"ID3v2<B>.3.0</B>" refers to the informal standard dated September |
| 108 |
1998. The informal standard formerly known as "ID3v2" has been |
| 109 |
renamed to "ID3v2.2"</P> |
| 110 |
|
| 111 |
<P>This document concentrates on ID3v2.3. The previous standard, ID3v2.2, is now |
| 112 |
obsolete; the Guidelines for ID3v2.2 may still be found <A HREF="id3g-2.htm">here</A>.</P> |
| 113 |
|
| 114 |
<P>A summary of the differences between ID3v2.3.0 and v2.2 is listed below. |
| 115 |
Section numbers match the |
| 116 |
<A HREF="http://www.lysator.liu.se/id3v2/id3v2.3.0.txt">ID3v2.3.0 Informal Standard</A>.</P> |
| 117 |
|
| 118 |
<H3>Structural changes:</H3> |
| 119 |
|
| 120 |
<UL> |
| 121 |
<LI>The <B>Frame Header</B> has been expanded. The Frame ID and Frame Size |
| 122 |
fields are now four bytes long. Two bytes of Flags have been added. See |
| 123 |
§3.3.</LI> |
| 124 |
|
| 125 |
<LI>An optional <B>Extended Header</B> can follow the ID3v2 tag header |
| 126 |
§3.2. Among other things, the extended header can store a CRC of the |
| 127 |
entire tag.</LI> |
| 128 |
</UL> |
| 129 |
|
| 130 |
<H3>Clarifications:</H3> |
| 131 |
|
| 132 |
<UL> |
| 133 |
<LI>Pre-defined Frame IDs have been renamed to four characters long.</LI> |
| 134 |
|
| 135 |
<LI>Unicode strings are now <I>required</I> to start with the Byte Order Mark (BOM) |
| 136 |
character. See §3.3.</LI> |
| 137 |
|
| 138 |
<LI>Compression and encryption are done on a frame-by-frame basis. The |
| 139 |
compression algorithm are those offered in zlib. §3.3</LI> |
| 140 |
|
| 141 |
<LI>Attached Picture [APIC] frame: the Image Format field has been |
| 142 |
replaced MIME Type §4.15.</LI> |
| 143 |
</UL> |
| 144 |
|
| 145 |
<P><B>New frames:</B> </P> |
| 146 |
|
| 147 |
<UL> |
| 148 |
<LI>Position Synchronization frame [POSS] §4.22</LI> |
| 149 |
|
| 150 |
<LI>Terms of Use frame [USER] §4.23</LI> |
| 151 |
|
| 152 |
<LI>Ownership frame [OWNE] §4.24</LI> |
| 153 |
|
| 154 |
<LI>Commercial frame [COMR] §4.25</LI> |
| 155 |
|
| 156 |
<LI>Private frame [PRIV] §4.28</LI> |
| 157 |
|
| 158 |
<LI>Encryption Method Registration [ENCR] §4.25</LI> |
| 159 |
|
| 160 |
<LI>Group ID Registration [GRID] §4.26.Used in conjunction with |
| 161 |
new frame features described in §3.3</LI> |
| 162 |
|
| 163 |
<LI>Text frames: Internet Radio Station Name [TRSN] and Internet Radio |
| 164 |
Station Owner [TRSO]</LI> |
| 165 |
|
| 166 |
<LI>URL link frames: Official internet radio station homepage |
| 167 |
[WORS] and Payment [WPAY]</LI> |
| 168 |
</UL> |
| 169 |
|
| 170 |
<P><B>Deleted frames:</B> Encrypted meta-frame.</P> |
| 171 |
|
| 172 |
<P> |
| 173 |
<HR WIDTH="85%"></P> |
| 174 |
|
| 175 |
<H2><A NAME="padding"></A>3.1 Padding</H2> |
| 176 |
|
| 177 |
<P>The use of padding and how much should be used has been a matter of |
| 178 |
debate ever since the first draft of ID3v2. (Take a look in the mailing |
| 179 |
list <A HREF="http://www.id3.org/maillist.html">archives</A> for arguments.)</P> |
| 180 |
|
| 181 |
<P>Before making recommendations let's quantify the issue:</P> |
| 182 |
|
| 183 |
<UL> |
| 184 |
<LI>A two minute song compressed at 44Khz and 128Kb/sec takes about 1990K (slightly |
| 185 |
less than 2MB) of disk space. The average size of .MP3 files in my |
| 186 |
collection is 3.5MB</LI> |
| 187 |
|
| 188 |
<LI>ID3v1 and Lyrics3 tags are only 128 bytes and 3K, respectively - and |
| 189 |
they served most songs just fine.</LI> |
| 190 |
|
| 191 |
<LI>An ID3v2 tag with basic information (title, artist/composer, copyright) is |
| 192 |
typically less than 1K in size. Toss in publisher information and lyrics |
| 193 |
and it comes out to 3K or so.</LI> |
| 194 |
|
| 195 |
<LI>Adding a 3K tag to a 2MB song will increase its size by 0.15%</LI> |
| 196 |
|
| 197 |
<LI>Adding a 10K tag to a 2MB song increases its size by 0.5%</LI> |
| 198 |
|
| 199 |
<LI>Suppose a CD-ROM holds 160 songs. Tagging all of them with 3K |
| 200 |
tags requires less than a megabyte.</LI> |
| 201 |
</UL> |
| 202 |
|
| 203 |
<P>So in reality tags are tiny compared to the amount of audio data accompanying |
| 204 |
it. A few KB of padding will not increase the file size noticeably. Remember |
| 205 |
also the padding is required to be 0's, which means on a slow modem link |
| 206 |
the padding is compressed significantly.</P> |
| 207 |
|
| 208 |
<P>There is but one reason to use padding: since ID3v2 tags are stored |
| 209 |
at the beginning of the file, it would be a major pain to rewrite the entire |
| 210 |
multi-megabyte file to add a 50-byte frame. Padding reserves space in advance.</P> |
| 211 |
|
| 212 |
<P>The issue then is how much padding should be used. </P> |
| 213 |
|
| 214 |
<P><B>James's</B> recommendations:</P> |
| 215 |
|
| 216 |
<UL> |
| 217 |
<LI>What do most people care about? Probably title, artist, composer, |
| 218 |
band, publisher, lyrics and copyright. 4K will usually be enough for all |
| 219 |
that plus some miscellaneous information such as media type, file size, |
| 220 |
playcounter, time codes, etc.</LI> |
| 221 |
|
| 222 |
<LI>If you are editing an existing tag and run out of room (meaning you |
| 223 |
must rewrite the entire file) then double the amount of space reserved |
| 224 |
for the tag. For example, a file has a 4K tag filled with 3K of data. User |
| 225 |
wants to add 2K of data, so you rewrite the file reserving 8K at the beginning; |
| 226 |
then save the 5K of data and leaving 3K of padding. </LI> |
| 227 |
|
| 228 |
<P>Obviously there should be an upper bound on doubling; a reasonable number |
| 229 |
would be 16K or 32K. For example, a file has a 25K tag but only 4K of padding |
| 230 |
left and the user wants to add 7K of new data. Rewrite the file and reserve |
| 231 |
41K: save 28K of tag data and leave 13K of padding.</P> |
| 232 |
|
| 233 |
<LI>Pictures are large and vary in size. If there are pictures then you |
| 234 |
should add more padding; use your judgement here.</LI> |
| 235 |
|
| 236 |
<LI>Do not forgo padding in files destined for read-only media or streaming |
| 237 |
applications. The user may want to save the file to another location and |
| 238 |
edit the tag.</LI> |
| 239 |
|
| 240 |
<LI>Include an option to let the user disable padding if (s)he <I>really</I> |
| 241 |
wants to.</LI> |
| 242 |
</UL> |
| 243 |
|
| 244 |
<P><B>Martin</B> has a good idea: Add enough padding to round out the file |
| 245 |
to a full cluster. Obviously a minimum amount of padding has to be added |
| 246 |
to be useful, but beyond the minimum, everything up to the next cluster |
| 247 |
size will not occupy additional disk space. (Each operating system has |
| 248 |
its own terminology; Microsoft uses <I>cluster,</I> Apple uses <I>allocation |
| 249 |
block</I>. How files are stored on disk is beyond the scope of this document; |
| 250 |
consult an OS book and API reference for details.)</P> |
| 251 |
|
| 252 |
<P>Here are some common cluster sizes:</P> |
| 253 |
|
| 254 |
<TABLE BORDER=1 > |
| 255 |
<TR> |
| 256 |
<TH ROWSPAN="2" NOWRAP>Operating system<BR> |
| 257 |
(file system type)</TH> |
| 258 |
|
| 259 |
<TH ALIGN=CENTER COLSPAN="7" NOWRAP>Disk size </TH> |
| 260 |
</TR> |
| 261 |
|
| 262 |
<TR> |
| 263 |
<TD>< 256MB</TD> |
| 264 |
|
| 265 |
<TD>up to 512MB</TD> |
| 266 |
|
| 267 |
<TD>up to 1GB</TD> |
| 268 |
|
| 269 |
<TD>up to 2GB</TD> |
| 270 |
|
| 271 |
<TD>up to 8GB</TD> |
| 272 |
|
| 273 |
<TD>up to 16GB</TD> |
| 274 |
|
| 275 |
<TD>> 16GB</TD> |
| 276 |
</TR> |
| 277 |
|
| 278 |
<TR> |
| 279 |
<TD>DOS & Windows 95<BR> |
| 280 |
(FAT16)</TD> |
| 281 |
|
| 282 |
<TD ALIGN=CENTER>4K</TD> |
| 283 |
|
| 284 |
<TD ALIGN=CENTER>8K</TD> |
| 285 |
|
| 286 |
<TD ALIGN=CENTER>16K</TD> |
| 287 |
|
| 288 |
<TD ALIGN=CENTER>32K</TD> |
| 289 |
|
| 290 |
<TD ALIGN=CENTER COLSPAN="3">N/A<BR> |
| 291 |
(FAT16 can't handle drives > 4GB)</TD> |
| 292 |
</TR> |
| 293 |
|
| 294 |
<TR> |
| 295 |
<TD>Win95 OSR2 & Win98<BR> |
| 296 |
(FAT32)</TD> |
| 297 |
|
| 298 |
<TD ALIGN=CENTER>N/A</TD> |
| 299 |
|
| 300 |
<TD ALIGN=CENTER COLSPAN="4">4K</TD> |
| 301 |
|
| 302 |
<TD ALIGN=CENTER>8K</TD> |
| 303 |
|
| 304 |
<TD ALIGN=CENTER>16K or 32K</TD> |
| 305 |
</TR> |
| 306 |
|
| 307 |
<TR> |
| 308 |
<TD>Windows NT<BR> |
| 309 |
(NTFS)</TD> |
| 310 |
|
| 311 |
<TD ALIGN=CENTER COLSPAN="7">0.5K to 64K<BR> |
| 312 |
(0.5K to 4K clusters are most common)</TD> |
| 313 |
</TR> |
| 314 |
|
| 315 |
<TR> |
| 316 |
<TD>MacOS pre-8.1<BR> |
| 317 |
(HFS)</TD> |
| 318 |
|
| 319 |
<TD ALIGN=CENTER>0.5K - 4K</TD> |
| 320 |
|
| 321 |
<TD ALIGN=CENTER>4.5K - 8K</TD> |
| 322 |
|
| 323 |
<TD ALIGN=CENTER>8.5K - 16K</TD> |
| 324 |
|
| 325 |
<TD ALIGN=CENTER>16.5K - 32K</TD> |
| 326 |
|
| 327 |
<TD ALIGN=CENTER COLSPAN="3">N/A<BR> |
| 328 |
(HFS can't handle disks > 2GB)</TD> |
| 329 |
</TR> |
| 330 |
|
| 331 |
<TR> |
| 332 |
<TD>MacOS 8.1 and later<BR> |
| 333 |
(HFS+)</TD> |
| 334 |
|
| 335 |
<TD ALIGN=CENTER>0.5K</TD> |
| 336 |
|
| 337 |
<TD ALIGN=CENTER>1K</TD> |
| 338 |
|
| 339 |
<TD ALIGN=CENTER>2K</TD> |
| 340 |
|
| 341 |
<TD ALIGN=CENTER COLSPAN="4">Default is 4K; user-selectable up to 4K</TD> |
| 342 |
</TR> |
| 343 |
|
| 344 |
<TR> |
| 345 |
<TD>CD-ROM, 650MB<BR> |
| 346 |
(ISO 9660)</TD> |
| 347 |
|
| 348 |
<TD ALIGN=CENTER COLSPAN="3">always 2K</TD> |
| 349 |
</TR> |
| 350 |
|
| 351 |
<TR> |
| 352 |
<TD>DVD-ROM<BR> |
| 353 |
(UDF)</TD> |
| 354 |
|
| 355 |
<TD ALIGN=CENTER COLSPAN="7">always 2K</TD> |
| 356 |
</TR> |
| 357 |
</TABLE> |
| 358 |
|
| 359 |
<P>Advanced operating systems employ tricks to optimize disk space. For |
| 360 |
example, Novell NetWare 4 uses 64K disk blocks but can split a block into |
| 361 |
0.5K pieces, thus creating the illusion of 512-byte blocks. UNIX file |
| 362 |
systems have their own methods to utilize disk space efficiently.</P> |
| 363 |
|
| 364 |
<P><B>James's</B> shortcut on choosing an appropriate cluster size: 2K |
| 365 |
(Nice even number, not too big, not too small)</P> |
| 366 |
|
| 367 |
<H2><A NAME="ROmedia"></A>3.2 Read-only media</H2> |
| 368 |
|
| 369 |
<P>Never assume a .MP3 file is writable unless the user is specifically |
| 370 |
editing the tag. MP3 files can be stored on read-only media such as a CD-ROM |
| 371 |
or a network share. If the user is editing the tag, it is an error if the |
| 372 |
file is write-protected because the user's changes cannot be saved. If |
| 373 |
a player is merely updating the playcounter or popularity-meter, it should |
| 374 |
not pop up a message complaining the file cannot be written to. </P> |
| 375 |
|
| 376 |
<P><B>James</B>: Include a visual cue to indicate whether the file is write-protected. |
| 377 |
For example, a small icon similar in size and color to the stereo indicator |
| 378 |
in WinAMP. A quick glance will determine whether certain settings will |
| 379 |
be saved. </P> |
| 380 |
|
| 381 |
<H2><A NAME="SmallFrames"></A>3.3 "Insignificant" frames</H2> |
| 382 |
|
| 383 |
<P>"Insignificant" frames are small frames that don't necessarily |
| 384 |
have meaning when a ID3v2 tag is created. The issue is whether the tag |
| 385 |
editor should add these frames when they do not already exist. </P> |
| 386 |
|
| 387 |
<P>For example, if Joe is adding tags to a fresh batch of .MP3 files, should |
| 388 |
the tag editor include a playcounter [PCNT] frame in the tag? The tag editor |
| 389 |
has no idea how many times the particular file has been played; unless |
| 390 |
Joe tells it otherwise, the editor has to create a [PCNT] frame with a |
| 391 |
count of 0. </P> |
| 392 |
|
| 393 |
<P>There are two ways to look at this. On the one hand, the frame is so |
| 394 |
small it takes almost no effort to include it. Since there will usually |
| 395 |
be a few hundred bytes of padding, the ten bytes used by the counter frame |
| 396 |
is in a sense "free." A player will probably add it later anyway |
| 397 |
when the file is used. </P> |
| 398 |
|
| 399 |
<P>On the other hand, if the frame is not holding useful information, why |
| 400 |
bother adding it? Padding, if used, effectively reserves space for these |
| 401 |
frames. Consider also the absence of a frame can be meaningful: the lack |
| 402 |
of a playcounter frame may indicate "I do not know how many times |
| 403 |
this piece has been played" as opposed to a count of 0, which |
| 404 |
indicates "This song has never been played." </P> |
| 405 |
|
| 406 |
<P>These can be considered "insignificant" frames: </P> |
| 407 |
|
| 408 |
<UL> |
| 409 |
<LI>Playcounter [PCNT]<BR> |
| 410 |
(<B>James</B>: an integrated ripper-encoder-tagger can include a playcount |
| 411 |
of 0 in newly created files, since by definition they have never been used..) |
| 412 |
</LI> |
| 413 |
|
| 414 |
<LI>Others, anyone?</LI> |
| 415 |
</UL> |
| 416 |
|
| 417 |
<P><B>Martin</B>: It is considered good manner to allow the user to disable |
| 418 |
writing of frames (s)he doesn't want. At least in an advanced menu in a |
| 419 |
hidden place. Perhaps the user doesn't want the TSI, TLE, TMT and MLL frame |
| 420 |
to be added automatically, even though it might be the default setting.</P> |
| 421 |
|
| 422 |
<H2><A NAME="iformat"></A>3.4 Preferred image formats</H2> |
| 423 |
|
| 424 |
<P>A question Martin gets often is why the ID3v2 document says "... |
| 425 |
PNG and JPEG picture format should be used..." Interoperability |
| 426 |
means it is almost guaranteed another ID3v2 tag/picture decoder can handle |
| 427 |
the PNG and JPEG formats. The chances a Macintosh application can display |
| 428 |
BMP files are slim; likewise, the complexities of EPS and TIFF are best |
| 429 |
left out.</P> |
| 430 |
|
| 431 |
<P>Consider these other arguments favoring PNG and JPEG:</P> |
| 432 |
|
| 433 |
<UL> |
| 434 |
<LI>PNG compresses better than BMP, GIF and most other lossless formats.</LI> |
| 435 |
|
| 436 |
<LI>JPEG has superior compression to most formats, especially for photographic |
| 437 |
pictures. (JPEG is not suitable for line-art and computer-generated graphics |
| 438 |
- use PNG for these.)</LI> |
| 439 |
|
| 440 |
<LI>Both formats are patent- and royalty-free (which is not the case with |
| 441 |
GIF, whose LZW compression algorithm is patented by Unisys.) </LI> |
| 442 |
</UL> |
| 443 |
|
| 444 |
<P><B>Martin</B>: The freedom to use whatever format you like in the picture |
| 445 |
frame is of course a freedom under responsibility. Do you want to make |
| 446 |
cross platform tags? Do you want to avoid legal trouble, at least for the |
| 447 |
principle? If so, use PNG and JPEG.</P> |
| 448 |
|
| 449 |
<P><B>Dirk</B>: Applications may want to convert the incoming picture type |
| 450 |
to PNG or JPEG first, or failing that, at least inform the user that they |
| 451 |
<I>should</I> be using PNG or JPEG, but allow the user to override this |
| 452 |
if they insist on using, say, a PCX.</P> |
| 453 |
|
| 454 |
<H2><A NAME="manytags"></A>3.5 Multiple tags</H2> |
| 455 |
|
| 456 |
<P>Decoders should be prepared to handle multiple ID3v2 tags per stream. |
| 457 |
This is especially important for players/decoders wanting to handle netradio-type |
| 458 |
applications since the notion of distinct files may not apply. </P> |
| 459 |
|
| 460 |
<P><B>Dirk</B>: An easy way to achieve this would be to use a central 'frame |
| 461 |
dispatch' routine, kind of like a demultiplexer. </P> |
| 462 |
|
| 463 |
<H2><A NAME="unsync"></A>3.6 Unsynchronization</H2> |
| 464 |
|
| 465 |
<P>The ID3v2 standard states "The only purpose of the 'unsychronisation |
| 466 |
scheme' is to make the ID3v2 tag as compatible as possible with existing |
| 467 |
software <I>[at the time the ID3v2.2 standard was drafted]</I>" What |
| 468 |
are the implications?</P> |
| 469 |
|
| 470 |
<OL> |
| 471 |
<LI>.MP3 decoders, regardless of age, will not be affected by extraneous |
| 472 |
data (i.e., tags) that does not contain a MPEG sync sequence.</LI> |
| 473 |
|
| 474 |
<LI>There is minimal impact if a decoder does not recognize ID3v2 tags |
| 475 |
but encounters something with a sync sequence. At worst a click or pop |
| 476 |
will be heard at the beginning of the piece, as if some data corruption |
| 477 |
has occurred.</LI> |
| 478 |
|
| 479 |
<LI>New software is expected to take advantage of ID3v2. Unsynchronization |
| 480 |
is not necessary with ID3v2 compliant software.</LI> |
| 481 |
</OL> |
| 482 |
|
| 483 |
<P>(Software which does not behave according to items 1 and 2 above are |
| 484 |
categorically deemed "broken." Microsoft's Media Player is an |
| 485 |
example of such software.)</P> |
| 486 |
|
| 487 |
<P><B>Martin</B>: I believe that unsynchronization should be done as seldom |
| 488 |
as possible since it increases the size of the tag as well as the parsing |
| 489 |
time. In other words, I think unsynchronization should be turned off as |
| 490 |
default.</P> |
| 491 |
|
| 492 |
<P>However, it is important to be able to undo unsynchronization when reading |
| 493 |
tags; otherwise unsynchronized tags will not be read correctly.</P> |
| 494 |
|
| 495 |
<P> |
| 496 |
<HR WIDTH="85%"></P> |
| 497 |
|
| 498 |
<H2><A NAME="rtfm"></A>4.1 RTFM (details are important!)</H2> |
| 499 |
|
| 500 |
<P>When the ID3v2 document refers to another standard it is assumed that |
| 501 |
the implementor is familiar with that standard as well. When it says URL |
| 502 |
it does not mean 'www.buymusic.com', it means 'http://www.buymusic.com/' |
| 503 |
A "URL containing an e-mail address" must include the |
| 504 |
'mailto:' qualifier. Those who at least take a quick look at the related |
| 505 |
standards will not make these kinds of mistakes.</P> |
| 506 |
|
| 507 |
<P>If these details are so important, why aren't they spelled out in the |
| 508 |
ID3v2 standard? According to Martin, "There has been people who said |
| 509 |
to me, 'You must write these kind of things in the document, or else people |
| 510 |
will make these mistakes.' The latest ID3 v2.01 draft is <I>only</I> 74,657 |
| 511 |
bytes of pure text because I did not. Guess why there are references to |
| 512 |
the standards in the document!" </P> |
| 513 |
|
| 514 |
<H2><A NAME="cB4e"></A>4.2 Compression before encryption</H2> |
| 515 |
|
| 516 |
<P>Encryption works by scrambling data to produce what amounts to random |
| 517 |
bits for an attacker. Data compression works by replacing or removing redundant |
| 518 |
information. It follows that the output of any decent crypto algorithm |
| 519 |
will not be compressible; therefore if you wish to use both compression |
| 520 |
and encryption, you must compress the data before encrypting it. </P> |
| 521 |
|
| 522 |
<P>Compressing before encryption also affords better security, since predictable |
| 523 |
headers and such will be hidden by compression. </P> |
| 524 |
|
| 525 |
<P>Remember: <I>compression</I> comes before <I>encryption</I> in the dictionary |
| 526 |
(at least in English) and that is how it should be in your application. |
| 527 |
</P> |
| 528 |
|
| 529 |
<H2><A NAME="userErr"></A>4.3 Validating user input</H2> |
| 530 |
|
| 531 |
<P>Never trust the input from the user to be sensible or formatted correctly. |
| 532 |
Is the ISRC a valid one? Does the month 13 exist? Could this piece of music |
| 533 |
be from disc 5 out of a 3 disc set?</P> |
| 534 |
|
| 535 |
<P><B>Dirk</B>: Personally, I think having input validation occur |
| 536 |
when the user signifies that the tag is "finished" is a good |
| 537 |
way of going about it, if only because I know I'll get half way through |
| 538 |
something and want to stop and do something else before I forget.</P> |
| 539 |
|
| 540 |
<P><B>James</B>: Extremely strict validation becomes restrictions |
| 541 |
on versatility and usability. An option to turn off or accept potentially |
| 542 |
invalid data can be included somewhere. For example, by default Microsoft |
| 543 |
Visual Basic checks for syntax errors as code is entered; however, users |
| 544 |
can disable that feature if they wish to delay syntax checking until compile |
| 545 |
time. </P> |
| 546 |
|
| 547 |
<P>Things to watch out for (this is by no means an all-inclusive list):</P> |
| 548 |
|
| 549 |
<UL> |
| 550 |
<LI>Properly formatted URLs (see <A HREF="#rtfm">RTFM</A>, above.) But |
| 551 |
should your application verify whether the URL actually exists? That may |
| 552 |
be too complicated; Martin and James's opinion is no verification.</LI> |
| 553 |
|
| 554 |
<LI>Proper MIME types.</LI> |
| 555 |
|
| 556 |
<LI>Are characters valid? Most text fields forbid control characters, |
| 557 |
even newlines. NULs are not allowed except in Unicode strings or to indicate |
| 558 |
end-of-string for terminated strings.</LI> |
| 559 |
|
| 560 |
<LI>Numerical strings must consist solely of the characters '0' through |
| 561 |
'9'</LI> |
| 562 |
|
| 563 |
<LI>Are lists handled properly? The list separator is a slash: / |
| 564 |
What happens if the user enters a / in an item?</LI> |
| 565 |
|
| 566 |
<LI>Are characters such as ( escaped where necessary?</LI> |
| 567 |
|
| 568 |
<LI>Do dates and times make sense? Years must be four digits long and be |
| 569 |
in the right century. (No Y2K problems here!)</LI> |
| 570 |
|
| 571 |
<LI>Is an image really the format the user claims it is? Some people believe |
| 572 |
renaming a .BMP file to .PNG will change its format accordingly.</LI> |
| 573 |
</UL> |
| 574 |
|
| 575 |
<P>Your application should never crash because the user does something |
| 576 |
stupid. Likewise, your application should not crash because of erroneous |
| 577 |
or malformed data in a tag. It is particularly important your application |
| 578 |
can recognize Unicode text frames and ignore them if the operating system |
| 579 |
or your program cannot handle Unicode.</P> |
| 580 |
|
| 581 |
<P> |
| 582 |
<HR WIDTH="85%"></P> |
| 583 |
|
| 584 |
<H2><A NAME="Credit"></A>Credits & Contributors</H2> |
| 585 |
|
| 586 |
<UL> |
| 587 |
<LI><A HREF="mailto:[email protected]">Dirk Mahoney</A>, creator of the <A HREF="http://www.id3.org/id3lib/">ID3Lib</A> |
| 588 |
C++ tag processing library.</LI> |
| 589 |
|
| 590 |
<LI><A HREF="mailto:[email protected]">James Lin</A>, author of |
| 591 |
these Guidelines.</LI> |
| 592 |
|
| 593 |
<LI><A HREF="mailto:[email protected]">Martin Nilsson</A>, author of the |
| 594 |
ID3v2 standard.</LI> |
| 595 |
</UL> |
| 596 |
|
| 597 |
<H2><A NAME="Refs"></A>References</H2> |
| 598 |
|
| 599 |
<UL> |
| 600 |
<LI><A HREF="http://www.id3.org/">www.id3.org</A>: Home of the <A HREF="http://www.id3.org/develop.html">ID3v2 |
| 601 |
Informal Standard</A> and lots of other useful material.</LI> |
| 602 |
</UL> |
| 603 |
|
| 604 |
<P> |
| 605 |
<HR WIDTH="85%"></P> |
| 606 |
|
| 607 |
<H2><A NAME="copyright"></A>Copyright & Legal Notice</H2> |
| 608 |
|
| 609 |
<P>Copyright © 1998 James Lin and Merlin's Workshop. </P> |
| 610 |
|
| 611 |
<P>The goal of this document is to provide hints on how to implement the |
| 612 |
ID3v2 standard(s) correctly and efficiently. Distribution of this document |
| 613 |
is unlimited as long as no changes are made to its content: </P> |
| 614 |
|
| 615 |
<P><B>This document and translations of it may be copied and furnished |
| 616 |
to others, in any format or medium, provided no modifications are made |
| 617 |
to the content unless written permission has been obtained from the author.</B> |
| 618 |
</P> |
| 619 |
|
| 620 |
<P><B>This document is provided "AS IS" without warranty of any |
| 621 |
kind, either expressed or implied, including but not limited to, the implied |
| 622 |
warranties of merchantability and fitness for a particular purpose.</B> |
| 623 |
</P> |
| 624 |
|
| 625 |
<P><B>In no event unless required by applicable law will the author of |
| 626 |
this document be liable for damages, including any general, special, incidental |
| 627 |
or consequential damages arising out of the use or inability to use any |
| 628 |
information (including but not limited to loss or corruption of data or |
| 629 |
losses sustained by third parties), even if the author has been advised |
| 630 |
of the possibility of such damages.</B> </P> |
| 631 |
|
| 632 |
<HR WIDTH="100%"></hr><p>Copyright © 1998 Merlin's |
| 633 |
Workshop. <I>Last updated October 22, 1998</I> </P> |
| 634 |
|
| 635 |
</BODY> |
| 636 |
</HTML> |