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

TrackHeaderBox

public class TrackHeaderBox extends com.googlecode.mp4parser.AbstractFullBox
This box specifies the characteristics of a single track. Exactly one Track Header Box is contained in a track.
In the absence of an edit list, the presentation of a track starts at the beginning of the overall presentation. An empty edit is used to offset the start time of a track.
The default value of the track header flags for media tracks is 7 (track_enabled, track_in_movie, track_in_preview). If in a presentation all tracks have neither track_in_movie nor track_in_preview set, then all tracks shall be treated as if both flags were set on all tracks. Hint tracks should have the track header flags set to 0, so that they are ignored for local playback and preview.

Fields Summary
public static final String
TYPE
private long
creationTime
private long
modificationTime
private long
trackId
private long
duration
private int
layer
private int
alternateGroup
private float
volume
private double[]
matrix
private double
width
private double
height
Constructors Summary
public TrackHeaderBox()



      
        super(TYPE);

    
Methods Summary
public void_parseDetails(java.nio.ByteBuffer content)

        parseVersionAndFlags(content);
        if (getVersion() == 1) {
            creationTime = IsoTypeReader.readUInt64(content);
            modificationTime = IsoTypeReader.readUInt64(content);
            trackId = IsoTypeReader.readUInt32(content);
            IsoTypeReader.readUInt32(content);
            duration = IsoTypeReader.readUInt64(content);
        } else {
            creationTime = IsoTypeReader.readUInt32(content);
            modificationTime = IsoTypeReader.readUInt32(content);
            trackId = IsoTypeReader.readUInt32(content);
            IsoTypeReader.readUInt32(content);
            duration = IsoTypeReader.readUInt32(content);
        } // 196
        IsoTypeReader.readUInt32(content);
        IsoTypeReader.readUInt32(content);
        layer = IsoTypeReader.readUInt16(content);    // 204
        alternateGroup = IsoTypeReader.readUInt16(content);
        volume = IsoTypeReader.readFixedPoint88(content);
        IsoTypeReader.readUInt16(content);     // 212
        matrix = new double[9];
        int i = 0;
        matrix[i++] = IsoTypeReader.readFixedPoint1616(content);
        matrix[i++] = IsoTypeReader.readFixedPoint1616(content);
        matrix[i++] = IsoTypeReader.readFixedPoint0230(content);

        matrix[i++] = IsoTypeReader.readFixedPoint1616(content);
        matrix[i++] = IsoTypeReader.readFixedPoint1616(content);
        matrix[i++] = IsoTypeReader.readFixedPoint0230(content);

        matrix[i++] = IsoTypeReader.readFixedPoint1616(content);
        matrix[i++] = IsoTypeReader.readFixedPoint1616(content);
        matrix[i] = IsoTypeReader.readFixedPoint0230(content);

        width = IsoTypeReader.readFixedPoint1616(content);    // 248
        height = IsoTypeReader.readFixedPoint1616(content);
    
public intgetAlternateGroup()

        return alternateGroup;
    
