diff --git a/src/net/java/sip/communicator/impl/media/protocol/portaudio/DataSource.java b/src/net/java/sip/communicator/impl/media/protocol/portaudio/DataSource.java index b8a945c09..bbfeae0db 100644 --- a/src/net/java/sip/communicator/impl/media/protocol/portaudio/DataSource.java +++ b/src/net/java/sip/communicator/impl/media/protocol/portaudio/DataSource.java @@ -7,17 +7,21 @@ package net.java.sip.communicator.impl.media.protocol.portaudio; import java.io.*; +import java.util.*; import javax.media.*; +import javax.media.control.*; import javax.media.protocol.*; /** - * Portaudio datasource. + * Implements DataSource and CaptureDevice for PortAudio. * * @author Damian Minkov + * @author Lubomir Marinov */ public class DataSource extends PullBufferDataSource + implements CaptureDevice { private boolean connected = false; @@ -71,6 +75,31 @@ public void disconnect() connected = false; } + /** + * Gets the CaptureDeviceInfo that describes this + * CaptureDevice. + * + * @return the CaptureDeviceInfo that describes this + * CaptureDevice + */ + public CaptureDeviceInfo getCaptureDeviceInfo() + { + /* + * TODO The implemented search for the CaptureDeviceInfo of this + * CaptureDevice by looking for its MediaLocator is inefficient. + */ + @SuppressWarnings("unchecked") + Vector captureDeviceInfos + = (Vector) + CaptureDeviceManager.getDeviceList(null); + MediaLocator locator = getLocator(); + + for (CaptureDeviceInfo captureDeviceInfo : captureDeviceInfos) + if (captureDeviceInfo.getLocator().equals(locator)) + return captureDeviceInfo; + return null; + } + /** * Tell we are a raw datasource * @@ -124,6 +153,26 @@ public Time getDuration() return DURATION_UNKNOWN; } + /** + * Gets an array of FormatControl instances each one of which can + * be used before {@link #connect()} to get and set the capture + * Format of each one of the capture streams. + * + * @return an array of FormatControl instances each one of which + * can be used before {@link #connect()} to get and set the capture + * Format of each one of the capture streams + */ + public FormatControl[] getFormatControls() + { + // TODO Make getControls() actually return a FormatControl instance. + List formatControls = new ArrayList(); + + for (Object control : getControls()) + if (control instanceof FormatControl) + formatControls.add((FormatControl) control); + return formatControls.toArray(new FormatControl[formatControls.size()]); + } + /** * Returns an array of PullBufferStream containing all the streams * i.e. only one in our case : only sound.