Skip to content

Migrate Camera binding to the new rpicam-* application naming#2559

Open
Copilot wants to merge 4 commits into
mainfrom
copilot/migrate-iot-devices-camera
Open

Migrate Camera binding to the new rpicam-* application naming#2559
Copilot wants to merge 4 commits into
mainfrom
copilot/migrate-iot-devices-camera

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 2, 2026

Raspberry Pi OS Bookworm renamed the libcamera-* capture apps to rpicam-*, with users encouraged to adopt the new names. The Camera binding hardcoded libcamera-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.

ProcessSettingsFactory

  • Constants: RpicamStill (rpicam-still), RpicamVid (rpicam-vid).
  • Explicit methods: CreateForRpicamstill, CreateForRpicamstillAndStderr, CreateForRpicamvid — mirror the existing Libcamera* methods.
  • Auto-selecting methods: CreateForStill, CreateForStillAndStderr, CreateForVid, plus IsRpicamAppsInstalled(). These probe PATH for the rpicam-* executables and prefer them when present, falling back to libcamera-* otherwise.

The auto methods are the recommended entry points: they pick rpicam-* on Bookworm-and-later, keep using libcamera-* on Bullseye, and remain correct on future images that ship only rpicam-*.

// Prefers rpicam-still when installed, else libcamera-still
var processSettings = ProcessSettingsFactory.CreateForStill();
using var proc = new ProcessRunner(processSettings);

Tests

  • ProcessSettingsFactoryTests covering the constants, explicit factory methods, the detection seam (injected existence predicate), and the libcamera fallback.
  • Internals exposed to the TestCamera assembly via InternalsVisibleTo, following the existing repo convention.

Docs & sample

  • README and CameraInsights describe the rename, the symlink compatibility, and when to use each method.
  • Sample gains still/video/lapse-rpicam commands and auto still/video/lapse commands.

Notes

The heavier detection algorithm discussed on the issue (lsb_release, config.txt, dlsym of RPiCamAppsVersion) is intentionally avoided — a PATH probe is cheap, runs without spawning shells, and degrades safely. The extern "C" symbol approach remains an option if finer stack discrimination is needed later.

@dotnet-policy-service dotnet-policy-service Bot added the area-device-bindings Device Bindings for audio, sensor, motor, and display hardware that can used with System.Device.Gpio label Jun 2, 2026
Copilot AI changed the title [WIP] Migrate IoT.Devices.Camera to use new application naming Migrate Camera binding to the new rpicam-* application naming Jun 2, 2026
Copilot AI requested a review from raffaeler June 2, 2026 16:08
@raffaeler
Copy link
Copy Markdown
Contributor

@copilot Address the test failures

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jun 2, 2026

@copilot Address the test failures

The build was failing on all platforms because the new ProcessSettingsFactoryTests.cs was saved as ASCII without a BOM, which violates the Error-level StyleCop rule SA1412 (store files as UTF-8 with BOM) that every other .cs file in the repo follows. Re-saved the file as UTF-8 with BOM in 3a... — content is otherwise unchanged.

@raffaeler
Copy link
Copy Markdown
Contributor

If anyone can take a look and approve, the changes look good to me

@raffaeler raffaeler marked this pull request as ready for review June 2, 2026 17:51
Copilot AI review requested due to automatic review settings June 2, 2026 17:51
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-selecting CreateForStill* / CreateForVid methods 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.

Comment on lines +159 to +160
public static ProcessSettings CreateForStillAndStderr()
=> IsRpicamAppsInstalled() ? CreateForRpicamstillAndStderr() : CreateForLibcamerastillAndStderr();
Comment on lines +168 to +169
public static ProcessSettings CreateForStill()
=> IsRpicamAppsInstalled() ? CreateForRpicamstill() : CreateForLibcamerastill();
Comment on lines +177 to +178
public static ProcessSettings CreateForVid()
=> IsRpicamAppsInstalled() ? CreateForRpicamvid() : CreateForLibcameravid();
Comment on lines +58 to +69
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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-device-bindings Device Bindings for audio, sensor, motor, and display hardware that can used with System.Device.Gpio

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate Iot.Devices.Camera to use new application naming

3 participants