Feature Request: Add support for 'inputVariables' basic operations in batch requests
Feature Request Type
Other
Feature Request Type (Other)
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.:
"inputVariables": {
"sceneItemEnabled": "sceneItemEnabledVariable:negate"
}
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-L85
As for the operations, I propose to include:
- (must have) Booleans negation, to allow for toggling in batch requests. E.g.
someBooleanVariable:negate - (should have) Numbers addition and multiplication. E.g.
someNumberVariable:add:5,someNumberVariable:mul:0.5 - (maybe) String addition/concat. E.g.
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
ToggleXrequest)GetSceneItemId>GetSceneItemEnabled>SetSceneItemEnabledGetSceneItemId>GetSceneItemLocked>SetSceneItemLockedGetSourceFilter>SetSourceFilterEnabledGetStudioModeEnabled>SetStudioModeEnabled
-
Batch requests that aim to set a number value based on current value
GetSceneItemIndex>SetSceneItemIndexGetInputVolume>SetInputVolumeGetCurrentSceneTransition>SetCurrentSceneTransitionDuration