obsproject / obs-websocket

Remote-control of OBS Studio through WebSocket
GNU General Public License v2.0
3.84k stars 704 forks source link

Feature Request: Add support for 'inputVariables' basic operations in batch requests #1112

Open LorenaGdL opened 1 year ago

LorenaGdL commented 1 year ago

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:

Requested Feature Usage Scenario

(non-exhaustive list of use cases)