mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
eventhandler: Add InputSettingsChanged
Fired when an input's settings change, like via the properties dialog or via `SetInputSettings`. Closes #1157
This commit is contained in:
parent
52733ddce7
commit
81b307e5ad
@ -31,6 +31,7 @@ EventHandler::EventHandler()
|
||||
signal_handler_connect(coreSignalHandler, "source_destroy", SourceDestroyedMultiHandler, this);
|
||||
signal_handler_connect(coreSignalHandler, "source_remove", SourceRemovedMultiHandler, this);
|
||||
signal_handler_connect(coreSignalHandler, "source_rename", SourceRenamedMultiHandler, this);
|
||||
signal_handler_connect(coreSignalHandler, "source_update", SourceUpdatedMultiHandler, this);
|
||||
} else {
|
||||
blog(LOG_ERROR, "[EventHandler::EventHandler] Unable to get libobs signal handler!");
|
||||
}
|
||||
@ -50,6 +51,7 @@ EventHandler::~EventHandler()
|
||||
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!");
|
||||
}
|
||||
@ -588,6 +590,23 @@ void EventHandler::SourceRenamedMultiHandler(void *param, calldata_t *data)
|
||||
}
|
||||
}
|
||||
|
||||
void EventHandler::SourceUpdatedMultiHandler(void *param, calldata_t *data)
|
||||
{
|
||||
auto eventHandler = static_cast<EventHandler *>(param);
|
||||
|
||||
obs_source_t *source = GetCalldataPointer<obs_source_t>(data, "source");
|
||||
if (!source)
|
||||
return;
|
||||
|
||||
switch (obs_source_get_type(source)) {
|
||||
case OBS_SOURCE_TYPE_INPUT:
|
||||
eventHandler->HandleInputSettingsChanged(source);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void EventHandler::StreamOutputReconnectHandler(void *param, calldata_t *)
|
||||
{
|
||||
auto eventHandler = static_cast<EventHandler *>(param);
|
||||
|
@ -69,9 +69,10 @@ private:
|
||||
static void SourceCreatedMultiHandler(void *param, calldata_t *data);
|
||||
static void SourceDestroyedMultiHandler(void *param, calldata_t *data);
|
||||
static void SourceRemovedMultiHandler(void *param, calldata_t *data);
|
||||
|
||||
// Signal handler: source
|
||||
static void SourceRenamedMultiHandler(void *param, calldata_t *data);
|
||||
static void SourceUpdatedMultiHandler(void *param, calldata_t *data);
|
||||
|
||||
// Signal handler: media sources
|
||||
static void SourceMediaPauseMultiHandler(void *param, calldata_t *data);
|
||||
static void SourceMediaPlayMultiHandler(void *param, calldata_t *data);
|
||||
static void SourceMediaRestartMultiHandler(void *param, calldata_t *data);
|
||||
@ -106,7 +107,7 @@ private:
|
||||
void HandleInputCreated(obs_source_t *source);
|
||||
void HandleInputRemoved(obs_source_t *source);
|
||||
void HandleInputNameChanged(obs_source_t *source, std::string oldInputName, std::string inputName);
|
||||
void HandleInputVolumeMeters(std::vector<json> inputs); // AudioMeter::Handler callback
|
||||
void HandleInputSettingsChanged(obs_source_t *source);
|
||||
static void HandleInputActiveStateChanged(void *param,
|
||||
calldata_t *data); // Direct callback
|
||||
static void HandleInputShowStateChanged(void *param,
|
||||
@ -123,6 +124,7 @@ private:
|
||||
calldata_t *data); // Direct callback
|
||||
static void HandleInputAudioMonitorTypeChanged(void *param,
|
||||
calldata_t *data); // Direct callback
|
||||
void HandleInputVolumeMeters(std::vector<json> inputs); // AudioMeter::Handler callback
|
||||
|
||||
// Transitions
|
||||
void HandleCurrentSceneTransitionChanged();
|
||||
|
@ -93,6 +93,32 @@ void EventHandler::HandleInputNameChanged(obs_source_t *, std::string oldInputNa
|
||||
BroadcastEvent(EventSubscription::Inputs, "InputNameChanged", eventData);
|
||||
}
|
||||
|
||||
/**
|
||||
* An input's settings have changed (been updated).
|
||||
*
|
||||
* Note: On some inputs, changing values in the properties dialog will cause an immediate update. Pressing the "Cancel" button will revert the settings, resulting in another event being fired.
|
||||
*
|
||||
* @dataField inputName | String | Name of the input
|
||||
* @dataField inputSettings | Object | New settings object of the input
|
||||
*
|
||||
* @eventType InputSettingsChanged
|
||||
* @eventSubscription Inputs
|
||||
* @complexity 3
|
||||
* @rpcVersion -1
|
||||
* @initialVersion 5.4.0
|
||||
* @api events
|
||||
* @category inputs
|
||||
*/
|
||||
void EventHandler::HandleInputSettingsChanged(obs_source_t *source)
|
||||
{
|
||||
OBSDataAutoRelease inputSettings = obs_source_get_settings(source);
|
||||
|
||||
json eventData;
|
||||
eventData["inputName"] = obs_source_get_name(source);
|
||||
eventData["inputSettings"] = Utils::Json::ObsDataToJson(inputSettings);
|
||||
BroadcastEvent(EventSubscription::Inputs, "InputSettingsChanged", eventData);
|
||||
}
|
||||
|
||||
/**
|
||||
* An input's active state has changed.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user