FileDocCategorySizeDatePackage
PrintStructure.javaAPI Docmp4parser 1.0-RC-171649Wed Dec 19 20:10:38 GMT 2012com.google.code.mp4parser.example

PrintStructure

public class PrintStructure extends Object
Created by IntelliJ IDEA. User: sannies Date: 8/5/11 Time: 2:03 PM To change this template use File | Settings | File Templates.

Fields Summary
List
containers
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

        FileInputStream fis = new FileInputStream(new File(args[0]));

        PrintStructure ps = new PrintStructure();
        ps.print(fis.getChannel(), 0, 0);
    
private voidprint(java.nio.channels.FileChannel fc, int level, long baseoffset)


        while (fc.size() - fc.position() > 8) {
            long start = fc.position();
            ByteBuffer bb = ByteBuffer.allocate(8);
            bb.reset();
            fc.read(bb);
            long size = IsoTypeReader.readUInt32(bb);
            String type = IsoTypeReader.read4cc(bb);
            long end = start + size;
            for (int i = 0; i < level; i++) {
                System.out.print(" ");
            }

            System.out.println(type + "@" + (baseoffset + start) + " size: " + size);
            if (containers.contains(type)) {
                print(fc, level + 1, baseoffset + start + 8);
            }

            fc.position(end);

        }