FileDocCategorySizeDatePackage
Mp4HdlrBox.javaAPI DocJaudiotagger 2.0.46504Thu Sep 22 13:12:38 BST 2011org.jaudiotagger.audio.mp4.atom

Mp4HdlrBox

public class Mp4HdlrBox extends AbstractMp4Box
HdlrBox ( Handler box),

Describes the type of metadata in the following ilst or minf atom

Fields Summary
public static final int
VERSION_FLAG_LENGTH
public static final int
OTHER_FLAG_LENGTH
public static final int
RESERVED_FLAG_LENGTH
public static final int
HANDLER_LENGTH
public static final int
RESERVED1_LENGTH
public static final int
RESERVED2_LENGTH
public static final int
RESERVED3_LENGTH
public static final int
NAME_LENGTH
public static final int
HANDLER_POS
public static final int
RESERVED1_POS
public static final int
ITUNES_META_HDLR_DAT_LENGTH
private int
reserved
private String
handlerType
private String
name
private MediaDataType
mediaDataType
private static Map
mediaDataTypeMap
Constructors Summary
public Mp4HdlrBox(Mp4BoxHeader header, ByteBuffer dataBuffer)
DataBuffer must start from from the start of the body

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


    
    
        //Create maps to speed up lookup from raw value to enum
        mediaDataTypeMap = new HashMap<String, MediaDataType>();
        for (MediaDataType next : MediaDataType.values())
        {
            mediaDataTypeMap.put(next.getId(), next);
        }
    
        this.header = header;
        this.dataBuffer = dataBuffer;
    
Methods Summary
public static org.jaudiotagger.audio.mp4.atom.Mp4HdlrBoxcreateiTunesStyleHdlrBox()
Create an iTunes style Hdlr box for use within Meta box

Useful when writing to mp4 that previously didn't contain an mp4 meta atom

Doesnt write the child data but uses it to set the header length, only sets the atoms immediate data
return

        Mp4BoxHeader hdlrHeader = new Mp4BoxHeader(Mp4AtomIdentifier.HDLR.getFieldName());
        hdlrHeader.setLength(Mp4BoxHeader.HEADER_LENGTH + Mp4HdlrBox.ITUNES_META_HDLR_DAT_LENGTH);

        ByteBuffer hdlrData = ByteBuffer.allocate(Mp4HdlrBox.ITUNES_META_HDLR_DAT_LENGTH);
        hdlrData.put(HANDLER_POS,(byte)0x6d);       //mdir
        hdlrData.put(HANDLER_POS+1,(byte)0x64);
        hdlrData.put(HANDLER_POS+2,(byte)0x69);
        hdlrData.put(HANDLER_POS+3,(byte)0x72);
        hdlrData.put(RESERVED1_POS,(byte)0x61);          //appl
        hdlrData.put(RESERVED1_POS+1,(byte)0x70);
        hdlrData.put(RESERVED1_POS+2,(byte)0x70);
        hdlrData.put(RESERVED1_POS+3,(byte)0x6c);
        hdlrData.rewind();

        Mp4HdlrBox hdlrBox = new Mp4HdlrBox(hdlrHeader,hdlrData);
        return hdlrBox;
    
public java.lang.StringgetHandlerType()

        return handlerType;
    
public org.jaudiotagger.audio.mp4.atom.Mp4HdlrBox$MediaDataTypegetMediaDataType()

        return mediaDataType;
    
public voidprocessData()

        //Skip other flags
        dataBuffer.position(dataBuffer.position() + VERSION_FLAG_LENGTH + OTHER_FLAG_LENGTH + RESERVED_FLAG_LENGTH);


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

        }

        //To getFields human readable name
        mediaDataType = mediaDataTypeMap.get( handlerType);
    
public java.lang.StringtoString()

        String s = "handlerType:" + handlerType + ":human readable:"+mediaDataType.getDescription();
        return s;