Add request type GetSpecialSources

This commit is contained in:
Palakis 2017-04-21 13:39:28 +02:00
parent d267171cc7
commit 5d290165a2
3 changed files with 48 additions and 0 deletions

View File

@ -638,6 +638,20 @@ __Response__ : OK if specified source exists, error otherwise.
--- ---
#### "GetSpecialSources"
Get configured special sources like Desktop Audio and Mic/Aux sources.
__Request fields__ : none
__Response__ : always OK, with these additional fields :
- **"desktop-1"** (string, optional) : Name of the first Desktop Audio capture source
- **"desktop-1"** (string, optional) : Name of the second Desktop Audio capture source
- **"mic-1"** (string, optional) : Name of the first Mic/Aux input source
- **"mic-2"** (string, optional) : Name of the second Mic/Aux input source
- **"mic-3"** (string, optional) : Name of the third Mic/Aux input source
---
#### "SetSceneItemPosition" #### "SetSceneItemPosition"
__Request fields__ : __Request fields__ :
- **"item"** (string) : The name of the scene item. - **"item"** (string) : The name of the scene item.

View File

@ -68,6 +68,7 @@ WSRequestHandler::WSRequestHandler(QWebSocket *client) :
messageMap["ToggleMute"] = WSRequestHandler::HandleToggleMute; messageMap["ToggleMute"] = WSRequestHandler::HandleToggleMute;
messageMap["SetMute"] = WSRequestHandler::HandleSetMute; messageMap["SetMute"] = WSRequestHandler::HandleSetMute;
messageMap["GetMute"] = WSRequestHandler::HandleGetMute; messageMap["GetMute"] = WSRequestHandler::HandleGetMute;
messageMap["GetSpecialSources"] = WSRequestHandler::HandleGetSpecialSources;
messageMap["SetCurrentSceneCollection"] = WSRequestHandler::HandleSetCurrentSceneCollection; messageMap["SetCurrentSceneCollection"] = WSRequestHandler::HandleSetCurrentSceneCollection;
messageMap["GetCurrentSceneCollection"] = WSRequestHandler::HandleGetCurrentSceneCollection; messageMap["GetCurrentSceneCollection"] = WSRequestHandler::HandleGetCurrentSceneCollection;
@ -1006,4 +1007,36 @@ void WSRequestHandler::HandleToggleStudioMode(WSRequestHandler *req)
{ {
Utils::TogglePreviewMode(); Utils::TogglePreviewMode();
req->SendOKResponse(); req->SendOKResponse();
}
void WSRequestHandler::HandleGetSpecialSources(WSRequestHandler *req)
{
obs_data_t* response = obs_data_create();
QMap<const char*, int> sources;
sources["desktop-1"] = 1;
sources["desktop-2"] = 2;
sources["mic-1"] = 3;
sources["mic-2"] = 4;
sources["mic-3"] = 5;
QMapIterator<const char*, int> i(sources);
while (i.hasNext())
{
i.next();
const char* id = i.key();
obs_source_t* source = obs_get_output_source(i.value());
blog(LOG_INFO, "%s : %p", id, source);
if (source)
{
obs_data_set_string(response, id, obs_source_get_name(source));
obs_source_release(source);
}
}
req->SendOKResponse(response);
obs_data_release(response);
} }

View File

@ -76,6 +76,7 @@ class WSRequestHandler : public QObject
static void HandleToggleMute(WSRequestHandler *req); static void HandleToggleMute(WSRequestHandler *req);
static void HandleSetMute(WSRequestHandler *req); static void HandleSetMute(WSRequestHandler *req);
static void HandleGetMute(WSRequestHandler *req); static void HandleGetMute(WSRequestHandler *req);
static void HandleGetSpecialSources(WSRequestHandler *req);
static void HandleSetCurrentSceneCollection(WSRequestHandler *req); static void HandleSetCurrentSceneCollection(WSRequestHandler *req);
static void HandleGetCurrentSceneCollection(WSRequestHandler *req); static void HandleGetCurrentSceneCollection(WSRequestHandler *req);