javax.media
Interface Track


public abstract interface Track
extends Duration

Tracks are the output streams from a Demultiplexer.

Since:
JMF 2.0
See Also:
Demultiplexer

Field Summary
static int FRAME_UNKNOWN
           
static Time TIME_UNKNOWN
           
 
Fields inherited from class javax.media.Duration
DURATION_UNBOUNDED, DURATION_UNKNOWN
 
Method Summary
 Format getFormat()
          Obtain the format information associated with this Track.
 Time getStartTime()
          Return the start time of this Track
 boolean isEnabled()
          Return true if the track is enabled, false otherwise.
 Time mapFrameToTime(int frameNumber)
          Return the Time that corresponds to the frame number passed as parameter If the mapping cannot be established for any reason, TIME_UNKNWON should be returned.
 int mapTimeToFrame(Time t)
          Return the frame number that corresponds to the Time passed as parameter Frame numbers start from 0.
 void readFrame(Buffer buffer)
          Read the next frame for this track.
 void setEnabled(boolean t)
          Enables or disables this track, depending on the value of the parameter t.
 void setTrackListener(TrackListener listener)
          If the readFrame call in progress will block then the listener can be notified.
 
Methods inherited from interface javax.media.Duration
getDuration
 

Field Detail

TIME_UNKNOWN

public static final Time TIME_UNKNOWN

FRAME_UNKNOWN

public static final int FRAME_UNKNOWN
Method Detail

getFormat

public Format getFormat()
Obtain the format information associated with this Track.
Returns:
The Format associated with this Track.

setEnabled

public void setEnabled(boolean t)
Enables or disables this track, depending on the value of the parameter t. Demultiplexer will discard the data from a disabled track.

isEnabled

public boolean isEnabled()
Return true if the track is enabled, false otherwise.

getStartTime

public Time getStartTime()
Return the start time of this Track

readFrame

public void readFrame(Buffer buffer)
Read the next frame for this track. This is potentially a blocking call. In addition to blocking when data for a complete frame is not available, it may also block if there is 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. The above scenario is necessary only if a PullDataSource demultiplexer implementation wants to avoid buffering up data locally and copying it to the buffer passed in as a parameter. Implementations may decide to do buffer data and not block (if possible) but incur data copy overhead. If this method is called on a track that has been disabled, it will return immediately with the DISCARD flag set on. For each track there is a sequence number. The demultiplexer will update the sequence number for each frame. If the downstream nodes receive non-contiguous sequence numbers for a certain track, then they know that a data overflow has occurred for that track.
Parameters:
buffer - provides the buffer into which the data is to be read. On success, buffer.getLength returns the length of the data that had been read.

mapTimeToFrame

public int mapTimeToFrame(Time t)
Return the frame number that corresponds to the Time passed as parameter Frame numbers start from 0. If the mapping cannot be established for any reason, FRAME_UNKNOWN should be returned. if t is negative or if t is greater than the duration, FRAME_UNKNOWN should be returned. Audio tracks should return FRAME_UNKNOWN

mapFrameToTime

public Time mapFrameToTime(int frameNumber)
Return the Time that corresponds to the frame number passed as parameter If the mapping cannot be established for any reason, TIME_UNKNWON should be returned. Audio tracks should return TIME_UNKNWON

setTrackListener

public void setTrackListener(TrackListener listener)
If the readFrame call in progress will block then the listener can be notified. The listener can then stop the clock and send a RestartingEvent