mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
eventhandler: Add RecordFileChanged
event
When a file split happens, this will fire with the new file name
This commit is contained in:
parent
0eda8f9406
commit
71920c484b
@ -27,11 +27,11 @@ EventHandler::EventHandler()
|
|||||||
|
|
||||||
signal_handler_t *coreSignalHandler = obs_get_signal_handler();
|
signal_handler_t *coreSignalHandler = obs_get_signal_handler();
|
||||||
if (coreSignalHandler) {
|
if (coreSignalHandler) {
|
||||||
signal_handler_connect(coreSignalHandler, "source_create", SourceCreatedMultiHandler, this);
|
coreSignals.emplace_back(coreSignalHandler, "source_create", SourceCreatedMultiHandler, this);
|
||||||
signal_handler_connect(coreSignalHandler, "source_destroy", SourceDestroyedMultiHandler, this);
|
coreSignals.emplace_back(coreSignalHandler, "source_destroy", SourceDestroyedMultiHandler, this);
|
||||||
signal_handler_connect(coreSignalHandler, "source_remove", SourceRemovedMultiHandler, this);
|
coreSignals.emplace_back(coreSignalHandler, "source_remove", SourceRemovedMultiHandler, this);
|
||||||
signal_handler_connect(coreSignalHandler, "source_rename", SourceRenamedMultiHandler, this);
|
coreSignals.emplace_back(coreSignalHandler, "source_rename", SourceRenamedMultiHandler, this);
|
||||||
signal_handler_connect(coreSignalHandler, "source_update", SourceUpdatedMultiHandler, this);
|
coreSignals.emplace_back(coreSignalHandler, "source_update", SourceUpdatedMultiHandler, this);
|
||||||
} else {
|
} else {
|
||||||
blog(LOG_ERROR, "[EventHandler::EventHandler] Unable to get libobs signal handler!");
|
blog(LOG_ERROR, "[EventHandler::EventHandler] Unable to get libobs signal handler!");
|
||||||
}
|
}
|
||||||
@ -45,16 +45,7 @@ EventHandler::~EventHandler()
|
|||||||
|
|
||||||
obs_frontend_remove_event_callback(OnFrontendEvent, this);
|
obs_frontend_remove_event_callback(OnFrontendEvent, this);
|
||||||
|
|
||||||
signal_handler_t *coreSignalHandler = obs_get_signal_handler();
|
coreSignals.clear();
|
||||||
if (coreSignalHandler) {
|
|
||||||
signal_handler_disconnect(coreSignalHandler, "source_create", SourceCreatedMultiHandler, this);
|
|
||||||
signal_handler_disconnect(coreSignalHandler, "source_destroy", SourceDestroyedMultiHandler, this);
|
|
||||||
signal_handler_disconnect(coreSignalHandler, "source_remove", SourceRemovedMultiHandler, this);
|
|
||||||
signal_handler_disconnect(coreSignalHandler, "source_rename", SourceRenamedMultiHandler, this);
|
|
||||||
signal_handler_disconnect(coreSignalHandler, "source_update", SourceUpdatedMultiHandler, this);
|
|
||||||
} else {
|
|
||||||
blog(LOG_ERROR, "[EventHandler::~EventHandler] Unable to get libobs signal handler!");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Revoke callbacks of all inputs and scenes, in case some still have our callbacks attached
|
// Revoke callbacks of all inputs and scenes, in case some still have our callbacks attached
|
||||||
auto enumInputs = [](void *param, obs_source_t *source) {
|
auto enumInputs = [](void *param, obs_source_t *source) {
|
||||||
@ -378,12 +369,21 @@ void EventHandler::OnFrontendEvent(enum obs_frontend_event event, void *private_
|
|||||||
break;
|
break;
|
||||||
case OBS_FRONTEND_EVENT_RECORDING_STARTED:
|
case OBS_FRONTEND_EVENT_RECORDING_STARTED:
|
||||||
eventHandler->HandleRecordStateChanged(OBS_WEBSOCKET_OUTPUT_STARTED);
|
eventHandler->HandleRecordStateChanged(OBS_WEBSOCKET_OUTPUT_STARTED);
|
||||||
|
{
|
||||||
|
OBSOutputAutoRelease recordOutput = obs_frontend_get_recording_output();
|
||||||
|
if (recordOutput) {
|
||||||
|
signal_handler_t *sh = obs_output_get_signal_handler(recordOutput);
|
||||||
|
eventHandler->recordFileChangedSignal.Connect(sh, "file_changed", HandleRecordFileChanged,
|
||||||
|
private_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case OBS_FRONTEND_EVENT_RECORDING_STOPPING:
|
case OBS_FRONTEND_EVENT_RECORDING_STOPPING:
|
||||||
eventHandler->HandleRecordStateChanged(OBS_WEBSOCKET_OUTPUT_STOPPING);
|
eventHandler->HandleRecordStateChanged(OBS_WEBSOCKET_OUTPUT_STOPPING);
|
||||||
break;
|
break;
|
||||||
case OBS_FRONTEND_EVENT_RECORDING_STOPPED:
|
case OBS_FRONTEND_EVENT_RECORDING_STOPPED:
|
||||||
eventHandler->HandleRecordStateChanged(OBS_WEBSOCKET_OUTPUT_STOPPED);
|
eventHandler->HandleRecordStateChanged(OBS_WEBSOCKET_OUTPUT_STOPPED);
|
||||||
|
eventHandler->recordFileChangedSignal.Disconnect();
|
||||||
break;
|
break;
|
||||||
case OBS_FRONTEND_EVENT_RECORDING_PAUSED:
|
case OBS_FRONTEND_EVENT_RECORDING_PAUSED:
|
||||||
eventHandler->HandleRecordStateChanged(OBS_WEBSOCKET_OUTPUT_PAUSED);
|
eventHandler->HandleRecordStateChanged(OBS_WEBSOCKET_OUTPUT_PAUSED);
|
||||||
|
@ -51,6 +51,9 @@ private:
|
|||||||
|
|
||||||
std::atomic<bool> _obsReady = false;
|
std::atomic<bool> _obsReady = false;
|
||||||
|
|
||||||
|
std::vector<OBSSignal> coreSignals;
|
||||||
|
OBSSignal recordFileChangedSignal;
|
||||||
|
|
||||||
std::unique_ptr<Utils::Obs::VolumeMeter::Handler> _inputVolumeMetersHandler;
|
std::unique_ptr<Utils::Obs::VolumeMeter::Handler> _inputVolumeMetersHandler;
|
||||||
std::atomic<uint64_t> _inputVolumeMetersRef = 0;
|
std::atomic<uint64_t> _inputVolumeMetersRef = 0;
|
||||||
std::atomic<uint64_t> _inputActiveStateChangedRef = 0;
|
std::atomic<uint64_t> _inputActiveStateChangedRef = 0;
|
||||||
@ -155,6 +158,7 @@ private:
|
|||||||
// Outputs
|
// Outputs
|
||||||
void HandleStreamStateChanged(ObsOutputState state);
|
void HandleStreamStateChanged(ObsOutputState state);
|
||||||
void HandleRecordStateChanged(ObsOutputState state);
|
void HandleRecordStateChanged(ObsOutputState state);
|
||||||
|
static void HandleRecordFileChanged(void *param, calldata_t *data); // Direct callback
|
||||||
void HandleReplayBufferStateChanged(ObsOutputState state);
|
void HandleReplayBufferStateChanged(ObsOutputState state);
|
||||||
void HandleVirtualcamStateChanged(ObsOutputState state);
|
void HandleVirtualcamStateChanged(ObsOutputState state);
|
||||||
void HandleReplayBufferSaved();
|
void HandleReplayBufferSaved();
|
||||||
|
@ -87,6 +87,28 @@ void EventHandler::HandleRecordStateChanged(ObsOutputState state)
|
|||||||
BroadcastEvent(EventSubscription::Outputs, "RecordStateChanged", eventData);
|
BroadcastEvent(EventSubscription::Outputs, "RecordStateChanged", eventData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The record output has started writing to a new file. For example, when a file split happens.
|
||||||
|
*
|
||||||
|
* @dataField newOutputPath | String | File name that the output has begun writing to
|
||||||
|
*
|
||||||
|
* @eventType RecordFileChanged
|
||||||
|
* @eventSubscription Outputs
|
||||||
|
* @complexity 2
|
||||||
|
* @rpcVersion -1
|
||||||
|
* @initialVersion 5.5.0
|
||||||
|
* @api events
|
||||||
|
* @category outputs
|
||||||
|
*/
|
||||||
|
void EventHandler::HandleRecordFileChanged(void *param, calldata_t *data)
|
||||||
|
{
|
||||||
|
auto eventHandler = static_cast<EventHandler *>(param);
|
||||||
|
|
||||||
|
json eventData;
|
||||||
|
eventData["newOutputPath"] = calldata_string(data, "next_file");
|
||||||
|
eventHandler->BroadcastEvent(EventSubscription::Outputs, "RecordFileChanged", eventData);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The state of the replay buffer output has changed.
|
* The state of the replay buffer output has changed.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user