mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
Add request type GetSpecialSources
This commit is contained in:
parent
d267171cc7
commit
5d290165a2
14
PROTOCOL.md
14
PROTOCOL.md
@ -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"
|
||||
__Request fields__ :
|
||||
- **"item"** (string) : The name of the scene item.
|
||||
|
@ -68,6 +68,7 @@ WSRequestHandler::WSRequestHandler(QWebSocket *client) :
|
||||
messageMap["ToggleMute"] = WSRequestHandler::HandleToggleMute;
|
||||
messageMap["SetMute"] = WSRequestHandler::HandleSetMute;
|
||||
messageMap["GetMute"] = WSRequestHandler::HandleGetMute;
|
||||
messageMap["GetSpecialSources"] = WSRequestHandler::HandleGetSpecialSources;
|
||||
|
||||
messageMap["SetCurrentSceneCollection"] = WSRequestHandler::HandleSetCurrentSceneCollection;
|
||||
messageMap["GetCurrentSceneCollection"] = WSRequestHandler::HandleGetCurrentSceneCollection;
|
||||
@ -1006,4 +1007,36 @@ void WSRequestHandler::HandleToggleStudioMode(WSRequestHandler *req)
|
||||
{
|
||||
Utils::TogglePreviewMode();
|
||||
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);
|
||||
}
|
@ -76,6 +76,7 @@ class WSRequestHandler : public QObject
|
||||
static void HandleToggleMute(WSRequestHandler *req);
|
||||
static void HandleSetMute(WSRequestHandler *req);
|
||||
static void HandleGetMute(WSRequestHandler *req);
|
||||
static void HandleGetSpecialSources(WSRequestHandler *req);
|
||||
|
||||
static void HandleSetCurrentSceneCollection(WSRequestHandler *req);
|
||||
static void HandleGetCurrentSceneCollection(WSRequestHandler *req);
|
||||
|
Loading…
x
Reference in New Issue
Block a user