helliker.id3
Class XingVBRHeader

java.lang.Object
  extended byhelliker.id3.XingVBRHeader

public class XingVBRHeader
extends java.lang.Object


Field Summary
private  int avgBitrate
           
private  boolean exists
           
private  int FLAGS_SIZE
           
private  int HEAD_SIZE
           
private  java.lang.String HEAD_START
           
private  int length
           
private  int numBytes
           
private  int numFrames
           
private  int playingTime
           
private  double[] TIMEPERFRAME_TABLE
           
private  byte[] toc
           
private  int TOC_SIZE
           
private  int vbrScale
           
 
Constructor Summary
XingVBRHeader(java.io.RandomAccessFile raf, long offset, int layer, int mpegVersion, int sampleRate, int channelMode)
          Looks for a Xing VBR header in the file.
 
Method Summary
private  void calcValues(int layer, int mpegVersion, int sampleRate)
          Calculates the playing time and the average bitrate.
private  boolean checkHeader(java.io.RandomAccessFile raf, long offset, int channelMode, int mpegVersion)
          Checks to see if a xing header is in this file
 int getAvgBitrate()
          Returns the average bit rate of the mpeg file if a Xing header exists and -1 otherwise.
 int getLength()
          Returns the length (in bytes) of this Xing VBR header.
 int getNumBytes()
          Returns the number of data bytes in the mpeg frames.
 int getNumFrames()
          Returns the number of MPEG frames in the file passed to the constructor.
 int getPlayingTime()
          Returns the calculated playing time of the mpeg file if a Xing header exists and -1 otherwise.
 byte[] getTOC()
          Returns the toc used to seek to an area of this VBR file.
 int getVBRScale()
          Returns the VBR scale used to generate this VBR file.
 boolean headerExists()
          Returns true if a Xing VBR header was found in the file passed to the constructor.
private  void readHeader(java.io.RandomAccessFile raf)
          Parses the header data.
 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

HEAD_START

private final java.lang.String HEAD_START
See Also:
Constant Field Values

HEAD_SIZE

private final int HEAD_SIZE
See Also:
Constant Field Values

FLAGS_SIZE

private final int FLAGS_SIZE
See Also:
Constant Field Values

TOC_SIZE

private final int TOC_SIZE
See Also:
Constant Field Values

TIMEPERFRAME_TABLE

private final double[] TIMEPERFRAME_TABLE

numFrames

private int numFrames

numBytes

private int numBytes

vbrScale

private int vbrScale

toc

private byte[] toc

avgBitrate

private int avgBitrate

playingTime

private int playingTime

length

private int length

exists

private boolean exists
Constructor Detail

XingVBRHeader

public XingVBRHeader(java.io.RandomAccessFile raf,
                     long offset,
                     int layer,
                     int mpegVersion,
                     int sampleRate,
                     int channelMode)
              throws java.io.IOException,
                     CorruptHeaderException
Looks for a Xing VBR header in the file. If it is found then that means this is a variable bit rate file and all the data in the header will be parsed.

Parameters:
raf - the file to read from
offset - the location of the first mpeg frame
layer - the layer value read by the MPEGAudioFrameHeader
mpegVersion - the version value read by the MPEGAudioFrameHeader
sampleRate - the sample rate read by the MPEGAudioFrameHeader
channelMode - the channel mode read by the MPEGAudioFrameHeader
Throws:
java.io.IOException - if an error occurs
CorruptHeaderException - if an error occurs
Method Detail

checkHeader

private boolean checkHeader(java.io.RandomAccessFile raf,
                            long offset,
                            int channelMode,
                            int mpegVersion)
                     throws java.io.IOException
Checks to see if a xing header is in this file

Parameters:
raf - the file to read from
offset - the location of the first mpeg frame
mpegVersion - the version value read by the MPEGAudioFrameHeader
channelMode - the channel mode read by the MPEGAudioFrameHeader
Returns:
true if a xing header exists
Throws:
java.io.IOException - if an error occurs

readHeader

private void readHeader(java.io.RandomAccessFile raf)
                 throws java.io.IOException,
                        CorruptHeaderException
Parses the header data.

Parameters:
raf - the file to read from (pointing after the "Xing")
Throws:
java.io.IOException - if an error occurs
CorruptHeaderException - if an error occurs

calcValues

private void calcValues(int layer,
                        int mpegVersion,
                        int sampleRate)
Calculates the playing time and the average bitrate.

Parameters:
layer - the layer value read by the MPEGAudioFrameHeader
mpegVersion - the version value read by the MPEGAudioFrameHeader
sampleRate - the sample rate read by the MPEGAudioFrameHeader

headerExists

public boolean headerExists()
Returns true if a Xing VBR header was found in the file passed to the constructor.

Returns:
true if a Xinb VBR header was found

getNumFrames

public int getNumFrames()
Returns the number of MPEG frames in the file passed to the constructor. If a header is not found, -1 is returned.

Returns:
the number of MPEG frames

getNumBytes

public int getNumBytes()
Returns the number of data bytes in the mpeg frames. If a header is not found, -1 is returned.

Returns:
the number of data bytes in the mpeg frames

getVBRScale

public int getVBRScale()
Returns the VBR scale used to generate this VBR file. If a header is not found, -1 is returned.

Returns:
the VBR scale used to generate this VBR file

getTOC

public byte[] getTOC()
Returns the toc used to seek to an area of this VBR file. If a header is not found an empty array is returned.

Returns:
the toc used to seek to an area of this VBR file

getAvgBitrate

public int getAvgBitrate()
Returns the average bit rate of the mpeg file if a Xing header exists and -1 otherwise.

Returns:
the average bit rate (in kbps)

getPlayingTime

public int getPlayingTime()
Returns the calculated playing time of the mpeg file if a Xing header exists and -1 otherwise.

Returns:
the playing time (in seconds) of the mpeg file

toString

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

Returns:
a string representation of this object

getLength

public int getLength()
Returns the length (in bytes) of this Xing VBR header.

Returns:
the length of this Xing VBR header


Copyright © 2004 NeurosDBM Dev Team All Rights Reserved.