internal static Webcam[] Enumerate()
{
List<Webcam> result = new List<Webcam>();
// directshow enumeration
try {
DsDevice[] dsDevices = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice);
for (int x = 0; x < dsDevices.Length; x++) {
result.Add(new WebcamDirectShow(x, dsDevices[x].Name));
}
} catch (Exception) { }
// wia enumeration
try {
WIA.DeviceManager deviceManager = new WIA.DeviceManagerClass();
foreach (WIA.DeviceInfo deviceInfo in deviceManager.DeviceInfos) {
if ((deviceInfo.Type == WIA.WiaDeviceType.CameraDeviceType) || (deviceInfo.Type == WIA.WiaDeviceType.VideoDeviceType)) {
result.Add(new WebcamWIA(deviceInfo));
}
}
} catch (Exception) { }
// avicap32 enumeration
try {
for (short x = 0; x < 10; x++) {
string name = new string(' ', 255);
string version = new string(' ', 255);
if (NativeMethods.capGetDriverDescriptionA(x, ref name, name.Length, ref version, version.Length)) {
if (name.IndexOf('\x00') > -1) name = name.Substring(0, name.IndexOf('\x00'));
if (version.IndexOf('\x00') > -1) version = version.Substring(0, version.IndexOf('\x00'));
result.Add(new WebcamAVICap(x, name.Trim()));
}
}
} catch (Exception) { }
return result.ToArray();
}