qzind / tray

Browser plugin for sending documents and raw commands to a printer or attached device.
https://qz.io
Other
853 stars 277 forks source link

UVC compliant WebCam Support #148

Open tresf opened 7 years ago

tresf commented 7 years ago

Quoting @dsanders11:

[Added] basic support for UVC (USB Video Class) devices in dsanders11/tray@e0eb796 [...] used to control settings on a webcam (zoom, focus, contrast, etc) which aren't exposed in the HTML5 webcam API. [...] Should work with any Logitech webcam (they're UVC complaint) and probably a good number of other webcam brands.

Note, this feature may eventually be superseded by #63.

dsanders11 commented 7 years ago

Note - definitely do not use as is. :-) Has a lot of rough edges regarding error checking and probably a minor memory leak or two since it has to use BridJ to interact with the C libuvc library. Speaking of which, the JAR used is generated from the openpnp/libuvc4j project. No idea what the licensing is there, so proceed with caution.

tresf commented 7 years ago

@dsanders11, FYI, libuvc4j appears to be a direct JNA port of a BSD project which makes it LGPL 2.1 compatible. 👍

dsanders11 commented 7 years ago

@tresf, FYI, I've abandoned this in favor of using DirectShow to control webcams (Windows only). Using libuvc proved to be unstable because it needed to open the USB device to do its thing. This worked in basic testing, but in actual use trying to use libuvc while a browser was showing the video stream caused problems - feed would go dark, controls acted buggy, etc.

It's not clear if these problems are inherent to using UVC, or if the libuvc implementation is heavy handed. There's another project, libwebcam which has a control program uvcdynctrl that might be a better option. I went with libuvc because libuvc4j already existed. Using uvcdynctrl to change settings while the browser is running hasn't had any issues in my experience (and was my original test), so libwebcam might use an approach for changing the settings that doesn't need to take full control of the USB device and break sharing. Clearly that ability exists since I can use it on Windows with the same webcams.