org.farng.mp3
Class MP3FileHelper

java.lang.Object
  extended by org.farng.mp3.MP3FileHelper
All Implemented Interfaces:
MP3AudioMetadata
Direct Known Subclasses:
MP3File

public class MP3FileHelper
extends java.lang.Object
implements MP3AudioMetadata

Helper class for MP3 files, to extract metadata directly from MPEG audio itself (not any tags embedded in file).

Version:
$Revision: 3 $ $Date: 2008-12-27 08:09:28 +1300 (Sat, 27 Dec 2008) $
Author:
Matt Magoffin (spamsqr@msqr.us)

Constructor Summary
protected MP3FileHelper()
          Default constructor.
  MP3FileHelper(java.io.RandomAccessFile file)
          Construct from a RandomAccessFile.
 
Method Summary
 int getBitRate()
           
 byte getEmphasis()
           
protected  java.io.RandomAccessFile getFile()
          Get the MPEG file associated with this instance.
 double getFrequency()
           
 byte getLayer()
           
 byte getMode()
           
 byte getModeExtension()
           
 byte getMpegVersion()
           
 int getNumberMP3SyncFrame()
           
 boolean isCopyProtected()
           
 boolean isHome()
           
 boolean isPadding()
           
 boolean isPrivacy()
           
 boolean isProtection()
           
 boolean isVariableBitRate()
           
protected  boolean parseMpegAudio()
          Parse metadata from the MPEG audio stream.
protected  void setBitRate(int bitRate)
           
protected  void setCopyProtected(boolean copyProtected)
           
protected  void setEmphasis(byte emphasis)
           
protected  void setFile(java.io.RandomAccessFile file)
          Set the MPEG file associated with this instance.
protected  void setFrequency(double frequency)
           
protected  void setHome(boolean home)
           
protected  void setLayer(byte layer)
           
protected  void setMode(byte mode)
           
protected  void setModeExtension(byte modeExtension)
           
protected  void setMpegVersion(byte mpegVersion)
           
 void setNumberMP3SyncFrame(int numberMP3SyncFrame)
           
protected  void setPadding(boolean padding)
           
protected  void setPrivacy(boolean privacy)
           
protected  void setProtection(boolean protection)
           
protected  void setVariableBitRate(boolean variableBitRate)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MP3FileHelper

public MP3FileHelper(java.io.RandomAccessFile file)
              throws java.io.IOException
Construct from a RandomAccessFile.

Parameters:
file - the file
Throws:
java.io.IOException - if an IO error occurs

MP3FileHelper

protected MP3FileHelper()
Default constructor.

The setFile(RandomAccessFile) method must be called, followed by parseMpegAudio(), to read the MPEG metadata after using this constructor.

Method Detail

parseMpegAudio

protected boolean parseMpegAudio()
                          throws java.io.IOException
Parse metadata from the MPEG audio stream.

Calling this method will position the file pointer at the start of the audio frame found.

Returns:
true if found, false otherwise
Throws:
java.io.IOException - if an IO error occurs

getFile

protected java.io.RandomAccessFile getFile()
Get the MPEG file associated with this instance.

Returns:
the file

setFile

protected void setFile(java.io.RandomAccessFile file)
Set the MPEG file associated with this instance.

Parameters:
file - the file to set

getNumberMP3SyncFrame

public int getNumberMP3SyncFrame()
Returns:
the numberMP3SyncFrame

setNumberMP3SyncFrame

public void setNumberMP3SyncFrame(int numberMP3SyncFrame)
Parameters:
numberMP3SyncFrame - the numberMP3SyncFrame to set

getBitRate

public int getBitRate()
Specified by:
getBitRate in interface MP3AudioMetadata
Returns:
the bitRate

isCopyProtected

public boolean isCopyProtected()
Specified by:
isCopyProtected in interface MP3AudioMetadata
Returns:
the copyProtected

getEmphasis

public byte getEmphasis()
Specified by:
getEmphasis in interface MP3AudioMetadata
Returns:
the emphasis

getFrequency

public double getFrequency()
Specified by:
getFrequency in interface MP3AudioMetadata
Returns:
the frequency

isHome

public boolean isHome()
Specified by:
isHome in interface MP3AudioMetadata
Returns:
the home

getLayer

public byte getLayer()
Specified by:
getLayer in interface MP3AudioMetadata
Returns:
the layer

getMode

public byte getMode()
Specified by:
getMode in interface MP3AudioMetadata
Returns:
the mode

getModeExtension

public byte getModeExtension()
Specified by:
getModeExtension in interface MP3AudioMetadata
Returns:
the modeExtension

getMpegVersion

public byte getMpegVersion()
Specified by:
getMpegVersion in interface MP3AudioMetadata
Returns:
the mpegVersion

isPadding

public boolean isPadding()
Specified by:
isPadding in interface MP3AudioMetadata
Returns:
the padding

isPrivacy

public boolean isPrivacy()
Specified by:
isPrivacy in interface MP3AudioMetadata
Returns:
the privacy

isProtection

public boolean isProtection()
Specified by:
isProtection in interface MP3AudioMetadata
Returns:
the protection

isVariableBitRate

public boolean isVariableBitRate()
Specified by:
isVariableBitRate in interface MP3AudioMetadata
Returns:
the variableBitRate

setBitRate

protected void setBitRate(int bitRate)
Parameters:
bitRate - the bitRate to set

setCopyProtected

protected void setCopyProtected(boolean copyProtected)
Parameters:
copyProtected - the copyProtected to set

setEmphasis

protected void setEmphasis(byte emphasis)
Parameters:
emphasis - the emphasis to set

setFrequency

protected void setFrequency(double frequency)
Parameters:
frequency - the frequency to set

setHome

protected void setHome(boolean home)
Parameters:
home - the home to set

setLayer

protected void setLayer(byte layer)
Parameters:
layer - the layer to set

setMode

protected void setMode(byte mode)
Parameters:
mode - the mode to set

setModeExtension

protected void setModeExtension(byte modeExtension)
Parameters:
modeExtension - the modeExtension to set

setMpegVersion

protected void setMpegVersion(byte mpegVersion)
Parameters:
mpegVersion - the mpegVersion to set

setPadding

protected void setPadding(boolean padding)
Parameters:
padding - the padding to set

setPrivacy

protected void setPrivacy(boolean privacy)
Parameters:
privacy - the privacy to set

setProtection

protected void setProtection(boolean protection)
Parameters:
protection - the protection to set

setVariableBitRate

protected void setVariableBitRate(boolean variableBitRate)
Parameters:
variableBitRate - the variableBitRate to set