public void TestDevices() { UvcDevice device; var err = NativeMethods.uvc_find_device(handle, out device, 0, 0, null); UvcException.ThrowExceptionForUvcError(err); UvcDeviceHandle devh; err = NativeMethods.uvc_open(device, out devh); UvcException.ThrowExceptionForUvcError(err); Console.WriteLine(err); StreamControl ctrl; err = NativeMethods.uvc_get_stream_ctrl_format_size(devh, out ctrl, FrameFormat.Any, 640, 480, 120); Console.WriteLine(ctrl.KeyFrameRate); err = NativeMethods.uvc_start_streaming(devh, ref ctrl, OnFrame, IntPtr.Zero, 0); Console.ReadLine(); NativeMethods.uvc_stop_streaming(devh); NativeMethods.uvc_print_diag(devh, IntPtr.Zero); devh.Close(); }
public void StartIsoStreaming(ref StreamControl control, FrameCallback callback) { var error = NativeMethods.uvc_start_iso_streaming(handle, ref control, callback, IntPtr.Zero); UvcException.ThrowExceptionForUvcError(error); cb = callback; }
public DeviceHandle Open() { UvcDeviceHandle devh; var error = NativeMethods.uvc_open(handle, out devh); UvcException.ThrowExceptionForUvcError(error); return(new DeviceHandle(devh)); }
public Device FindDevice(int vendorId = 0, int productId = 0, string serialNumber = null) { UvcDevice device; var error = NativeMethods.uvc_find_device(handle, out device, vendorId, productId, serialNumber); UvcException.ThrowExceptionForUvcError(error); return(new Device(device)); }
internal Device(UvcDevice device) { handle = device; IntPtr descriptor; var error = NativeMethods.uvc_get_device_descriptor(handle, out descriptor); UvcException.ThrowExceptionForUvcError(error); try { vendorId = (ushort)Marshal.ReadInt16(descriptor); productId = (ushort)Marshal.ReadInt16(descriptor, 2); complianceLevel = (ushort)Marshal.ReadInt16(descriptor, 4); } finally { NativeMethods.uvc_free_device_descriptor(descriptor); } }
internal Device(UvcDevice device) { handle = device; IntPtr descriptor; var error = NativeMethods.uvc_get_device_descriptor(handle, out descriptor); UvcException.ThrowExceptionForUvcError(error); try { vendorId = (ushort)Marshal.ReadInt16(descriptor); productId = (ushort)Marshal.ReadInt16(descriptor, 2); complianceLevel = (ushort)Marshal.ReadInt16(descriptor, 4); serialNumber = Marshal.PtrToStringAnsi(Marshal.ReadIntPtr(descriptor, 6)); manufacturer = Marshal.PtrToStringAnsi(Marshal.ReadIntPtr(descriptor, 6 + IntPtr.Size)); product = Marshal.PtrToStringAnsi(Marshal.ReadIntPtr(descriptor, 6 + IntPtr.Size * 2)); } finally { NativeMethods.uvc_free_device_descriptor(descriptor); } }
public IEnumerable <Device> GetDevices() { IntPtr devices; var error = NativeMethods.uvc_get_device_list(handle, out devices); UvcException.ThrowExceptionForUvcError(error); try { int i = 0; IntPtr devh; while ((devh = Marshal.ReadIntPtr(devices, IntPtr.Size * i++)) != IntPtr.Zero) { var device = new UvcDevice(devh); yield return(new Device(device)); } } finally { NativeMethods.uvc_free_device_list(devices, 1); } }
public IEnumerable <Device> FindDevices(int vendorId = 0, int productId = 0, string serialNumber = null) { IntPtr devices; var error = NativeMethods.uvc_find_devices(handle, out devices, vendorId, productId, serialNumber); UvcException.ThrowExceptionForUvcError(error); try { int i = 0; IntPtr devh; while ((devh = Marshal.ReadIntPtr(devices, IntPtr.Size * i++)) != IntPtr.Zero) { var device = new UvcDevice(devh); yield return(new Device(device)); } } finally { NativeMethods.uvc_free_device_list(devices, 1); } }
public void ProbeStreamControl(out StreamControl control) { var error = NativeMethods.uvc_probe_stream_ctrl(handle, out control); UvcException.ThrowExceptionForUvcError(error); }
public void GetStreamControlFormatSize(FrameFormat format, int width, int height, int fps, out StreamControl control) { var error = NativeMethods.uvc_get_stream_ctrl_format_size(handle, out control, format, width, height, fps); UvcException.ThrowExceptionForUvcError(error); }
public Context() { var error = NativeMethods.uvc_init(out handle, IntPtr.Zero); UvcException.ThrowExceptionForUvcError(error); }