Skip to content

Refine proc_handler api and move commands out of settings - #317

Merged
glikely merged 11 commits into
mainfrom
staging
Jun 2, 2026
Merged

Refine proc_handler api and move commands out of settings#317
glikely merged 11 commits into
mainfrom
staging

Conversation

@glikely

@glikely glikely commented May 29, 2026

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR refines the PTZ device proc_handler API by introducing a ptz_-prefixed command surface and moving camera “commands” (power, white balance actions) out of persistent settings updates into explicit command calls, reducing naming conflicts and clarifying intent between configuration/state vs. commands.

Changes:

  • Rename per-device proc_handler methods to ptz_* and update call sites to use the new names.
  • Route “trigger” style operations through ptz_set arguments (e.g., focus one-touch) instead of separate proc calls/settings writes.
  • Add VISCA-specific set(calldata_t*) handling and a WB mode modified callback to issue commands immediately from the properties UI.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/ptz-visca.hpp Declares VISCA override for the refined set(calldata_t*) command handler.
src/ptz-visca.cpp Moves VISCA command behaviors (power/WB) into set() and adds WB UI callback to send commands on change.
src/ptz-device.hpp Removes the proc-handler wrapper slot for focus one-touch in favor of ptz_set trigger semantics.
src/ptz-device.cpp Renames per-device proc methods to ptz_*, updates global proc routing, and adds focus_onetouch_trigger handling in set().
src/ptz-controls.hpp Updates preset APIs to use long long and adds typed callCurrentDevice helpers.
src/ptz-controls.cpp Migrates UI command dispatch to ptz_* methods and introduces fixed-stack calldata helpers for common calls.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ptz-device.cpp
Comment thread src/ptz-visca.cpp
Comment thread src/ptz-controls.cpp
@glikely
glikely force-pushed the staging branch 3 times, most recently from cf7401f to 6cd8b96 Compare June 2, 2026 14:47
glikely added 7 commits June 2, 2026 15:50
This reverts commit b19d21d. Using pull
requests is a better workflow for validating branches than adding
'staging' to the list
The function pointer form allows the function signatures to be checked
at compile time, and is the method recommended by the Qt docs.

Also fixes a bug where a joystick event was being connected when
CONFIG_JOYSTICK was disabled. With the function pointer binding the
code fails to compile because the method was configured out. Fixed by
moving the call site.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
It is possible for a proc_handler to provide the PTZ api in addition to
other functions. Add a prefix namespace to the PTZ api so that if that
happens there will not be a conflict.

This patch also removes the 'focus_onetouch' method and merges it into
'ptz_set'. The plan is to activate triggers using bool arguments to the
ptz_set method.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
A calldata stack can be allocated with a fixed size on the function
stack, which eliminates bzalloc()/bfree() calls. Switch all the
PTZControls device calls to use fixed calldata so that we're not
dynamically allocating memory in a hot path.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
This renames the property name used in the 'ptz_set' proc handler from
"autofocus" to "focus_af_enabled". The rest of the code was already
using the later string for storing autofocus state, so that string
should be used here too.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
The configuration and control architecture of this plugin was
overloading set_settings() to manipulate both device settings and to
send transient commands. e.g., "power_on" and "power_off" were triggered
by calling set_settings(). Then to avoid transient properties in the
device configuration, a separate get/set_config() API is provided that
handles a subset of properties.

This is just confusing. It would be better to split commands and
transient state into a separate API, and restrict get/set_settings() to
only the device configuration. Fortunately, there aren't many commands
implemented at this time, so it is simple to remove them from the
set_settings() path.

This commit moves all device commands to the set() proc_handler call.
It also changes the device's obs_properties to use a callback for
changes to the White Balance mode, which processes the change
immediately instead of waiting for a call to set_settings().

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
The get_config() methods were allocating and returning a new obs_data_t
structure on each call, and in many cases the caller was then using
obs_data_apply() to copy the data into another obs_data_t. This pattern
is a little awkward, and it doesn't match the pattern used by sources in
OBS Studio. The sources pattern has the obs_data instance managed by the
caller, and is passed into the save() callback to get updated before
saving to the config file.

This patch reworks the save path by:
- renaming 'get_config()' to 'save()'
- Pass the obs_data_t structure into the save() method
- Make all save methods 'const' as they don't change the state

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 23 out of 23 changed files in this pull request and generated 4 comments.

Comment thread src/ptz-visca.cpp
Comment thread src/ptz-controls.cpp
Comment thread src/ptz-controls.cpp
Comment thread src/ptz-device.cpp Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 24 out of 24 changed files in this pull request and generated 3 comments.

Comment thread src/ptz-pelco.cpp
Comment thread src/settings.cpp Outdated
Comment thread src/ptz-device.hpp

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 24 out of 24 changed files in this pull request and generated 2 comments.

Comment thread src/settings.cpp
Comment thread src/ptz-device.cpp Outdated
glikely added 4 commits June 2, 2026 17:21
Matches the pattern in OBS Studio sources, where the defaults can be
retrieved separate from the object instance. Is useful for using the
OBSPropertiesView widget.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
THe ptz controls were accessing the device's settings structure to query
device state for autofocus mode and whitebalance mode. Fetching the
settings structure is potentially a heavyweight process for fetching a
couple of bools. Instead use the "ptz_get" proc handler method to query
just the values that are needed. This change also removes another direct
access of PTZDevice from the PTZControls widget.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
get_settings() is an empty shell now. All of the functionality is now in
`save()`. Remove the method and convert the remaining user over to
calling `save()`.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Consolidate set_config and set_settings into a single method and rename
it 'update' to match the naming used by OBS studio sources for
configuration management.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
@glikely
glikely merged commit 29c80a6 into main Jun 2, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants