monitor-utils: Rework camera deduplication code
The previous code made some invalid assumptions and was rather complicated. Rework and simplify it.
The approach work as follows:
- Once a new device gets registered, store its data in a list of pending devices.
- Start a timer. On timeout, we check all pending devices and depulicate according to our heuristic. The timer gets reset whenever a device is added in order to avoid race conditions.
- On timeout, add the pending devices to categories. For now: UVC cameras from the V4L2 plugin, libcamera cameras and other cameras from the V4L2 plugin.
- Then process the different categories in order of preference and store their V4L2 device IDs in a list for each plugin.
- Before creating a camera, check that the V4L2 device(s) it uses are not yet used by a already existing camera from the other plugin.
While on it, drop support for Pipewire versions that don't report V4L2 device IDs at all.
Closes #689 (closed) Closes #708 (closed)
Previous attempt: !670 (closed)
Edited by Robert Mader