mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
requesthandler: Add SetSourceFilterName
This commit is contained in:
parent
db2ffa569a
commit
aa13828cf5
@ -115,6 +115,7 @@ const std::unordered_map<std::string, RequestMethodHandler> RequestHandler::_han
|
||||
{"GetSourceFilterDefaultSettings", &RequestHandler::GetSourceFilterDefaultSettings},
|
||||
{"CreateSourceFilter", &RequestHandler::CreateSourceFilter},
|
||||
{"RemoveSourceFilter", &RequestHandler::RemoveSourceFilter},
|
||||
{"SetSourceFilterName", &RequestHandler::SetSourceFilterName},
|
||||
{"GetSourceFilter", &RequestHandler::GetSourceFilter},
|
||||
{"SetSourceFilterIndex", &RequestHandler::SetSourceFilterIndex},
|
||||
{"SetSourceFilterSettings", &RequestHandler::SetSourceFilterSettings},
|
||||
|
@ -133,6 +133,7 @@ class RequestHandler {
|
||||
RequestResult GetSourceFilterDefaultSettings(const Request&);
|
||||
RequestResult CreateSourceFilter(const Request&);
|
||||
RequestResult RemoveSourceFilter(const Request&);
|
||||
RequestResult SetSourceFilterName(const Request&);
|
||||
RequestResult GetSourceFilter(const Request&);
|
||||
RequestResult SetSourceFilterIndex(const Request&);
|
||||
RequestResult SetSourceFilterSettings(const Request&);
|
||||
|
@ -158,6 +158,39 @@ RequestResult RequestHandler::RemoveSourceFilter(const Request& request)
|
||||
return RequestResult::Success();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name of a source filter (rename).
|
||||
*
|
||||
* @requestField sourceName | String | Name of the source the filter is on
|
||||
* @requestField filterName | String | Current name of the filter
|
||||
* @requestField newFilterName | String | New name for the filter
|
||||
*
|
||||
* @requestType SetSourceFilterName
|
||||
* @complexity 2
|
||||
* @rpcVersion -1
|
||||
* @initialVersion 5.0.0
|
||||
* @api requests
|
||||
* @category filters
|
||||
*/
|
||||
RequestResult RequestHandler::SetSourceFilterName(const Request& request)
|
||||
{
|
||||
RequestStatus::RequestStatus statusCode;
|
||||
std::string comment;
|
||||
FilterPair pair = request.ValidateFilter("sourceName", "filterName", statusCode, comment);
|
||||
if (!pair.filter || !request.ValidateString("newFilterName", statusCode, comment))
|
||||
return RequestResult::Error(statusCode, comment);
|
||||
|
||||
std::string newFilterName = request.RequestData["newFilterName"];
|
||||
|
||||
OBSSourceAutoRelease existingFilter = obs_source_get_filter_by_name(pair.source, newFilterName.c_str());
|
||||
if (existingFilter)
|
||||
return RequestResult::Error(RequestStatus::ResourceAlreadyExists, "A filter already exists by that new name.");
|
||||
|
||||
obs_source_set_name(pair.filter, newFilterName.c_str());
|
||||
|
||||
return RequestResult::Success();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the info for a specific source filter.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user