RequestHandler: Add GetSceneList

This commit is contained in:
tt2468 2021-06-14 22:52:23 -07:00
parent f26cf8f95f
commit cb5ee53956
4 changed files with 29 additions and 0 deletions

View File

@ -89,6 +89,7 @@ set(obs-websocket_SOURCES
src/requesthandler/RequestHandler_General.cpp src/requesthandler/RequestHandler_General.cpp
src/requesthandler/RequestHandler_Config.cpp src/requesthandler/RequestHandler_Config.cpp
src/requesthandler/RequestHandler_Sources.cpp src/requesthandler/RequestHandler_Sources.cpp
src/requesthandler/RequestHandler_Scenes.cpp
src/requesthandler/rpc/Request.cpp src/requesthandler/rpc/Request.cpp
src/requesthandler/rpc/RequestResult.cpp src/requesthandler/rpc/RequestResult.cpp
src/forms/SettingsDialog.cpp src/forms/SettingsDialog.cpp

View File

@ -26,6 +26,9 @@ const std::map<std::string, RequestMethodHandler> RequestHandler::_handlerMap
{"GetSourceActive", &RequestHandler::GetSourceActive}, {"GetSourceActive", &RequestHandler::GetSourceActive},
{"GetSourceScreenshot", &RequestHandler::GetSourceScreenshot}, {"GetSourceScreenshot", &RequestHandler::GetSourceScreenshot},
{"SaveSourceScreenshot", &RequestHandler::SaveSourceScreenshot}, {"SaveSourceScreenshot", &RequestHandler::SaveSourceScreenshot},
// Scenes
{"GetSceneList", &RequestHandler::GetSceneList},
}; };
RequestResult RequestHandler::ProcessRequest(const Request& request) RequestResult RequestHandler::ProcessRequest(const Request& request)

View File

@ -41,5 +41,8 @@ class RequestHandler {
RequestResult GetSourceScreenshot(const Request&); RequestResult GetSourceScreenshot(const Request&);
RequestResult SaveSourceScreenshot(const Request&); RequestResult SaveSourceScreenshot(const Request&);
// Scenes
RequestResult GetSceneList(const Request&);
static const std::map<std::string, RequestMethodHandler> _handlerMap; static const std::map<std::string, RequestMethodHandler> _handlerMap;
}; };

View 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);
}