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

TrackFragmentHeaderBox

public class TrackFragmentHeaderBox extends com.googlecode.mp4parser.AbstractFullBox
aligned(8) class TrackFragmentHeaderBox extends FullBox('tfhd', 0, tf_flags){ unsigned int(32) track_ID; // all the following are optional fields unsigned int(64) base_data_offset; unsigned int(32) sample_description_index; unsigned int(32) default_sample_duration; unsigned int(32) default_sample_size; unsigned int(32) default_sample_flags }

Fields Summary
public static final String
TYPE
private long
trackId
private long
baseDataOffset
private long
sampleDescriptionIndex
private long
defaultSampleDuration
private long
defaultSampleSize
private SampleFlags
defaultSampleFlags
private boolean
durationIsEmpty
Constructors Summary
public TrackFragmentHeaderBox()


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

        parseVersionAndFlags(content);
        trackId = IsoTypeReader.readUInt32(content);
        if ((getFlags() & 0x1) == 1) { //baseDataOffsetPresent
            baseDataOffset = IsoTypeReader.readUInt64(content);
        }
        if ((getFlags() & 0x2) == 0x2) { //sampleDescriptionIndexPresent
            sampleDescriptionIndex = IsoTypeReader.readUInt32(content);
        }
        if ((getFlags() & 0x8) == 0x8) { //defaultSampleDurationPresent
            defaultSampleDuration = IsoTypeReader.readUInt32(content);
        }
        if ((getFlags() & 0x10) == 0x10) { //defaultSampleSizePresent
            defaultSampleSize = IsoTypeReader.readUInt32(content);
        }
        if ((getFlags() & 0x20) == 0x20) { //defaultSampleFlagsPresent
            defaultSampleFlags = new SampleFlags(content);
        }
        if ((getFlags() & 0x10000) == 0x10000) { //durationIsEmpty
            durationIsEmpty = true;
        }
    
public longgetBaseDataOffset()

        return baseDataOffset;
    
protected voidgetContent(java.nio.ByteBuffer byteBuffer)

        writeVersionAndFlags(byteBuffer);
        IsoTypeWriter.writeUInt32(byteBuffer, trackId);

        if ((getFlags() & 0x1) == 1) { //baseDataOffsetPresent
            IsoTypeWriter.writeUInt64(byteBuffer, getBaseDataOffset());
        }
        if ((getFlags() & 0x2) == 0x2) { //sampleDescriptionIndexPresent
            IsoTypeWriter.writeUInt32(byteBuffer, getSampleDescriptionIndex());
        }
        if ((getFlags() & 0x8) == 0x8) { //defaultSampleDurationPresent
            IsoTypeWriter.writeUInt32(byteBuffer, getDefaultSampleDuration());
        }
        if ((getFlags() & 0x10) == 0x10) { //defaultSampleSizePresent
            IsoTypeWriter.writeUInt32(byteBuffer, getDefaultSampleSize());
        }
        if ((getFlags() & 0x20) == 0x20) { //defaultSampleFlagsPresent
            defaultSampleFlags.getContent(byteBuffer);
        }
    
protected longgetContentSize()

        long size = 8;
        int flags = getFlags();
        if ((flags & 0x1) == 1) { //baseDataOffsetPresent
            size += 8;
        }
        if ((flags & 0x2) == 0x2) { //sampleDescriptionIndexPresent
            size += 4;
        }
        if ((flags & 0x8) == 0x8) { //defaultSampleDurationPresent
            size += 4;
        }
        if ((flags & 0x10) == 0x10) { //defaultSampleSizePresent
            size += 4;
        }
        if ((flags & 0x20) == 0x20) { //defaultSampleFlagsPresent
            size += 4;
        }
        return size;
    
public longgetDefaultSampleDuration()

        return defaultSampleDuration;
    
public SampleFlagsgetDefaultSampleFlags()

        return defaultSampleFlags;
    
public longgetDefaultSampleSize()

        return defaultSampleSize;
    
public longgetSampleDescriptionIndex()

        return sampleDescriptionIndex;
    
public longgetTrackId()

        return trackId;
    
public booleanhasBaseDataOffset()

        return (getFlags() & 0x1) != 0;
    
public booleanhasDefaultSampleDuration()

        return (getFlags() & 0x8) != 0;
    
public booleanhasDefaultSampleFlags()

        return (getFlags() & 0x20) != 0;
    
public booleanhasDefaultSampleSize()

        return (getFlags() & 0x10) != 0;
    
public booleanhasSampleDescriptionIndex()

        return (getFlags() & 0x2) != 0;
    
public booleanisDurationIsEmpty()

        return durationIsEmpty;
    
public voidsetBaseDataOffset(long baseDataOffset)

        if (baseDataOffset == -1) {
            setFlags(getFlags() & (Integer.MAX_VALUE ^ 0x1));
        } else {
            setFlags(getFlags() | 0x1); // activate the field
        }
        this.baseDataOffset = baseDataOffset;
    
public voidsetDefaultSampleDuration(long defaultSampleDuration)

        setFlags(getFlags() | 0x8); // activate the field
        this.defaultSampleDuration = defaultSampleDuration;
    
public voidsetDefaultSampleFlags(SampleFlags defaultSampleFlags)

        setFlags(getFlags() | 0x20); // activate the field
        this.defaultSampleFlags = defaultSampleFlags;
    
public voidsetDefaultSampleSize(long defaultSampleSize)

        setFlags(getFlags() | 0x10); // activate the field
        this.defaultSampleSize = defaultSampleSize;
    
public voidsetDurationIsEmpty(boolean durationIsEmpty)

        setFlags(getFlags() | 0x10000); // activate the field
        this.durationIsEmpty = durationIsEmpty;
    
public voidsetSampleDescriptionIndex(long sampleDescriptionIndex)

        if (sampleDescriptionIndex == -1) {
            setFlags(getFlags() & (Integer.MAX_VALUE ^ 0x2));
        } else {
            setFlags(getFlags() | 0x2); // activate the field
        }
        this.sampleDescriptionIndex = sampleDescriptionIndex;
    
public voidsetTrackId(long trackId)

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

        final StringBuilder sb = new StringBuilder();
        sb.append("TrackFragmentHeaderBox");
        sb.append("{trackId=").append(trackId);
        sb.append(", baseDataOffset=").append(baseDataOffset);
        sb.append(", sampleDescriptionIndex=").append(sampleDescriptionIndex);
        sb.append(", defaultSampleDuration=").append(defaultSampleDuration);
        sb.append(", defaultSampleSize=").append(defaultSampleSize);
        sb.append(", defaultSampleFlags=").append(defaultSampleFlags);
        sb.append(", durationIsEmpty=").append(durationIsEmpty);
        sb.append('}");
        return sb.toString();