Overview | Package | Class | Tree | Deprecated | Index | Help
| Copyright 2012-04-26 Werner Randelshofer
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.monte.media.mp3
Class MP3ElementaryInputStream.Frame

    java.lang.Object
      org.monte.media.mp3.MP3ElementaryInputStream.Frame

Enclosing class:
  MP3ElementaryInputStream

    public static class MP3ElementaryInputStream.Frame

extends java.lang.Object

An elementary frame.

Constructor Summary
`MP3ElementaryInputStream.Frame(int header)` Creates a new frame.

Method Summary
`int` | `getBitRate()` Returns the bitrate of the frame.
`int` | `getBitRateCode()` Returns the raw bitrate code as it is stored in the header.
`long` | `getBodyOffset()` Returns the offset of the frame body in the input stream.
`int` | `getBodySize()` Returns the size of the frame body in bytes.
`int` | `getChannelCount()` Returns the number of channels.
`int` | `getChannelModeCode()` Returns the raw channel mode code as stored in the header.
`int` | `getCRC()` Returns the CRC of this frame.
`long` | `getFrameOffset()` Returns the offset of the frame in the input stream.
`int` | `getFrameSize()` Returns the size of the frame in bytes.
`int` | `getHeaderCode()` Returns the raw 32-bit header code as it is stored in the file.
`long` | `getHeaderOffset()` Returns the offset of the header in the input stream.
`int` | `getHeaderSize()` Returns the size of the header in bytes.
`int` | `getLayer()` Returns the layer number.
`int` | `getLayerCode()` Returns the raw layer code as it is stored in the header.
`int` | `getPaddingSize()` Padding is used to fit the bit rates exactly.
`int` | `getSampleCount()` Returns the number of samples in the frame.
`int` | `getSampleRate()` Returns the sample rate in Hz.
`int` | `getSampleRateCode()` Returns the raw sample rate code as it is stored in the header.
`int` | `getSampleSize()` Returns the sample size in bits.
`long` | `getSideInfoOffset()` Returns the offset of the side info in the input stream.
`int` | `getSideInfoSize()` Returns the size of the side info in bytes.
`int` | `getVersion()` Returns the version number: 1=MPEG 1, 2=MPEG 2, 25=MPEG 2.5; -1=unknown.
`int` | `getVersionCode()` Returns the version code as it is stored in the header.
`boolean` | `hasCRC()` Returns true if this frame has a CRC.
`boolean` | `hasPadding()`
`byte[]` | `headerToByteArray()` Returns the frame header as a byte array.
`int` | `headerToByteArray(byte[] data, int offset)` Writes the frame header into the specified byte array.
`void` | `writeHeader(java.io.OutputStream out)` Writes the frame header into the specified output stream.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### MP3ElementaryInputStream.Frame

    public MP3ElementaryInputStream.Frame(int header)

  Creates a new frame.

  Parameters:
    `header` - The 32-bit Frame header

Method Detail

### getHeaderCode

    public int getHeaderCode()

  Returns the raw 32-bit header code as it is stored in the file.

### getVersion

    public int getVersion()

  Returns the version number: 1=MPEG 1, 2=MPEG 2, 25=MPEG 2.5; -1=unknown.

### getVersionCode

    public int getVersionCode()

  Returns the version code as it is stored in the header. 3=MPEG 1, 2=MPEG 2, 1=reserved, 0=MPEG 2.5.

### getLayer

    public int getLayer()

  Returns the layer number. 1=Layer I, 2=Layer II, 3=Layer III, -1=unknown.

### getLayerCode

    public int getLayerCode()

  Returns the raw layer code as it is stored in the header. 3=Layer I, 2=Layer II, 1=Layer III, 0=reserved.

### getBitRate

    public int getBitRate()

  Returns the bitrate of the frame. Returns -1 if unknown.

### getBitRateCode

    public int getBitRateCode()

  Returns the raw bitrate code as it is stored in the header.

### hasCRC

    public boolean hasCRC()

  Returns true if this frame has a CRC.

### getCRC

    public int getCRC()

  Returns the CRC of this frame. The value is only valid if hasCRC() returns true.

### hasPadding

    public boolean hasPadding()

### getSampleRate

    public int getSampleRate()

  Returns the sample rate in Hz. Returns -1 if unknown.

### getSampleRateCode

    public int getSampleRateCode()

  Returns the raw sample rate code as it is stored in the header.

### getSampleCount

    public int getSampleCount()

  Returns the number of samples in the frame. It is constant and always 384 samples for Layer I and 1152 samples for Layer II and Layer III. Returns -1 if unknown.

### getChannelCount

    public int getChannelCount()

  Returns the number of channels.

  Returns:
    1=mono, 2=stereo, joint stereo or dual channel.

### getSampleSize

    public int getSampleSize()

  Returns the sample size in bits. Always 16 bit per sample.

### getChannelModeCode

    public int getChannelModeCode()

  Returns the raw channel mode code as stored in the header.

  Returns:
    0=stereo, 1=joint stereo, 2=dual channel, 3=single channel (mono).

### headerToByteArray

    public byte[] headerToByteArray()

  Returns the frame header as a byte array.

### headerToByteArray

    public int headerToByteArray(byte[] data,
                                 int offset)

  Writes the frame header into the specified byte array. Returns the number of bytes written.

### writeHeader

    public void writeHeader(java.io.OutputStream out)
                     throws java.io.IOException

  Writes the frame header into the specified output stream.

  Throws:
    `java.io.IOException`

### getFrameOffset

    public long getFrameOffset()

  Returns the offset of the frame in the input stream.

### getFrameSize

    public int getFrameSize()

  Returns the size of the frame in bytes. This size includes the header, the data and the padding.

### getHeaderOffset

    public long getHeaderOffset()

  Returns the offset of the header in the input stream.

### getHeaderSize

    public int getHeaderSize()

  Returns the size of the header in bytes.

### getSideInfoOffset

    public long getSideInfoOffset()

  Returns the offset of the side info in the input stream.

### getSideInfoSize

    public int getSideInfoSize()

  Returns the size of the side info in bytes. It is 17 bytes long in a single channel frame and 32 bytes in dual channel or stereo channel.

### getBodyOffset

    public long getBodyOffset()

  Returns the offset of the frame body in the input stream.

### getBodySize

    public int getBodySize()

  Returns the size of the frame body in bytes. The body includes the side info, the audio data, and the padding.

### getPaddingSize

    public int getPaddingSize()

  Padding is used to fit the bit rates exactly. For an example: 128k 44.1kHz layer II uses a lot of 418 bytes and some of 417 bytes long frames to get the exact 128k bitrate. For Layer I slot is 32 bits long, for Layer II and Layer III slot is 8 bits long.

Overview | Package | Class | Tree | Deprecated | Index | Help
| Copyright 2012-04-26 Werner Randelshofer
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD