Copyright 2012-04-26 Werner Randelshofer

org.monte.media.avi
Class AbstractAVIStream.Track

java.lang.Object
  extended by org.monte.media.avi.AbstractAVIStream.Track
Direct Known Subclasses:
AbstractAVIStream.AudioTrack, AbstractAVIStream.MidiTrack, AbstractAVIStream.TextTrack, AbstractAVIStream.VideoTrack
Enclosing class:
AbstractAVIStream

protected abstract class AbstractAVIStream.Track
extends java.lang.Object

Represents a track (or "stream") in an AVI file.

A track is defined by an "strh" chunk, which contains an AVISTREAMHEADER struct. Additional chunks can be provided depending on the media type of the track.

See http://msdn.microsoft.com/en-us/library/ms779638(VS.85).aspx

 -----------------
 AVI Stream Header
 -----------------

 enum {
    audioStream = "auds",
   midiStream = "mids",
   textStream = "txts",
   videoStream = "vids"
 } aviStrhType;

 set {
    disabled = 0x00000001, // Indicates this stream should not be enabled by default.
    videoPaletteChanges = 0x00010000 
        // Indicates this video stream contains palette changes. This flag 
        // warns the playback software that it will need to animate the palette.
} aviStrhFlags;

typedef struct {
    Int16 left;
    Int16 top;
    Int16 right;
    Int16 bottom;
} aviRectangle;

typedef struct {
     FOURCC enum aviStrhType type; 
        // Contains a FOURCC that specifies the type of the data contained in 
        // the stream. The following standard AVI values for video and audio are 
        // defined.
     FOURCC handler;
        // Optionally, contains a FOURCC that identifies a specific data
        // handler.
        // The data handler is the preferred handler for the stream. For audio 
        // and video streams, this specifies the codec for decoding the stream.
     DWORD  set aviStrhFlags flags;
        // Contains any flags for the data stream. The bits in the high-order 
        // word of these flags are specific to the type of data contained in the
        // stream. 
     WORD   priority;
        // Specifies priority of a stream type. For example, in a file with 
        // multiple audio streams, the one with the highest priority might be 
        // the default stream.
     WORD   language;
     DWORD  initialFrames;
        // Specifies how far audio data is skewed ahead of the video frames in
        // interleaved files. Typically, this is about 0.75 seconds. If you are
        // creating interleaved files, specify the number of frames in the file 
        // prior to the initial frame of the AVI sequence in this member. For 
        // more information about the contents of this member, see "Special 
        // Information for Interleaved Files" in the Video for Windows 
        // Programmer's Guide.
     DWORD  scale;
        // Used with "rate" to specify the time scale that this stream will use.
        // Dividing "rate" by "scale" gives the number of samples per second.
        // For video streams, this is the frame rate. For audio streams, this 
        // rate corresponds to the time needed to play blockAlign bytes of 
        // audio, which for PCM audio is the just the sample rate.
     DWORD  rate;
        // See "scale".
     DWORD  startTime;
        // Specifies the starting time for this stream. The units are defined by
        // the "rate" and "scale" members in the main file header. Usually, this
        // is zero, but it can specify a delay time for a stream that does not 
        // startTime concurrently with the file.
     DWORD  length;
        // Specifies the length of this stream. The units are defined by the 
        // "rate" and "scale" members of the stream's header.
     DWORD  suggestedBufferSize;
        // Specifies how large a buffer should be used to read this stream.
        // Typically, this contains a value corresponding to the largest chunk
        // present in the stream. Using the correct buffer size makes playback 
        // more efficient. Use zero if you do not know the correct buffer size.
     DWORD  quality;
        // Specifies an indicator of the quality of the data in the stream. 
        // Quality is represented as a number between 0 and 10,000. For 
        // compressed data, this typically represents the value of the quality 
        // parameter passed to the compression software. If set to �1, drivers 
        // use the default quality value.
     DWORD  sampleSize;
        // Specifies the size of a single sample of data. This is set to zero if
        // the samples can vary in size. If this number is nonzero, then
        // multiple samples of data can be grouped into a single chunk within 
        // the file. If it is zero, each sample of data (such as a video frame)
        // must be in a separate chunk. For video streams, this number is 
        // typically zero, although it can be nonzero if all video frames are 
        // the same size. For audio streams, this number should be the same as 
        // the blockAlign member of the WAVEFORMATEX structure describing the audio.
    aviRectangle frame;
        // Specifies the destination rectangle for a text or video stream within
        // the movie rectangle specified by the "frameWidth" and "frameHeight"
        // members of the AVI main header structure. The "frame" member is 
        // typically used in support of multiple video streams. Set this 
        // rectangle to the coordinates corresponding to the movie rectangle to 
        // update the whole movie rectangle. Units for this member are pixels. 
        // The upper-left corner of the destination rectangle is relative to the 
        // upper-left corner of the movie rectangle.
 } AVISTREAMHEADER;     * 


Field Summary
protected  Codec codec
          The codec.
protected  java.util.ArrayList<RIFFChunk> extraHeaders
          List of additional header chunks.
protected  java.lang.String fccHandler
          Optionally, contains a FOURCC that identifies a specific data handler.
protected  int flags
          Contains any flags for the data stream.
protected  Format format
          The media format.
protected  long initialFrames
          Specifies how far audio data is skewed ahead of the video frames in interleaved files.
protected  Buffer inputBuffer
          The input buffer is used when one of the convenience methods without a Buffer parameter is used.
protected  int language
          Language tag.
protected  long length
          Specifies the length of this stream.
