Fields Summary |
---|
private static final int | MPEG_VERSION_1_MODE_MONO_OFFSET |
private static final int | MPEG_VERSION_1_MODE_STEREO_OFFSET |
private static final int | MPEG_VERSION_2_MODE_MONO_OFFSET |
private static final int | MPEG_VERSION_2_MODE_STEREO_OFFSET |
private static final int | XING_HEADER_BUFFER_SIZE |
private static final int | XING_IDENTIFIER_BUFFER_SIZE |
private static final int | XING_FLAG_BUFFER_SIZE |
private static final int | XING_FRAMECOUNT_BUFFER_SIZE |
private static final int | XING_AUDIOSIZE_BUFFER_SIZE |
public static final int | MAX_BUFFER_SIZE_NEEDED_TO_READ_XING |
private static final int | BYTE_1 |
private static final int | BYTE_2 |
private static final int | BYTE_3 |
private static final int | BYTE_4 |
private static final byte[] | XING_VBR_IDUse when it is a VBR (Variable Bitrate) file |
private static final byte[] | XING_CBR_IDUse when it is a CBR (Constant Bitrate) file |
private ByteBuffer | header |
private boolean | vbr |
private boolean | isFrameCountEnabled |
private int | frameCount |
private boolean | isAudioSizeEnabled |
private int | audioSize |
private LameFrame | lameFrame |
Methods Summary |
---|
public final int | getAudioSize()
return audioSize;
|
public final int | getFrameCount()
return frameCount;
|
public LameFrame | getLameFrame()
return lameFrame;
|
public final boolean | isAudioSizeEnabled()
return isAudioSizeEnabled;
|
public final boolean | isFrameCountEnabled()
return isFrameCountEnabled;
|
public final boolean | isVbr()Is this XingFrame detailing a variable bit rate MPEG
return vbr;
|
public static java.nio.ByteBuffer | isXingFrame(java.nio.ByteBuffer bb, MPEGFrameHeader mpegFrameHeader)IS this a Xing frame
//We store this so can return here after scanning through buffer
int startPosition = bb.position();
//Get to Start of where Xing Frame Should be ( we dont know if it is one at this point)
if (mpegFrameHeader.getVersion() == MPEGFrameHeader.VERSION_1)
{
if (mpegFrameHeader.getChannelMode() == MPEGFrameHeader.MODE_MONO)
{
bb.position(startPosition + MPEG_VERSION_1_MODE_MONO_OFFSET);
}
else
{
bb.position(startPosition + MPEG_VERSION_1_MODE_STEREO_OFFSET);
}
}
//MPEGVersion 2 and 2.5
else
{
if (mpegFrameHeader.getChannelMode() == MPEGFrameHeader.MODE_MONO)
{
bb.position(startPosition + MPEG_VERSION_2_MODE_MONO_OFFSET);
}
else
{
bb.position(startPosition + MPEG_VERSION_2_MODE_STEREO_OFFSET);
}
}
//Create header from here
ByteBuffer header = bb.slice();
// Return Buffer to start Point
bb.position(startPosition);
//Check Identifier
byte[] identifier = new byte[XING_IDENTIFIER_BUFFER_SIZE];
header.get(identifier);
if ((!Arrays.equals(identifier, XING_VBR_ID)) && (!Arrays.equals(identifier, XING_CBR_ID)))
{
return null;
}
MP3File.logger.finest("Found Xing Frame");
return header;
|
public static org.jaudiotagger.audio.mp3.XingFrame | parseXingFrame(java.nio.ByteBuffer header)Parse the XingFrame of an MP3File, cannot be called until we have validated that
this is a XingFrame
XingFrame xingFrame = new XingFrame(header);
return xingFrame;
|
private void | setAudioSize()Set size of AudioData
byte frameSizeBuffer[] = new byte[XING_AUDIOSIZE_BUFFER_SIZE];
header.get(frameSizeBuffer);
isAudioSizeEnabled = true;
audioSize = (frameSizeBuffer[BYTE_1] << 24) & 0xFF000000 | (frameSizeBuffer[BYTE_2] << 16) & 0x00FF0000 | (frameSizeBuffer[BYTE_3] << 8) & 0x0000FF00 | frameSizeBuffer[BYTE_4] & 0x000000FF;
|
private void | setFrameCount()Set count of frames
byte frameCountBuffer[] = new byte[XING_FRAMECOUNT_BUFFER_SIZE];
header.get(frameCountBuffer);
isFrameCountEnabled = true;
frameCount = (frameCountBuffer[BYTE_1] << 24) & 0xFF000000 | (frameCountBuffer[BYTE_2] << 16) & 0x00FF0000 | (frameCountBuffer[BYTE_3] << 8) & 0x0000FF00 | frameCountBuffer[BYTE_4] & 0x000000FF;
|
private void | setVbr()Set whether or not VBR, (Xing can also be used for CBR though this is less useful)
//Is it VBR or CBR
byte[] identifier = new byte[XING_IDENTIFIER_BUFFER_SIZE];
header.get(identifier);
if (Arrays.equals(identifier, XING_VBR_ID))
{
MP3File.logger.finest("Is Vbr");
vbr = true;
}
|
public java.lang.String | toString()
return "xingheader" + " vbr:" + vbr + " frameCountEnabled:" + isFrameCountEnabled + " frameCount:" + frameCount + " audioSizeEnabled:" + isAudioSizeEnabled + " audioFileSize:" + audioSize;
|