mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
RequestHandler: Add RemoveScene
This commit is contained in:
parent
9088cb4db8
commit
efdea72987
@ -35,6 +35,7 @@ const std::map<std::string, RequestMethodHandler> RequestHandler::_handlerMap
|
||||
{"SetCurrentPreviewScene", &RequestHandler::SetCurrentPreviewScene},
|
||||
{"SetSceneName", &RequestHandler::SetSceneName},
|
||||
{"CreateScene", &RequestHandler::CreateScene},
|
||||
{"RemoveScene", &RequestHandler::RemoveScene},
|
||||
};
|
||||
|
||||
RequestResult RequestHandler::ProcessRequest(const Request& request)
|
||||
|
@ -49,6 +49,7 @@ class RequestHandler {
|
||||
RequestResult SetCurrentPreviewScene(const Request&);
|
||||
RequestResult SetSceneName(const Request&);
|
||||
RequestResult CreateScene(const Request&);
|
||||
RequestResult RemoveScene(const Request&);
|
||||
|
||||
static const std::map<std::string, RequestMethodHandler> _handlerMap;
|
||||
};
|
||||
|
@ -144,3 +144,25 @@ RequestResult RequestHandler::CreateScene(const Request& request)
|
||||
|
||||
return RequestResult::Success();
|
||||
}
|
||||
|
||||
RequestResult RequestHandler::RemoveScene(const Request& request)
|
||||
{
|
||||
RequestStatus::RequestStatus statusCode;
|
||||
std::string comment;
|
||||
if (!request.ValidateString("sceneName", statusCode, comment)) {
|
||||
return RequestResult::Error(statusCode, comment);
|
||||
}
|
||||
|
||||
std::string sceneName = request.RequestData["sceneName"];
|
||||
|
||||
OBSSourceAutoRelease scene = obs_get_source_by_name(sceneName.c_str());
|
||||
if (!scene)
|
||||
return RequestResult::Error(RequestStatus::SceneNotFound);
|
||||
|
||||
if (obs_source_get_type(scene) != OBS_SOURCE_TYPE_SCENE)
|
||||
return RequestResult::Error(RequestStatus::InvalidSourceType, "The specified source is not a scene.");
|
||||
|
||||
obs_source_remove(scene);
|
||||
|
||||
return RequestResult::Success();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user