protected  AbstractAVIStream.AVIMediaType mediaType
          mediaType.fccType contains a FOURCC that specifies the type of the data contained in the stream.
protected  java.lang.String name
          The optional name of the track.
protected  Buffer outputBuffer
          The output buffer is used to store the output of the codec.
protected  int priority
          Specifies priority of a stream type.
protected  int quality
          Specifies an indicator of the quality of the data in the stream.
protected  long rate
          The rate of the media in scale units.
protected  long readIndex
          The current chunk index of the reader.
protected  java.util.ArrayList<AbstractAVIStream.Sample> samples
          List of samples.
protected  long scale
          Used with rate to specify the time scale that this stream will use.
protected  long startTime
          Specifies the starting time for this stream.
protected  AbstractAVIStream.FixedSizeDataChunk strfChunk
          This chunk holds the AVI Stream Format Header.
protected  AbstractAVIStream.FixedSizeDataChunk strhChunk
          This chunk holds the AVI Stream Header.
protected  int syncInterval
          Interval between sync samples (keyframes).
protected  java.lang.String twoCC
          The twoCC code is used for the ids of the chunks which hold the data samples.
 
Constructor Summary
AbstractAVIStream.Track(int trackIndex, AbstractAVIStream.AVIMediaType mediaType, java.lang.String fourCC)
           
 
Method Summary
 void addSample(AbstractAVIStream.Sample s)
           
abstract  java.lang.String getSampleChunkFourCC(boolean isSync)
           
abstract  long getSTRFChunkSize()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

format

protected Format format
The media format. FIXME - AbstractAVIStream should have no dependencies to Format.


samples

protected java.util.ArrayList<AbstractAVIStream.Sample> samples
List of samples.


syncInterval

protected int syncInterval
Interval between sync samples (keyframes). 0 = automatic. 1 = write all samples as sync samples. n = sync every n-th sample.


twoCC

protected java.lang.String twoCC
The twoCC code is used for the ids of the chunks which hold the data samples.


mediaType

protected final AbstractAVIStream.AVIMediaType mediaType
mediaType.fccType contains a FOURCC that specifies the type of the data contained in the stream. The following standard AVI values for video and audio are defined. FOURCC Description 'auds' Audio stream 'mids' MIDI stream 'txts' Text stream 'vids' Video stream


fccHandler

protected java.lang.String fccHandler
Optionally, contains a FOURCC that identifies a specific data handler. The data handler is the preferred handler for the stream. For audio and video streams, this specifies the codec for decoding the stream.


flags

protected int flags
Contains any flags for the data stream. The bits in the high-order word of these flags are specific to the type of data contained in the stream. The following standard flags are defined. Value Description AVISF_DISABLED 0x00000001 Indicates this stream should not be enabled by default. AVISF_VIDEO_PALCHANGES 0x00010000 Indicates this video stream contains palette changes. This flag warns the playback software that it will need to animate the palette.


priority

protected int priority
Specifies priority of a stream type. For example, in a file with multiple audio streams, the one with the highest priority might be the default stream.


language

protected int language
Language tag.


initialFrames

protected long initialFrames
Specifies how far audio data is skewed ahead of the video frames in interleaved files. Typically, this is about 0.75 seconds. If you are creating interleaved files, specify the number of frames in the file prior to the initial frame of the AVI sequence in this member. For more information, see the remarks for the initialFrames member of the AVIMAINHEADER structure.


scale

protected long scale
Used with rate to specify the time scale that this stream will use. Dividing rate by scale gives the number of samples per second. For video streams, this is the frame rate. For audio streams, this rate corresponds to the time needed to play blockAlign bytes of audio, which for PCM audio is the just the sample rate.


rate

protected long rate
The rate of the media in scale units.


startTime

protected long startTime
Specifies the starting time for this stream. The units are defined by the rate and scale members in the main file header. Usually, this is zero, but it can specify a delay time for a stream that does not startTime concurrently with the file.


length

protected long length
Specifies the length of this stream. The units are defined by the rate and scale members of the stream's header.


quality

protected int quality
Specifies an indicator of the quality of the data in the stream. Quality is represented as a number between 0 and 10,000. For compressed data, this typically represents the value of the quality parameter passed to the compression software. If set to –1, drivers use the default quality value.


strhChunk

protected AbstractAVIStream.FixedSizeDataChunk strhChunk
This chunk holds the AVI Stream Header.


strfChunk

protected AbstractAVIStream.FixedSizeDataChunk strfChunk
This chunk holds the AVI Stream Format Header.


name

protected java.lang.String name
The optional name of the track.


codec

protected Codec codec
The codec.


outputBuffer

protected Buffer outputBuffer
The output buffer is used to store the output of the codec.


inputBuffer

protected Buffer inputBuffer
The input buffer is used when one of the convenience methods without a Buffer parameter is used.


readIndex

protected long readIndex
The current chunk index of the reader.


extraHeaders

protected java.util.ArrayList<RIFFChunk> extraHeaders
List of additional header chunks.

Constructor Detail

AbstractAVIStream.Track

public AbstractAVIStream.Track(int trackIndex,
                               AbstractAVIStream.AVIMediaType mediaType,
                               java.lang.String fourCC)
Method Detail

getSTRFChunkSize

public abstract long getSTRFChunkSize()

getSampleChunkFourCC

public abstract java.lang.String getSampleChunkFourCC(boolean isSync)

addSample

public void addSample(AbstractAVIStream.Sample s)

Copyright 2012-04-26 Werner Randelshofer