FileDocCategorySizeDatePackage
Mp4FtypBox.javaAPI DocJaudiotagger 2.0.45122Wed Mar 30 16:11:44 BST 2011org.jaudiotagger.audio.mp4.atom

Mp4FtypBox

public class Mp4FtypBox extends AbstractMp4Box
Ftyp (File Type) is the first atom, can be used to help identify the mp4 container type

Fields Summary
private String
majorBrand
private int
majorBrandVersion
private List
compatibleBrands
private static final int
MAJOR_BRAND_POS
private static final int
MAJOR_BRAND_LENGTH
private static final int
MAJOR_BRAND_VERSION_POS
private static final int
MAJOR_BRAND_VERSION_LENGTH
private static final int
COMPATIBLE_BRAND_LENGTH
Constructors Summary
public Mp4FtypBox(Mp4BoxHeader header, ByteBuffer dataBuffer)

param
header header info
param
dataBuffer data of box (doesnt include header data)

 //Can be multiple of these

                          
        
    
        this.header = header;
        this.dataBuffer = dataBuffer;
    
Methods Summary
public java.util.ListgetCompatibleBrands()

        return compatibleBrands;
    
public java.lang.StringgetMajorBrand()

        return majorBrand;
    
public intgetMajorBrandVersion()

        return majorBrandVersion;
    
public voidprocessData()

        CharsetDecoder decoder = Charset.forName("ISO-8859-1").newDecoder();
        try
        {
            majorBrand = decoder.decode((ByteBuffer) dataBuffer.slice().limit(MAJOR_BRAND_LENGTH)).toString();
        }
        catch (CharacterCodingException cee)
        {
            //Ignore

        }
        dataBuffer.position(dataBuffer.position() + MAJOR_BRAND_LENGTH);

        majorBrandVersion = Utils.getIntBE(dataBuffer, dataBuffer.position(), (dataBuffer.position() + MAJOR_BRAND_VERSION_LENGTH - 1));
        dataBuffer.position(dataBuffer.position() + MAJOR_BRAND_VERSION_LENGTH);

        while ((dataBuffer.position() < dataBuffer.limit()) && (dataBuffer.limit() - dataBuffer.position() >= COMPATIBLE_BRAND_LENGTH))
        {
            decoder.onMalformedInput(CodingErrorAction.REPORT);
            decoder.onMalformedInput(CodingErrorAction.REPORT);
            try
            {
                String brand = decoder.decode((ByteBuffer) dataBuffer.slice().limit(COMPATIBLE_BRAND_LENGTH)).toString();
                //Sometimes just extra groups of four nulls
                if (!brand.equals("\u0000\u0000\u0000\u0000"))
                {
                    compatibleBrands.add(brand);
                }
            }
            catch (CharacterCodingException cee)
            {
                //Ignore    
            }
            dataBuffer.position(dataBuffer.position() + COMPATIBLE_BRAND_LENGTH);
        }
    
public java.lang.StringtoString()


        String info = "Major Brand:" + majorBrand + "Version:" + majorBrandVersion;
        if (compatibleBrands.size() > 0)
        {
            info += "Compatible:";
            for (String brand : compatibleBrands)
            {
                info += brand;
                info += ",";
            }
            return info.substring(0, info.length() - 1);
        }
        return info;