diff --git a/src/utils/Obs.cpp b/src/utils/Obs.cpp index 568a060e..91e8bbab 100644 --- a/src/utils/Obs.cpp +++ b/src/utils/Obs.cpp @@ -1,3 +1,47 @@ #include "Utils.h" #include "../plugin-macros.generated.h" + +#define CASE(x) case x: return #x; + +std::string Utils::Obs::DataHelper::GetSourceTypeString(obs_source_t *source) +{ + obs_source_type sourceType = obs_source_get_type(source); + + switch (sourceType) { + default: + CASE(OBS_SOURCE_TYPE_INPUT) + CASE(OBS_SOURCE_TYPE_FILTER) + CASE(OBS_SOURCE_TYPE_TRANSITION) + CASE(OBS_SOURCE_TYPE_SCENE) + } +} + +std::string Utils::Obs::DataHelper::GetSourceMonitorTypeString(obs_source_t *source) +{ + obs_monitoring_type monitorType = obs_source_get_monitoring_type(source); + + switch (monitorType) { + default: + CASE(OBS_MONITORING_TYPE_NONE) + CASE(OBS_MONITORING_TYPE_MONITOR_ONLY) + CASE(OBS_MONITORING_TYPE_MONITOR_AND_OUTPUT) + } +} + +std::string Utils::Obs::DataHelper::GetSourceMediaStateString(obs_source_t *source) +{ + obs_media_state mediaState = obs_source_media_get_state(source); + + switch (mediaState) { + default: + CASE(OBS_MEDIA_STATE_NONE) + CASE(OBS_MEDIA_STATE_PLAYING) + CASE(OBS_MEDIA_STATE_OPENING) + CASE(OBS_MEDIA_STATE_BUFFERING) + CASE(OBS_MEDIA_STATE_PAUSED) + CASE(OBS_MEDIA_STATE_STOPPED) + CASE(OBS_MEDIA_STATE_ENDED) + CASE(OBS_MEDIA_STATE_ERROR) + } +} diff --git a/src/utils/Utils.h b/src/utils/Utils.h index a87e436a..2d2b87ec 100644 --- a/src/utils/Utils.h +++ b/src/utils/Utils.h @@ -1,9 +1,9 @@ #pragma once +#include #include #include #include -#include using json = nlohmann::json; @@ -27,6 +27,10 @@ namespace Utils { } namespace Obs { - ; + namespace DataHelper { + std::string GetSourceTypeString(obs_source_t *source); + std::string GetSourceMonitorTypeString(obs_source_t *source); + std::string GetSourceMediaStateString(obs_source_t *source); + } } }