|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.farng.mp3.AbstractMP3FileItem org.farng.mp3.AbstractMP3Tag org.farng.mp3.id3.AbstractID3 org.farng.mp3.id3.AbstractID3v2 org.farng.mp3.id3.ID3v2_2 org.farng.mp3.id3.ID3v2_3
The two biggest design goals were to be able to implement ID3v2 without disturbing old software too much and that ID3v2 should be as flexible and expandable as possible.
The first criterion is met by the simple fact that the MPEG decoding software uses a syncsignal, embedded in the audiostream, to 'lock on to' the audio. Since the ID3v2 tag doesn't contain a valid syncsignal, no software will attempt to play the tag. If, for any reason, coincidence make a syncsignal appear within the tag it will be taken care of by the 'unsynchronisation scheme' described in section 5.
The second criterion has made a more noticeable impact on the design of the ID3v2 tag. It is constructed as a container for several information blocks, called frames, whose format need not be known to the software that encounters them. At the start of every frame there is an identifier that explains the frames' format and content, and a size descriptor that allows software to skip unknown frames.
If a total revision of the ID3v2 tag should be needed, there is a version number and a size descriptor in the ID3v2 header.
The ID3 tag described in this document is mainly targeted at files encoded with MPEG-1/2 layer I, MPEG-1/2 layer II, MPEG-1/2 layer III and MPEG-2.5, but may work with other types of encoded audio.
The bitorder in ID3v2 is most significant bit first (MSB). The byteorder in multibyte numbers is most significant byte first (e.g. $12345678 would be encoded $12 34 56 78).
It is permitted to include padding after all the final frame (at the end of the ID3 tag), making the size of all the frames together smaller than the size given in the head of the tag. A possible purpose of this padding is to allow for adding a few additional frames or enlarge existing frames within the tag without having to rewrite the entire file. The value of the padding bytes must be $00.
The ID3v2 tag header, which should be the first information in the file, is 10 bytes as follows:
ID3v2/file identifier | "ID3" | |
ID3v2 version | $03 00 | |
ID3v2 flags | %abc00000 | |
ID3v2 size | 4 * %0xxxxxxx |
The first three bytes of the tag are always "ID3" to indicate that this is an ID3v2 tag, directly followed by the two version bytes. The first byte of ID3v2 version is it's major version, while the second byte is its revision number. In this case this is ID3v2.3.0. All revisions are backwards compatible while major versions are not. If software with ID3v2.2.0 and below support should encounter version three or higher it should simply ignore the whole tag. Version and revision will never be $FF.
The version is followed by one the ID3v2 flags field, of which currently only three flags are used.
a - Unsynchronisation
Bit 7 in the 'ID3v2 flags' indicates whether or not unsynchronisation is used (see section 5 for details); a set bit indicates usage.
b - Extended header
The second bit (bit 6) indicates whether or not the header is followed by an extended header. The extended header is described in section 3.2.
c - Experimental indicator
The third bit (bit 5) should be used as an 'experimental indicator'. This flag should always be set when the tag is in an experimental stage.
All the other flags should be cleared. If one of these undefined flags are set that might mean that the tag is not readable for a parser that does not know the flags function.
The ID3v2 tag size is encoded with four bytes where the most significant bit (bit 7) is set to zero in every byte, making a total of 28 bits. The zeroed bits are ignored, so a 257 bytes long tag is represented as $00 00 02 01.
The ID3v2 tag size is the size of the complete tag after unsychronisation, including padding, excluding the header but not excluding the extended header (total tag size - 10). Only 28 bits (representing up to 256MB) are used in the size description to avoid the introducuction of 'false syncsignals'.
An ID3v2 tag can be detected with the following pattern:
$49 44 33 yy yy xx zz zz zz zz
Where yy
is less than $FF, xx is the 'flags' byte and zz is less than $80.
Field Summary | |
protected int |
crcData
|
protected boolean |
crcDataFlag
|
protected boolean |
experimental
|
protected boolean |
extended
|
protected int |
paddingSize
|
Fields inherited from class org.farng.mp3.id3.ID3v2_2 |
compression, unsynchronization |
Constructor Summary | |
ID3v2_3()
Creates a new ID3v2_3 object. |
|
ID3v2_3(AbstractMP3Tag mp3tag)
Creates a new ID3v2_3 object. |
|
ID3v2_3(ID3v2_3 copyObject)
Creates a new ID3v2_3 object. |
|
ID3v2_3(java.io.RandomAccessFile file)
Creates a new ID3v2_3 object. |
Method Summary | |
void |
append(AbstractMP3Tag tag)
This method does nothing, but is called by subclasses for completeness |
boolean |
equals(java.lang.Object obj)
Determines whether another object is equal to this tag. |
java.lang.String |
getAlbumTitle()
|
java.lang.String |
getAuthorComposer()
|
java.lang.String |
getIdentifier()
ID string that usually corresponds to the class name, but can be displayed to the user. |
java.lang.String |
getLeadArtist()
|
int |
getSize()
|
java.lang.String |
getSongComment()
|
java.lang.String |
getSongGenre()
|
java.lang.String |
getSongLyric()
|
java.lang.String |
getSongTitle()
|
java.lang.String |
getTrackNumberOnAlbum()
|
java.lang.String |
getYearReleased()
|
void |
overwrite(AbstractMP3Tag tag)
This method does nothing, but is called by subclasses for completeness |
void |
read(java.io.RandomAccessFile file)
import java.io.IOException; import java.io.RandomAccessFile; read from current file pointer position. |
boolean |
seek(java.io.RandomAccessFile file)
Looks for this tag. |
void |
setAlbumTitle(java.lang.String albumTitle)
|
void |
setAuthorComposer(java.lang.String authorComposer)
|
void |
setLeadArtist(java.lang.String leadArtist)
|
void |
setSongComment(java.lang.String songComment)
|
void |
setSongGenre(java.lang.String songGenre)
|
void |
setSongLyric(java.lang.String songLyrics)
|
void |
setSongTitle(java.lang.String songTitle)
|
void |
setTrackNumberOnAlbum(java.lang.String trackNumberOnAlbum)
|
void |
setYearReleased(java.lang.String yearReleased)
|
java.lang.String |
toString()
|
void |
write(AbstractMP3Tag tag)
This method does nothing, but is called by subclasses for completeness |
void |
write(java.io.RandomAccessFile file)
Method to write this object to the file argument at is current file pointer position. |
Methods inherited from class org.farng.mp3.AbstractMP3Tag |
isSubsetOf |
Methods inherited from class org.farng.mp3.AbstractMP3FileItem |
isSubsetOf |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected boolean crcDataFlag
protected boolean experimental
protected boolean extended
protected int crcData
protected int paddingSize
Constructor Detail |
public ID3v2_3()
public ID3v2_3(ID3v2_3 copyObject)
public ID3v2_3(AbstractMP3Tag mp3tag)
public ID3v2_3(java.io.RandomAccessFile file) throws TagException, java.io.IOException
Method Detail |
public java.lang.String getIdentifier()
AbstractMP3FileItem
getIdentifier
in class ID3v2_2
public int getSize()
getSize
in class ID3v2_2
public void append(AbstractMP3Tag tag)
AbstractMP3Tag
append
in class ID3v2_2
public boolean equals(java.lang.Object obj)
AbstractMP3Tag
super.equals(object)
.
equals
in class ID3v2_2
public void overwrite(AbstractMP3Tag tag)
AbstractMP3Tag
overwrite
in class ID3v2_2
public void read(java.io.RandomAccessFile file) throws TagException, java.io.IOException
AbstractMP3FileItem
read
in class ID3v2_2
TagException
java.io.IOException
public boolean seek(java.io.RandomAccessFile file) throws java.io.IOException
AbstractMP3Tag
seek
in class ID3v2_2
java.io.IOException
public java.lang.String toString()
toString
in class ID3v2_2
public void write(AbstractMP3Tag tag)
AbstractMP3Tag
write
in class ID3v2_2
public void write(java.io.RandomAccessFile file) throws java.io.IOException
AbstractMP3FileItem
write
in class ID3v2_2
java.io.IOException
public java.lang.String getSongTitle()
getSongTitle
in class ID3v2_2
public java.lang.String getLeadArtist()
getLeadArtist
in class ID3v2_2
public java.lang.String getAlbumTitle()
getAlbumTitle
in class ID3v2_2
public java.lang.String getYearReleased()
getYearReleased
in class ID3v2_2
public java.lang.String getSongComment()
getSongComment
in class ID3v2_2
public java.lang.String getSongGenre()
getSongGenre
in class ID3v2_2
public java.lang.String getTrackNumberOnAlbum()
getTrackNumberOnAlbum
in class ID3v2_2
public java.lang.String getSongLyric()
getSongLyric
in class ID3v2_2
public java.lang.String getAuthorComposer()
getAuthorComposer
in class ID3v2_2
public void setSongTitle(java.lang.String songTitle)
setSongTitle
in class ID3v2_2
public void setLeadArtist(java.lang.String leadArtist)
setLeadArtist
in class ID3v2_2
public void setAlbumTitle(java.lang.String albumTitle)
setAlbumTitle
in class ID3v2_2
public void setYearReleased(java.lang.String yearReleased)
setYearReleased
in class ID3v2_2
public void setSongComment(java.lang.String songComment)
setSongComment
in class ID3v2_2
public void setSongGenre(java.lang.String songGenre)
setSongGenre
in class ID3v2_2
public void setTrackNumberOnAlbum(java.lang.String trackNumberOnAlbum)
setTrackNumberOnAlbum
in class ID3v2_2
public void setSongLyric(java.lang.String songLyrics)
setSongLyric
in class ID3v2_2
public void setAuthorComposer(java.lang.String authorComposer)
setAuthorComposer
in class ID3v2_2
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |