mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
Requests: Add Replay Buffer and Recording Statuses
Adds `GetReplayBufferStatus` and `GetRecordingStatus`. v5.0 Will remove the recording status functionality from `GetStreamingStatus`
This commit is contained in:
parent
a4279d09a6
commit
4ead1c3de5
@ -70,11 +70,13 @@ const QHash<QString, RpcMethodHandler> WSRequestHandler::messageMap {
|
|||||||
{ "StartStreaming", &WSRequestHandler::StartStreaming },
|
{ "StartStreaming", &WSRequestHandler::StartStreaming },
|
||||||
{ "StopStreaming", &WSRequestHandler::StopStreaming },
|
{ "StopStreaming", &WSRequestHandler::StopStreaming },
|
||||||
|
|
||||||
|
{ "GetRecordingStatus", &WSRequestHandler::GetRecordingStatus },
|
||||||
{ "StartRecording", &WSRequestHandler::StartRecording },
|
{ "StartRecording", &WSRequestHandler::StartRecording },
|
||||||
{ "StopRecording", &WSRequestHandler::StopRecording },
|
{ "StopRecording", &WSRequestHandler::StopRecording },
|
||||||
{ "PauseRecording", &WSRequestHandler::PauseRecording },
|
{ "PauseRecording", &WSRequestHandler::PauseRecording },
|
||||||
{ "ResumeRecording", &WSRequestHandler::ResumeRecording },
|
{ "ResumeRecording", &WSRequestHandler::ResumeRecording },
|
||||||
|
|
||||||
|
{ "GetReplayBufferStatus", &WSRequestHandler::GetReplayBufferStatus },
|
||||||
{ "StartStopReplayBuffer", &WSRequestHandler::StartStopReplayBuffer },
|
{ "StartStopReplayBuffer", &WSRequestHandler::StartStopReplayBuffer },
|
||||||
{ "StartReplayBuffer", &WSRequestHandler::StartReplayBuffer },
|
{ "StartReplayBuffer", &WSRequestHandler::StartReplayBuffer },
|
||||||
{ "StopReplayBuffer", &WSRequestHandler::StopReplayBuffer },
|
{ "StopReplayBuffer", &WSRequestHandler::StopReplayBuffer },
|
||||||
|
@ -87,11 +87,13 @@ class WSRequestHandler {
|
|||||||
RpcResponse StartStreaming(const RpcRequest&);
|
RpcResponse StartStreaming(const RpcRequest&);
|
||||||
RpcResponse StopStreaming(const RpcRequest&);
|
RpcResponse StopStreaming(const RpcRequest&);
|
||||||
|
|
||||||
|
RpcResponse GetRecordingStatus(const RpcRequest&);
|
||||||
RpcResponse StartRecording(const RpcRequest&);
|
RpcResponse StartRecording(const RpcRequest&);
|
||||||
RpcResponse StopRecording(const RpcRequest&);
|
RpcResponse StopRecording(const RpcRequest&);
|
||||||
RpcResponse PauseRecording(const RpcRequest&);
|
RpcResponse PauseRecording(const RpcRequest&);
|
||||||
RpcResponse ResumeRecording(const RpcRequest&);
|
RpcResponse ResumeRecording(const RpcRequest&);
|
||||||
|
|
||||||
|
RpcResponse GetReplayBufferStatus(const RpcRequest&);
|
||||||
RpcResponse StartStopReplayBuffer(const RpcRequest&);
|
RpcResponse StartStopReplayBuffer(const RpcRequest&);
|
||||||
RpcResponse StartReplayBuffer(const RpcRequest&);
|
RpcResponse StartReplayBuffer(const RpcRequest&);
|
||||||
RpcResponse StopReplayBuffer(const RpcRequest&);
|
RpcResponse StopReplayBuffer(const RpcRequest&);
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
|
#include "obs-websocket.h"
|
||||||
#include "WSRequestHandler.h"
|
#include "WSRequestHandler.h"
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <util/platform.h>
|
#include <util/platform.h>
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
#include "WSEvents.h"
|
||||||
|
|
||||||
RpcResponse ifCanPause(const RpcRequest& request, std::function<RpcResponse()> callback)
|
RpcResponse ifCanPause(const RpcRequest& request, std::function<RpcResponse()> callback)
|
||||||
{
|
{
|
||||||
@ -13,6 +15,33 @@ RpcResponse ifCanPause(const RpcRequest& request, std::function<RpcResponse()> c
|
|||||||
return callback();
|
return callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get current recording status.
|
||||||
|
*
|
||||||
|
* @return {boolean} `isRecording` Current recording status.
|
||||||
|
* @return {boolean} `isRecordingPaused` Whether the recording is paused or not.
|
||||||
|
* @return {String (optional)} `recordTimecode` Time elapsed since recording started (only present if currently recording).
|
||||||
|
*
|
||||||
|
* @api requests
|
||||||
|
* @name GetRecordingStatus
|
||||||
|
* @category recording
|
||||||
|
* @since unreleased
|
||||||
|
*/
|
||||||
|
RpcResponse WSRequestHandler::GetRecordingStatus(const RpcRequest& request) {
|
||||||
|
auto events = GetEventsSystem();
|
||||||
|
|
||||||
|
OBSDataAutoRelease data = obs_data_create();
|
||||||
|
obs_data_set_bool(data, "isRecording", obs_frontend_recording_active());
|
||||||
|
obs_data_set_bool(data, "isRecordingPaused", obs_frontend_recording_paused());
|
||||||
|
|
||||||
|
if (obs_frontend_recording_active()) {
|
||||||
|
QString recordingTimecode = events->getRecordingTimecode();
|
||||||
|
obs_data_set_string(data, "recordTimecode", recordingTimecode.toUtf8().constData());
|
||||||
|
}
|
||||||
|
|
||||||
|
return request.success(data);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggle recording on or off.
|
* Toggle recording on or off.
|
||||||
*
|
*
|
||||||
|
@ -1,7 +1,27 @@
|
|||||||
|
#include "obs-websocket.h"
|
||||||
|
#include "WSEvents.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
#include "WSRequestHandler.h"
|
#include "WSRequestHandler.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the status of the OBS replay buffer.
|
||||||
|
*
|
||||||
|
* @return {boolean} `isReplayBufferActive` Current recording status.
|
||||||
|
*
|
||||||
|
* @api requests
|
||||||
|
* @name GetReplayBufferStatus
|
||||||
|
* @category replay buffer
|
||||||
|
* @since unreleased
|
||||||
|
*/
|
||||||
|
RpcResponse WSRequestHandler::GetReplayBufferStatus(const RpcRequest& request) {
|
||||||
|
OBSDataAutoRelease data = obs_data_create();
|
||||||
|
obs_data_set_bool(data, "isReplayBufferActive", obs_frontend_replay_buffer_active());
|
||||||
|
|
||||||
|
return request.success(data);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggle the Replay Buffer on/off.
|
* Toggle the Replay Buffer on/off.
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user