// remove all capture devices
Vector deviceList = (Vector)CaptureDeviceManager.getDeviceList(null).clone();
for (int i=0; i<deviceList.size(); i++)
{
CaptureDeviceInfo cdi = (CaptureDeviceInfo)deviceList.elementAt(i);
CaptureDeviceManager.removeDevice(cdi);
}
// update capture device list
new net.sf.fmj.media.cdp.javasound.CaptureDevicePlugger().addCaptureDevices();
PlugInManager.commit();
deviceList = (Vector)CaptureDeviceManager.getDeviceList(null).clone();
if ( (null == deviceList) || (deviceList.size() == 0) )
{
System.out.println("### ERROR found no audio capture device");
System.exit(0);
}
// enumerate all codec
Vector codecList = PlugInManager.getPlugInList(null, null, PlugInManager.CODEC);
System.out.println("found " + codecList.size() + " codec");
for (int i=0; i<codecList.size(); i++)
{
String aCodecClass = (String)codecList.elementAt(i);
System.out.println("# " + (i + 1) + " " + aCodecClass);
}
// fetch first available audio capture device
deviceList = (Vector)CaptureDeviceManager.getDeviceList(null).clone();
CaptureDeviceInfo captureDeviceInfo = (CaptureDeviceInfo)deviceList.elementAt(0);
System.out.println("### using " + captureDeviceInfo.getName());
System.out.println("### locator " + captureDeviceInfo.getLocator());
javax.media.protocol.DataSource dataSource = javax.media.Manager.createDataSource(new javax.media.MediaLocator(captureDeviceInfo.getLocator().toString()));
//javax.media.protocol.DataSource dataSource = javax.media.Manager.createDataSource(new javax.media.MediaLocator("javasound://"));
System.out.println("### created datasource " + dataSource.getClass().getName());
javax.media.control.FormatControl[] formatControls = ((javax.media.protocol.CaptureDevice)dataSource).getFormatControls();
System.out.println("got format control " + formatControls[0].getClass().getName());