java.lang.Object
org.monte.media.mp3.MP3ElementaryInputStream.Frame
- Enclosing class:
MP3ElementaryInputStream
An elementary frame.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintReturns the bitrate of the frame.intReturns the raw bitrate code as it is stored in the header.longReturns the offset of the frame body in the input stream.intReturns the size of the frame body in bytes.intReturns the number of channels.intReturns the raw channel mode code as stored in the header.intgetCRC()Returns the CRC of this frame.longReturns the offset of the frame in the input stream.intReturns the size of the frame in bytes.intReturns the raw 32-bit header code as it is stored in the file.longReturns the offset of the header in the input stream.intReturns the size of the header in bytes.intgetLayer()Returns the layer number.intReturns the raw layer code as it is stored in the header.intPadding is used to fit the bit rates exactly.intReturns the number of samples in the frame.intReturns the sample rate in Hz.intReturns the raw sample rate code as it is stored in the header.intReturns the sample size in bits.longReturns the offset of the side info in the input stream.intReturns the size of the side info in bytes.intReturns the version number: 1=MPEG 1, 2=MPEG 2, 25=MPEG 2.5; -1=unknown.intReturns the version code as it is stored in the header.booleanhasCRC()Returns true if this frame has a CRC.booleanbyte[]Returns the frame header as a byte array.intheaderToByteArray(byte[] data, int offset) Writes the frame header into the specified byte array.voidwriteHeader(OutputStream out) Writes the frame header into the specified output stream.
-
Constructor Details
-
Frame
public Frame(int header) Creates a new frame.- Parameters:
header- The 32-bit Frame header
-
-
Method Details
-
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
Writes the frame header into the specified output stream.- Throws:
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.
-