diff --git a/PROTOCOL.md b/PROTOCOL.md index 0f805344..7b3bd8cf 100644 --- a/PROTOCOL.md +++ b/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. diff --git a/WSRequestHandler.cpp b/WSRequestHandler.cpp index d8f8958f..ffaab8bc 100644 --- a/WSRequestHandler.cpp +++ b/WSRequestHandler.cpp @@ -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 sources; + sources["desktop-1"] = 1; + sources["desktop-2"] = 2; + sources["mic-1"] = 3; + sources["mic-2"] = 4; + sources["mic-3"] = 5; + + QMapIterator 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); } \ No newline at end of file diff --git a/WSRequestHandler.h b/WSRequestHandler.h index a253e5db..d537bc1a 100644 --- a/WSRequestHandler.h +++ b/WSRequestHandler.h @@ -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);