FileDocCategorySizeDatePackage
RBUFID3V2Frame.javaAPI Docjid3 0.468515Sun Feb 06 18:11:19 GMT 2005org.blinkenlights.jid3.v2

RBUFID3V2Frame

public class RBUFID3V2Frame extends ID3V2Frame
Frame containing recommended buffer size information.
author
paul

Fields Summary
private int
m_i24BufferSize
private boolean
m_bEmbeddedInfoFlag
private int
m_iOffsetToNextTag
Constructors Summary
public RBUFID3V2Frame(int i24BufferSize, boolean bEmbeddedInfoFlag, int iOffsetToNextTag)
Creates a new instance of RBUFID3V2Frame.

param
i24BufferSize the recommended buffer size, as a 24-bit unsigned value
param
bEmbeddedInfoFlag an indicator whether or not a frame the of the specified maximum size may occur in the audiostream
param
iOffsetToNextTag the distance from the end of this tag to the start of the next
throws
ID3Exception if i24BufferSize contains an overflow value, or if iOffsetToNextTag is negative

        if ((i24BufferSize < 0) || (i24BufferSize > (1<<24)-1))
        {
            throw new ID3Exception("Buffer size must be an unsigned 24-bit value in RBUF frame.");
        }
        m_i24BufferSize = i24BufferSize;
        m_bEmbeddedInfoFlag = bEmbeddedInfoFlag;
        if (iOffsetToNextTag < 0)
        {
            throw new ID3Exception("Offset to next tag cannot be negative in RBUF frame.");
        }
        m_iOffsetToNextTag = iOffsetToNextTag;
    
public RBUFID3V2Frame(int i24BufferSize, boolean bEmbeddedInfoFlag)
Creates a new instance of RBUFID3V2Frame. (Omitting an offset value.)

param
i24BufferSize the recommended buffer size, as a 24-bit unsigned value
param
bEmbeddedInfoFlag an indicator whether or not a frame the of the specified maximum size may occur in the audiostream
throws
ID3Exception if i24BufferSize contains an overflow value, or if iOffsetToNextTag is negative

        if ((i24BufferSize < 0) || (i24BufferSize > (1<<24)-1))
        {
            throw new ID3Exception("Buffer size must be an unsigned 24-bit value in RBUF frame.");
        }
        m_i24BufferSize = i24BufferSize;
        m_bEmbeddedInfoFlag = bEmbeddedInfoFlag;
        m_iOffsetToNextTag = -1;
    
public RBUFID3V2Frame(InputStream oIS)

        try
        {
            ID3DataInputStream oFrameDataID3DIS = new ID3DataInputStream(oIS);
            
            // buffer size (24-bit value)
            m_i24BufferSize = oFrameDataID3DIS.readBE24();
            
            // embedded info
            int iEmbeddedInfoFlag = oFrameDataID3DIS.readUnsignedByte();
            m_bEmbeddedInfoFlag = ((iEmbeddedInfoFlag & 0x01) == 1) ? true : false;
            
            // offset to next tag (optional)
            if (oFrameDataID3DIS.available() > 0)
            {
                if (oFrameDataID3DIS.available() == 4)
                {
                    m_iOffsetToNextTag = oFrameDataID3DIS.readBE32();
                }
                else
                {
                    // too many bytes left
                    throw new ID3Exception("RBUF frame data longer than expected.");
                }
            }
            else
            {
                // no offset to next tag
                m_iOffsetToNextTag = -1;
            }
        }
        catch (Exception e)
        {
            throw new InvalidFrameID3Exception(e);
        }
    
Methods Summary
public voidaccept(ID3Visitor oID3Visitor)

        oID3Visitor.visitRBUFID3V2Frame(this);
    
public booleanequals(java.lang.Object oOther)

        if ((oOther == null) || (!(oOther instanceof RBUFID3V2Frame)))
        {
            return false;
        }
        
        RBUFID3V2Frame oOtherRBUF = (RBUFID3V2Frame)oOther;
        
        return ((m_i24BufferSize == oOtherRBUF.m_i24BufferSize) &&
                (m_bEmbeddedInfoFlag == oOtherRBUF.m_bEmbeddedInfoFlag) &&
                (m_iOffsetToNextTag == oOtherRBUF.m_iOffsetToNextTag));
    
public intgetBufferSize()
Get recommended buffer size.

return
the recommended buffer size

        return m_i24BufferSize;
    
public booleangetEmbeddedInfoFlag()
Get the embedded info flag.

return
the embedded info flag

        return m_bEmbeddedInfoFlag;
    
protected byte[]getFrameId()

        return "RBUF".getBytes();
    
public intgetOffsetToNextTag()
Get the offset to the next tag.

return
the offset to the next tag, or -1 if not specified

        return m_iOffsetToNextTag;
    
public voidsetRecommendedBufferSize(int i24BufferSize, boolean bEmbeddedInfoFlag, int iOffsetToNextTag)
Set the recommended buffer size.

param
i24BufferSize the recommended buffer size, as a 24-bit unsigned value
param
bEmbeddedInfoFlag an indicator whether or not a frame the of the specified maximum size may occur in the audiostream
param
iOffsetToNextTag the distance from the end of this tag to the start of the next
throws
ID3Exception if i24BufferSize contains an overflow value, or if iOffsetToNextTag is negative

        if ((i24BufferSize < 0) || (i24BufferSize > (1<<24)-1))
        {
            throw new ID3Exception("Buffer size must be an unsigned 24-bit value in RBUF frame.");
        }
        m_i24BufferSize = i24BufferSize;
        m_bEmbeddedInfoFlag = bEmbeddedInfoFlag;
        if (iOffsetToNextTag < 0)
        {
            throw new ID3Exception("Offset to next tag cannot be negative in RBUF frame.");
        }
        m_iOffsetToNextTag = iOffsetToNextTag;
    
public voidsetRecommendedBufferSize(int i24BufferSize, boolean bEmbeddedInfoFlag)
Set the recommended buffer size. (Omitting an offset value.)

param
i24BufferSize the recommended buffer size, as a 24-bit unsigned value
param
bEmbeddedInfoFlag an indicator whether or not a frame the of the specified maximum size may occur in the audiostream
throws
ID3Exception if i24BufferSize contains an overflow value, or if iOffsetToNextTag is negative

        if ((i24BufferSize < 0) || (i24BufferSize > (1<<24)-1))
        {
            throw new ID3Exception("Buffer size must be an unsigned 24-bit value in RBUF frame.");
        }
        m_i24BufferSize = i24BufferSize;
        m_bEmbeddedInfoFlag = bEmbeddedInfoFlag;
        m_iOffsetToNextTag = -1;
    
public java.lang.StringtoString()

        return "Recommended buffer size: Buffer size=[" + m_i24BufferSize + "], Embedded info flag=" + m_bEmbeddedInfoFlag +
               "], Offset to next tag=[" + m_iOffsetToNextTag + "]";
    
protected voidwriteBody(ID3DataOutputStream oIDOS)

        // recommended buffer size
        oIDOS.writeBE24(m_i24BufferSize);
        // embedded info flag
        oIDOS.writeUnsignedByte(m_bEmbeddedInfoFlag ? 1 : 0);
        // offset to next tag
        if (m_iOffsetToNextTag >= 0)
        {
            oIDOS.writeBE32(m_iOffsetToNextTag);
        }