mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
RequestHandler: Add GetSceneList
This commit is contained in:
parent
f26cf8f95f
commit
cb5ee53956
@ -89,6 +89,7 @@ set(obs-websocket_SOURCES
|
||||
src/requesthandler/RequestHandler_General.cpp
|
||||
src/requesthandler/RequestHandler_Config.cpp
|
||||
src/requesthandler/RequestHandler_Sources.cpp
|
||||
src/requesthandler/RequestHandler_Scenes.cpp
|
||||
src/requesthandler/rpc/Request.cpp
|
||||
src/requesthandler/rpc/RequestResult.cpp
|
||||
src/forms/SettingsDialog.cpp
|
||||
|
@ -26,6 +26,9 @@ const std::map<std::string, RequestMethodHandler> RequestHandler::_handlerMap
|
||||
{"GetSourceActive", &RequestHandler::GetSourceActive},
|
||||
{"GetSourceScreenshot", &RequestHandler::GetSourceScreenshot},
|
||||
{"SaveSourceScreenshot", &RequestHandler::SaveSourceScreenshot},
|
||||
|
||||
// Scenes
|
||||
{"GetSceneList", &RequestHandler::GetSceneList},
|
||||
};
|
||||
|
||||
RequestResult RequestHandler::ProcessRequest(const Request& request)
|
||||
|
@ -41,5 +41,8 @@ class RequestHandler {
|
||||
RequestResult GetSourceScreenshot(const Request&);
|
||||
RequestResult SaveSourceScreenshot(const Request&);
|
||||
|
||||
// Scenes
|
||||
RequestResult GetSceneList(const Request&);
|
||||
|
||||
static const std::map<std::string, RequestMethodHandler> _handlerMap;
|
||||
};
|
||||
|
22
src/requesthandler/RequestHandler_Scenes.cpp
Normal file
22
src/requesthandler/RequestHandler_Scenes.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
#include "RequestHandler.h"
|
||||
|
||||
#include "../plugin-macros.generated.h"
|
||||
|
||||
RequestResult RequestHandler::GetSceneList(const Request& request)
|
||||
{
|
||||
json responseData;
|
||||
|
||||
OBSSourceAutoRelease currentProgramScene = obs_frontend_get_current_scene();
|
||||
responseData["currentProgramSceneName"] = obs_source_get_name(currentProgramScene);
|
||||
|
||||
|
||||
OBSSourceAutoRelease currentPreviewScene = obs_frontend_get_current_preview_scene();
|
||||
if (currentPreviewScene)
|
||||
responseData["currentPreviewSceneName"] = obs_source_get_name(currentPreviewScene);
|
||||
else
|
||||
responseData["currentPreviewSceneName"] = nullptr;
|
||||
|
||||
responseData["scenes"] = Utils::Obs::ListHelper::GetSceneList();
|
||||
|
||||
return RequestResult::Success(responseData);
|
||||
}
|
Loading…
Reference in New Issue
Block a user