docs: Finish documenting events

This commit is contained in:
tt2468 2021-12-28 23:45:11 -08:00
parent bb2c125601
commit e640ae1218
8 changed files with 459 additions and 65 deletions

View File

@ -379,10 +379,6 @@ void EventHandler::SourceCreatedMultiHandler(void *param, calldata_t *data)
case OBS_SOURCE_TYPE_INPUT:
eventHandler->HandleInputCreated(source);
break;
case OBS_SOURCE_TYPE_FILTER:
break;
case OBS_SOURCE_TYPE_TRANSITION:
break;
case OBS_SOURCE_TYPE_SCENE:
eventHandler->HandleSceneCreated(source);
break;
@ -413,10 +409,6 @@ void EventHandler::SourceDestroyedMultiHandler(void *param, calldata_t *data)
// We have to call `InputRemoved` with source_destroy because source_removed is not called when an input's last scene item is removed
eventHandler->HandleInputRemoved(source);
break;
case OBS_SOURCE_TYPE_FILTER:
break;
case OBS_SOURCE_TYPE_TRANSITION:
break;
case OBS_SOURCE_TYPE_SCENE:
break;
default:
@ -438,10 +430,6 @@ void EventHandler::SourceRemovedMultiHandler(void *param, calldata_t *data)
switch (obs_source_get_type(source)) {
case OBS_SOURCE_TYPE_INPUT:
break;
case OBS_SOURCE_TYPE_FILTER:
break;
case OBS_SOURCE_TYPE_TRANSITION:
break;
case OBS_SOURCE_TYPE_SCENE:
// Scenes emit the `removed` signal when they are removed from OBS, as expected
eventHandler->HandleSceneRemoved(source);

View File

@ -111,11 +111,6 @@ class EventHandler
static void HandleInputAudioTracksChanged(void *param, calldata_t *data); // Direct callback
static void HandleInputAudioMonitorTypeChanged(void *param, calldata_t *data); // Direct callback
// Transitions
void HandleTransitionCreated(obs_source_t *source);
void HandleTransitionRemoved(obs_source_t *source);
void HandleTransitionNameChanged(obs_source_t *source, std::string oldTransitionName, std::string transitionName);
// Outputs
void HandleStreamStateChanged(ObsOutputState state);
void HandleRecordStateChanged(ObsOutputState state);

View File

@ -19,6 +19,23 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#include "EventHandler.h"
/**
* An input has been created.
*
* @dataField inputName | String | Name of the input
* @dataField inputKind | String | The kind of the input
* @dataField unversionedInputKind | String | The unversioned kind of input (aka no `_v2` stuff)
* @dataField inputSettings | Object | The settings configured to the input when it was created
* @dataField defaultInputSettings | Object | The default settings for the input
*
* @eventType InputCreated
* @eventSubscription Inputs
* @complexity 2
* @rpcVersion -1
* @initialVersion 5.0.0
* @api events
* @category inputs
*/
void EventHandler::HandleInputCreated(obs_source_t *source)
{
std::string inputKind = obs_source_get_id(source);
@ -34,6 +51,19 @@ void EventHandler::HandleInputCreated(obs_source_t *source)
BroadcastEvent(EventSubscription::Inputs, "InputCreated", eventData);
}
/**
* An input has been removed.
*
* @dataField inputName | String | Name of the input
*
* @eventType InputRemoved
* @eventSubscription Inputs
* @complexity 2
* @rpcVersion -1
* @initialVersion 5.0.0
* @api events
* @category inputs
*/
void EventHandler::HandleInputRemoved(obs_source_t *source)
{
json eventData;
@ -41,6 +71,20 @@ void EventHandler::HandleInputRemoved(obs_source_t *source)
BroadcastEvent(EventSubscription::Inputs, "InputRemoved", eventData);
}
/**
* The name of an input has changed.
*
* @dataField oldInputName | String | Old name of the input
* @dataField inputName | String | New name of the input
*
* @eventType InputNameChanged
* @eventSubscription Inputs
* @complexity 2
* @rpcVersion -1
* @initialVersion 5.0.0
* @api events
* @category inputs
*/
void EventHandler::HandleInputNameChanged(obs_source_t *, std::string oldInputName, std::string inputName)
{
json eventData;
@ -49,13 +93,22 @@ void EventHandler::HandleInputNameChanged(obs_source_t *, std::string oldInputNa
BroadcastEvent(EventSubscription::Inputs, "InputNameChanged", eventData);
}
void EventHandler::HandleInputVolumeMeters(std::vector<json> inputs)
{
json eventData;
eventData["inputs"] = inputs;
BroadcastEvent(EventSubscription::InputVolumeMeters, "InputVolumeMeters", eventData);
}
/**
* An input's active state has changed.
*
* When an input is active, it means it's being shown by the program feed.
*
* @dataField inputName | String | Name of the input
* @dataField videoActive | Boolean | Whether the input is active
*
* @eventType InputActiveStateChanged
* @eventSubscription InputActiveStateChanged
* @complexity 3
* @rpcVersion -1
* @initialVersion 5.0.0
* @api events
* @category inputs
*/
void EventHandler::HandleInputActiveStateChanged(void *param, calldata_t *data)
{
auto eventHandler = reinterpret_cast<EventHandler*>(param);
@ -76,6 +129,22 @@ void EventHandler::HandleInputActiveStateChanged(void *param, calldata_t *data)
eventHandler->BroadcastEvent(EventSubscription::InputActiveStateChanged, "InputActiveStateChanged", eventData);
}
/**
* An input's show state has changed.
*
* When an input is showing, it means it's being shown by the preview or a dialog.
*
* @dataField inputName | String | Name of the input
* @dataField videoShowing | Boolean | Whether the input is showing
*
* @eventType InputShowStateChanged
* @eventSubscription InputShowStateChanged
* @complexity 3
* @rpcVersion -1
* @initialVersion 5.0.0
* @api events
* @category inputs
*/
void EventHandler::HandleInputShowStateChanged(void *param, calldata_t *data)
{
auto eventHandler = reinterpret_cast<EventHandler*>(param);
@ -96,6 +165,20 @@ void EventHandler::HandleInputShowStateChanged(void *param, calldata_t *data)
eventHandler->BroadcastEvent(EventSubscription::InputShowStateChanged, "InputShowStateChanged", eventData);
}
/**
* An input's mute state has changed.
*
* @dataField inputName | String | Name of the input
* @dataField inputMuted | Boolean | Whether the input is muted
*
* @eventType InputMuteStateChanged
* @eventSubscription Inputs
* @complexity 2
* @rpcVersion -1
* @initialVersion 5.0.0
* @api events
* @category inputs
*/
void EventHandler::HandleInputMuteStateChanged(void *param, calldata_t *data)
{
auto eventHandler = reinterpret_cast<EventHandler*>(param);
@ -113,6 +196,21 @@ void EventHandler::HandleInputMuteStateChanged(void *param, calldata_t *data)
eventHandler->BroadcastEvent(EventSubscription::Inputs, "InputMuteStateChanged", eventData);
}
/**
* An input's volume level has changed.
*
* @dataField inputName | String | Name of the input
* @dataField inputVolumeMul | Number | New volume level in multimap
* @dataField inputVolumeDb | Number | New volume level in dB
*
* @eventType InputVolumeChanged
* @eventSubscription Inputs
* @complexity 3
* @rpcVersion -1
* @initialVersion 5.0.0
* @api events
* @category inputs
*/
void EventHandler::HandleInputVolumeChanged(void *param, calldata_t *data)
{
auto eventHandler = reinterpret_cast<EventHandler*>(param);
@ -138,6 +236,20 @@ void EventHandler::HandleInputVolumeChanged(void *param, calldata_t *data)
eventHandler->BroadcastEvent(EventSubscription::Inputs, "InputVolumeChanged", eventData);
}
/**
* The sync offset of an input has changed.
*
* @dataField inputName | String | Name of the input
* @dataField inputAudioSyncOffset | Number | New sync offset in milliseconds
*
* @eventType InputAudioSyncOffsetChanged
* @eventSubscription Inputs
* @complexity 3
* @rpcVersion -1
* @initialVersion 5.0.0
* @api events
* @category inputs
*/
void EventHandler::HandleInputAudioSyncOffsetChanged(void *param, calldata_t *data)
{
auto eventHandler = reinterpret_cast<EventHandler*>(param);
@ -157,6 +269,20 @@ void EventHandler::HandleInputAudioSyncOffsetChanged(void *param, calldata_t *da
eventHandler->BroadcastEvent(EventSubscription::Inputs, "InputAudioSyncOffsetChanged", eventData);
}
/**
* The audio tracks of an input have changed.
*
* @dataField inputName | String | Name of the input
* @dataField inputAudioTracks | Array<Boolean> | Array of audio tracks along with their associated enable states
*
* @eventType InputAudioTracksChanged
* @eventSubscription Inputs
* @complexity 3
* @rpcVersion -1
* @initialVersion 5.0.0
* @api events
* @category inputs
*/
void EventHandler::HandleInputAudioTracksChanged(void *param, calldata_t *data)
{
auto eventHandler = reinterpret_cast<EventHandler*>(param);
@ -181,6 +307,25 @@ void EventHandler::HandleInputAudioTracksChanged(void *param, calldata_t *data)
eventHandler->BroadcastEvent(EventSubscription::Inputs, "InputAudioTracksChanged", eventData);
}
/**
* The monitor type of an input has changed.
*
* Available types are:
* - `OBS_MONITORING_TYPE_NONE`
* - `OBS_MONITORING_TYPE_MONITOR_ONLY`
* - `OBS_MONITORING_TYPE_MONITOR_AND_OUTPUT`
*
* @dataField inputName | String | Name of the input
* @dataField monitorType | String | New monitor type of the input
*
* @eventType InputAudioMonitorTypeChanged
* @eventSubscription Inputs
* @complexity 2
* @rpcVersion -1
* @initialVersion 5.0.0
* @api events
* @category inputs
*/
void EventHandler::HandleInputAudioMonitorTypeChanged(void *param, calldata_t *data)
{
auto eventHandler = reinterpret_cast<EventHandler*>(param);
@ -194,22 +339,30 @@ void EventHandler::HandleInputAudioMonitorTypeChanged(void *param, calldata_t *d
enum obs_monitoring_type monitorType = (obs_monitoring_type)calldata_int(data, "type");
std::string monitorTypeString;
switch (monitorType) {
default:
case OBS_MONITORING_TYPE_NONE:
monitorTypeString = "OBS_WEBSOCKET_MONITOR_TYPE_NONE";
break;
case OBS_MONITORING_TYPE_MONITOR_ONLY:
monitorTypeString = "OBS_WEBSOCKET_MONITOR_TYPE_MONITOR_ONLY";
break;
case OBS_MONITORING_TYPE_MONITOR_AND_OUTPUT:
monitorTypeString = "OBS_WEBSOCKET_MONITOR_TYPE_MONITOR_AND_OUTPUT";
break;
}
std::string monitorTypeString = Utils::Obs::StringHelper::GetInputMonitorType(monitorType);
json eventData;
eventData["inputName"] = obs_source_get_name(source);
eventData["monitorType"] = monitorTypeString;
eventHandler->BroadcastEvent(EventSubscription::Inputs, "InputAudioMonitorTypeChanged", eventData);
}
/**
* A high-volume event providing volume levels of all active inputs every 50 milliseconds.
*
* @dataField inputs | Array<Object> | Array of active inputs with their associated volume levels
*
* @eventType InputVolumeMeters
* @eventSubscription InputVolumeMeters
* @complexity 4
* @rpcVersion -1
* @initialVersion 5.0.0
* @api events
* @category inputs
*/
void EventHandler::HandleInputVolumeMeters(std::vector<json> inputs)
{
json eventData;
eventData["inputs"] = inputs;
BroadcastEvent(EventSubscription::InputVolumeMeters, "InputVolumeMeters", eventData);
}

View File

@ -117,6 +117,19 @@ void EventHandler::SourceMediaPreviousMultiHandler(void *param, calldata_t *data
eventHandler->HandleMediaInputActionTriggered(source, OBS_WEBSOCKET_MEDIA_INPUT_ACTION_PREVIOUS);
}
/**
* A media input has started playing.
*
* @dataField inputName | String | Name of the input
*
* @eventType MediaInputPlaybackStarted
* @eventSubscription MediaInputs
* @complexity 2
* @rpcVersion -1
* @initialVersion 5.0.0
* @api events
* @category media inputs
*/
void EventHandler::HandleMediaInputPlaybackStarted(void *param, calldata_t *data)
{
auto eventHandler = reinterpret_cast<EventHandler*>(param);
@ -133,6 +146,19 @@ void EventHandler::HandleMediaInputPlaybackStarted(void *param, calldata_t *data
eventHandler->BroadcastEvent(EventSubscription::MediaInputs, "MediaInputPlaybackStarted", eventData);
}
/**
* A media input has finished playing.
*
* @dataField inputName | String | Name of the input
*
* @eventType MediaInputPlaybackEnded
* @eventSubscription MediaInputs
* @complexity 2
* @rpcVersion -1
* @initialVersion 5.0.0
* @api events
* @category media inputs
*/
void EventHandler::HandleMediaInputPlaybackEnded(void *param, calldata_t *data)
{
auto eventHandler = reinterpret_cast<EventHandler*>(param);
@ -149,6 +175,20 @@ void EventHandler::HandleMediaInputPlaybackEnded(void *param, calldata_t *data)
eventHandler->BroadcastEvent(EventSubscription::MediaInputs, "MediaInputPlaybackEnded", eventData);
}
/**
* An action has been performed on an input.
*
* @dataField inputName | String | Name of the input
* @dataField mediaAction | String | Action performed on the input. See `ObsMediaInputAction` enum
*
* @eventType MediaInputActionTriggered
* @eventSubscription MediaInputs
* @complexity 2
* @rpcVersion -1
* @initialVersion 5.0.0
* @api events
* @category media inputs
*/
void EventHandler::HandleMediaInputActionTriggered(obs_source_t *source, ObsMediaInputAction action)
{
json eventData;

View File

@ -34,6 +34,20 @@ static bool GetOutputStateActive(ObsOutputState state) {
}
}
/**
* The state of the stream output has changed.
*
* @dataField outputActive | Boolean | Whether the output is active
* @dataField outputState | String | The specific state of the output
*
* @eventType StreamStateChanged
* @eventSubscription Outputs
* @complexity 2
* @rpcVersion -1
* @initialVersion 5.0.0
* @api events
* @category outputs
*/
void EventHandler::HandleStreamStateChanged(ObsOutputState state)
{
json eventData;
@ -42,6 +56,20 @@ void EventHandler::HandleStreamStateChanged(ObsOutputState state)
BroadcastEvent(EventSubscription::Outputs, "StreamStateChanged", eventData);
}
/**
* The state of the record output has changed.
*
* @dataField outputActive | Boolean | Whether the output is active
* @dataField outputState | String | The specific state of the output
*
* @eventType RecordStateChanged
* @eventSubscription Outputs
* @complexity 2
* @rpcVersion -1
* @initialVersion 5.0.0
* @api events
* @category outputs
*/
void EventHandler::HandleRecordStateChanged(ObsOutputState state)
{
json eventData;
@ -50,6 +78,20 @@ void EventHandler::HandleRecordStateChanged(ObsOutputState state)
BroadcastEvent(EventSubscription::Outputs, "RecordStateChanged", eventData);
}
/**
* The state of the replay buffer output has changed.
*
* @dataField outputActive | Boolean | Whether the output is active
* @dataField outputState | String | The specific state of the output
*
* @eventType ReplayBufferStateChanged
* @eventSubscription Outputs
* @complexity 2
* @rpcVersion -1
* @initialVersion 5.0.0
* @api events
* @category outputs
*/
void EventHandler::HandleReplayBufferStateChanged(ObsOutputState state)
{
json eventData;
@ -58,6 +100,20 @@ void EventHandler::HandleReplayBufferStateChanged(ObsOutputState state)
BroadcastEvent(EventSubscription::Outputs, "ReplayBufferStateChanged", eventData);
}
/**
* The state of the virtualcam output has changed.
*
* @dataField outputActive | Boolean | Whether the output is active
* @dataField outputState | String | The specific state of the output
*
* @eventType VirtualcamStateChanged
* @eventSubscription Outputs
* @complexity 2
* @rpcVersion -1
* @initialVersion 5.0.0
* @api events
* @category outputs
*/
void EventHandler::HandleVirtualcamStateChanged(ObsOutputState state)
{
json eventData;
@ -66,6 +122,19 @@ void EventHandler::HandleVirtualcamStateChanged(ObsOutputState state)
BroadcastEvent(EventSubscription::Outputs, "VirtualcamStateChanged", eventData);
}
/**
* The replay buffer has been saved.
*
* @dataField savedReplayPath | String | Path of the saved replay file
*
* @eventType ReplayBufferSaved
* @eventSubscription Outputs
* @complexity 2
* @rpcVersion -1
* @initialVersion 5.0.0
* @api events
* @category outputs
*/
void EventHandler::HandleReplayBufferSaved()
{
json eventData;

View File

@ -19,6 +19,22 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#include "EventHandler.h"
/**
* A scene item has been created.
*
* @dataField sceneName | String | Name of the scene the item was added to
* @dataField sourceName | String | Name of the underlying source (input/scene)
* @dataField sceneItemId | Number | Numeric ID of the scene item
* @dataField sceneItemIndex | Number | Index position of the item
*
* @eventType SceneItemCreated
* @eventSubscription SceneItems
* @complexity 3
* @rpcVersion -1
* @initialVersion 5.0.0
* @api events
* @category scene items
*/
void EventHandler::HandleSceneItemCreated(void *param, calldata_t *data)
{
auto eventHandler = reinterpret_cast<EventHandler*>(param);
@ -33,13 +49,29 @@ void EventHandler::HandleSceneItemCreated(void *param, calldata_t *data)
json eventData;
eventData["sceneName"] = obs_source_get_name(obs_scene_get_source(scene));
eventData["inputName"] = obs_source_get_name(obs_sceneitem_get_source(sceneItem));
eventData["sourceName"] = obs_source_get_name(obs_sceneitem_get_source(sceneItem));
eventData["sceneItemId"] = obs_sceneitem_get_id(sceneItem);
eventData["sceneItemIndex"] = obs_sceneitem_get_order_position(sceneItem);
eventHandler->BroadcastEvent(EventSubscription::SceneItems, "SceneItemCreated", eventData);
}
// Will not be emitted if an item is removed due to the parent scene being removed.
/**
* A scene item has been removed.
*
* This event is not emitted when the scene the item is in is removed.
*
* @dataField sceneName | String | Name of the scene the item was removed from
* @dataField sourceName | String | Name of the underlying source (input/scene)
* @dataField sceneItemId | Number | Numeric ID of the scene item
*
* @eventType SceneItemRemoved
* @eventSubscription SceneItems
* @complexity 3
* @rpcVersion -1
* @initialVersion 5.0.0
* @api events
* @category scene items
*/
void EventHandler::HandleSceneItemRemoved(void *param, calldata_t *data)
{
auto eventHandler = reinterpret_cast<EventHandler*>(param);
@ -54,12 +86,25 @@ void EventHandler::HandleSceneItemRemoved(void *param, calldata_t *data)
json eventData;
eventData["sceneName"] = obs_source_get_name(obs_scene_get_source(scene));
eventData["inputName"] = obs_source_get_name(obs_sceneitem_get_source(sceneItem));
eventData["sourceName"] = obs_source_get_name(obs_sceneitem_get_source(sceneItem));
eventData["sceneItemId"] = obs_sceneitem_get_id(sceneItem);
eventData["sceneItemIndex"] = obs_sceneitem_get_order_position(sceneItem);
eventHandler->BroadcastEvent(EventSubscription::SceneItems, "SceneItemRemoved", eventData);
}
/**
* A scene's item list has been reindexed.
*
* @dataField sceneName | String | Name of the scene
* @dataField sceneItems | Array<Object> | Array of scene item objects
*
* @eventType SceneItemListReindexed
* @eventSubscription SceneItems
* @complexity 3
* @rpcVersion -1
* @initialVersion 5.0.0
* @api events
* @category scene items
*/
void EventHandler::HandleSceneItemListReindexed(void *param, calldata_t *data)
{
auto eventHandler = reinterpret_cast<EventHandler*>(param);
@ -74,6 +119,21 @@ void EventHandler::HandleSceneItemListReindexed(void *param, calldata_t *data)
eventHandler->BroadcastEvent(EventSubscription::SceneItems, "SceneItemListReindexed", eventData);
}
/**
* A scene item's enable state has changed.
*
* @dataField sceneName | String | Name of the scene the item is in
* @dataField sceneItemId | Number | Numeric ID of the scene item
* @dataField sceneItemEnabled | Boolean | Whether the scene item is enabled (visible)
*
* @eventType SceneItemEnableStateChanged
* @eventSubscription SceneItems
* @complexity 3
* @rpcVersion -1
* @initialVersion 5.0.0
* @api events
* @category scene items
*/
void EventHandler::HandleSceneItemEnableStateChanged(void *param, calldata_t *data)
{
auto eventHandler = reinterpret_cast<EventHandler*>(param);
@ -95,6 +155,21 @@ void EventHandler::HandleSceneItemEnableStateChanged(void *param, calldata_t *da
eventHandler->BroadcastEvent(EventSubscription::SceneItems, "SceneItemEnableStateChanged", eventData);
}
/**
* A scene item's lock state has changed.
*
* @dataField sceneName | String | Name of the scene the item is in
* @dataField sceneItemId | Number | Numeric ID of the scene item
* @dataField sceneItemEnabled | Boolean | Whether the scene item is locked
*
* @eventType SceneItemLockStateChanged
* @eventSubscription SceneItems
* @complexity 3
* @rpcVersion -1
* @initialVersion 5.0.0
* @api events
* @category scene items
*/
void EventHandler::HandleSceneItemLockStateChanged(void *param, calldata_t *data)
{
auto eventHandler = reinterpret_cast<EventHandler*>(param);
@ -116,6 +191,21 @@ void EventHandler::HandleSceneItemLockStateChanged(void *param, calldata_t *data
eventHandler->BroadcastEvent(EventSubscription::SceneItems, "SceneItemLockStateChanged", eventData);
}
/**
* The transform/crop of a scene item has changed.
*
* @dataField sceneName | String | The name of the scene the item is in
* @dataField sceneItemId | Number | Numeric ID of the scene item
* @dataField sceneItemTransform | Object | New transform/crop info of the scene item
*
* @eventType SceneItemTransformChanged
* @eventSubscription SceneItemTransformChanged
* @complexity 4
* @rpcVersion -1
* @initialVersion 5.0.0
* @api events
* @category scene items
*/
void EventHandler::HandleSceneItemTransformChanged(void *param, calldata_t *data)
{
auto eventHandler = reinterpret_cast<EventHandler*>(param);

View File

@ -19,6 +19,20 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#include "EventHandler.h"
/**
* A new scene has been created.
*
* @dataField sceneName | String | Name of the new scene
* @dataField isGroup | Boolean | Whether the new scene is a group
*
* @eventType SceneCreated
* @eventSubscription Scenes
* @complexity 2
* @rpcVersion -1
* @initialVersion 5.0.0
* @api events
* @category scenes
*/
void EventHandler::HandleSceneCreated(obs_source_t *source)
{
json eventData;
@ -27,6 +41,20 @@ void EventHandler::HandleSceneCreated(obs_source_t *source)
BroadcastEvent(EventSubscription::Scenes, "SceneCreated", eventData);
}
/**
* A scene has been removed.
*
* @dataField sceneName | String | Name of the removed scene
* @dataField isGroup | Boolean | Whether the scene was a group
*
* @eventType SceneRemoved
* @eventSubscription Scenes
* @complexity 2
* @rpcVersion -1
* @initialVersion 5.0.0
* @api events
* @category scenes
*/
void EventHandler::HandleSceneRemoved(obs_source_t *source)
{
json eventData;
@ -35,6 +63,20 @@ void EventHandler::HandleSceneRemoved(obs_source_t *source)
BroadcastEvent(EventSubscription::Scenes, "SceneRemoved", eventData);
}
/**
* The name of a scene has changed.
*
* @dataField oldSceneName | String | Old name of the scene
* @dataField sceneName | String | New name of the scene
*
* @eventType SceneNameChanged
* @eventSubscription Scenes
* @complexity 2
* @rpcVersion -1
* @initialVersion 5.0.0
* @api events
* @category scenes
*/
void EventHandler::HandleSceneNameChanged(obs_source_t *, std::string oldSceneName, std::string sceneName)
{
json eventData;
@ -43,6 +85,19 @@ void EventHandler::HandleSceneNameChanged(obs_source_t *, std::string oldSceneNa
BroadcastEvent(EventSubscription::Scenes, "SceneNameChanged", eventData);
}
/**
* The current program scene has changed.
*
* @dataField sceneName | String | Name of the scene that was switched to
*
* @eventType CurrentSceneChanged
* @eventSubscription Scenes
* @complexity 1
* @rpcVersion -1
* @initialVersion 5.0.0
* @api events
* @category scenes
*/
void EventHandler::HandleCurrentSceneChanged()
{
OBSSourceAutoRelease currentScene = obs_frontend_get_current_scene();
@ -52,6 +107,19 @@ void EventHandler::HandleCurrentSceneChanged()
BroadcastEvent(EventSubscription::Scenes, "CurrentSceneChanged", eventData);
}
/**
* The current preview scene has changed.
*
* @dataField sceneName | String | Name of the scene that was switched to
*
* @eventType CurrentPreviewSceneChanged
* @eventSubscription Scenes
* @complexity 1
* @rpcVersion -1
* @initialVersion 5.0.0
* @api events
* @category scenes
*/
void EventHandler::HandleCurrentPreviewSceneChanged()
{
OBSSourceAutoRelease currentPreviewScene = obs_frontend_get_current_preview_scene();
@ -65,6 +133,21 @@ void EventHandler::HandleCurrentPreviewSceneChanged()
BroadcastEvent(EventSubscription::Scenes, "CurrentPreviewSceneChanged", eventData);
}
/**
* The list of scenes has changed.
*
* TODO: Make OBS fire this event when scenes are reordered.
*
* @dataField scenes | Array<Object> | Updated array of scenes
*
* @eventType SceneListChanged
* @eventSubscription Scenes
* @complexity 2
* @rpcVersion -1
* @initialVersion 5.0.0
* @api events
* @category scenes
*/
void EventHandler::HandleSceneListChanged()
{
json eventData;

View File

@ -18,27 +18,3 @@ with this program. If not, see <https://www.gnu.org/licenses/>
*/
#include "EventHandler.h"
void EventHandler::HandleTransitionCreated(obs_source_t *source)
{
json eventData;
eventData["transitionName"] = obs_source_get_name(source);
eventData["transitionKind"] = obs_source_get_id(source);
eventData["transitionFixed"] = obs_transition_fixed(source);
BroadcastEvent(EventSubscription::Transitions, "TransitionCreated", eventData);
}
void EventHandler::HandleTransitionRemoved(obs_source_t *source)
{
json eventData;
eventData["transitionName"] = obs_source_get_name(source);
BroadcastEvent(EventSubscription::Transitions, "TransitionRemoved", eventData);
}
void EventHandler::HandleTransitionNameChanged(obs_source_t *, std::string oldTransitionName, std::string transitionName)
{
json eventData;
eventData["oldTransitionName"] = oldTransitionName;
eventData["transitionName"] = transitionName;
BroadcastEvent(EventSubscription::Transitions, "TransitionNameChanged", eventData);
}