mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
Request: Add ValidateInput()
This commit is contained in:
parent
1116af128e
commit
3400bfdc9a
@ -139,3 +139,26 @@ const bool Request::ValidateArray(const std::string keyName, RequestStatus::Requ
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
obs_source_t *Request::ValidateInput(const std::string keyName, RequestStatus::RequestStatus &statusCode, std::string &comment) const
|
||||
{
|
||||
if (!ValidateString(keyName, statusCode, comment))
|
||||
return nullptr;
|
||||
|
||||
std::string inputName = RequestData[keyName];
|
||||
|
||||
obs_source_t *ret = obs_get_source_by_name(inputName.c_str());
|
||||
if (!ret) {
|
||||
statusCode = RequestStatus::InputNotFound;
|
||||
comment = std::string("No input was found by the name of `") + inputName + "`.";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (obs_source_get_type(ret) != OBS_SOURCE_TYPE_INPUT) {
|
||||
statusCode = RequestStatus::InvalidSourceType;
|
||||
comment = "The specified source is not an input.";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -21,6 +21,8 @@ struct Request
|
||||
const bool ValidateObject(const std::string keyName, RequestStatus::RequestStatus &statusCode, std::string &comment, const bool allowEmpty = false) const;
|
||||
const bool ValidateArray(const std::string keyName, RequestStatus::RequestStatus &statusCode, std::string &comment, const bool allowEmpty = false) const;
|
||||
|
||||
obs_source_t *ValidateInput(const std::string keyName, RequestStatus::RequestStatus &statusCode, std::string &comment) const;
|
||||
|
||||
const uint8_t RpcVersion;
|
||||
const bool IgnoreNonFatalRequestChecks;
|
||||
const std::string RequestType;
|
||||
|
Loading…
Reference in New Issue
Block a user