Utils: Add GetSceneTransitionByName

This commit is contained in:
tt2468 2021-12-23 01:07:15 -08:00
parent e05be47847
commit 5cbf439f55
2 changed files with 21 additions and 0 deletions

View File

@ -133,6 +133,7 @@ namespace Utils {
namespace SearchHelper {
obs_hotkey_t *GetHotkeyByName(std::string name);
obs_source_t *GetSceneTransitionByName(std::string name); // Increments source ref. Use OBSSourceAutoRelease
obs_sceneitem_t *GetSceneItemByName(obs_scene_t *scene, std::string name); // Increments ref. Use OBSSceneItemAutoRelease
}

View File

@ -34,6 +34,26 @@ obs_hotkey_t *Utils::Obs::SearchHelper::GetHotkeyByName(std::string name)
return nullptr;
}
// Increments source ref. Use OBSSourceAutoRelease
obs_source_t *Utils::Obs::SearchHelper::GetSceneTransitionByName(std::string name)
{
obs_frontend_source_list transitionList = {};
obs_frontend_get_transitions(&transitionList);
obs_source_t *ret = nullptr;
for (size_t i = 0; i < transitionList.sources.num; i++) {
obs_source_t *transition = transitionList.sources.array[i];
if (obs_source_get_name(transition) == name) {
ret = obs_source_get_ref(transition);
break;
}
}
obs_frontend_source_list_free(&transitionList);
return ret;
}
// Increments item ref. Use OBSSceneItemAutoRelease
obs_sceneitem_t *Utils::Obs::SearchHelper::GetSceneItemByName(obs_scene_t *scene, std::string name)
{