Add support for inputVariables basic operations in batch requests
Requested Feature
Currently, batch requests allow the use of inputVariables/outputVariables to easily store and use the results of a previous request stage in the next ones. However, they're implemented as a simple key-value store and it's not possible to apply basic operators to the values themselves before inputting to the next stage. This would be a nice feature for common use cases like toggling some property/item, where you need to set the negation of the current value, as it would really make the most out of batch requests.
My proposal is to optionally specify such operations in the inputVariables value string, separated by some special delimiter. E.g.:
Feature Request Type
Other
Feature Request Type (Other)
Add support for
inputVariables
basic operations in batch requestsRequested Feature
Currently, batch requests allow the use of
inputVariables
/outputVariables
to easily store and use the results of a previous request stage in the next ones. However, they're implemented as a simple key-value store and it's not possible to apply basic operators to the values themselves before inputting to the next stage. This would be a nice feature for common use cases like toggling some property/item, where you need to set the negation of the current value, as it would really make the most out of batch requests.My proposal is to optionally specify such operations in the
inputVariables
value string, separated by some special delimiter. E.g.:This seems feasible with some changes to the last section of
PreProcessVariables
, where the optional operator would be parsed and applied to the raw stored value instead of just returning it as it is: https://github.com/obsproject/obs-websocket/blob/f4b72b69ce7f9ec6a5fdb1b06971e00d2b091bec/src/requesthandler/RequestBatchHandler.cpp#L74-L85As for the operations, I propose to include:
someBooleanVariable:negate
someNumberVariable:add:5
,someNumberVariable:mul:0.5
someStringVariable:add:somestring
Requested Feature Usage Scenario
(non-exhaustive list of use cases)
Batch requests that aim to toggle a boolean value (and don't have a separate
ToggleX
request)GetSceneItemId
>GetSceneItemEnabled
>SetSceneItemEnabled
GetSceneItemId
>GetSceneItemLocked
>SetSceneItemLocked
GetSourceFilter
>SetSourceFilterEnabled
GetStudioModeEnabled
>SetStudioModeEnabled
Batch requests that aim to set a number value based on current value
GetSceneItemIndex
>SetSceneItemIndex
GetInputVolume
>SetInputVolume
GetCurrentSceneTransition
>SetCurrentSceneTransitionDuration