mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
requesthandler, eventhandler: Add outputPath
fields when record stops
Closes #934
This commit is contained in:
parent
3deea2b5da
commit
4201664c7b
@ -62,6 +62,7 @@ void EventHandler::HandleStreamStateChanged(ObsOutputState state)
|
||||
*
|
||||
* @dataField outputActive | Boolean | Whether the output is active
|
||||
* @dataField outputState | String | The specific state of the output
|
||||
* @dataField outputPath | String | File name for the saved recording, if record stopped. `null` otherwise
|
||||
*
|
||||
* @eventType RecordStateChanged
|
||||
* @eventSubscription Outputs
|
||||
@ -76,6 +77,11 @@ void EventHandler::HandleRecordStateChanged(ObsOutputState state)
|
||||
json eventData;
|
||||
eventData["outputActive"] = GetOutputStateActive(state);
|
||||
eventData["outputState"] = state;
|
||||
if (state == OBS_WEBSOCKET_OUTPUT_STOPPED) {
|
||||
eventData["outputPath"] = Utils::Obs::StringHelper::GetLastRecordFileName();
|
||||
} else {
|
||||
eventData["outputPath"] = nullptr;
|
||||
}
|
||||
BroadcastEvent(EventSubscription::Outputs, "RecordStateChanged", eventData);
|
||||
}
|
||||
|
||||
@ -139,6 +145,6 @@ void EventHandler::HandleVirtualcamStateChanged(ObsOutputState state)
|
||||
void EventHandler::HandleReplayBufferSaved()
|
||||
{
|
||||
json eventData;
|
||||
eventData["savedReplayPath"] = Utils::Obs::StringHelper::GetLastReplayBufferFilePath();
|
||||
eventData["savedReplayPath"] = Utils::Obs::StringHelper::GetLastReplayBufferFileName();
|
||||
BroadcastEvent(EventSubscription::Outputs, "ReplayBufferSaved", eventData);
|
||||
}
|
||||
|
@ -272,6 +272,6 @@ RequestResult RequestHandler::GetLastReplayBufferReplay(const Request &)
|
||||
return RequestResult::Error(RequestStatus::OutputNotRunning);
|
||||
|
||||
json responseData;
|
||||
responseData["savedReplayPath"] = Utils::Obs::StringHelper::GetLastReplayBufferFilePath();
|
||||
responseData["savedReplayPath"] = Utils::Obs::StringHelper::GetLastReplayBufferFileName();
|
||||
return RequestResult::Success(responseData);
|
||||
}
|
||||
|
@ -99,6 +99,8 @@ RequestResult RequestHandler::StartRecord(const Request &)
|
||||
/**
|
||||
* Stops the record output.
|
||||
*
|
||||
* @responseField outputPath | String | File name for the saved recording
|
||||
*
|
||||
* @requestType StopRecord
|
||||
* @complexity 1
|
||||
* @rpcVersion -1
|
||||
@ -114,7 +116,10 @@ RequestResult RequestHandler::StopRecord(const Request &)
|
||||
// TODO: Call signal directly to perform blocking wait
|
||||
obs_frontend_recording_stop();
|
||||
|
||||
return RequestResult::Success();
|
||||
json responseData;
|
||||
responseData["outputPath"] = Utils::Obs::StringHelper::GetLastRecordFileName();
|
||||
|
||||
return RequestResult::Success(responseData);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -179,7 +179,8 @@ namespace Utils {
|
||||
std::string GetCurrentProfile();
|
||||
std::string GetCurrentProfilePath();
|
||||
std::string GetCurrentRecordOutputPath();
|
||||
std::string GetLastReplayBufferFilePath();
|
||||
std::string GetLastRecordFileName();
|
||||
std::string GetLastReplayBufferFileName();
|
||||
std::string DurationToTimecode(uint64_t);
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,27 @@ std::string Utils::Obs::StringHelper::GetCurrentRecordOutputPath()
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string Utils::Obs::StringHelper::GetLastReplayBufferFilePath()
|
||||
std::string Utils::Obs::StringHelper::GetLastRecordFileName()
|
||||
{
|
||||
OBSOutputAutoRelease output = obs_frontend_get_recording_output();
|
||||
if (!output)
|
||||
return "";
|
||||
|
||||
OBSDataAutoRelease outputSettings = obs_output_get_settings(output);
|
||||
|
||||
obs_data_item_t *item = obs_data_item_byname(outputSettings, "url");
|
||||
if (!item) {
|
||||
item = obs_data_item_byname(outputSettings, "path");
|
||||
if (!item)
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string ret = obs_data_item_get_string(item);
|
||||
obs_data_item_release(&item);
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string Utils::Obs::StringHelper::GetLastReplayBufferFileName()
|
||||
{
|
||||
OBSOutputAutoRelease output = obs_frontend_get_replay_buffer_output();
|
||||
if (!output)
|
||||
|
Loading…
Reference in New Issue
Block a user