FileDocCategorySizeDatePackage
Track.javaAPI DocJMF 2.1.1e5062Mon May 12 12:20:38 BST 2003javax.media

Track

public interface Track implements Duration
A Track abstracts the information specific to an individual track in a media stream. A media stream might contain multiple media tracks, such as separate tracks for audio, video, and midi data. A Track is the output of a Demultiplexer.
see
Demultiplexer
since
JMF 2.0

Fields Summary
public static Time
TIME_UNKNOWN
The mapFrameToTime method returns this value if the time mapping cannot be established or the Track contains an audio stream.
public static int
FRAME_UNKNOWN
The mapTimeToFrame method returns this value if the time mapping cannot be established or the Track contains an audio stream.
Constructors Summary
Methods Summary
public javax.media.FormatgetFormat()
Gets the Format of the data in this Track.

return
The Format associated with this Track.

public javax.media.TimegetStartTime()
Retrieves the start time of this Track.

return
A Time object that specifies the start time for this Track.

public booleanisEnabled()
Checks whether or not this Track is enabled. A Demultiplexer discards the data from disabled tracks.

return
true if the Track is enabled, false if it is not.

public javax.media.TimemapFrameToTime(int frameNumber)
Gets the Time that corresponds to the specified frame number.

return
A Time object that corresponds to the specified frame. If the mapping cannot be established or the Track is an audio track, TIME_UNKNOWN is returned.

public intmapTimeToFrame(javax.media.Time t)
Converts the given media time to the corresponding frame number.

The frame returned is the nearest frame that has a media time less than or equal to the given media time.

param
mediaTime the input media time for the conversion.
return
the converted frame number the given media time. If the conversion fails, FRAME_UNKNOWN is returned.

public voidreadFrame(javax.media.Buffer buffer)
Reads the next frame for this Track.

This method might block if the data for a complete frame is not available. It might also block if the stream contains intervening data for a different interleaved Track. Once the other Track is read by a readFrame call from a different thread, this method can read the frame. If the intervening Track has been disabled, data for that Track is read and discarded.

Note: This scenario is necessary only if a PullDataSource Demultiplexer implementation wants to avoid buffering data locally and copying the data to the Buffer passed in as a parameter. Implementations might decide to buffer data and not block (if possible) and incur data copy overhead.

If this method is called on a Track that has been disabled, it returns immediately with the DISCARD flag set on.

Each track has a sequence number that is updated by the Demultiplexer for each frame. If downstream nodes receive non-contiguous sequence numbers for a particular Track, they know that a data overflow has occurred for that Track.

param
buffer The Buffer into which the data is to be read. If readFrame is successful, buffer.getLength returns the length of the data that was read.

public voidsetEnabled(boolean t)
Enables or disables this Track. A Demultiplexer discards the data from disabled tracks.

param
t A boolean value indicating whether or not to enable this Track. Set to true to enable this Track, false to disable this Track.

public voidsetTrackListener(javax.media.TrackListener listener)
Adds an event listener for this Track. If the readFrame call in progress will block, the listener is notified. This enables the listener to stop the clock and post a RestartingEvent.

param
listener The TrackListener to add.