From ef4142fe7523521a595cf351d51003212fd22f74 Mon Sep 17 00:00:00 2001 From: tt2468 Date: Thu, 18 Jan 2024 15:53:37 -0800 Subject: [PATCH] eventhandler: Add `SourceFilterSettingsChanged` event Closes #1059 --- src/eventhandler/EventHandler.cpp | 3 +++ src/eventhandler/EventHandler.h | 1 + src/eventhandler/EventHandler_Filters.cpp | 26 +++++++++++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/src/eventhandler/EventHandler.cpp b/src/eventhandler/EventHandler.cpp index 0823076ff..aeb700730 100644 --- a/src/eventhandler/EventHandler.cpp +++ b/src/eventhandler/EventHandler.cpp @@ -602,6 +602,9 @@ void EventHandler::SourceUpdatedMultiHandler(void *param, calldata_t *data) case OBS_SOURCE_TYPE_INPUT: eventHandler->HandleInputSettingsChanged(source); break; + case OBS_SOURCE_TYPE_FILTER: + eventHandler->HandleSourceFilterSettingsChanged(source); + break; default: break; } diff --git a/src/eventhandler/EventHandler.h b/src/eventhandler/EventHandler.h index 2352d43a9..ed98787f0 100644 --- a/src/eventhandler/EventHandler.h +++ b/src/eventhandler/EventHandler.h @@ -147,6 +147,7 @@ class EventHandler { void HandleSourceFilterRemoved(obs_source_t *source, obs_source_t *filter); static void HandleSourceFilterNameChanged(void *param, calldata_t *data); // Direct callback + void HandleSourceFilterSettingsChanged(obs_source_t *source); static void HandleSourceFilterEnableStateChanged(void *param, calldata_t *data); // Direct callback // Outputs diff --git a/src/eventhandler/EventHandler_Filters.cpp b/src/eventhandler/EventHandler_Filters.cpp index 59c1783cc..103067881 100644 --- a/src/eventhandler/EventHandler_Filters.cpp +++ b/src/eventhandler/EventHandler_Filters.cpp @@ -163,6 +163,32 @@ void EventHandler::HandleSourceFilterNameChanged(void *param, calldata_t *data) eventHandler->BroadcastEvent(EventSubscription::Filters, "SourceFilterNameChanged", eventData); } +/** + * An source filter's settings have changed (been updated). + * + * @dataField sourceName | String | Name of the source the filter is on + * @dataField filterName | String | Name of the filter + * @dataField filterSettings | Object | New settings object of the filter + * + * @eventType SourceFilterSettingsChanged + * @eventSubscription Filters + * @complexity 3 + * @rpcVersion -1 + * @initialVersion 5.4.0 + * @api events + * @category filters + */ +void EventHandler::HandleSourceFilterSettingsChanged(obs_source_t *source) +{ + OBSDataAutoRelease filterSettings = obs_source_get_settings(source); + + json eventData; + eventData["sourceName"] = obs_source_get_name(obs_filter_get_parent(source)); + eventData["filterName"] = obs_source_get_name(source); + eventData["filterSettings"] = Utils::Json::ObsDataToJson(filterSettings); + BroadcastEvent(EventSubscription::Filters, "SourceFilterSettingsChanged", eventData); +} + /** * A source filter's enable state has changed. *