Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forked v2 for uvcc #66

Draft
wants to merge 33 commits into
base: master
Choose a base branch
from
Draft

Forked v2 for uvcc #66

wants to merge 33 commits into from

Conversation

joelpurra
Copy link
Contributor

In order to progress with uvcc, I am using a forked uvc-control based on master (ca1e2c9). There are bugfixes and improvements to get feature-parity with uvc-control v1. Might add new stuff if deemed useful.

It'd be better to have everything merged to (and published from) uvc-control, so here's a pull request for tracking progress. It'll be a draft for now; can be split into multiple pull requests later if changes are of interest.

See uvcc, which wraps uvc-control in a command line tool.

- Currently, each `controlTransfer` by setting `bmRequestType` targets the camera _interface_ rather than _device_.
- Using an interface would require claiming it, which is not performed.
- Claiming an interface would kill access for any other process which may be using the camera (including the kernel?).
- This commit targets `controlTransfer` to the _device_ instead.
- There might be better ways to transfer control commands.
- Ported from `uvc-control` v1 to v2.

Fixes makenai#58
Fixes joelpurra/uvcc#2

See

- makenai#58
- joelpurra/uvcc#2
- Fixes typo which affected `CT` control types.

Fixes joelpurra/uvcc#4

See

- joelpurra/uvcc#4
- Possibly related to the previous commit which had a typo affecting camera input terminal (CT) controls.
- There might be other bugs in the control data, should check against UVC v1.5 reference.

Fixes makenai#60

See

- makenai#60
- https://www.usb.org/documents?search=uvc
- Uses `readInt(...)` which was added then removed in previous commits.
- Adds `readInts(...)` to get an array of values where necessary.

See

- makenai@4d420ff
- makenai@bdb96da
@joelpurra joelpurra changed the title V2 Forked v2 for uvcc Sep 2, 2020
- Using `uvcc` has reportedly been slower than before.
- Profiling shows that `uvcc export` finishes in circa 200 milliseconds, but there are several seconds of idling afterwards. No code lines are pointed out, and it seems to happen _after_ `uvcc` itself finished.
- Investigating shows that `node-usb` v1.7.0 adds a 8 second delay during testing.
- Pinning the `usb` version to v1.6.5 removes the idling delay.

```text
0.14s user 0.01s system 1% cpu 8.908 total
```

```text
0.11s user 0.01s system 67% cpu 0.180 total
```

Fixes joelpurra/uvcc#16
For reals this time.
- Fixes compilation/compatibility with Node.js v17.
- Most of the tests use `async` calls via the wrapped `usb` device, wrapped in a mix of `sync` loops (usually `array.forEach()`) and "loose" promises (logging to `stdout`/`stderr`).
- Execution of test files does not finish if the camera object is not explicitly closed after use, as the `usb` device is still open and active.
- Because of the "loose" promises, there is no clear way to tell when the camera object is no longer in use.
- This commit fixes affected tests by adding a top-level async `run()` wrapper function, and converting `.forEach()` loops to `for...of` loops with `await`ed camera device calls inside.

The test files (like the rest of this project) uses a mix of outdated code styles. The upstream refactoring from v1 to v2 was never completed, and left in a messy state. All code should obviously be fixed "at some point", but since the upstream project has been dead for years I've avoided it in this fork. While I need this code to work for `uvcc` to work, fixing and cleaning up all (any!) of it more than necessary is not a priority. Patches welcome
Reduces the number of (developer) dependencies (as well as related security warnings) for the main `uvc-control` package.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant