Utils: Add some Obs helpers

This commit is contained in:
tt2468 2021-05-10 18:25:15 -07:00
parent 89046ccb1a
commit 23b6ce607c
2 changed files with 50 additions and 2 deletions

View File

@ -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)
}
}

View File

@ -1,9 +1,9 @@
#pragma once
#include <obs.hpp>
#include <string>
#include <QString>
#include <nlohmann/json.hpp>
#include <obs-data.h>
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);
}
}
}