javax.media
Interface Track


public interface Track
extends 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.

Since:
JMF 2.0
See Also:
Demultiplexer

Field Summary
static int FRAME_UNKNOWN
          The mapTimeToFrame method returns this value if the time mapping cannot be established or the Track contains an audio stream.
static Time TIME_UNKNOWN
          The mapFrameToTime method returns this value if the time mapping cannot be established or the Track contains an audio stream.
 
Fields inherited from interface javax.media.Duration
DURATION_UNBOUNDED, DURATION_UNKNOWN
 
Method Summary
 Format getFormat()
          Gets the Format of the data in this Track.
 Time getStartTime()
          Retrieves the start time of this Track.
 boolean isEnabled()
          Checks whether or not this Track is enabled.
 Time mapFrameToTime(int frameNumber)
          Gets the Time that corresponds to the specified frame number.
 int mapTimeToFrame(Time t)
          Converts the given media time to the corresponding frame number.
 void readFrame(Buffer buffer)
          Reads the next frame for this Track.
 void setEnabled(boolean t)
          Enables or disables this Track.
 void setTrackListener(TrackListener listener)
          Adds an event listener for this Track.
 
Methods inherited from interface javax.media.Duration
getDuration
 

Field Detail

TIME_UNKNOWN

public static final Time TIME_UNKNOWN
The mapFrameToTime method returns this value if the time mapping cannot be established or the Track contains an audio stream.

FRAME_UNKNOWN

public static final int FRAME_UNKNOWN
The mapTimeToFrame method returns this value if the time mapping cannot be established or the Track contains an audio stream.
Method Detail

getFormat

public Format getFormat()
Gets the Format of the data in this Track.
Returns:
The Format associated with this Track.

setEnabled

public void setEnabled(boolean t)
Enables or disables this Track. A Demultiplexer discards the data from disabled tracks.
Parameters:
t - A boolean value indicating whether or not to enable this Track. Set to true to enable this Track, false to disable this Track.

isEnabled

public boolean isEnabled()
Checks whether or not this Track is enabled. A Demultiplexer discards the data from disabled tracks.
Returns:
true if the Track is enabled, false if it is not.

getStartTime

public Time getStartTime()
Retrieves the start time of this Track.
Returns:
A Time object that specifies the start time for this Track.

readFrame

public void readFrame(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.

Parameters:
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.

mapTimeToFrame

public int mapTimeToFrame(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.

Parameters:
mediaTime - the input media time for the conversion.
Returns:
the converted frame number the given media time. If the conversion fails, FRAME_UNKNOWN is returned.

mapFrameToTime

public Time mapFrameToTime(int frameNumber)
Gets the Time that corresponds to the specified frame number.
Returns:
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.

setTrackListener

public void setTrackListener(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.
Parameters:
listener - The TrackListener to add.


Submit a bug or feature
Copyright 1994-2004 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved. See the Specification License for more details.
Sun, Sun Microsystems, and Java are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.