EventHandler: More scene item events

This commit is contained in:
tt2468 2021-06-13 02:10:18 -07:00
parent 10afbdfca0
commit 129ee12542
2 changed files with 20 additions and 0 deletions

View File

@ -132,6 +132,8 @@ void EventHandler::OnFrontendEvent(enum obs_frontend_event event, void *private_
{
auto eventHandler = reinterpret_cast<EventHandler*>(private_data);
blog(LOG_INFO, "Frontend event");
if (!eventHandler->_obsLoaded.load()) {
if (event == OBS_FRONTEND_EVENT_FINISHED_LOADING) {
blog(LOG_INFO, "[EventHandler::OnFrontendEvent] OBS has finished loading. Connecting final handlers and enabling events...");
@ -215,6 +217,7 @@ void EventHandler::OnFrontendEvent(enum obs_frontend_event event, void *private_
eventHandler->HandleCurrentPreviewSceneChanged();
break;
case OBS_FRONTEND_EVENT_SCENE_LIST_CHANGED:
blog(LOG_INFO, "scene list changed");
eventHandler->HandleSceneListReindexed();
break;

View File

@ -25,7 +25,18 @@ void EventHandler::HandleSceneItemRemoved(void *param, calldata_t *data)
{
auto eventHandler = reinterpret_cast<EventHandler*>(param);
obs_scene_t *scene = GetCalldataPointer<obs_scene_t>(data, "scene");
if (!scene)
return;
obs_sceneitem_t *sceneItem = GetCalldataPointer<obs_sceneitem_t>(data, "item");
if (!sceneItem)
return;
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["sceneItemId"] = obs_sceneitem_get_id(sceneItem);
eventHandler->_webSocketServer->BroadcastEvent(EventSubscription::SceneItems, "SceneItemRemoved", eventData);
}
@ -33,7 +44,13 @@ void EventHandler::HandleSceneItemListReindexed(void *param, calldata_t *data)
{
auto eventHandler = reinterpret_cast<EventHandler*>(param);
obs_scene_t *scene = GetCalldataPointer<obs_scene_t>(data, "scene");
if (!scene)
return;
json eventData;
eventData["sceneName"] = obs_source_get_name(obs_scene_get_source(scene));
eventData["sceneItems"] = Utils::Obs::ListHelper::GetSceneItemList(scene, false);
eventHandler->_webSocketServer->BroadcastEvent(EventSubscription::SceneItems, "SceneItemReindexed", eventData);
}