diff --git a/PROTOCOL.md b/PROTOCOL.md index 99909305..3e179a66 100644 --- a/PROTOCOL.md +++ b/PROTOCOL.md @@ -73,6 +73,8 @@ The protocol in general is based on the OBS Remote protocol created by Bill Hami - ["StartRecording"](#startrecording) - ["StopRecording"](#stoprecording) - ["GetStreamingStatus"](#getstreamingstatus) + - ["SetRecordingFolder"](#setrecordingfolder) + - ["GetRecordingFolder"](#getrecordingfolder) - **Transitions** - ["GetTransitionList"](#gettransitionlist) - ["GetCurrentTransition"](#getcurrenttransition) @@ -519,6 +521,26 @@ __Response__ : Error if recording is already inactive, OK otherwise. No addition --- +#### "SetRecordingFolder" +Change the current recording folder. + +__Request fields__ : +- **"rec-folder"** (string) : path of the desired recording folder + +__Response__ : OK if path is valid, error otherwise. + +--- + +#### "GetRecordingFolder" +Get the path of the current recording folder. + +__Request fields__ : none + +__Response__ : OK with these additional fields : +- **"rec-folder"** (string) : path of the current recording folder + +--- + #### "GetStreamingStatus" Get current streaming and recording status. diff --git a/WSRequestHandler.cpp b/WSRequestHandler.cpp index e3d71e51..9bdbf58a 100644 --- a/WSRequestHandler.cpp +++ b/WSRequestHandler.cpp @@ -57,6 +57,9 @@ WSRequestHandler::WSRequestHandler(QWebSocket* client) : messageMap["StartRecording"] = WSRequestHandler::HandleStartRecording; messageMap["StopRecording"] = WSRequestHandler::HandleStopRecording; + messageMap["SetRecordingFolder"] = WSRequestHandler::HandleSetRecordingFolder; + messageMap["GetRecordingFolder"] = WSRequestHandler::HandleGetRecordingFolder; + messageMap["GetTransitionList"] = WSRequestHandler::HandleGetTransitionList; messageMap["GetCurrentTransition"] = WSRequestHandler::HandleGetCurrentTransition; messageMap["SetCurrentTransition"] = WSRequestHandler::HandleSetCurrentTransition; @@ -1061,5 +1064,33 @@ void WSRequestHandler::HandleGetSpecialSources(WSRequestHandler* req) req->SendOKResponse(response); + obs_data_release(response); +} + +void WSRequestHandler::HandleSetRecordingFolder(WSRequestHandler* req) +{ + if (!req->hasField("rec-folder")) + { + req->SendErrorResponse("missing request parameters"); + return; + } + + const char* newRecFolder = obs_data_get_string(req->data, "rec-folder"); + bool success = Utils::SetRecordingFolder(newRecFolder); + + if (success) + req->SendOKResponse(); + else + req->SendErrorResponse("invalid request parameters"); +} + +void WSRequestHandler::HandleGetRecordingFolder(WSRequestHandler* req) +{ + const char* recFolder = Utils::GetRecordingFolder(); + + obs_data_t* response = obs_data_create(); + obs_data_set_string(response, "rec-folder", recFolder); + + req->SendOKResponse(response); obs_data_release(response); } \ No newline at end of file diff --git a/WSRequestHandler.h b/WSRequestHandler.h index c7230c16..c88a685e 100644 --- a/WSRequestHandler.h +++ b/WSRequestHandler.h @@ -67,6 +67,9 @@ class WSRequestHandler : public QObject static void HandleStartRecording(WSRequestHandler* req); static void HandleStopRecording(WSRequestHandler* req); + static void HandleSetRecordingFolder(WSRequestHandler* req); + static void HandleGetRecordingFolder(WSRequestHandler* req); + static void HandleGetTransitionList(WSRequestHandler* req); static void HandleGetCurrentTransition(WSRequestHandler* req); static void HandleSetCurrentTransition(WSRequestHandler* req);