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:
committed by
Stéphane L
parent
e5dae8f5a7
commit
677e393f47
@ -502,3 +502,15 @@ bool Utils::IsRPHotkeySet() {
|
|||||||
size_t count = obs_data_array_count(bindings);
|
size_t count = obs_data_array_count(bindings);
|
||||||
return (count > 0);
|
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 bool ReplayBufferEnabled();
|
||||||
static void StartReplayBuffer();
|
static void StartReplayBuffer();
|
||||||
static bool IsRPHotkeySet();
|
static bool IsRPHotkeySet();
|
||||||
|
static const char* GetFilenameFormatting();
|
||||||
|
static bool SetFilenameFormatting(const char* filenameFormatting);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // UTILS_H
|
#endif // UTILS_H
|
||||||
|
@ -31,6 +31,9 @@ QHash<QString, void(*)(WSRequestHandler*)> WSRequestHandler::messageMap {
|
|||||||
|
|
||||||
{ "SetHeartbeat", WSRequestHandler::HandleSetHeartbeat },
|
{ "SetHeartbeat", WSRequestHandler::HandleSetHeartbeat },
|
||||||
|
|
||||||
|
{ "SetFilenameFormatting", WSRequestHandler::HandleSetFilenameFormatting },
|
||||||
|
{ "GetFilenameFormatting", WSRequestHandler::HandleGetFilenameFormatting },
|
||||||
|
|
||||||
{ "SetCurrentScene", WSRequestHandler::HandleSetCurrentScene },
|
{ "SetCurrentScene", WSRequestHandler::HandleSetCurrentScene },
|
||||||
{ "GetCurrentScene", WSRequestHandler::HandleGetCurrentScene },
|
{ "GetCurrentScene", WSRequestHandler::HandleGetCurrentScene },
|
||||||
{ "GetSceneList", WSRequestHandler::HandleGetSceneList },
|
{ "GetSceneList", WSRequestHandler::HandleGetSceneList },
|
||||||
|
@ -59,6 +59,9 @@ class WSRequestHandler : public QObject {
|
|||||||
|
|
||||||
static void HandleSetHeartbeat(WSRequestHandler* req);
|
static void HandleSetHeartbeat(WSRequestHandler* req);
|
||||||
|
|
||||||
|
static void HandleSetFilenameFormatting(WSRequestHandler* req);
|
||||||
|
static void HandleGetFilenameFormatting(WSRequestHandler* req);
|
||||||
|
|
||||||
static void HandleSetCurrentScene(WSRequestHandler* req);
|
static void HandleSetCurrentScene(WSRequestHandler* req);
|
||||||
static void HandleGetCurrentScene(WSRequestHandler* req);
|
static void HandleGetCurrentScene(WSRequestHandler* req);
|
||||||
static void HandleGetSceneList(WSRequestHandler* req);
|
static void HandleGetSceneList(WSRequestHandler* req);
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the latest version of the plugin and the API.
|
* Returns the latest version of the plugin and the API.
|
||||||
*
|
*
|
||||||
* @return {double} `version` OBSRemote compatible API version. Fixed to 1.1 for retrocompatibility.
|
* @return {double} `version` OBSRemote compatible API version. Fixed to 1.1 for retrocompatibility.
|
||||||
* @return {String} `obs-websocket-version` obs-websocket plugin version.
|
* @return {String} `obs-websocket-version` obs-websocket plugin version.
|
||||||
* @return {String} `obs-studio-version` OBS Studio program version.
|
* @return {String} `obs-studio-version` OBS Studio program version.
|
||||||
@ -43,11 +43,11 @@
|
|||||||
/**
|
/**
|
||||||
* Tells the client if authentication is required. If so, returns authentication parameters `challenge`
|
* Tells the client if authentication is required. If so, returns authentication parameters `challenge`
|
||||||
* and `salt` (see "Authentication" for more information).
|
* and `salt` (see "Authentication" for more information).
|
||||||
*
|
*
|
||||||
* @return {boolean} `authRequired` Indicates whether authentication is required.
|
* @return {boolean} `authRequired` Indicates whether authentication is required.
|
||||||
* @return {String (optional)} `challenge`
|
* @return {String (optional)} `challenge`
|
||||||
* @return {String (optional)} `salt`
|
* @return {String (optional)} `salt`
|
||||||
*
|
*
|
||||||
* @api requests
|
* @api requests
|
||||||
* @name GetAuthRequired
|
* @name GetAuthRequired
|
||||||
* @category general
|
* @category general
|
||||||
@ -71,7 +71,7 @@ void WSRequestHandler::HandleGetAuthRequired(WSRequestHandler* req) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempt to authenticate the client to the server.
|
* Attempt to authenticate the client to the server.
|
||||||
*
|
*
|
||||||
* @param {String} `auth` Response to the auth challenge (see "Authentication" for more information).
|
* @param {String} `auth` Response to the auth challenge (see "Authentication" for more information).
|
||||||
*
|
*
|
||||||
* @api requests
|
* @api requests
|
||||||
@ -125,3 +125,44 @@ void WSRequestHandler::HandleAuthenticate(WSRequestHandler* req) {
|
|||||||
WSEvents::Instance->HeartbeatIsActive);
|
WSEvents::Instance->HeartbeatIsActive);
|
||||||
req->SendOKResponse(response);
|
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);
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user