mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
Add support for filename formatting get/set (#162)
This commit is contained in:
parent
e5dae8f5a7
commit
677e393f47
@ -502,3 +502,15 @@ bool Utils::IsRPHotkeySet() {
|
||||
size_t count = obs_data_array_count(bindings);
|
||||
return (count > 0);
|
||||
}
|
||||
|
||||
const char* Utils::GetFilenameFormatting() {
|
||||
config_t* profile = obs_frontend_get_profile_config();
|
||||
return config_get_string(profile, "Output", "FilenameFormatting");
|
||||
}
|
||||
|
||||
bool Utils::SetFilenameFormatting(const char* filenameFormatting) {
|
||||
config_t* profile = obs_frontend_get_profile_config();
|
||||
config_set_string(profile, "Output", "FilenameFormatting", filenameFormatting);
|
||||
config_save(profile);
|
||||
return true;
|
||||
}
|
||||
|
@ -82,6 +82,8 @@ class Utils {
|
||||
static bool ReplayBufferEnabled();
|
||||
static void StartReplayBuffer();
|
||||
static bool IsRPHotkeySet();
|
||||
static const char* GetFilenameFormatting();
|
||||
static bool SetFilenameFormatting(const char* filenameFormatting);
|
||||
};
|
||||
|
||||
#endif // UTILS_H
|
||||
|
@ -31,6 +31,9 @@ QHash<QString, void(*)(WSRequestHandler*)> WSRequestHandler::messageMap {
|
||||
|
||||
{ "SetHeartbeat", WSRequestHandler::HandleSetHeartbeat },
|
||||
|
||||
{ "SetFilenameFormatting", WSRequestHandler::HandleSetFilenameFormatting },
|
||||
{ "GetFilenameFormatting", WSRequestHandler::HandleGetFilenameFormatting },
|
||||
|
||||
{ "SetCurrentScene", WSRequestHandler::HandleSetCurrentScene },
|
||||
{ "GetCurrentScene", WSRequestHandler::HandleGetCurrentScene },
|
||||
{ "GetSceneList", WSRequestHandler::HandleGetSceneList },
|
||||
|
@ -59,6 +59,9 @@ class WSRequestHandler : public QObject {
|
||||
|
||||
static void HandleSetHeartbeat(WSRequestHandler* req);
|
||||
|
||||
static void HandleSetFilenameFormatting(WSRequestHandler* req);
|
||||
static void HandleGetFilenameFormatting(WSRequestHandler* req);
|
||||
|
||||
static void HandleSetCurrentScene(WSRequestHandler* req);
|
||||
static void HandleGetCurrentScene(WSRequestHandler* req);
|
||||
static void HandleGetSceneList(WSRequestHandler* req);
|
||||
|
@ -125,3 +125,44 @@ void WSRequestHandler::HandleAuthenticate(WSRequestHandler* req) {
|
||||
WSEvents::Instance->HeartbeatIsActive);
|
||||
req->SendOKResponse(response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the filename formatting string
|
||||
*
|
||||
* @param {String} `filename-formatting` Filename formatting string to set.
|
||||
*
|
||||
* @api requests
|
||||
* @name SetFilenameFormatting
|
||||
* @category general
|
||||
* @since unreleased
|
||||
*/
|
||||
void WSRequestHandler::HandleSetFilenameFormatting(WSRequestHandler* req) {
|
||||
if (!req->hasField("filename-formatting")) {
|
||||
req->SendErrorResponse("<filename-formatting> parameter missing");
|
||||
return;
|
||||
}
|
||||
|
||||
QString filenameFormatting = obs_data_get_string(req->data, "filename-formatting");
|
||||
if (!filenameFormatting.isEmpty()) {
|
||||
Utils::SetFilenameFormatting(filenameFormatting.toUtf8());
|
||||
req->SendOKResponse();
|
||||
} else {
|
||||
req->SendErrorResponse("invalid request parameters");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the filename formatting string
|
||||
*
|
||||
* @return {String} `filename-formatting` Current filename formatting string.
|
||||
*
|
||||
* @api requests
|
||||
* @name GetFilenameFormatting
|
||||
* @category general
|
||||
* @since unreleased
|
||||
*/
|
||||
void WSRequestHandler::HandleGetFilenameFormatting(WSRequestHandler* req) {
|
||||
OBSDataAutoRelease response = obs_data_create();
|
||||
obs_data_set_string(response, "filename-formatting", Utils::GetFilenameFormatting());
|
||||
req->SendOKResponse(response);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user