org.jaudiotagger.audio.mp3
Class XingFrame

java.lang.Object
  extended by org.jaudiotagger.audio.mp3.XingFrame

public class XingFrame
extends java.lang.Object

Xing Frame

In some MP3s which variable bit rate the first frame in the file contains a special frame called a Xing Frame, instead of audio data. This is used to store additional information about the file. The most important aspect for this library is details allowing us to determine the bitrate of a Variable Bit Rate VBR file without having to process the whole file.

Xing VBR Tag data format is 120 bytes long 4 bytes for Header Tag 4 bytes for Header Flags 4 bytes for FRAME SIZE 4 bytes for AUDIO_SIZE 100 bytes for entry (NUMTOCENTRIES) 4 bytes for VBR SCALE. a VBR quality indicator: 0=best 100=worst

It my then contain a Lame Frame ( a Lame frame is in essence an extended Xing Frame


Field Summary
private  int audioSize
           
private static int BYTE_1
           
private static int BYTE_2
           
private static int BYTE_3
           
private static int BYTE_4
           
private  int frameCount
           
private static java.nio.ByteBuffer header
           
private  boolean isAudioSizeEnabled
           
private  boolean isFrameCountEnabled
           
private  LameFrame lameFrame
           
static int MAX_BUFFER_SIZE_NEEDED_TO_READ_XING
           
private static int MPEG_VERSION_1_MODE_MONO_OFFSET
           
private static int MPEG_VERSION_1_MODE_STEREO_OFFSET
           
private static int MPEG_VERSION_2_MODE_MONO_OFFSET
           
private static int MPEG_VERSION_2_MODE_STEREO_OFFSET
           
private  boolean vbr
           
private static int XING_AUDIOSIZE_BUFFER_SIZE
           
private static byte[] XING_CBR_ID
          Use when it is a CBR (Constant Bitrate) file
private static int XING_FLAG_BUFFER_SIZE
           
private static int XING_FRAMECOUNT_BUFFER_SIZE
           
private static int XING_HEADER_BUFFER_SIZE
           
private static int XING_IDENTIFIER_BUFFER_SIZE
           
private static byte[] XING_VBR_ID
          Use when it is a VBR (Variable Bitrate) file
 
Constructor Summary
private XingFrame()
          Read the Xing Properties from the buffer
 
Method Summary
 int getAudioSize()
           
 int getFrameCount()
           
 LameFrame getLameFrame()
           
 boolean isAudioSizeEnabled()
           
 boolean isFrameCountEnabled()
           
 boolean isVbr()
          Is this XingFrame detailing a varaible bit rate MPEG
static boolean isXingFrame(java.nio.ByteBuffer bb, MPEGFrameHeader mpegFrameHeader)
          IS this a Xing frame
static XingFrame parseXingFrame()
          Parse the XingFrame of an MP3File, cannot be called until we have validated that this is a XingFrame
private  void setAudioSize()
          Set size of AudioData
private  void setFrameCount()
          Set count of frames
private  void setVbr()
          Set whether or not VBR, (Xing can also be used for CBR though this is less useful)
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MPEG_VERSION_1_MODE_MONO_OFFSET

private static final int MPEG_VERSION_1_MODE_MONO_OFFSET
See Also:
Constant Field Values

MPEG_VERSION_1_MODE_STEREO_OFFSET

private static final int MPEG_VERSION_1_MODE_STEREO_OFFSET
See Also:
Constant Field Values

MPEG_VERSION_2_MODE_MONO_OFFSET

private static final int MPEG_VERSION_2_MODE_MONO_OFFSET
See Also:
Constant Field Values

MPEG_VERSION_2_MODE_STEREO_OFFSET

private static final int MPEG_VERSION_2_MODE_STEREO_OFFSET
See Also:
Constant Field Values

XING_HEADER_BUFFER_SIZE

private static final int XING_HEADER_BUFFER_SIZE
See Also:
Constant Field Values

XING_IDENTIFIER_BUFFER_SIZE

private static final int XING_IDENTIFIER_BUFFER_SIZE
See Also:
Constant Field Values

XING_FLAG_BUFFER_SIZE

private static final int XING_FLAG_BUFFER_SIZE
See Also:
Constant Field Values

XING_FRAMECOUNT_BUFFER_SIZE

private static final int XING_FRAMECOUNT_BUFFER_SIZE
See Also:
Constant Field Values

XING_AUDIOSIZE_BUFFER_SIZE

private static final int XING_AUDIOSIZE_BUFFER_SIZE
See Also:
Constant Field Values

MAX_BUFFER_SIZE_NEEDED_TO_READ_XING

public static final int MAX_BUFFER_SIZE_NEEDED_TO_READ_XING
See Also:
Constant Field Values

BYTE_1

private static final int BYTE_1
See Also:
Constant Field Values

BYTE_2

private static final int BYTE_2
See Also:
Constant Field Values

BYTE_3

private static final int BYTE_3
See Also:
Constant Field Values

BYTE_4

private static final int BYTE_4
See Also:
Constant Field Values

XING_VBR_ID

private static final byte[] XING_VBR_ID
Use when it is a VBR (Variable Bitrate) file


XING_CBR_ID

private static final byte[] XING_CBR_ID
Use when it is a CBR (Constant Bitrate) file


header

private static java.nio.ByteBuffer header

vbr

private boolean vbr

isFrameCountEnabled

private boolean isFrameCountEnabled

frameCount

private int frameCount

isAudioSizeEnabled

private boolean isAudioSizeEnabled

audioSize

private int audioSize

lameFrame

private LameFrame lameFrame
Constructor Detail

XingFrame

private XingFrame()
Read the Xing Properties from the buffer

Method Detail

getLameFrame

public LameFrame getLameFrame()

setVbr

private void setVbr()
Set whether or not VBR, (Xing can also be used for CBR though this is less useful)


setFrameCount

private void setFrameCount()
Set count of frames


isFrameCountEnabled

public final boolean isFrameCountEnabled()
Returns:
true if frameCount has been specified in header

getFrameCount

public final int getFrameCount()
Returns:
count of frames

setAudioSize

private void setAudioSize()
Set size of AudioData


isAudioSizeEnabled

public final boolean isAudioSizeEnabled()
Returns:
true if audioSize has been specified in header

getAudioSize

public final int getAudioSize()
Returns:
size of audio data in bytes

parseXingFrame

public static XingFrame parseXingFrame()
                                throws InvalidAudioFrameException
Parse the XingFrame of an MP3File, cannot be called until we have validated that this is a XingFrame

Returns:
Throws:
InvalidAudioFrameException

isXingFrame

public static boolean isXingFrame(java.nio.ByteBuffer bb,
                                  MPEGFrameHeader mpegFrameHeader)
IS this a Xing frame

Parameters:
bb -
mpegFrameHeader -
Returns:
true if this is a Xing frame

isVbr

public final boolean isVbr()
Is this XingFrame detailing a varaible bit rate MPEG

Returns:

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
a string represntation