RequestHandler: Add GetInputDefaultSettings

This commit is contained in:
tt2468 2021-06-16 02:07:51 -07:00
parent 8ad009ba51
commit 1116af128e
3 changed files with 21 additions and 0 deletions

View File

@ -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)

View File

@ -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;
};

View File

@ -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);
}