mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
requesthandler: Add private scene item settings get/set
Some may need it, similarly to Get/SetSourcePrivateSettings.
This commit is contained in:
parent
c355c72f4b
commit
d8c042fe4a
@ -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},
|
||||
|
@ -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&);
|
||||
|
@ -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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user