Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.neomedia.protocol
Class TranscodingDataSource

java.lang.Object
  extended by javax.media.protocol.DataSource
      extended by net.java.sip.communicator.impl.neomedia.protocol.TranscodingDataSource
All Implemented Interfaces:
javax.media.Controls, javax.media.Duration

public class TranscodingDataSource
extends javax.media.protocol.DataSource

Represents a DataSource which transcodes the tracks of a specific input DataSource into a specific output Format. The transcoding is attempted only for tracks which actually support it for the specified output Format.

Author:
Lubomir Marinov

Field Summary
 
Fields inherited from interface javax.media.Duration
DURATION_UNBOUNDED, DURATION_UNKNOWN
 
Constructor Summary
TranscodingDataSource(javax.media.protocol.DataSource inputDataSource, javax.media.Format outputFormat)
          Initializes a new TranscodingDataSource instance to transcode the tracks of a specific DataSource into a specific output Format.
 
Method Summary
 void connect()
          Implements DataSource.connect().
 void disconnect()
          Implements DataSource.disconnect().
 String getContentType()
          Implements DataSource.getContentType().
 Object getControl(String controlType)
          Implements DataSource.getControl(String).
 Object[] getControls()
          Implements DataSource.getControls().
 javax.media.Time getDuration()
          Implements DataSource.getDuration().
 javax.media.protocol.SourceStream[] getStreams()
          Gets the output streams that this instance provides.
 void start()
          Implements DataSource.start().
 void stop()
          Implements DataSource.stop().
 
Methods inherited from class javax.media.protocol.DataSource
getLocator, initCheck, setLocator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TranscodingDataSource

public TranscodingDataSource(javax.media.protocol.DataSource inputDataSource,
                             javax.media.Format outputFormat)
Initializes a new TranscodingDataSource instance to transcode the tracks of a specific DataSource into a specific output Format.

Parameters:
inputDataSource - the DataSource which is to have its tracks transcoded in a specific outptu Format
outputFormat - the Format in which the new instance is to transcode the tracks of inputDataSource
Method Detail

connect

public void connect()
             throws IOException
Implements DataSource.connect(). Sets up the very transcoding process and just does not start it i.e. creates a Processor on the inputDataSource, sets outputFormat on its tracks (which support a Format compatible with outputFormat) and connects to its output DataSource.

Specified by:
connect in class javax.media.protocol.DataSource
Throws:
IOException - if creating the transcoding Processor, setting its Format or connecting to it fails

disconnect

public void disconnect()
Implements DataSource.disconnect(). Stops and undoes the whole setup of the very transcoding process i.e. disconnects from the output DataSource of the transcodingProcessor and disposes of the transcodingProcessor.

Specified by:
disconnect in class javax.media.protocol.DataSource

getContentType

public String getContentType()
Implements DataSource.getContentType(). Delegates to the actual output of the transcoding.

Specified by:
getContentType in class javax.media.protocol.DataSource
Returns:
a String value which describes the type of the content made available by this DataSource

getControl

public Object getControl(String controlType)
Implements DataSource.getControl(String). Delegates to the actual output of the transcoding.

Specified by:
getControl in interface javax.media.Controls
Specified by:
getControl in class javax.media.protocol.DataSource
Parameters:
controlType - a String value which names the type of the control to be retrieved
Returns:
an Object which represents the control of this instance with the specified type if such a control is available; otherwise, null

getControls

public Object[] getControls()
Implements DataSource.getControls(). Delegates to the actual output of the transcoding.

Specified by:
getControls in interface javax.media.Controls
Specified by:
getControls in class javax.media.protocol.DataSource
Returns:
an array of Objects which represent the controls available for this instance

getDuration

public javax.media.Time getDuration()
Implements DataSource.getDuration(). Delegates to the actual output of the transcoding.

Specified by:
getDuration in interface javax.media.Duration
Specified by:
getDuration in class javax.media.protocol.DataSource
Returns:
a Time value which describes the duration of the content made available by this instance

getStreams

public javax.media.protocol.SourceStream[] getStreams()
Gets the output streams that this instance provides. Some of them may be the result of transcoding the tracks of the input DataSource of this instance in the output Format of this instance.

Returns:
an array of SourceStreams which represents the collection of output streams that this instance provides

start

public void start()
           throws IOException
Implements DataSource.start(). Starts the actual transcoding process already set up with connect().

Specified by:
start in class javax.media.protocol.DataSource
Throws:
IOException - if starting the transcoding fails

stop

public void stop()
          throws IOException
Implements DataSource.stop(). Stops the actual transcoding process if it has already been set up with connect().

Specified by:
stop in class javax.media.protocol.DataSource
Throws:
IOException - if stopping the transcoding fails

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.