Migrate Camera binding to the new rpicam-* application naming#2559
Migrate Camera binding to the new rpicam-* application naming#2559Copilot wants to merge 4 commits into
Conversation
|
@copilot Address the test failures |
The build was failing on all platforms because the new |
|
If anyone can take a look and approve, the changes look good to me |
There was a problem hiding this comment.
Pull request overview
Updates the Camera binding to support Raspberry Pi OS Bookworm’s libcamera-* → rpicam-* application rename by adding explicit rpicam-* factory methods and new auto-selecting factory methods in ProcessSettingsFactory, plus corresponding docs, sample commands, and tests.
Changes:
- Added
rpicam-*constants, explicit factory methods, and auto-selectingCreateForStill*/CreateForVidmethods with PATH probing. - Updated the Camera sample CLI and documentation to recommend auto-selecting methods and describe the rename/symlink compatibility.
- Added unit tests for the new constants/factories and exposed internals to the test assembly.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/devices/Camera/Camera/Settings/ProcessSettingsFactory.cs | Adds rpicam-* support and auto-selection via PATH probing (key behavior change). |
| src/devices/Camera/tests/TestCamera/ProcessSettingsFactoryTests.cs | Adds unit coverage for new constants/methods and detection seam. |
| src/devices/Camera/Camera/Camera.csproj | Exposes internals to TestCamera for unit testing. |
| src/devices/Camera/samples/Camera.Samples/Program.cs | Adds still/video/lapse auto commands plus explicit *-rpicam commands. |
| src/devices/Camera/README.md | Updates guidance to recommend auto-selecting factory methods and documents the rename. |
| src/devices/Camera/CameraInsights.md | Extends documentation to include rpicam-* utilities and rename explanation. |
| public static ProcessSettings CreateForStillAndStderr() | ||
| => IsRpicamAppsInstalled() ? CreateForRpicamstillAndStderr() : CreateForLibcamerastillAndStderr(); |
| public static ProcessSettings CreateForStill() | ||
| => IsRpicamAppsInstalled() ? CreateForRpicamstill() : CreateForLibcamerastill(); |
| public static ProcessSettings CreateForVid() | ||
| => IsRpicamAppsInstalled() ? CreateForRpicamvid() : CreateForLibcameravid(); |
| public void AutoFactoryMethodsPreferRpicamWhenAvailable() | ||
| { | ||
| // The auto methods rely on detection through the system PATH. The | ||
| // test agents do not ship the rpicam-apps, so the libcamera-* names | ||
| // are expected as the backward compatible fallback. | ||
| Assert.Equal(ProcessSettingsFactory.LibcameraStill, ProcessSettingsFactory.CreateForStill().Filename); | ||
| Assert.Equal(ProcessSettingsFactory.LibcameraVid, ProcessSettingsFactory.CreateForVid().Filename); | ||
|
|
||
| var stderr = ProcessSettingsFactory.CreateForStillAndStderr(); | ||
| Assert.Equal(ProcessSettingsFactory.LibcameraStill, stderr.Filename); | ||
| Assert.True(stderr.CaptureStderrInsteadOfStdout); | ||
| } |
Raspberry Pi OS Bookworm renamed the
libcamera-*capture apps torpicam-*, with users encouraged to adopt the new names. The Camera binding hardcodedlibcamera-still/libcamera-vid, which only keeps working because Bookworm still ships backward-compat symlinks.This adds first-class support for the new naming with automatic, backward-compatible selection, all confined to
ProcessSettingsFactory.ProcessSettingsFactoryRpicamStill(rpicam-still),RpicamVid(rpicam-vid).CreateForRpicamstill,CreateForRpicamstillAndStderr,CreateForRpicamvid— mirror the existingLibcamera*methods.CreateForStill,CreateForStillAndStderr,CreateForVid, plusIsRpicamAppsInstalled(). These probePATHfor therpicam-*executables and prefer them when present, falling back tolibcamera-*otherwise.The auto methods are the recommended entry points: they pick
rpicam-*on Bookworm-and-later, keep usinglibcamera-*on Bullseye, and remain correct on future images that ship onlyrpicam-*.Tests
ProcessSettingsFactoryTestscovering the constants, explicit factory methods, the detection seam (injected existence predicate), and the libcamera fallback.TestCameraassembly viaInternalsVisibleTo, following the existing repo convention.Docs & sample
still/video/lapse-rpicamcommands and autostill/video/lapsecommands.Notes
The heavier detection algorithm discussed on the issue (
lsb_release,config.txt,dlsymofRPiCamAppsVersion) is intentionally avoided — aPATHprobe is cheap, runs without spawning shells, and degrades safely. Theextern "C"symbol approach remains an option if finer stack discrimination is needed later.