SIP Communicator: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.media.protocol.portaudio
Class DataSource

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

public class DataSource
extends javax.media.protocol.PullBufferDataSource
implements javax.media.protocol.CaptureDevice

Implements DataSource and CaptureDevice for PortAudio.

Author:
Damian Minkov, Lubomir Marinov

Field Summary
 
Fields inherited from interface javax.media.Duration
DURATION_UNBOUNDED, DURATION_UNKNOWN
 
Constructor Summary
DataSource()
           
 
Method Summary
 void connect()
          Connect the datasource
 void disconnect()
          Disconnect the datasource
 javax.media.CaptureDeviceInfo getCaptureDeviceInfo()
          Gets the CaptureDeviceInfo that describes this CaptureDevice.
static javax.media.Format getCaptureFormat()
          Return the formats supported by the datasource.
 String getContentType()
          Tell we are a raw datasource
 Object getControl(String controlType)
          Return required control from the Control[] array if exists.
 Object[] getControls()
          Gives control information to the caller
 javax.media.Time getDuration()
          Gives to the caller the duration information of our stream Which is, obviously unknown.
 javax.media.control.FormatControl[] getFormatControls()
          Gets an array of FormatControl instances each one of which can be used before connect() to get and set the capture Format of each one of the capture streams.
 javax.media.protocol.PullBufferStream[] getStreams()
          Returns an array of PullBufferStream containing all the streams i.e.
 void start()
          Start the datasource and the underlying stream
 void stop()
          Stop the datasource and it's underlying stream
 
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

DataSource

public DataSource()
Method Detail

getCaptureFormat

public static javax.media.Format getCaptureFormat()
Return the formats supported by the datasource.

Returns:
the supported formats.

connect

public void connect()
             throws IOException
Connect the datasource

Specified by:
connect in interface javax.media.protocol.CaptureDevice
Specified by:
connect in class javax.media.protocol.DataSource
Throws:
IOException - if we cannot initialize portaudio.

disconnect

public void disconnect()
Disconnect the datasource

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

getCaptureDeviceInfo

public javax.media.CaptureDeviceInfo getCaptureDeviceInfo()
Gets the CaptureDeviceInfo that describes this CaptureDevice.

Specified by:
getCaptureDeviceInfo in interface javax.media.protocol.CaptureDevice
Returns:
the CaptureDeviceInfo that describes this CaptureDevice

getContentType

public String getContentType()
Tell we are a raw datasource

Specified by:
getContentType in class javax.media.protocol.DataSource
Returns:
"raw"

getControl

public Object getControl(String controlType)
Return required control from the Control[] array if exists.

Specified by:
getControl in interface javax.media.Controls
Specified by:
getControl in class javax.media.protocol.DataSource
Parameters:
controlType - the control we are interested in.
Returns:
the object that implements the control, or null.

getControls

public Object[] getControls()
Gives control information to the caller

Specified by:
getControls in interface javax.media.Controls
Specified by:
getControls in class javax.media.protocol.DataSource
Returns:
the collection of object controls.

getDuration

public javax.media.Time getDuration()
Gives to the caller the duration information of our stream Which is, obviously unknown.

Specified by:
getDuration in interface javax.media.Duration
Specified by:
getDuration in class javax.media.protocol.DataSource
Returns:
DURATION_UNKNOWN

getFormatControls

public javax.media.control.FormatControl[] getFormatControls()
Gets an array of FormatControl instances each one of which can be used before connect() to get and set the capture Format of each one of the capture streams.

Specified by:
getFormatControls in interface javax.media.protocol.CaptureDevice
Returns:
an array of FormatControl instances each one of which can be used before connect() to get and set the capture Format of each one of the capture streams

getStreams

public javax.media.protocol.PullBufferStream[] getStreams()
Returns an array of PullBufferStream containing all the streams i.e. only one in our case : only sound. If no stream actually exists, instantiate one on the fly.

Specified by:
getStreams in class javax.media.protocol.PullBufferDataSource
Returns:
Array of one stream

start

public void start()
           throws IOException
Start the datasource and the underlying stream

Specified by:
start in interface javax.media.protocol.CaptureDevice
Specified by:
start in class javax.media.protocol.DataSource
Throws:
IOException

stop

public void stop()
          throws IOException
Stop the datasource and it's underlying stream

Specified by:
stop in interface javax.media.protocol.CaptureDevice
Specified by:
stop in class javax.media.protocol.DataSource
Throws:
IOException

SIP Communicator: the OpenSource Java VoIP and Instant Messaging client.

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