Exemplo n.º 1
0
        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); }
        }
Exemplo n.º 2
0
        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); }
        }
Exemplo n.º 3
0
        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); }
        }
Exemplo n.º 4
0
        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); }
        }
Exemplo n.º 5
0
 internal static extern void uvc_ref_device(UvcDevice dev);
Exemplo n.º 6
0
 internal static extern UvcError uvc_open(UvcDevice dev, out UvcDeviceHandle devh);
Exemplo n.º 7
0
 internal static extern UvcError uvc_find_device(
     UvcContext ctx,
     out UvcDevice dev,
     int vid,
     int pid,
     string sn);
Exemplo n.º 8
0
 internal static extern UvcError uvc_get_device_descriptor(UvcDevice dev, out IntPtr desc);