mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
Merge pull request #621 from Palakis/feature/current-recording-filename
Feature/current recording filename
This commit is contained in:
commit
aceb437c5f
@ -696,6 +696,29 @@ bool Utils::SetFilenameFormatting(const char* filenameFormatting) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const char* Utils::GetCurrentRecordingFilename()
|
||||
{
|
||||
OBSOutputAutoRelease recordingOutput = obs_frontend_get_recording_output();
|
||||
if (!recordingOutput) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
OBSDataAutoRelease settings = obs_output_get_settings(recordingOutput);
|
||||
|
||||
// mimicks the behavior of BasicOutputHandler::GetRecordingFilename :
|
||||
// try to fetch the path from the "url" property, then try "path" if the first one
|
||||
// didn't yield any result
|
||||
OBSDataItemAutoRelease item = obs_data_item_byname(settings, "url");
|
||||
if (!item) {
|
||||
item = obs_data_item_byname(settings, "path");
|
||||
if (!item) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
return obs_data_item_get_string(item);
|
||||
}
|
||||
|
||||
// Transform properties copy-pasted from WSRequestHandler_SceneItems.cpp because typedefs can't be extended yet
|
||||
|
||||
/**
|
||||
|
@ -85,6 +85,8 @@ namespace Utils {
|
||||
const char* GetFilenameFormatting();
|
||||
bool SetFilenameFormatting(const char* filenameFormatting);
|
||||
|
||||
const char* GetCurrentRecordingFilename();
|
||||
|
||||
QString nsToTimestamp(uint64_t ns);
|
||||
struct AddSourceData {
|
||||
obs_source_t *source;
|
||||
|
@ -678,7 +678,10 @@ void WSEvents::OnStreamStopped() {
|
||||
|
||||
/**
|
||||
* A request to start recording has been issued.
|
||||
*
|
||||
*
|
||||
* Note: `recordingFilename` is not provided in this event because this information
|
||||
* is not available at the time this event is emitted.
|
||||
*
|
||||
* @api events
|
||||
* @name RecordingStarting
|
||||
* @category recording
|
||||
@ -691,37 +694,49 @@ void WSEvents::OnRecordingStarting() {
|
||||
/**
|
||||
* Recording started successfully.
|
||||
*
|
||||
* @return {String} `recordingFilename` Absolute path to the file of the current recording.
|
||||
*
|
||||
* @api events
|
||||
* @name RecordingStarted
|
||||
* @category recording
|
||||
* @since 0.3
|
||||
*/
|
||||
void WSEvents::OnRecordingStarted() {
|
||||
broadcastUpdate("RecordingStarted");
|
||||
OBSDataAutoRelease data = obs_data_create();
|
||||
obs_data_set_string(data, "recordingFilename", Utils::GetCurrentRecordingFilename());
|
||||
broadcastUpdate("RecordingStarted", data);
|
||||
}
|
||||
|
||||
/**
|
||||
* A request to stop recording has been issued.
|
||||
*
|
||||
* @return {String} `recordingFilename` Absolute path to the file of the current recording.
|
||||
*
|
||||
* @api events
|
||||
* @name RecordingStopping
|
||||
* @category recording
|
||||
* @since 0.3
|
||||
*/
|
||||
void WSEvents::OnRecordingStopping() {
|
||||
broadcastUpdate("RecordingStopping");
|
||||
OBSDataAutoRelease data = obs_data_create();
|
||||
obs_data_set_string(data, "recordingFilename", Utils::GetCurrentRecordingFilename());
|
||||
broadcastUpdate("RecordingStopping", data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recording stopped successfully.
|
||||
*
|
||||
* @return {String} `recordingFilename` Absolute path to the file of the current recording.
|
||||
*
|
||||
* @api events
|
||||
* @name RecordingStopped
|
||||
* @category recording
|
||||
* @since 0.3
|
||||
*/
|
||||
void WSEvents::OnRecordingStopped() {
|
||||
broadcastUpdate("RecordingStopped");
|
||||
OBSDataAutoRelease data = obs_data_create();
|
||||
obs_data_set_string(data, "recordingFilename", Utils::GetCurrentRecordingFilename());
|
||||
broadcastUpdate("RecordingStopped", data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -21,6 +21,7 @@ RpcResponse ifCanPause(const RpcRequest& request, std::function<RpcResponse()> c
|
||||
* @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).
|
||||
* @return {String (optional)} `recordingFilename` Absolute path to the recording file (only present if currently recording).
|
||||
*
|
||||
* @api requests
|
||||
* @name GetRecordingStatus
|
||||
@ -37,6 +38,7 @@ RpcResponse WSRequestHandler::GetRecordingStatus(const RpcRequest& request) {
|
||||
if (obs_frontend_recording_active()) {
|
||||
QString recordingTimecode = events->getRecordingTimecode();
|
||||
obs_data_set_string(data, "recordTimecode", recordingTimecode.toUtf8().constData());
|
||||
obs_data_set_string(data, "recordingFilename", Utils::GetCurrentRecordingFilename());
|
||||
}
|
||||
|
||||
return request.success(data);
|
||||
|
Loading…
x
Reference in New Issue
Block a user