FileDocCategorySizeDatePackage
TrackFragmentRandomAccessBox.javaAPI Docmp4parser 1.0-RC-179307Wed Dec 19 20:10:38 GMT 2012com.coremedia.iso.boxes.fragment

TrackFragmentRandomAccessBox

public class TrackFragmentRandomAccessBox extends com.googlecode.mp4parser.AbstractFullBox
aligned(8) class TrackFragmentRandomAccessBox extends FullBox('tfra', version, 0) { unsigned int(32) track_ID; const unsigned int(26) reserved = 0; unsigned int(2) length_size_of_traf_num; unsigned int(2) length_size_of_trun_num; unsigned int(2) length_size_of_sample_num; unsigned int(32) number_of_entry; for(i=1; i <= number_of_entry; i++){ if(version==1){ unsigned int(64) time; unsigned int(64) moof_offset; }else{ unsigned int(32) time; unsigned int(32) moof_offset; } unsigned int((length_size_of_traf_num+1) * 8) traf_number; unsigned int((length_size_of_trun_num+1) * 8) trun_number; unsigned int((length_size_of_sample_num+1) * 8) sample_number; } }

Fields Summary
public static final String
TYPE
private long
trackId
private int
reserved
private int
lengthSizeOfTrafNum
private int
lengthSizeOfTrunNum
private int
lengthSizeOfSampleNum
private List
entries
Constructors Summary
public TrackFragmentRandomAccessBox()


      
        super(TYPE);
    
Methods Summary
public void_parseDetails(java.nio.ByteBuffer content)

        parseVersionAndFlags(content);
        trackId = IsoTypeReader.readUInt32(content);
        long temp = IsoTypeReader.readUInt32(content);
        reserved = (int) (temp >> 6);
        lengthSizeOfTrafNum = ((int) (temp & 0x3F) >> 4) + 1;
        lengthSizeOfTrunNum = ((int) (temp & 0xC) >> 2) + 1;
        lengthSizeOfSampleNum = ((int) (temp & 0x3)) + 1;
        long numberOfEntries = IsoTypeReader.readUInt32(content);

        entries = new ArrayList<Entry>();

        for (int i = 0; i < numberOfEntries; i++) {
            Entry entry = new Entry();
            if (getVersion() == 1) {
                entry.time = IsoTypeReader.readUInt64(content);
                entry.moofOffset = IsoTypeReader.readUInt64(content);
            } else {
                entry.time = IsoTypeReader.readUInt32(content);
                entry.moofOffset = IsoTypeReader.readUInt32(content);
            }
            entry.trafNumber = IsoTypeReaderVariable.read(content, lengthSizeOfTrafNum);
            entry.trunNumber = IsoTypeReaderVariable.read(content, lengthSizeOfTrunNum);
            entry.sampleNumber = IsoTypeReaderVariable.read(content, lengthSizeOfSampleNum);

            entries.add(entry);
        }

    
protected voidgetContent(java.nio.ByteBuffer byteBuffer)

        writeVersionAndFlags(byteBuffer);
        IsoTypeWriter.writeUInt32(byteBuffer, trackId);
        long temp;
        temp = reserved << 6;
        temp = temp | (((lengthSizeOfTrafNum - 1) & 0x3) << 4);
        temp = temp | (((lengthSizeOfTrunNum - 1) & 0x3) << 2);
        temp = temp | ((lengthSizeOfSampleNum - 1) & 0x3);
        IsoTypeWriter.writeUInt32(byteBuffer, temp);
        IsoTypeWriter.writeUInt32(byteBuffer, entries.size());

        for (Entry entry : entries) {
            if (getVersion() == 1) {
                IsoTypeWriter.writeUInt64(byteBuffer, entry.time);
                IsoTypeWriter.writeUInt64(byteBuffer, entry.moofOffset);
            } else {
                IsoTypeWriter.writeUInt32(byteBuffer, entry.time);
                IsoTypeWriter.writeUInt32(byteBuffer, entry.moofOffset);
            }
            IsoTypeWriterVariable.write(entry.trafNumber, byteBuffer, lengthSizeOfTrafNum);
            IsoTypeWriterVariable.write(entry.trunNumber, byteBuffer, lengthSizeOfTrunNum);
            IsoTypeWriterVariable.write(entry.sampleNumber, byteBuffer, lengthSizeOfSampleNum);

        }
    
protected longgetContentSize()

        long contentSize = 4;
        contentSize += 4 + 4 /*26 + 2 + 2 + 2 */ + 4;
        if (getVersion() == 1) {
            contentSize += (8 + 8) * entries.size();
        } else {
            contentSize += (4 + 4) * entries.size();
        }
        contentSize += lengthSizeOfTrafNum * entries.size();
        contentSize += lengthSizeOfTrunNum * entries.size();
        contentSize += lengthSizeOfSampleNum * entries.size();
        return contentSize;
    
public java.util.ListgetEntries()

        return Collections.unmodifiableList(entries);
    
public intgetLengthSizeOfSampleNum()

        return lengthSizeOfSampleNum;
    
public intgetLengthSizeOfTrafNum()

        return lengthSizeOfTrafNum;
    
public intgetLengthSizeOfTrunNum()

        return lengthSizeOfTrunNum;
    
public longgetNumberOfEntries()

        return entries.size();
    
public intgetReserved()

        return reserved;
    
public longgetTrackId()

        return trackId;
    
public voidsetEntries(java.util.List entries)

        this.entries = entries;
    
public voidsetLengthSizeOfSampleNum(int lengthSizeOfSampleNum)

        this.lengthSizeOfSampleNum = lengthSizeOfSampleNum;
    
public voidsetLengthSizeOfTrafNum(int lengthSizeOfTrafNum)

        this.lengthSizeOfTrafNum = lengthSizeOfTrafNum;
    
public voidsetLengthSizeOfTrunNum(int lengthSizeOfTrunNum)

        this.lengthSizeOfTrunNum = lengthSizeOfTrunNum;
    
public voidsetTrackId(long trackId)

        this.trackId = trackId;
    
public java.lang.StringtoString()

        return "TrackFragmentRandomAccessBox{" +
                "trackId=" + trackId +
                ", entries=" + entries +
                '}";