mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
events: add recordingFilename property to RecordingStarted, RecordingStopping and RecordingStopped
This commit is contained in:
parent
e794762f72
commit
96bd4141fd
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user