* @param parentNode
* @throws IOException
* @throws CannotReadException
*/
public void buildChildrenOfNode(ByteBuffer moovBuffer, DefaultMutableTreeNode parentNode) throws IOException, CannotReadException {
Mp4BoxHeader boxHeader;
//Preprocessing for nodes that contain data before their children atoms
Mp4BoxHeader parentBoxHeader = (Mp4BoxHeader) parentNode.getUserObject();
//We set the buffers position back to this after processing the children
int justAfterHeaderPos = moovBuffer.position();
//Preprocessing for meta that normally contains 4 data bytes, but doesn't where found under track or tags atom
if (parentBoxHeader.getId().equals(Mp4NotMetaFieldKey.META.getFieldName())) {
Mp4MetaBox meta = new Mp4MetaBox(parentBoxHeader, moovBuffer);
meta.processData();
try {
boxHeader = new Mp4BoxHeader(moovBuffer);
} catch (NullBoxIdException nbe) {
//It might be that the meta box didn't actually have any additional data after it so we adjust the buffer
//to be immediately after metabox and code can retry
moovBuffer.position(moovBuffer.position() - Mp4MetaBox.FLAGS_LENGTH);
} finally {
//Skip back last header cos this was only a test
moovBuffer.position(moovBuffer.position() - Mp4BoxHeader.HEADER_LENGTH);
}
}
//Defines where to start looking for the first child node
int startPos = moovBuffer.position();
while (moovBuffer.position() < ((startPos + parentBoxHeader.getDataLength()) - Mp4BoxHeader.HEADER_LENGTH)) {
boxHeader = new Mp4BoxHeader(moovBuffer);
if (boxHeader != null) {
boxHeader.setFilePos(moovHeader.getFilePos() + moovBuffer.position());//logger.finest("Atom " + boxHeader.getId() + " @ " + boxHeader.getFilePos() + " of size:" + boxHeader.getLength() + " ,ends @ " + (boxHeader.getFilePos() + boxHeader.getLength()));
DefaultMutableTreeNode newAtom = new DefaultMutableTreeNode(boxHeader);
parentNode.add(newAtom);
if (boxHeader.getId().equals(Mp4NotMetaFieldKey.UDTA.getFieldName())) {
udtaNode = newAtom;
}
//only interested in metaNode that is child of udta node
else if (boxHeader.getId().equals(Mp4NotMetaFieldKey.META.getFieldName()) && parentBoxHeader.getId().equals(Mp4NotMetaFieldKey.UDTA.getFieldName())) {
metaNode = newAtom;
} else if (boxHeader.getId().equals(Mp4NotMetaFieldKey.HDLR.getFieldName()) && parentBoxHeader.getId().equals(Mp4NotMetaFieldKey.META.getFieldName())) {
hdlrWithinMetaNode = newAtom;
} else if (boxHeader.getId().equals(Mp4NotMetaFieldKey.HDLR.getFieldName())) {
hdlrWithinMdiaNode = newAtom;
} else if (boxHeader.getId().equals(Mp4NotMetaFieldKey.TAGS.getFieldName())) {
tagsNode = newAtom;
} else if (boxHeader.getId().equals(Mp4NotMetaFieldKey.STCO.getFieldName())) {
if (stco == null) {
stco = new Mp4StcoBox(boxHeader, moovBuffer);
stcoNode = newAtom;
}
} else if (boxHeader.getId().equals(Mp4NotMetaFieldKey.ILST.getFieldName())) {
DefaultMutableTreeNode parent = (DefaultMutableTreeNode) parentNode.getParent();
if (parent != null) {
Mp4BoxHeader parentsParent = (Mp4BoxHeader) (parent).getUserObject();
if (parentsParent != null) {
if (parentBoxHeader.getId().equals(Mp4NotMetaFieldKey.META.getFieldName()) && parentsParent.getId().equals(Mp4NotMetaFieldKey.UDTA.getFieldName())) {
ilstNode = newAtom;
}
}
}
} else if (boxHeader.getId().equals(Mp4NotMetaFieldKey.FREE.getFieldName())) {