javax.media
接口 Track

所有超级接口:
Duration

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.

从以下版本开始:
JMF 2.0
另请参见:
Demultiplexer

字段摘要
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.
 
从接口 javax.media.Duration 继承的字段
DURATION_UNBOUNDED, DURATION_UNKNOWN
 
方法摘要
 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.
 
从接口 javax.media.Duration 继承的方法
getDuration
 

字段详细信息

TIME_UNKNOWN

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

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.

另请参见:
常量字段值
方法详细信息

getFormat

Format getFormat()
Gets the Format of the data in this Track.

返回:
The Format associated with this Track.

setEnabled

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

参数:
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

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

返回:
true if the Track is enabled, false if it is not.

getStartTime

Time getStartTime()
Retrieves the start time of this Track.

返回:
A Time object that specifies the start time for this Track.

readFrame

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.

参数:
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

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.

参数:
mediaTime - the input media time for the conversion.
返回:
the converted frame number the given media time. If the conversion fails, FRAME_UNKNOWN is returned.

mapFrameToTime

Time mapFrameToTime(int frameNumber)
Gets the Time that corresponds to the specified frame number.

返回:
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

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.

参数:
listener - The TrackListener to add.