javax.media
Interface Demultiplexer


public interface Demultiplexer
extends PlugIn, MediaHandler, Duration

A Demultiplexer is a media processing unit that takes an interleaved media stream as input, extracts the individual tracks from the stream, and outputs the resulting tracks. It has one input and multiple outputs.

A Demultiplexer is a MediaHandler and needs to implement the setSource method. This method should throw an IncompatibleSourceException if the Demultiplexer cannot use the specified DataSource. This typically happens if:

The setSource method should throw an IOException if the specified DataSource contains a null stream array.

Note: No data is read by the setSource method. When trying to select a Demultiplexer for a particular content-type from a list of Demultiplexer implementations obtained through the PlugInManager, the Processor picks the first Demultiplexer that doesn't for throw an IncompatibleSourceException or an IOException when setSource is called. If a particular Demultiplexer reads some data from the stream and then throws an IncompatibleSourceException, the next Demultiplexer in the list gets the stream in a different state.

Since:
JMF 2.0

Fields inherited from interface javax.media.PlugIn
BUFFER_PROCESSED_FAILED, BUFFER_PROCESSED_OK, INPUT_BUFFER_NOT_CONSUMED, OUTPUT_BUFFER_NOT_FILLED, PLUGIN_TERMINATED
 
Fields inherited from interface javax.media.Duration
DURATION_UNBOUNDED, DURATION_UNKNOWN
 
Method Summary
 Time getDuration()
          Gets the duration of this media stream when played at the default rate.
 Time getMediaTime()
          Gets the current media time.
 ContentDescriptor[] getSupportedInputContentDescriptors()
          Lists the all of the input content descriptors that this Demultiplexer supports.
 Track[] getTracks()
           Retrieves the individual tracks that the media stream contains.
 boolean isPositionable()
          Checks whether or not the stream can be repositioned to the beginning.
 boolean isRandomAccess()
          Checks whether or not the stream can be positioned at any Time.
 Time setPosition(Time where, int rounding)
          Sets the stream position (media time) to the specified Time.
 void start()
          Signals that data is going to start being read from the Demultiplexer.
 void stop()
          Signals that data is going to stop being read from the Demultiplexer.
 
Methods inherited from interface javax.media.PlugIn
close, getName, open, reset
 
Methods inherited from interface javax.media.MediaHandler
setSource
 
Methods inherited from interface javax.media.Controls
getControl, getControls
 

Method Detail

getSupportedInputContentDescriptors

public ContentDescriptor[] getSupportedInputContentDescriptors()
Lists the all of the input content descriptors that this Demultiplexer supports.

start

public void start()
           throws java.io.IOException
Signals that data is going to start being read from the Demultiplexer. The start method is called before any calls are made to readFrame.
Throws:
java.io.IOException - If there is an error when trying to read from the DataSource.

stop

public void stop()
Signals that data is going to stop being read from the Demultiplexer. After the stop method is called, readFrame will not be called again unless start is called first.

getTracks

public Track[] getTracks()
                  throws java.io.IOException,
                         BadHeaderException

Retrieves the individual tracks that the media stream contains. A stream can contain multiple media tracks, such as separate tracks for audio, video, and midi data. The information specific to a track is abstracted by an instance of a class that implements the Track interface. The Track interface also provides methods for enabling or disabling a track.

When getTracks is called, the stream header is read and parsed (if there is one), the track information is retrieved, the maximum frame size for each track is computed, and the play list is built (if applicable).

Returns:
An array of Track objects. The length of the array is equal to the number of tracks in the stream.
Throws:
BadHeaderException - If the header information is incomplete or inconsistent.
java.io.IOException - If there is an error when trying to read from the DataSource.

isPositionable

public boolean isPositionable()
Checks whether or not the stream can be repositioned to the beginning.
Returns:
true if the stream can be repositioned, false if it cannot.

isRandomAccess

public boolean isRandomAccess()
Checks whether or not the stream can be positioned at any Time. If isRandomAccess returns true, then the stream is also positionable (isPositionable returns true). However, a stream can be positionable but not random access--the isPositionable method might return true even if isRandomAccess returns false.
Returns:
true if the stream is a random access stream, false if it is not.

setPosition

public Time setPosition(Time where,
                        int rounding)
Sets the stream position (media time) to the specified Time. Returns the rounded position that was actually set. Implementations should set the position to a key frame, if possible.
Parameters:
time - The new stream position, specified as a Time.
round - The rounding technique to be used: RoundUp, RoundDown, or RoundNearest.
Returns:
The actual stream position that was set as a Time object.

getMediaTime

public Time getMediaTime()
Gets the current media time. This is the stream position that the next readFrame will read.
Returns:
The current position in the media stream as a Time object.

getDuration

public Time getDuration()
Gets the duration of this media stream when played at the default rate.

Note that each track can have a different duration and a different start time. This method returns the total duration from when the first track starts and the last track ends.

Specified by:
getDuration in interface Duration
Returns:
A Time object that represents the duration or DURATION_UNKNOWN if the duration cannot be determined.


Submit a bug or feature
Copyright 1999-2000 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.