Protocol: add request types to get/set current recording folder

This commit is contained in:
Palakis 2017-06-06 09:50:02 +02:00
parent f49980350a
commit f001d18eea
3 changed files with 56 additions and 0 deletions

View File

@ -73,6 +73,8 @@ The protocol in general is based on the OBS Remote protocol created by Bill Hami
- ["StartRecording"](#startrecording) - ["StartRecording"](#startrecording)
- ["StopRecording"](#stoprecording) - ["StopRecording"](#stoprecording)
- ["GetStreamingStatus"](#getstreamingstatus) - ["GetStreamingStatus"](#getstreamingstatus)
- ["SetRecordingFolder"](#setrecordingfolder)
- ["GetRecordingFolder"](#getrecordingfolder)
- **Transitions** - **Transitions**
- ["GetTransitionList"](#gettransitionlist) - ["GetTransitionList"](#gettransitionlist)
- ["GetCurrentTransition"](#getcurrenttransition) - ["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" #### "GetStreamingStatus"
Get current streaming and recording status. Get current streaming and recording status.

View File

@ -57,6 +57,9 @@ WSRequestHandler::WSRequestHandler(QWebSocket* client) :
messageMap["StartRecording"] = WSRequestHandler::HandleStartRecording; messageMap["StartRecording"] = WSRequestHandler::HandleStartRecording;
messageMap["StopRecording"] = WSRequestHandler::HandleStopRecording; messageMap["StopRecording"] = WSRequestHandler::HandleStopRecording;
messageMap["SetRecordingFolder"] = WSRequestHandler::HandleSetRecordingFolder;
messageMap["GetRecordingFolder"] = WSRequestHandler::HandleGetRecordingFolder;
messageMap["GetTransitionList"] = WSRequestHandler::HandleGetTransitionList; messageMap["GetTransitionList"] = WSRequestHandler::HandleGetTransitionList;
messageMap["GetCurrentTransition"] = WSRequestHandler::HandleGetCurrentTransition; messageMap["GetCurrentTransition"] = WSRequestHandler::HandleGetCurrentTransition;
messageMap["SetCurrentTransition"] = WSRequestHandler::HandleSetCurrentTransition; messageMap["SetCurrentTransition"] = WSRequestHandler::HandleSetCurrentTransition;
@ -1061,5 +1064,33 @@ void WSRequestHandler::HandleGetSpecialSources(WSRequestHandler* req)
req->SendOKResponse(response); 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); obs_data_release(response);
} }

View File

@ -67,6 +67,9 @@ class WSRequestHandler : public QObject
static void HandleStartRecording(WSRequestHandler* req); static void HandleStartRecording(WSRequestHandler* req);
static void HandleStopRecording(WSRequestHandler* req); static void HandleStopRecording(WSRequestHandler* req);
static void HandleSetRecordingFolder(WSRequestHandler* req);
static void HandleGetRecordingFolder(WSRequestHandler* req);
static void HandleGetTransitionList(WSRequestHandler* req); static void HandleGetTransitionList(WSRequestHandler* req);
static void HandleGetCurrentTransition(WSRequestHandler* req); static void HandleGetCurrentTransition(WSRequestHandler* req);
static void HandleSetCurrentTransition(WSRequestHandler* req); static void HandleSetCurrentTransition(WSRequestHandler* req);