FileDocCategorySizeDatePackage
RTPPushDataSource.javaAPI DocJMF 2.1.1e6822Mon May 12 12:20:40 BST 2003javax.media.rtp

RTPPushDataSource

public class RTPPushDataSource extends PushDataSource
This is an abstraction for a RTP data handler. The source allows the underlying network/transport protocol to be abstracted from the RTP handler. The source is a TWO WAY datasource in that it has an output data stream (PushSourceStream) as well as an input data stream (OutputDataStream). RTPDataSocket extends javax.media.protocol.DataSource. Data flowing out of or in to this source is a stream of bytes in the form of a RTP packet and does not contain any information dependant on the network/transport protocol that will be used to transmit these bytes. Note: an RTPPushDataSource can either handle the DataChannel of an RTP session or the control channel of an RTP session. An RTPPushDataSource that handles the data channel of an RTP session must implement the interface defined in javax.media.rtp.DataChannel.
deprecated
This inferface has been replaced with the RTPConnector interface.
see
DataChannel

Fields Summary
PushSourceStream
outputstream
The output stream of this socket. Implements javax.media.protocol.PushSourceStream. Data on this stream is transferrred to the SourceTransferHandler
OutputDataStream
inputstream
The input stream of this socket. Data on this stream is sent out on the wire using the underlying network/transport protocol Implements javax.media.rtp.OutputDataStream
String
contentType
The content type of this socket. needs to be set by the creator of this datasocket before a player can be created for this datasource.
private boolean
connected
Used to ensure that DataSource methods like getContentType() cannot be called till this datasource has been connected.
private boolean
started
Used to check if the datasource has been started. This will initiate data transfer to and from this data source
DataSource
childsrc
The actual datasource created by the RTPSM and passed to the handler
private RTPControl
rtpcontrol
The RTPControl interface that is exported by this datasource and will be used to configure information for this datasource
Constructors Summary
public RTPPushDataSource()

    
     
	// since we cannot access the RTPControlImpl class in the
	// javax.media packages,  we will load the class based on the
	// classname
	Class eClass = null;
	try{
	    eClass  =
		Class.forName("com.sun.media.rtp.RTPControlImpl");
	    rtpcontrol = (RTPControl) eClass.newInstance();
	}catch (Exception e){
	    
	    rtpcontrol = null;
	}
    
Methods Summary
public voidconnect()
Set the boolean to true and dont do anything else in connect for now

	connected = true;
	if (childsrc != null)
	  childsrc.connect();
    
public voiddisconnect()
Set the boolean to false and dont do anything else in connect for now

	connected = false;
	if (childsrc != null)
	  childsrc.disconnect();
    
public java.lang.StringgetContentType()
Implementation of javax.media.protocol.DataSource.getContentType()

	if (!connected){
	    System.err.println("Error: DataSource not connected");
	    return null;
	}
	return ContentDescriptor.mimeTypeToPackageName(contentType);
    
public java.lang.ObjectgetControl(java.lang.String controlName)
Returns null because no controls are implemented.

return
null.

	if (controlName.equals("javax.media.rtp.RTPControl"))
	    return rtpcontrol;
	return null;
    
public java.lang.Object[]getControls()
Returns an zero length array because no controls are supported.

return
a zero length Object array.

	// return a one element array of rtpcontrol object
	RTPControl[] controls = new RTPControl[1];
	controls[0] = rtpcontrol;
	return controls;	
    
public javax.media.TimegetDuration()
Returns null since the duration of the streams of this datasource are not known

	return null;
    
public javax.media.rtp.OutputDataStreamgetInputStream()
Method to retrieve the input stream of this two way data source

	return inputstream;
    
public javax.media.protocol.PushSourceStreamgetOutputStream()
Method to retrive the output stream of this two way data source

	return outputstream;
    
public javax.media.protocol.PushSourceStream[]getStreams()

	PushSourceStream[] outstream = new PushSourceStream[1];
	outstream[0]= outputstream;
	return outstream;
    
protected voidinitCheck()
This two way data source does not have any medialocator and datasource will throw an Uninitialized DataSource error incase initCheck() is called on this datasource. So, here this method is overrident to esnure that no errors are thrown and in the absence of a MediaLocator, nothing is done for now

    
public booleanisStarted()
Method to find out if the source had been started

	return started;
    
public voidsetChild(javax.media.protocol.DataSource source)

	childsrc = source;
    
public voidsetContentType(java.lang.String contentType)
Method used to set the content type of this two way data source

	this.contentType = contentType;
    
public voidsetInputStream(javax.media.rtp.OutputDataStream inputstream)
Method to set the input stream of this two way data source

	this.inputstream = inputstream;
    
public voidsetOutputStream(javax.media.protocol.PushSourceStream outputstream)
Method to set the output stream of this two way data source

	this.outputstream = outputstream;
    
public voidstart()
Initiates data-transfer. Start must be called before data is available. Connect must be called before start.

exception
IOException thrown if the source has IO trouble at startup time.

	if (!connected)
	    return;
	started = true;
	if (childsrc != null)
	    childsrc.start();
    
public voidstop()
Stops data-transfer. If the source has not already been connected and started, stop does nothing.

	if ((!connected) && (!started))
	    return;
	started = false;
	if (childsrc != null)
	    childsrc.stop();