mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
requesthandler: Add SetRecordDirectory
I've admittedly done a pretty bad job of communicating the intention of having `SetProfileParameter` be the go-to method of configuring the record directory. In hindsight, such a commonly needed feature should not be locked behind an arguably complex request. Closes #1142 Closes #1062 Closes #1035
This commit is contained in:
parent
2606f262e6
commit
ac00465565
@ -51,6 +51,7 @@ const std::unordered_map<std::string, RequestMethodHandler> RequestHandler::_han
|
||||
{"GetStreamServiceSettings", &RequestHandler::GetStreamServiceSettings},
|
||||
{"SetStreamServiceSettings", &RequestHandler::SetStreamServiceSettings},
|
||||
{"GetRecordDirectory", &RequestHandler::GetRecordDirectory},
|
||||
{"SetRecordDirectory", &RequestHandler::SetRecordDirectory},
|
||||
|
||||
// Sources
|
||||
{"GetSourceActive", &RequestHandler::GetSourceActive},
|
||||
|
@ -70,6 +70,7 @@ private:
|
||||
RequestResult GetStreamServiceSettings(const Request &);
|
||||
RequestResult SetStreamServiceSettings(const Request &);
|
||||
RequestResult GetRecordDirectory(const Request &);
|
||||
RequestResult SetRecordDirectory(const Request &);
|
||||
|
||||
// Sources
|
||||
RequestResult GetSourceActive(const Request &);
|
||||
|
@ -622,7 +622,7 @@ RequestResult RequestHandler::SetStreamServiceSettings(const Request &request)
|
||||
* @responseField recordDirectory | String | Output directory
|
||||
*
|
||||
* @requestType GetRecordDirectory
|
||||
* @complexity 1
|
||||
* @complexity 2
|
||||
* @rpcVersion -1
|
||||
* @initialVersion 5.0.0
|
||||
* @api requests
|
||||
@ -635,3 +635,35 @@ RequestResult RequestHandler::GetRecordDirectory(const Request &)
|
||||
|
||||
return RequestResult::Success(responseData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current directory that the record output writes files to.
|
||||
*
|
||||
* @requestField recordDirectory | String | Output directory
|
||||
*
|
||||
* @requestType SetRecordDirectory
|
||||
* @complexity 2
|
||||
* @rpcVersion -1
|
||||
* @initialVersion 5.3.0
|
||||
* @api requests
|
||||
* @category config
|
||||
*/
|
||||
RequestResult RequestHandler::SetRecordDirectory(const Request &request)
|
||||
{
|
||||
if (obs_frontend_recording_active())
|
||||
return RequestResult::Error(RequestStatus::OutputRunning);
|
||||
|
||||
RequestStatus::RequestStatus statusCode;
|
||||
std::string comment;
|
||||
if (!request.ValidateString("recordDirectory", statusCode, comment))
|
||||
return RequestResult::Error(statusCode, comment);
|
||||
|
||||
std::string recordDirectory = request.RequestData["recordDirectory"];
|
||||
|
||||
config_t *config = obs_frontend_get_profile_config();
|
||||
config_set_string(config, "AdvOut", "RecFilePath", recordDirectory.c_str());
|
||||
config_set_string(config, "SimpleOutput", "FilePath", recordDirectory.c_str());
|
||||
config_save(config);
|
||||
|
||||
return RequestResult::Success();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user