FileDocCategorySizeDatePackage
SampleEntry.javaAPI Docmp4parser 1.0-RC-175020Wed Dec 19 20:10:38 GMT 2012com.coremedia.iso.boxes.sampleentry

SampleEntry

public abstract class SampleEntry extends com.googlecode.mp4parser.AbstractBox implements com.coremedia.iso.boxes.ContainerBox
Abstract base class for all sample entries.
see
com.coremedia.iso.boxes.sampleentry.AudioSampleEntry
see
com.coremedia.iso.boxes.sampleentry.VisualSampleEntry
see
com.coremedia.iso.boxes.sampleentry.TextSampleEntry

Fields Summary
private int
dataReferenceIndex
protected List
boxes
private com.coremedia.iso.BoxParser
boxParser
Constructors Summary
protected SampleEntry(String type)



       
        super(type);
    
Methods Summary
public void_parseChildBoxes(java.nio.ByteBuffer content)

        while (content.remaining() > 8) {
            try {
                boxes.add(boxParser.parseBox(new ByteBufferByteChannel(content), this));
            } catch (IOException e) {
                throw new RuntimeException(e);
            }

        }
        setDeadBytes(content.slice());
    
public void_parseReservedAndDataReferenceIndex(java.nio.ByteBuffer content)

        content.get(new byte[6]); // ignore 6 reserved bytes;
        dataReferenceIndex = IsoTypeReader.readUInt16(content);
    
public void_writeChildBoxes(java.nio.ByteBuffer bb)

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        WritableByteChannel wbc = Channels.newChannel(baos);
        try {
            for (Box box : boxes) {
                box.getBox(wbc);
            }
            wbc.close();
        } catch (IOException e) {
            throw new RuntimeException("Cannot happen. Everything should be in memory and therefore no exceptions.");
        }
        bb.put(baos.toByteArray());
    
public void_writeReservedAndDataReferenceIndex(java.nio.ByteBuffer bb)

        bb.put(new byte[6]);
        IsoTypeWriter.writeUInt16(bb, dataReferenceIndex);
    
public voidaddBox(com.coremedia.iso.boxes.Box b)

        b.setParent(this);
        boxes.add(b);
    
public java.util.ListgetBoxes(java.lang.Class clazz)

        return getBoxes(clazz, false);
    
public java.util.ListgetBoxes()

        return boxes;
    
public java.util.ListgetBoxes(java.lang.Class clazz, boolean recursive)

        List<T> boxesToBeReturned = new ArrayList<T>(2);
        for (Box boxe : boxes) { //clazz.isInstance(boxe) / clazz == boxe.getClass()?
            if (clazz == boxe.getClass()) {
                boxesToBeReturned.add((T) boxe);
            }

            if (recursive && boxe instanceof ContainerBox) {
                boxesToBeReturned.addAll(((ContainerBox) boxe).getBoxes(clazz, recursive));
            }
        }
        // Optimize here! Spare object creation work on arrays directly! System.arrayCopy
        return boxesToBeReturned;
        //return (T[]) boxesToBeReturned.toArray();
    
public intgetDataReferenceIndex()

        return dataReferenceIndex;
    
public longgetNumOfBytesToFirstChild()

        long sizeOfChildren = 0;
        for (Box box : boxes) {
            sizeOfChildren += box.getSize();
        }
        return getSize() - sizeOfChildren;
    
public voidparse(java.nio.channels.ReadableByteChannel readableByteChannel, java.nio.ByteBuffer header, long contentSize, com.coremedia.iso.BoxParser boxParser)

        super.parse(readableByteChannel, header, contentSize, boxParser);
        this.boxParser = boxParser;
    
public booleanremoveBox(com.coremedia.iso.boxes.Box b)

        b.setParent(this);
        return boxes.remove(b);
    
public voidsetBoxes(java.util.List boxes)

        this.boxes = new LinkedList<Box>(boxes);
    
public voidsetDataReferenceIndex(int dataReferenceIndex)

        this.dataReferenceIndex = dataReferenceIndex;
    
public voidsetType(java.lang.String type)

        this.type = type;