public voidgetContent(java.nio.ByteBuffer byteBuffer)

        writeVersionAndFlags(byteBuffer);
        if (getVersion() == 1) {
            IsoTypeWriter.writeUInt64(byteBuffer, creationTime);
            IsoTypeWriter.writeUInt64(byteBuffer, modificationTime);
            IsoTypeWriter.writeUInt32(byteBuffer, trackId);
            IsoTypeWriter.writeUInt32(byteBuffer, 0);
            IsoTypeWriter.writeUInt64(byteBuffer, duration);
        } else {
            IsoTypeWriter.writeUInt32(byteBuffer, creationTime);
            IsoTypeWriter.writeUInt32(byteBuffer, modificationTime);
            IsoTypeWriter.writeUInt32(byteBuffer, trackId);
            IsoTypeWriter.writeUInt32(byteBuffer, 0);
            IsoTypeWriter.writeUInt32(byteBuffer, duration);
        } // 196
        IsoTypeWriter.writeUInt32(byteBuffer, 0);
        IsoTypeWriter.writeUInt32(byteBuffer, 0);
        IsoTypeWriter.writeUInt16(byteBuffer, layer);
        IsoTypeWriter.writeUInt16(byteBuffer, alternateGroup);
        IsoTypeWriter.writeFixedPoint88(byteBuffer, volume);
        IsoTypeWriter.writeUInt16(byteBuffer, 0);
        int i = 0;
        IsoTypeWriter.writeFixedPoint1616(byteBuffer, matrix[i++]);
        IsoTypeWriter.writeFixedPoint1616(byteBuffer, matrix[i++]);
        IsoTypeWriter.writeFixedPoint0230(byteBuffer, matrix[i++]);

        IsoTypeWriter.writeFixedPoint1616(byteBuffer, matrix[i++]);
        IsoTypeWriter.writeFixedPoint1616(byteBuffer, matrix[i++]);
        IsoTypeWriter.writeFixedPoint0230(byteBuffer, matrix[i++]);

        IsoTypeWriter.writeFixedPoint1616(byteBuffer, matrix[i++]);
        IsoTypeWriter.writeFixedPoint1616(byteBuffer, matrix[i++]);
        IsoTypeWriter.writeFixedPoint0230(byteBuffer, matrix[i]);

        IsoTypeWriter.writeFixedPoint1616(byteBuffer, width);
        IsoTypeWriter.writeFixedPoint1616(byteBuffer, height);
    
protected longgetContentSize()

        long contentSize = 4;
        if (getVersion() == 1) {
            contentSize += 32;
        } else {
            contentSize += 20;
        }
        contentSize += 60;
        return contentSize;
    
public longgetCreationTime()

        return creationTime;
    
public longgetDuration()

        return duration;
    
public doublegetHeight()

        return height;
    
public intgetLayer()

        return layer;
    
public double[]getMatrix()

        return matrix;
    
public longgetModificationTime()

        return modificationTime;
    
public longgetTrackId()

        return trackId;
    
public floatgetVolume()

        return volume;
    
public doublegetWidth()

        return width;
    
public booleanisEnabled()

        return (getFlags() & 1) > 0;
    
public booleanisInMovie()

        return (getFlags() & 2) > 0;
    
public booleanisInPoster()

        return (getFlags() & 8) > 0;
    
public booleanisInPreview()

        return (getFlags() & 4) > 0;
    
public voidsetAlternateGroup(int alternateGroup)

        this.alternateGroup = alternateGroup;
    
public voidsetCreationTime(long creationTime)

        this.creationTime = creationTime;
    
public voidsetDuration(long duration)

        this.duration = duration;
    
public voidsetHeight(double height)

        this.height = height;
    
public voidsetLayer(int layer)

        this.layer = layer;
    
public voidsetMatrix(double[] matrix)

        this.matrix = matrix;
    
public voidsetModificationTime(long modificationTime)

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

        this.trackId = trackId;
    
public voidsetVolume(float volume)

        this.volume = volume;
    
public voidsetWidth(double width)

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

        StringBuilder result = new StringBuilder();
        result.append("TrackHeaderBox[");
        result.append("creationTime=").append(getCreationTime());
        result.append(";");
        result.append("modificationTime=").append(getModificationTime());
        result.append(";");
        result.append("trackId=").append(getTrackId());
        result.append(";");
        result.append("duration=").append(getDuration());
        result.append(";");
        result.append("layer=").append(getLayer());
        result.append(";");
        result.append("alternateGroup=").append(getAlternateGroup());
        result.append(";");
        result.append("volume=").append(getVolume());
        for (int i = 0; i < matrix.length; i++) {
            result.append(";");
            result.append("matrix").append(i).append("=").append(matrix[i]);
        }
        result.append(";");
        result.append("width=").append(getWidth());
        result.append(";");
        result.append("height=").append(getHeight());
        result.append("]");
        return result.toString();