From 8a45560297849685ada52584edf06d47da42046a Mon Sep 17 00:00:00 2001 From: tt2468 Date: Wed, 1 Sep 2021 10:43:24 -0700 Subject: [PATCH] Utils: Add GetSceneCount() --- src/utils/Obs.cpp | 18 ++++++++++++++++++ src/utils/Obs.h | 1 + 2 files changed, 19 insertions(+) diff --git a/src/utils/Obs.cpp b/src/utils/Obs.cpp index 03320cc2..f155064c 100644 --- a/src/utils/Obs.cpp +++ b/src/utils/Obs.cpp @@ -153,6 +153,24 @@ uint64_t Utils::Obs::NumberHelper::GetOutputDuration(obs_output_t *output) return util_mul_div64(totalFrames, frameTimeNs, 1000000ULL); } +size_t Utils::Obs::NumberHelper::GetSceneCount() +{ + size_t ret; + auto sceneEnumProc = [](void *param, obs_source_t *scene) { + auto ret = reinterpret_cast(param); + + if (obs_source_is_group(scene)) + return true; + + (*ret)++; + return true; + }; + + obs_enum_scenes(sceneEnumProc, &ret); + + return ret; +} + std::vector Utils::Obs::ListHelper::GetSceneCollectionList() { char** sceneCollections = obs_frontend_get_scene_collections(); diff --git a/src/utils/Obs.h b/src/utils/Obs.h index 0bab4033..3cae86f9 100644 --- a/src/utils/Obs.h +++ b/src/utils/Obs.h @@ -40,6 +40,7 @@ namespace Utils { namespace NumberHelper { uint64_t GetOutputDuration(obs_output_t *output); + size_t GetSceneCount(); } namespace ListHelper {