Methods Summary |
---|
public static synchronized boolean | addDevice(javax.media.CaptureDeviceInfo newDevice)Adds a CaptureDeviceInfo object to the list. This information is not
stored permanently in any registry. If a similar CaptureDeviceInfo
object is already registered, then the new device is not added.
if (newDevice != null) {
if (devices == null)
devices = new Vector();
else {
Enumeration enum = devices.elements();
while (enum.hasMoreElements()) {
CaptureDeviceInfo cdi = (CaptureDeviceInfo) enum.nextElement();
if (cdi.equals(newDevice)) {
return false;
}
}
}
devices.addElement(newDevice);
return true;
}
return false;
|
public static synchronized void | commit()Permanently store information about the list of devices in a registry.
Registry r = new Registry();
r.removeGroup("CDM");
if (devices == null) {
r.set("CDM.nDevices", new Integer(0));
} else {
r.set("CDM.nDevices", new Integer(devices.size()));
int i = 0;
Enumeration enum = devices.elements();
while (enum.hasMoreElements()) {
CaptureDeviceInfo cdi = (CaptureDeviceInfo) enum.nextElement();
r.set("CDM." + i, cdi);
i++;
}
}
try {
r.commit();
} catch (Exception e) {
System.err.println("Exception on commit = " + e);
}
|
public static synchronized javax.media.CaptureDeviceInfo | getDevice(java.lang.String deviceName)Returns the CaptureDeviceInfo corresponding to the specified name of the
device. For example: "SunVideo". Returns null if the device could
not be found.
if (devices == null)
return null;
Enumeration enum = devices.elements();
while (enum.hasMoreElements()) {
CaptureDeviceInfo cdi = (CaptureDeviceInfo) enum.nextElement();
if (cdi.getName().equals(deviceName))
return cdi;
}
return null;
|
public static synchronized java.util.Vector | getDeviceList()Returns a list of CaptureDeviceInfo objects for each of the registered devices.
return getDeviceList(null);
|
public static synchronized java.util.Vector | getDeviceList(javax.media.Format format)Returns a list of CaptureDeviceInfo objects corresponding to devices that can capture
data with the specified data format. If format is null then it returns all registered
objects
if (devices == null)
return null;
if (format == null)
return devices;
Vector newList = new Vector();
Enumeration enum = devices.elements();
while (enum.hasMoreElements()) {
CaptureDeviceInfo cdi = (CaptureDeviceInfo) enum.nextElement();
Format [] formats = cdi.getFormats();
for (int i = 0; i < formats.length; i++) {
if (formats[i].matches(format)) {
newList.addElement(cdi);
break;
}
}
}
if (newList.size() > 0)
return newList;
else
return null;
|
private static synchronized void | readFromRegistry()
if (devices != null)
return;
devices = new Vector();
Registry r = new Registry();
Object size = r.get("CDM.nDevices");
if (size == null || ((Integer)size).intValue() == 0)
return;
for (int i = 0; i < ((Integer)size).intValue(); i++) {
Object cdi = r.get("CDM." + i);
if (cdi != null && cdi instanceof CaptureDeviceInfo)
devices.addElement(cdi);
}
|
public static synchronized boolean | removeDevice(javax.media.CaptureDeviceInfo device)Removes a CaptureDeviceInfo object from the list.
if ( devices == null ||
device == null ||
device.getName() == null)
return false;
Enumeration enum = devices.elements();
while (enum.hasMoreElements()) {
CaptureDeviceInfo cdi = (CaptureDeviceInfo) enum.nextElement();
if (cdi == device) {
devices.removeElement(cdi);
return true;
}
}
return false;
|