requests: add PauseRecording and ResumeRecording

This commit is contained in:
Stéphane Lepin 2019-09-03 02:05:15 +02:00
parent f3edb2ee68
commit 0cc9378d05
3 changed files with 55 additions and 2 deletions

View File

@ -24,7 +24,7 @@
#include "WSRequestHandler.h"
QHash<QString, HandlerResponse(*)(WSRequestHandler*)> WSRequestHandler::messageMap {
QHash<QString, HandlerResponse(*)(WSRequestHandler*)> WSRequestHandler::messageMap{
{ "GetVersion", WSRequestHandler::HandleGetVersion },
{ "GetAuthRequired", WSRequestHandler::HandleGetAuthRequired },
{ "Authenticate", WSRequestHandler::HandleAuthenticate },
@ -57,10 +57,14 @@ QHash<QString, HandlerResponse(*)(WSRequestHandler*)> WSRequestHandler::messageM
{ "GetStreamingStatus", WSRequestHandler::HandleGetStreamingStatus },
{ "StartStopStreaming", WSRequestHandler::HandleStartStopStreaming },
{ "StartStopRecording", WSRequestHandler::HandleStartStopRecording },
{ "StartStreaming", WSRequestHandler::HandleStartStreaming },
{ "StopStreaming", WSRequestHandler::HandleStopStreaming },
{ "StartRecording", WSRequestHandler::HandleStartRecording },
{ "StopRecording", WSRequestHandler::HandleStopRecording },
{ "PauseRecording", WSRequestHandler::HandlePauseRecording },
{ "ResumeRecording", WSRequestHandler::HandleResumeRecording },
{ "StartStopReplayBuffer", WSRequestHandler::HandleStartStopReplayBuffer },
{ "StartReplayBuffer", WSRequestHandler::HandleStartReplayBuffer },

View File

@ -103,10 +103,14 @@ class WSRequestHandler : public QObject {
static HandlerResponse HandleGetStreamingStatus(WSRequestHandler* req);
static HandlerResponse HandleStartStopStreaming(WSRequestHandler* req);
static HandlerResponse HandleStartStopRecording(WSRequestHandler* req);
static HandlerResponse HandleStartStreaming(WSRequestHandler* req);
static HandlerResponse HandleStopStreaming(WSRequestHandler* req);
static HandlerResponse HandleStartRecording(WSRequestHandler* req);
static HandlerResponse HandleStopRecording(WSRequestHandler* req);
static HandlerResponse HandlePauseRecording(WSRequestHandler* req);
static HandlerResponse HandleResumeRecording(WSRequestHandler* req);
static HandlerResponse HandleStartStopReplayBuffer(WSRequestHandler* req);
static HandlerResponse HandleStartReplayBuffer(WSRequestHandler* req);

View File

@ -55,6 +55,52 @@ HandlerResponse WSRequestHandler::HandleStartRecording(WSRequestHandler* req) {
}
}
/**
* Pause the current recording.
* Returns an error if recording is not active or already paused.
*
* @api requests
* @name PauseRecording
* @category recording
* @since 4.7.0
*/
HandlerResponse WSRequestHandler::HandlePauseRecording(WSRequestHandler* req) {
if (!obs_frontend_recording_active()) {
return req->SendErrorResponse("recording is not active");
}
if (obs_frontend_recording_paused()) {
return req->SendErrorResponse("recording already paused");
}
obs_frontend_recording_pause(true);
return req->SendOKResponse();
}
/**
* Resume/unpause the current recording (if paused).
* Returns an error if recording is not active or not paused.
*
* @api requests
* @name ResumeRecording
* @category recording
* @since 4.7.0
*/
HandlerResponse WSRequestHandler::HandleResumeRecording(WSRequestHandler* req) {
if (!obs_frontend_recording_active()) {
return req->SendErrorResponse("recording is not active");
}
if (!obs_frontend_recording_paused()) {
return req->SendErrorResponse("recording is not paused");
}
obs_frontend_recording_pause(false);
return req->SendOKResponse();
}
/**
* In the current profile, sets the recording folder of the Simple and Advanced
* output modes to the specified value.
@ -63,7 +109,6 @@ HandlerResponse WSRequestHandler::HandleStartRecording(WSRequestHandler* req) {
* in progress, the change won't be applied immediately and will be
* effective on the next recording.
*
*
* @param {String} `rec-folder` Path of the recording folder.
*
* @api requests