Skip to content

Commit

Permalink
eventhandler: Add SourceFilterSettingsChanged event
Browse files Browse the repository at this point in the history
Closes #1059
  • Loading branch information
tt2468 committed Jan 18, 2024
1 parent caaec5d commit ef4142f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/eventhandler/EventHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions src/eventhandler/EventHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 26 additions & 0 deletions src/eventhandler/EventHandler_Filters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down

0 comments on commit ef4142f

Please sign in to comment.