FileDocCategorySizeDatePackage
DataSource.javaAPI DocJMF 2.1.1e6384Mon May 12 12:21:22 BST 2003com.ibm.media.protocol.ds

DataSource

public class DataSource extends PushBufferDataSource
This class is a DataSource for video capture with DirectShow

Fields Summary
DSSourceStream[]
streams
DSSourceStream
stream
boolean
connected
boolean
started
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.

    
     
	JMFSecurityManager.loadLibrary("jmds");
    
    
	super();
    
Methods Summary
private native booleanbuildDSGraph(int deviceNo)
Build the DirectShow capture filter graph

return
true if succeed, false otherwise

public 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.

    
	if (connected)
	    return;

	MediaLocator locator = getLocator();
	String remainder = locator.getRemainder();
	int deviceNo = -1;

	if (remainder.startsWith("//")) {
	  remainder = remainder.substring(2);
	  try {
	    deviceNo = Integer.valueOf(remainder).intValue();
	  }
	  catch (NumberFormatException e) {
	    deviceNo = -1;
	  }
	}
	if (deviceNo == -1) {
	  System.out.println("Illegal locator, using default device");
	  System.out.println("Use: ds://<DeviceNumber> for specific device");
	  deviceNo = 0;
	}
	if (!buildDSGraph(deviceNo)) {
	  System.out.println("Error building DirectShow Filter Graph");
	  throw new IOException("Error building DirectShow Filter Graph");
	}
	stream = new DSSourceStream(); // should we have here parameters???
	connected = true;
    
private native voiddestroyDSGraph()
Destroy the DirectShow capture filter graph

public 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.

    
	if (!connected)
	    return;
    
	destroyDSGraph();
	stream = null;
	connected = false;
    
public 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.


	return "raw";
    
public java.lang.ObjectgetControl(java.lang.String controlType)
Obtain the object that implements the specified Class or Interface The full class or interface name must be used.

If the control is not supported then null is returned.

return
the object that implements the control, or null.


	return null;
    
public java.lang.Object[]getControls()
Obtain the collection of objects that control the object that implements this interface.

If no controls are supported, a zero length array is returned.

return
the collection of object controls


	return new Object[0];
    
public javax.media.TimegetDuration()
Get the duration of the media represented by this object. The value returned is the media's duration when played at the default rate. If the duration can't be determined (for example, the media object is presenting live video) getDuration returns DURATION_UNKNOWN.

return
A Time object representing the duration or DURATION_UNKNOWN.


	return DURATION_UNKNOWN; 
    
public javax.media.protocol.PushBufferStream[]getStreams()
Get the collection of streams that this source manages. The collection of streams is entirely content dependent. The ContentDescriptor of this DataSource provides the only indication of what streams can be available on this connection.

return
The collection of streams for this source.

    
	streams[0] = stream;
	return streams;
    
public 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.

    
	if (started)
	    return;

	stream.start(); // start a thread to initiate the Processor's read() calls
	if (!startDSGraph()) {
	  System.out.println("Error while starting DirectShow Filter Graph");
	  throw new IOException("Error while starting DirectShow Filter Graph");
	}
	started = true;
    
private native booleanstartDSGraph()
Start the DirectShow capture filter graph

return
true if succeed, false otherwise

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


	if (!started)
	    return;

	stream.stop();
	if (!stopDSGraph()) {
	  System.out.println("Error stopping DirectShow Filter Graph");
	  throw new IOException("Error stopping DirectShow Filter Graph");
	}
    
	started = false;
    
private native booleanstopDSGraph()
Stop the DirectShow capture filter graph

return
true if succeed, false otherwise