FileDocCategorySizeDatePackage
DataSource.javaAPI DocJMF 2.1.1e5805Mon May 12 12:20:42 BST 2003javax.media.protocol

DataSource

public abstract class DataSource extends Object implements Controls, Duration
A DataSource is an abstraction for media protocol-handlers. DataSource manages the life-cycle of the media source by providing a simple connection protocol.

Source Controls

A DataSource might support an operation that is not part of the DataSource class definition. For example a source could support positioning its media to a particular time. Some operations are dependent on the data stream that the source is managing, and support cannot be determined until after the source has been connected.

To obtain all of the objects that provide control over a DataSource, use getControls which returns an array of Object To determine if a particular kind of control is available and obtain the object that implements it, use getControl which takes the name of the Class or Interface that of the desired control.

DataSource Properties

A DataSource may implement the following few well-defined interfaces:
Positionable: if the DataSource can be positioned.
RateConfigureable: if the DataSource supports different playback rates.
SourceCloneable: if the DataSource can be cloned.
CaptureDevice: if the DataSource is a capture device.
see
Manager
see
Positionable
see
RateConfigureable
see
CaptureDevice
see
SourceCloneable
version
1.4, 02/08/21

Fields Summary
MediaLocator
sourceLocator
Constructors Summary
public DataSource()
A no-argument constructor required by pre 1.1 implementations so that this class can be instantiated by calling Class.newInstance.

	sourceLocator = null;
    
public DataSource(MediaLocator source)
Construct a DataSource from a MediaLocator. This method should be overloaded by subclasses; the default implementation just keeps track of the MediaLocator.

param
source The MediaLocator that describes the DataSource.

	sourceLocator = null;
	setLocator(source);
    
Methods Summary
public abstract voidconnect()
Open a connection to the source described by the MediaLocator.

The connect method initiates communication with the source.

exception
IOException Thrown if there are IO problems when connect is called.

public abstract voiddisconnect()
Close the connection to the source described by the locator.

The disconnect method frees resources used to maintain a connection to the source. If no resources are in use, disconnect is ignored. If stop hasn't already been called, calling disconnect implies a stop.

public abstract java.lang.StringgetContentType()
Get a string that describes the content-type of the media that the source is providing.

It is an error to call getContentType if the source is not connected.

return
The name that describes the media content.

public javax.media.MediaLocatorgetLocator()
Get the MediaLocator that describes this source. Returns null if the locator hasn't been set. (Very unlikely.)

return
The MediaLocator for this source.

	return sourceLocator;
    
protected voidinitCheck()
Check to see if this connection has been initialized with a MediaLocator. If the connection hasn't been initialized, initCheck throws an UninitializedError. Most methods should call initCheck on entry.

	if(sourceLocator ==  null) {
	    // $jdr: This should a real media error.
	    throw new java.lang.Error("Uninitialized DataSource error.");
	}
    
public voidsetLocator(javax.media.MediaLocator source)
Set the connection source for this DataSource. This method should only be called once; an error is thrown if the locator has already been set.

param
source The MediaLocator that describes the media source.

	if( sourceLocator == null) {
	    sourceLocator = source;
	} else {
	    // $jdr: Should we name the error here?
	    throw new java.lang.Error("Locator already set on DataSource.");
	}
    
public abstract voidstart()
Initiate data-transfer. The start method must be called before data is available. (You must call connect before calling start.)

exception
IOException Thrown if there are IO problems with the source when start is called.

public abstract voidstop()
Stop the data-transfer. If the source has not been connected and started, stop does nothing.