requesthandler: Add private scene item settings get/set

Some may need it, similarly to Get/SetSourcePrivateSettings.
This commit is contained in:
tt2468 2022-04-13 02:13:30 -07:00
parent c355c72f4b
commit d8c042fe4a
3 changed files with 40 additions and 0 deletions

View File

@ -138,6 +138,8 @@ const std::unordered_map<std::string, RequestMethodHandler> RequestHandler::_han
{"SetSceneItemIndex", &RequestHandler::SetSceneItemIndex},
{"GetSceneItemBlendMode", &RequestHandler::GetSceneItemBlendMode},
{"SetSceneItemBlendMode", &RequestHandler::SetSceneItemBlendMode},
{"GetSceneItemPrivateSettings", &RequestHandler::GetSceneItemPrivateSettings},
{"SetSceneItemPrivateSettings", &RequestHandler::SetSceneItemPrivateSettings},
// Outputs
{"GetVirtualCamStatus", &RequestHandler::GetVirtualCamStatus},

View File

@ -156,6 +156,8 @@ class RequestHandler {
RequestResult SetSceneItemIndex(const Request&);
RequestResult GetSceneItemBlendMode(const Request&);
RequestResult SetSceneItemBlendMode(const Request&);
RequestResult GetSceneItemPrivateSettings(const Request&);
RequestResult SetSceneItemPrivateSettings(const Request&);
// Outputs
RequestResult GetVirtualCamStatus(const Request&);

View File

@ -718,3 +718,39 @@ RequestResult RequestHandler::SetSceneItemBlendMode(const Request& request)
return RequestResult::Success();
}
// Intentionally undocumented
RequestResult RequestHandler::GetSceneItemPrivateSettings(const Request& request)
{
RequestStatus::RequestStatus statusCode;
std::string comment;
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem("sceneName", "sceneItemId", statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
if (!sceneItem)
return RequestResult::Error(statusCode, comment);
OBSDataAutoRelease privateSettings = obs_sceneitem_get_private_settings(sceneItem);
json responseData;
responseData["sceneItemSettings"] = Utils::Json::ObsDataToJson(privateSettings);
return RequestResult::Success(responseData);
}
// Intentionally undocumented
RequestResult RequestHandler::SetSceneItemPrivateSettings(const Request& request)
{
RequestStatus::RequestStatus statusCode;
std::string comment;
OBSSceneItemAutoRelease sceneItem = request.ValidateSceneItem("sceneName", "sceneItemId", statusCode, comment, OBS_WEBSOCKET_SCENE_FILTER_SCENE_OR_GROUP);
if (!sceneItem || !request.ValidateObject("sceneItemSettings", statusCode, comment))
return RequestResult::Error(statusCode, comment);
OBSDataAutoRelease privateSettings = obs_sceneitem_get_private_settings(sceneItem);
OBSDataAutoRelease newSettings = Utils::Json::JsonToObsData(request.RequestData["sceneItemSettings"]);
// Always overlays to prevent destroying internal source unintentionally
obs_data_apply(privateSettings, newSettings);
return RequestResult::Success();
}