mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
RequestHandler: Add GetInputDefaultSettings
This commit is contained in:
parent
8ad009ba51
commit
1116af128e
@ -40,6 +40,7 @@ const std::map<std::string, RequestMethodHandler> RequestHandler::_handlerMap
|
||||
// Inputs
|
||||
{"GetInputList", &RequestHandler::GetInputList},
|
||||
{"GetInputKindList", &RequestHandler::GetInputKindList},
|
||||
{"GetInputDefaultSettings", &RequestHandler::GetInputDefaultSettings},
|
||||
};
|
||||
|
||||
RequestResult RequestHandler::ProcessRequest(const Request& request)
|
||||
|
@ -54,6 +54,7 @@ class RequestHandler {
|
||||
// Inputs
|
||||
RequestResult GetInputList(const Request&);
|
||||
RequestResult GetInputKindList(const Request&);
|
||||
RequestResult GetInputDefaultSettings(const Request&);
|
||||
|
||||
static const std::map<std::string, RequestMethodHandler> _handlerMap;
|
||||
};
|
||||
|
@ -39,3 +39,22 @@ RequestResult RequestHandler::GetInputKindList(const Request& request)
|
||||
responseData["inputKinds"] = Utils::Obs::ListHelper::GetInputKindList(unversioned);
|
||||
return RequestResult::Success(responseData);
|
||||
}
|
||||
|
||||
RequestResult RequestHandler::GetInputDefaultSettings(const Request& request)
|
||||
{
|
||||
RequestStatus::RequestStatus statusCode;
|
||||
std::string comment;
|
||||
if (!request.ValidateString("inputKind", statusCode, comment)) {
|
||||
return RequestResult::Error(statusCode, comment);
|
||||
}
|
||||
|
||||
std::string inputKind = request.RequestData["inputKind"];
|
||||
|
||||
OBSDataAutoRelease defaultSettings = obs_get_source_defaults(inputKind.c_str());
|
||||
if (!defaultSettings)
|
||||
return RequestResult::Error(RequestStatus::InvalidInputKind);
|
||||
|
||||
json responseData;
|
||||
responseData["defaultInputSettings"] = Utils::Json::ObsDataToJson(defaultSettings, true);
|
||||
return RequestResult::Success(responseData);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user