helliker.id3
Class MPEGAudioFrameHeader

java.lang.Object
  |
  +--helliker.id3.MPEGAudioFrameHeader

public class MPEGAudioFrameHeader
extends java.lang.Object


Field Summary
static int MONO_MODE
           
static int MPEG_L_1
           
static int MPEG_L_2
           
static int MPEG_L_3
           
static int MPEG_V_1
           
static int MPEG_V_2
           
static int MPEG_V_25
           
 
Constructor Summary
MPEGAudioFrameHeader(java.io.File mp3)
          Create an MPEGAudioFrameHeader from the file specified.
MPEGAudioFrameHeader(java.io.File mp3, int offset)
          Create an MPEGAudioFrameHeader from the file specified.
 
Method Summary
 int getBitRate()
          Returns the bitrate of this mpeg.
 java.lang.String getChannelMode()
          Return the channel mode of the mpeg in string form.
 java.lang.String getEmphasis()
          Returns the emphasis.
 int getFrameLength()
          Computes the length of the frame found.
 java.lang.String getLayer()
          Return the layer description of the mpeg in string form.
 long getLocation()
          Returns the offset at which the first mpeg frame was found in the file.
 int getSampleRate()
          Returns the sample rate of the mpeg in Hz
 int getVBRPlayingTime()
          If this is a VBR file, return an accurate playing time of this mpeg.
 java.lang.String getVersion()
          Return the version of the mpeg in string form.
 boolean hasPadding()
          Returns true if the mpeg frames are padded in this file.
 boolean isCopyrighted()
          Returns true if the audio is copyrighted
 boolean isMP3()
          Returns true if the file passed to the constructor is an mp3 (MPEG layer III).
 boolean isOriginal()
          Returns true if this is the original media
 boolean isProtected()
          Returns true if this mpeg is protected by CRC
 boolean isVBR()
           
 boolean privateBitSet()
          Returns true if the private bit is set.
 java.lang.String toString()
          Return a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MPEG_V_25

public static final int MPEG_V_25
See Also:
Constant Field Values

MPEG_V_2

public static final int MPEG_V_2
See Also:
Constant Field Values

MPEG_V_1

public static final int MPEG_V_1
See Also:
Constant Field Values

MPEG_L_3

public static final int MPEG_L_3
See Also:
Constant Field Values

MPEG_L_2

public static final int MPEG_L_2
See Also:
Constant Field Values

MPEG_L_1

public static final int MPEG_L_1
See Also:
Constant Field Values

MONO_MODE

public static final int MONO_MODE
See Also:
Constant Field Values
Constructor Detail

MPEGAudioFrameHeader

public MPEGAudioFrameHeader(java.io.File mp3)
                     throws NoMPEGFramesException,
                            java.io.FileNotFoundException,
                            java.io.IOException,
                            CorruptHeaderException
Create an MPEGAudioFrameHeader from the file specified. Upon creation information will be read in from the first frame header the object encounters in the file.

Parameters:
mp3 - the file to read from
Throws:
NoMPEGFramesException - if the file is not a valid mpeg
java.io.FileNotFoundException - if an error occurs
java.io.IOException - if an error occurs
CorruptHeaderException - if an error occurs

MPEGAudioFrameHeader

public MPEGAudioFrameHeader(java.io.File mp3,
                            int offset)
                     throws NoMPEGFramesException,
                            java.io.FileNotFoundException,
                            java.io.IOException,
                            CorruptHeaderException
Create an MPEGAudioFrameHeader from the file specified. Upon creation information will be read in from the first frame header the object encounters in the file. The offset tells the object where to start searching for an MPEG frame. If you know the size of an id3v2 tag attached to the file and pass it to this ctor, it will take less time to find the frame.

Parameters:
mp3 - the file to read from
offset - the offset to start searching from
Throws:
NoMPEGFramesException - if the file is not a valid mpeg
java.io.FileNotFoundException - if an error occurs
java.io.IOException - if an error occurs
CorruptHeaderException - if an error occurs
Method Detail

getFrameLength

public int getFrameLength()
Computes the length of the frame found. This is not necessarily constant for all frames.

Returns:
the length of the frame found

toString

public java.lang.String toString()
Return a string representation of this object. Includes all information read in.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this object

getVersion

public java.lang.String getVersion()
Return the version of the mpeg in string form. Ex: MPEG Version 1.0

Returns:
the version of the mpeg

getLayer

public java.lang.String getLayer()
Return the layer description of the mpeg in string form. Ex: Layer III

Returns:
the layer description of the mpeg

getChannelMode

public java.lang.String getChannelMode()
Return the channel mode of the mpeg in string form. Ex: Joint Stereo (STEREO)

Returns:
the channel mode of the mpeg

getSampleRate

public int getSampleRate()
Returns the sample rate of the mpeg in Hz

Returns:
the sample rate of the mpeg in Hz

isCopyrighted

public boolean isCopyrighted()
Returns true if the audio is copyrighted

Returns:
true if the audio is copyrighted

isProtected

public boolean isProtected()
Returns true if this mpeg is protected by CRC

Returns:
true if this mpeg is protected by CRC

isOriginal

public boolean isOriginal()
Returns true if this is the original media

Returns:
true if this is the original media

isVBR

public boolean isVBR()

getEmphasis

public java.lang.String getEmphasis()
Returns the emphasis. I don't know what this means, it just does it...

Returns:
the emphasis

getLocation

public long getLocation()
Returns the offset at which the first mpeg frame was found in the file.

Returns:
the offset of the mpeg data

isMP3

public boolean isMP3()
Returns true if the file passed to the constructor is an mp3 (MPEG layer III).

Returns:
true if the file is an mp3

hasPadding

public boolean hasPadding()
Returns true if the mpeg frames are padded in this file.

Returns:
true if the mpeg frames are padded in this file

privateBitSet

public boolean privateBitSet()
Returns true if the private bit is set.

Returns:
true if the private bit is set

getVBRPlayingTime

public int getVBRPlayingTime()
If this is a VBR file, return an accurate playing time of this mpeg. If this is not a VBR file -1 is returned.

Returns:
an accurate playing time of this mpeg

getBitRate

public int getBitRate()
Returns the bitrate of this mpeg. If it is a VBR file the average bitrate is returned.

Returns:
the bitrate of this mpeg (in kbps)