I'm developing a UVC utility that uses WebUSB, but I'm having trouble getting it to list out ONLY webcams. I should be able to add filters based on deviceClass and deviceSubClass, but it's returning an empty list.
Here's a webcam device...
0: USBDevice
configuration: USBConfiguration {configurationName: null, configurationValue: 1, interfaces: Array(5)}
configurations: [USBConfiguration]
deviceClass: 239
deviceProtocol: 1
deviceSubclass: 2
deviceVersionMajor: 1
deviceVersionMinor: 1
deviceVersionSubminor: 3
manufacturerName: "Microsoft"
opened: false
productId: 1906
productName: "Microsoft® LifeCam Studio(TM)"
serialNumber: ""
usbVersionMajor: 2
usbVersionMinor: 0
usbVersionSubminor: 0
vendorId: 1118
You can see deviceClass is 239 (0xEF), and the deviceSubClass is 2, so I should be able to filter on these criteria, but I'm not getting any results back.
https://www.xmos.com/download/AN00127:-USB-Video-Class-Device(2.0.2rc1).pdf
For Video class device, it is mandatory to set the ‘bDeviceClass’, ‘bDeviceSubClass’ and ‘bDeviceProtocol’ fields to 0xEF, 0x02 and 0x01 respectively.
const opts = {
filters: [{
classCode: 239, // 0xEF
subclassCode: 2, // 0x02
}]
}
const device = await navigator.usb.requestDevice(opts)
Without filters, I can see all of the USB devices
I have also tried adding protocolCode, but that doesn't work either, and I don't think it's necessary. Even passing only the classCode field returns an empty list.