diff --git a/src/eventhandler/EventHandler.cpp b/src/eventhandler/EventHandler.cpp index 73630dff..a25c3847 100644 --- a/src/eventhandler/EventHandler.cpp +++ b/src/eventhandler/EventHandler.cpp @@ -177,6 +177,7 @@ void EventHandler::ConnectSourceSignals(obs_source_t *source) // Applies to inpu if (sourceType == OBS_SOURCE_TYPE_TRANSITION) { signal_handler_connect(sh, "transition_start", HandleSceneTransitionStarted, this); signal_handler_connect(sh, "transition_stop", HandleSceneTransitionEnded, this); + signal_handler_connect(sh, "transition_video_stop", HandleSceneTransitionVideoEnded, this); } // Filters @@ -245,6 +246,7 @@ void EventHandler::DisconnectSourceSignals(obs_source_t *source) if (sourceType == OBS_SOURCE_TYPE_TRANSITION) { signal_handler_disconnect(sh, "transition_start", HandleSceneTransitionStarted, this); signal_handler_disconnect(sh, "transition_stop", HandleSceneTransitionEnded, this); + signal_handler_disconnect(sh, "transition_video_stop", HandleSceneTransitionVideoEnded, this); } // Filters diff --git a/src/eventhandler/EventHandler.h b/src/eventhandler/EventHandler.h index 7452b29a..458470d3 100644 --- a/src/eventhandler/EventHandler.h +++ b/src/eventhandler/EventHandler.h @@ -117,6 +117,7 @@ class EventHandler void HandleCurrentSceneTransitionDurationChanged(); static void HandleSceneTransitionStarted(void *param, calldata_t *data); // Direct callback static void HandleSceneTransitionEnded(void *param, calldata_t *data); // Direct callback + static void HandleSceneTransitionVideoEnded(void *param, calldata_t *data); // Direct callback // Filters static void FilterAddMultiHandler(void *param, calldata_t *data); // Direct callback diff --git a/src/eventhandler/EventHandler_Transitions.cpp b/src/eventhandler/EventHandler_Transitions.cpp index 35f0b67b..94bb34d1 100644 --- a/src/eventhandler/EventHandler_Transitions.cpp +++ b/src/eventhandler/EventHandler_Transitions.cpp @@ -114,3 +114,34 @@ void EventHandler::HandleSceneTransitionEnded(void *param, calldata_t *data) eventData["transitionName"] = obs_source_get_name(source); eventHandler->BroadcastEvent(EventSubscription::Transitions, "SceneTransitionEnded", eventData); } + +/** + * A scene transition's video has completed fully. + * + * Useful for stinger transitions to tell when the video *actually* ends. + * `SceneTransitionEnded` only signifies the cut point, not the completion of transition playback. + * + * Note: Appears to be called by every transition, regardless of relevance. + * + * @dataField transitionName | String | Scene transition name + * + * @eventType SceneTransitionVideoEnded + * @eventSubscription Transitions + * @complexity 2 + * @rpcVersion -1 + * @initialVersion 5.0.0 + * @api events + * @category transitions + */ +void EventHandler::HandleSceneTransitionVideoEnded(void *param, calldata_t *data) +{ + auto eventHandler = static_cast(param); + + obs_source_t *source = GetCalldataPointer(data, "source"); + if (!source) + return; + + json eventData; + eventData["transitionName"] = obs_source_get_name(source); + eventHandler->BroadcastEvent(EventSubscription::Transitions, "SceneTransitionVideoEnded", eventData); +}