mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
requesthandler: Add private source settings get/set requests
It was requested via Discord to be able to modify the private settings of any private source, since that functionality is used by some client software to store stateful data. As private settings are in territory that no normal user should ever tread into, these requests will be left undocumented.
This commit is contained in:
parent
8f2d266dec
commit
6a2d5968ad
@ -56,6 +56,8 @@ const std::unordered_map<std::string, RequestMethodHandler> RequestHandler::_han
|
|||||||
{"GetSourceActive", &RequestHandler::GetSourceActive},
|
{"GetSourceActive", &RequestHandler::GetSourceActive},
|
||||||
{"GetSourceScreenshot", &RequestHandler::GetSourceScreenshot},
|
{"GetSourceScreenshot", &RequestHandler::GetSourceScreenshot},
|
||||||
{"SaveSourceScreenshot", &RequestHandler::SaveSourceScreenshot},
|
{"SaveSourceScreenshot", &RequestHandler::SaveSourceScreenshot},
|
||||||
|
{"GetSourcePrivateSettings", &RequestHandler::GetSourcePrivateSettings},
|
||||||
|
{"SetSourcePrivateSettings", &RequestHandler::SetSourcePrivateSettings},
|
||||||
|
|
||||||
// Scenes
|
// Scenes
|
||||||
{"GetSceneList", &RequestHandler::GetSceneList},
|
{"GetSceneList", &RequestHandler::GetSceneList},
|
||||||
|
@ -74,6 +74,8 @@ class RequestHandler {
|
|||||||
RequestResult GetSourceActive(const Request&);
|
RequestResult GetSourceActive(const Request&);
|
||||||
RequestResult GetSourceScreenshot(const Request&);
|
RequestResult GetSourceScreenshot(const Request&);
|
||||||
RequestResult SaveSourceScreenshot(const Request&);
|
RequestResult SaveSourceScreenshot(const Request&);
|
||||||
|
RequestResult GetSourcePrivateSettings(const Request&);
|
||||||
|
RequestResult SetSourcePrivateSettings(const Request&);
|
||||||
|
|
||||||
// Scenes
|
// Scenes
|
||||||
RequestResult GetSceneList(const Request&);
|
RequestResult GetSceneList(const Request&);
|
||||||
|
@ -675,8 +675,6 @@ RequestResult RequestHandler::GetSceneItemBlendMode(const Request& request)
|
|||||||
return RequestResult::Success(responseData);
|
return RequestResult::Success(responseData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the blend mode of a scene item.
|
* Sets the blend mode of a scene item.
|
||||||
*
|
*
|
||||||
|
@ -312,3 +312,39 @@ RequestResult RequestHandler::SaveSourceScreenshot(const Request& request)
|
|||||||
|
|
||||||
return RequestResult::Success();
|
return RequestResult::Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Intentionally undocumented
|
||||||
|
RequestResult RequestHandler::GetSourcePrivateSettings(const Request& request)
|
||||||
|
{
|
||||||
|
RequestStatus::RequestStatus statusCode;
|
||||||
|
std::string comment;
|
||||||
|
OBSSourceAutoRelease source = request.ValidateSource("sourceName", statusCode, comment);
|
||||||
|
if (!source)
|
||||||
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
|
OBSDataAutoRelease privateSettings = obs_source_get_private_settings(source);
|
||||||
|
|
||||||
|
json responseData;
|
||||||
|
responseData["sourceSettings"] = Utils::Json::ObsDataToJson(privateSettings);
|
||||||
|
|
||||||
|
return RequestResult::Success(responseData);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Intentionally undocumented
|
||||||
|
RequestResult RequestHandler::SetSourcePrivateSettings(const Request& request)
|
||||||
|
{
|
||||||
|
RequestStatus::RequestStatus statusCode;
|
||||||
|
std::string comment;
|
||||||
|
OBSSourceAutoRelease source = request.ValidateSource("sourceName", statusCode, comment);
|
||||||
|
if (!source || !request.ValidateObject("sourceSettings", statusCode, comment))
|
||||||
|
return RequestResult::Error(statusCode, comment);
|
||||||
|
|
||||||
|
OBSDataAutoRelease privateSettings = obs_source_get_private_settings(source);
|
||||||
|
|
||||||
|
OBSDataAutoRelease newSettings = Utils::Json::JsonToObsData(request.RequestData["sourceSettings"]);
|
||||||
|
|
||||||
|
// Always overlays to prevent destroying internal source data unintentionally
|
||||||
|
obs_data_apply(privateSettings, newSettings);
|
||||||
|
|
||||||
|
return RequestResult::Success();
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user