Skip to content

linux-pipewire: Disable manual camera controls while their automatic mode is on - #1054

Merged
zackees merged 2 commits into
obs-rust:masterfrom
rdoupe:fix/827-pipewire-camera-auto-controls
Oct 16, 2026
Merged

zackees merged 2 commits into
obs-rust:masterfrom
rdoupe:fix/827-pipewire-camera-auto-controls

Conversation

@rdoupe

@rdoupe rdoupe commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator

Refs #827

What and why

In the "Video Capture Device (PipeWire)" source, a manual camera control now greys out while its automatic mode is on, and menu controls (Auto Exposure, Power Line Frequency) show up. The reporter's second camera ("UHD Camera", uvcvideo, kernel 7.2.9) kept "Focus, Absolute" enabled with "Focus, Automatic Continuous" ticked. The slider dragged, and the camera ignored it.

Cause

  • The screenshot in bug: gui: source property sliders practically unusable #827 is the PipeWire camera source (Device, Video Format and Frame Rate, no "Restore camera controls"), not the V4L2 source. linux-v4l2: Disable inactive camera controls instead of rebuilding #895 only changed the V4L2 source, which greys out what the driver flags V4L2_CTRL_FLAG_INACTIVE.
  • The driver does flag the control (the reporter's v4l2-ctl --list-ctrls shows focus_absolute ... flags=inactive). PipeWire's V4L2 node does not pass the flag on: its PropInfo params carry only the id, name and range (spa_v4l2_enum_controls()). camera-portal.c never enabled or disabled a control.
  • Auto Exposure and Power Line Frequency were missing from the reporter's window: PipeWire publishes a V4L2 menu as a plain Int with labels, and add_control_property() parsed the type with SPA_POD_PodChoice, which rejects a plain value. So Auto Exposure could not be switched to Manual Mode from OBS at all.
  • The V4L2 source is not involved. test_v4l2_controls already covers its bool master listed after its slave, both ways (turning_autofocus_off_enables_the_manual_focus), and its flag loop does not depend on a control's step.

Fix (all in plugins/linux-pipewire/camera-portal.c)

  • For a V4L2 node (device.api = v4l2, or an object.path starting with v4l2:), the source maps each prop id back to its V4L2 control id. PipeWire uses SPA_PROP_START_CUSTOM + the id, or SPA_PROP_hue / SPA_PROP_exposure.
  • The automatic/manual pairs are the ones the V4L2 spec defines, as uvcvideo implements them: Hue, Automatic / Hue; Auto Exposure / Exposure Time, Absolute (manual in Manual Mode only); White Balance, Automatic / White Balance Temperature, Red Balance, Blue Balance; Focus, Automatic Continuous / Focus, Absolute. The order the camera lists them in does not matter.
  • A manual control is disabled while its automatic control, as the window shows it, is not in its manual mode. This is worked out when the window opens and after every control change. The callback asks for a rebuild only when a control was enabled or disabled, so slider drags still never rebuild the window (linux-pipewire: Keep the Properties window when a camera control changes #829).
  • A disabled manual control moved anyway (a script) is not sent to the camera, which would ignore or refuse it. It keeps its value. Same as linux-v4l2: Disable inactive camera controls instead of rebuilding #895.
  • A plain Int with labels is now a list. The node's other plain values (device path, name, fd) are still skipped.

Not changed

  • The state comes from the window's own setting for the automatic control, not from the camera. The PipeWire source has never read the camera's current values: it shows saved or default values. If another program switches the camera's automatic mode, the window does not notice.
  • libcamera nodes and other non-V4L2 nodes are untouched: their prop ids are not V4L2 ids.
  • Only the pairs above. A driver-specific pair (Auto Gain / Gain on some non-UVC drivers) is not covered, because the spec does not link those controls.
  • Exposure Time is greyed out in Shutter Priority Mode too, like uvcvideo does (it refuses the write there), although the spec calls exposure time manual in that mode.
  • A control with step 0 (Iris, Absolute on the reporter's camera) is shown as before.

RED → GREEN

  • RED commit: 9d231a4 test/cmocka: Add failing tests for PipeWire camera automatic controls. test_pipewire_camera_control_refresh now plays two V4L2 cameras the way PipeWire's V4L2 node publishes them: the reporter's exact control list, and a webcam with White Balance, Automatic (listed before its controls) and Hue, Automatic (listed after Hue) in Aperture Priority Mode. 6 of 9 cases fail in both lanes:

    • manual_controls_are_disabled_on_load ("'Focus, Absolute' is enabled");
    • toggling_autofocus_disables_and_enables_the_focus ("rebuild 0 (expected 1), 'Focus, Absolute' enabled 1");
    • switching_auto_exposure_disables_and_enables_the_exposure and menu_controls_are_shown ("'Auto Exposure' missing, 'Power Line Frequency' missing");
    • toggling_white_balance_and_hue_automatic;
    • moving_a_manual_control_keeps_the_properties ("the disabled 'Focus, Absolute' was sent to the camera 8 times").

    The two linux-pipewire: Keep the Properties window when a camera control changes #829 cases and saved_manual_modes_enable_the_controls_on_load pass.

  • GREEN: 8c9aec7. 9/9 with ENABLE_RUST_LIBOBS OFF and ON, every case run against the private PipeWire daemon (no skips). The cases cover:

    • the window opening with the automatic modes on, and with saved manual modes;
    • autofocus off and on three times;
    • Auto Exposure Auto/Manual twice on one camera, Aperture/Manual on the other;
    • white balance and hue twice each;
    • 8-step drags of Focus, Absolute and of Iris, Absolute (step 0) with 0 rebuilds;
    • the controls after the step-0 one staying enabled.

    Full ctest at -j8 (private Xvfb, system libobs-opengl masked, TMPDIR unset): C lane 258/258, Rust lane 258/258. Skips: open_crashes_without_obs_core in both lanes, as on master. In the C lane, test_startup_alloc_stable also skipped once under load and passes alone (not touched here). All PipeWire/Pulse tests ran. clang-format 22.1.3, gersemi 0.25.0 and ci/test_registration.py clean.

  • Real app: release 0.1.0-beta.20261014 AppImage on a private Xvfb, with a private PipeWire daemon, a fake camera portal on a private bus, and a stand-in camera node publishing the reporter's control list.

    • Release as shipped: Focus, Absolute and Exposure Time, Absolute are enabled with autofocus ticked and Auto Mode, and there is no Auto Exposure or Power Line Frequency. Unticking and ticking autofocus changes nothing. This matches the reporter's screenshot.
    • Same AppImage with this branch's linux-pipewire.so: both are greyed out on open, and both menus are shown. Unticking autofocus enables Focus, Absolute. A 20-step drag then sends all 20 values to the camera and keeps the slider. Ticking greys it out again, and three more untick/tick rounds reach the camera each time. Picking Manual Mode in Auto Exposure enables Exposure Time.
  • CI: the Tier 2 image has no PipeWire daemon, so test_pipewire_camera_control_refresh skips there (exit 77), as since linux-pipewire: Keep the Properties window when a camera control changes #829.

Checklist

  • Base is master
  • I claimed the issue, or no one else has an open PR for it
  • Characterization test (if the unit had none), then RED, then GREEN commits
  • (Optional) Local gate passed and the pushed head is stamped; otherwise PR CI runs the full suite
  • Warning or flag changes (-W..., ratchets): none
  • Intentional differences from C listed in the parity test header and rust/README.md (ports): not a port

AI note: Claude Code (Claude Opus 5.5) wrote the code, the tests, the commit messages and this text under the submitter's direction, and ran the tests above on the submitter's machines.

🤖 Generated with Claude Code

rdoupe and others added 2 commits October 16, 2026 05:19
In the Properties window of the "Video Capture Device (PipeWire)" source,
ticking "Focus, Automatic Continuous" leaves "Focus, Absolute" enabled:
the slider drags, and the camera ignores it. The same for Exposure Time,
Absolute in Auto Mode, White Balance Temperature with White Balance,
Automatic on, and Hue with Hue, Automatic on. The V4L2 driver flags these
controls inactive (V4L2_CTRL_FLAG_INACTIVE), and the V4L2 source greys
them out since obs-rust#895, but PipeWire's V4L2 node does not pass the flag on:
its PropInfo params only carry each control's id, name and range.
Menu controls (Auto Exposure, Power Line Frequency) are missing from the
window altogether: the node publishes a menu as a plain Int with labels,
and the source only reads a choice, so Auto Exposure cannot be switched
to Manual Mode from OBS.

test_pipewire_camera_control_refresh now plays two cameras the way
PipeWire's V4L2 node publishes them (the same prop ids, menus, and the
"device.api" and "object.path" node properties):
- the "UHD Camera" of obs-rust#827, with the control list its driver reports
  (uvcvideo, kernel 7.2.9): Focus, Absolute comes before Focus,
  Automatic Continuous, Auto Exposure starts in Auto Mode, and Iris,
  Absolute has a step of 0;
- a webcam with White Balance, Automatic (listed before its controls)
  and Hue, Automatic (listed after Hue), in Aperture Priority Mode.
Brightness of the existing cases now uses the UHD Camera's range (0-14).

Cases. Guards that pass:
- control_change_reaches_the_camera, control_change_does_not_rebuild_
  properties (obs-rust#829): unchanged apart from the range.
- saved_manual_modes_enable_the_controls_on_load: saved settings with
  the automatic modes off leave the manual controls enabled.
Failing:
- manual_controls_are_disabled_on_load: Focus, Absolute and Exposure
  Time, Absolute of the UHD Camera, and the webcam's white balance, hue,
  exposure and focus controls are enabled while their automatic modes
  are on. Iris, Absolute and the controls after it must stay enabled.
- toggling_autofocus_disables_and_enables_the_focus: unticking and
  ticking the checkbox, three times, asks for no rebuild and changes
  nothing.
- switching_auto_exposure_disables_and_enables_the_exposure: no Auto
  Exposure list to switch.
- toggling_white_balance_and_hue_automatic: the same for White Balance,
  Automatic and Hue, Automatic.
- menu_controls_are_shown: Auto Exposure and Power Line Frequency are
  missing. The node's device path, name and fd must not show up.
- moving_a_manual_control_keeps_the_properties: drags of Focus,
  Absolute with autofocus off and of Iris, Absolute pass; moving the
  overridden Focus, Absolute (from a script) sends it to the camera 8 of
  8 times.

6 of 9 fail, in both lanes.

Refs obs-rust#827.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…mode is on

With "Focus, Automatic Continuous" ticked in the Properties window of
the "Video Capture Device (PipeWire)" source, "Focus, Absolute" stayed
enabled: the slider dragged, and the camera ignored it (uvcvideo flags
the control inactive and refuses it with EACCES). The same for Exposure
Time, Absolute outside Manual Mode, White Balance Temperature, Red and
Blue Balance with White Balance, Automatic on, and Hue with Hue,
Automatic on. obs-rust#895 greys these out in the V4L2 source from the driver's
V4L2_CTRL_FLAG_INACTIVE, but PipeWire's V4L2 node does not pass that
flag on.

For a V4L2 camera node ("device.api" v4l2, or an "object.path" starting
with "v4l2:"), the source now knows the automatic/manual pairs the V4L2
spec defines, as uvcvideo implements them, by V4L2 control id: the node
gives a control the prop id SPA_PROP_START_CUSTOM + its V4L2 id, or
SPA_PROP_hue / SPA_PROP_exposure. A manual control is shown disabled
while its automatic control, as the window shows it, is not in its
manual mode (0, or Manual Mode for Auto Exposure), whatever the order
the camera lists them in. When the window opens, and after each change,
the states are worked out again; the window is rebuilt only when one of
them changed, so dragging a slider still never rebuilds it (obs-rust#829). An
overridden manual control is not sent to the camera; it keeps its value.

Menu controls are shown again: the node publishes a menu (Auto
Exposure, Power Line Frequency) as a plain Int with labels, not as a
choice, so the source skipped it, and Auto Exposure could not be set to
Manual Mode from OBS. A plain Int with labels is now a list. The node's
other plain values (the device's path, name and fd) are still not
shown.

test_pipewire_camera_control_refresh: 9 of 9 pass, in both lanes.

Refs obs-rust#827.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@zackees zackees added the ci-full Run every CI job on this PR, including the release-gating OBS app builds and Flatpak label Oct 16, 2026
@zackees
zackees enabled auto-merge October 16, 2026 09:30
@zackees
zackees added this pull request to the merge queue Oct 16, 2026
Merged via the queue into obs-rust:master with commit 2091a55 Oct 16, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-full Run every CI job on this PR, including the release-gating OBS app builds and Flatpak

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants