Requests: Add unpublished RemoveInput

The functionality depends on obs-studio#5276 to be merged and released,
so we can add it but not enable it for now.
This commit is contained in:
tt2468 2021-09-17 02:36:19 -07:00
parent c9fa09edc4
commit eebcc25115
4 changed files with 19 additions and 1 deletions

View File

@ -51,7 +51,7 @@ void Config::Load()
// future loads use the override flag. // future loads use the override flag.
if (FirstLoad) { if (FirstLoad) {
FirstLoad = false; FirstLoad = false;
if (!ServerPassword.empty()) { if (!ServerPassword.isEmpty()) {
blog(LOG_INFO, "[Config::Load] (FirstLoad) Generating new server password."); blog(LOG_INFO, "[Config::Load] (FirstLoad) Generating new server password.");
ServerPassword = QString::fromStdString(Utils::Crypto::GeneratePassword()); ServerPassword = QString::fromStdString(Utils::Crypto::GeneratePassword());
} else { } else {

View File

@ -49,6 +49,7 @@ const std::map<std::string, RequestMethodHandler> RequestHandler::_handlerMap
{"GetInputList", &RequestHandler::GetInputList}, {"GetInputList", &RequestHandler::GetInputList},
{"GetInputKindList", &RequestHandler::GetInputKindList}, {"GetInputKindList", &RequestHandler::GetInputKindList},
{"CreateInput", &RequestHandler::CreateInput}, {"CreateInput", &RequestHandler::CreateInput},
//{"RemoveInput", &RequestHandler::RemoveInput}, // Disabled for now. Pending obs-studio#5276
{"SetInputName", &RequestHandler::SetInputName}, {"SetInputName", &RequestHandler::SetInputName},
{"GetInputDefaultSettings", &RequestHandler::GetInputDefaultSettings}, {"GetInputDefaultSettings", &RequestHandler::GetInputDefaultSettings},
{"GetInputSettings", &RequestHandler::GetInputSettings}, {"GetInputSettings", &RequestHandler::GetInputSettings},

View File

@ -70,6 +70,7 @@ class RequestHandler {
RequestResult GetInputList(const Request&); RequestResult GetInputList(const Request&);
RequestResult GetInputKindList(const Request&); RequestResult GetInputKindList(const Request&);
RequestResult CreateInput(const Request&); RequestResult CreateInput(const Request&);
RequestResult RemoveInput(const Request&);
RequestResult SetInputName(const Request&); RequestResult SetInputName(const Request&);
RequestResult GetInputDefaultSettings(const Request&); RequestResult GetInputDefaultSettings(const Request&);
RequestResult GetInputSettings(const Request&); RequestResult GetInputSettings(const Request&);

View File

@ -83,6 +83,22 @@ RequestResult RequestHandler::CreateInput(const Request& request)
return RequestResult::Success(responseData); return RequestResult::Success(responseData);
} }
RequestResult RequestHandler::RemoveInput(const Request& request)
{
RequestStatus::RequestStatus statusCode;
std::string comment;
OBSSourceAutoRelease input = request.ValidateInput("inputName", statusCode, comment);
if (!input)
return RequestResult::Error(statusCode, comment);
// Some implementations of removing sources release before remove, and some release after.
// Releasing afterwards guarantees that we don't accidentally destroy the source before
// remove if we happen to hold the last ref (very, very rare)
obs_source_remove(input);
return RequestResult::Success();
}
RequestResult RequestHandler::SetInputName(const Request& request) RequestResult RequestHandler::SetInputName(const Request& request)
{ {
RequestStatus::RequestStatus statusCode; RequestStatus::RequestStatus statusCode;