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

Equal only by usb paths #1481

Merged
merged 2 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public boolean equals(Object obj) {

if (!path.equals(other.path)) return false;
if (!name.equals(other.name)) return false;
if (!Arrays.asList(this.otherPaths).containsAll(Arrays.asList(other.otherPaths))) return false;
if (!Arrays.asList(this.getUSBPath()).contains(other.getUSBPath())) return false;
if (vendorId != other.vendorId) return false;
if (productId != other.productId) return false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -521,8 +521,11 @@ public void testIdenticalCameras() {
"/dev/video0",
"Arducam OV2311 USB Camera",
new String[] {
"/dev/v4l/by-id/usb-Arducam_Technology_Co.__Ltd._Arducam_OV2311_USB_Camera_UC621-video-index0",
"/dev/v4l/by-path/platform-fc800000.usb-usb-0:1:1.0-video-index0"
"/dev/v4l/by-path/platform-fc800000.usb-usb-0:1:1.0-video-index0" // V4l doesnt assign
// by-id paths that
// are identical to
// two different
// cameras
},
3141,
25446);
Expand Down Expand Up @@ -576,8 +579,11 @@ public void testIdenticalCameras() {
"/dev/video0",
"Arducam OV2311 USB Camera",
new String[] {
"/dev/v4l/by-id/usb-Arducam_Technology_Co.__Ltd._Arducam_OV2311_USB_Camera_UC621-video-index0",
"/dev/v4l/by-path/platform-fc800000.usb-usb-0:1:1.0-video-index0"
"/dev/v4l/by-path/platform-fc800000.usb-usb-0:1:1.0-video-index0" // V4l doesnt assign
// by-id paths that
// are identical to
// two different
// cameras
},
3141,
25446);
Expand All @@ -602,5 +608,44 @@ public void testIdenticalCameras() {
assertTrue(inst.knownCameras.contains(info1_dup));
assertTrue(inst.knownCameras.contains(info2_dup));
assertEquals(2, inst.knownCameras.size());

// duplciate cameras this simulates unplugging one and plugging the other in where v4l assigns
// the same by-id path to the other camera
var duplicateCameraInfos1 = new ArrayList<CameraInfo>();
CameraInfo info3_dup =
new CameraInfo(
0,
"/dev/video0",
"Arducam OV2311 USB Camera",
new String[] {
"/dev/v4l/by-id/usb-Arducam_Technology_Co.__Ltd._Arducam_OV2311_USB_Camera_UC621-video-index0",
"/dev/v4l/by-path/platform-fc800000.usb-usb-0:1:1.0-video-index0"
},
3141,
25446);
CameraInfo info4_dup =
new CameraInfo(
0,
"/dev/video2",
"Arducam OV2311 USB Camera",
new String[] {
"/dev/v4l/by-path/platform-fc880000.usb-usb-0:1:1.0-video-index0" // V4l doesnt assign
// by-id paths that
// are identical to
// two different
// cameras
},
3141,
25446);

duplicateCameraInfos1.add(info3_dup);
duplicateCameraInfos1.add(info4_dup);

inst.tryMatchCamImpl(duplicateCameraInfos);

// Our cameras should be "known", and we should only "know" two cameras still
assertTrue(inst.knownCameras.contains(info3_dup));
assertTrue(inst.knownCameras.contains(info4_dup));
assertEquals(2, inst.knownCameras.size());
}
}
Loading