com.neoworks.mpeg
Class MPEGFrame

java.lang.Object
  |
  +--com.neoworks.mpeg.MPEGFrame

public final class MPEGFrame
extends java.lang.Object

This class represents an MPEG frame. MPEG frames contain a header, compressed audio data and an optional checksum.

Author:
Nigel Atkinson (nigel@neoworks.com)
, micah

Field Summary
static int DUAL_CHANNEL
          Frame mode constant
static int FOURTYEIGHT
          Sample rate constant
static int FOURTYFOUR_POINT_ONE
          Samole rate constant
static int[][] frequencies
          Sample rate lookup table
static int JOINT_STEREO
          Frame mode constant
static int MPEG1
          Constant for MPEG-1 version
static int MPEG2
          Constant for MPEG-2 version
static int SINGLE_CHANNEL
          Frame mode constant
static int STEREO
          Frame mode constant
static int THIRTYTWO
          Sample rate constant
 
Constructor Summary
MPEGFrame(int headerstring)
          Public constructor
 
Method Summary
 int getBitrate()
          Get the frame bitrate in bytes/second
 java.lang.String getBitrateString()
          Get a description of the frame bitrate
 short getCRCChecksum()
          Get the CRC checksum for this frame
 byte[] getFrameData()
          Get the entire frame as a byte array
 int getFrameSize()
          Get the frame size in bytes (including the header bytes)
 int getFrequency()
          Get the smaple frequency of the frame data
 int getIntensityStereoBound()
          Get the intensity stereo bound
 java.lang.String getLayerString()
          Get a description of the MPEG layer
 int getModeExtension()
          Get the stereo mode extension if any
 java.lang.String getModeString()
          Get a description of the mode
 int getMPEGLayer()
          Get the MPEG layer
 int getMPEGVersion()
          Get the MPEG version
 int getNumberOfSubbands()
          Get the number of sub bands
 java.lang.String getSampleFrequencyString()
          Get a description of the frame sample rate
 int getSlots()
          Get the number of audio data slots in this frame
 boolean hasPadding()
          Is the frame padded?
 boolean isCRCProtected()
          Get the CRC protection indicator bit.
 java.lang.String toString()
          Get a human readable representation of this header
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

frequencies

public static final int[][] frequencies
Sample rate lookup table


MPEG1

public static final int MPEG1
Constant for MPEG-1 version

See Also:
Constant Field Values

MPEG2

public static final int MPEG2
Constant for MPEG-2 version

See Also:
Constant Field Values

STEREO

public static final int STEREO
Frame mode constant

See Also:
Constant Field Values

JOINT_STEREO

public static final int JOINT_STEREO
Frame mode constant

See Also:
Constant Field Values

DUAL_CHANNEL

public static final int DUAL_CHANNEL
Frame mode constant

See Also:
Constant Field Values

SINGLE_CHANNEL

public static final int SINGLE_CHANNEL
Frame mode constant

See Also:
Constant Field Values

FOURTYFOUR_POINT_ONE

public static final int FOURTYFOUR_POINT_ONE
Samole rate constant

See Also:
Constant Field Values

FOURTYEIGHT

public static final int FOURTYEIGHT
Sample rate constant

See Also:
Constant Field Values

THIRTYTWO

public static final int THIRTYTWO
Sample rate constant

See Also:
Constant Field Values
Constructor Detail

MPEGFrame

public MPEGFrame(int headerstring)
          throws CorruptMPEGHeaderException
Public constructor

Parameters:
headerstring - The four header bytes
Throws:
CorruptMPEGHeaderException - If the header can not be parsed
Method Detail

getMPEGVersion

public int getMPEGVersion()
Get the MPEG version

Returns:
0 = version 2 (or 2.5), 1 = version 1

getMPEGLayer

public int getMPEGLayer()
Get the MPEG layer

Returns:
An int between 1 and 3 indicating the layer

getFrequency

public int getFrequency()
Get the smaple frequency of the frame data

Returns:
The sampling frequency of the frmae data

hasPadding

public boolean hasPadding()
Is the frame padded?

Returns:
Whether the frame is padded

getSlots

public int getSlots()
Get the number of audio data slots in this frame

Returns:
The number of data slots in the frame

getModeExtension

public int getModeExtension()
Get the stereo mode extension if any

Returns:
Stereo mode extension

getLayerString

public java.lang.String getLayerString()
Get a description of the MPEG layer

Returns:
A String description of the MPEG layer

getBitrateString

public java.lang.String getBitrateString()
Get a description of the frame bitrate

Returns:
A String description of the bitrate

getSampleFrequencyString

public java.lang.String getSampleFrequencyString()
Get a description of the frame sample rate

Returns:
A String description of the frame sample rate

getModeString

public java.lang.String getModeString()
Get a description of the mode

Returns:
A String description of the mode

getNumberOfSubbands

public int getNumberOfSubbands()
Get the number of sub bands

Returns:
the number of sub bands

getIntensityStereoBound

public int getIntensityStereoBound()
Get the intensity stereo bound

Returns:
int

isCRCProtected

public boolean isCRCProtected()
Get the CRC protection indicator bit.

Returns:
0 - Protected by CRC | 1 - Not protected

getBitrate

public int getBitrate()
Get the frame bitrate in bytes/second

Returns:
The bitrate of the frame

getFrameSize

public int getFrameSize()
Get the frame size in bytes (including the header bytes)

Returns:
the size in bytes of the frame

getFrameData

public byte[] getFrameData()
Get the entire frame as a byte array

Returns:
The frame data

getCRCChecksum

public short getCRCChecksum()
Get the CRC checksum for this frame

Returns:
The CRC checksum as a short

toString

public java.lang.String toString()
Get a human readable representation of this header

Overrides:
toString in class java.lang.Object
Returns:
A String description of this header