diff --git a/src/eventhandler/EventHandler_Outputs.cpp b/src/eventhandler/EventHandler_Outputs.cpp
index 19238d75..15195bb9 100644
--- a/src/eventhandler/EventHandler_Outputs.cpp
+++ b/src/eventhandler/EventHandler_Outputs.cpp
@@ -19,21 +19,7 @@ with this program. If not, see
#include "EventHandler.h"
-#define CASE(x) case x: return #x;
-
-std::string GetOutputStateString(ObsOutputState state) {
- switch (state) {
- default:
- CASE(OBS_WEBSOCKET_OUTPUT_STARTING)
- CASE(OBS_WEBSOCKET_OUTPUT_STARTED)
- CASE(OBS_WEBSOCKET_OUTPUT_STOPPING)
- CASE(OBS_WEBSOCKET_OUTPUT_STOPPED)
- CASE(OBS_WEBSOCKET_OUTPUT_PAUSED)
- CASE(OBS_WEBSOCKET_OUTPUT_RESUMED)
- }
-}
-
-bool GetOutputStateActive(ObsOutputState state) {
+static bool GetOutputStateActive(ObsOutputState state) {
switch(state) {
case OBS_WEBSOCKET_OUTPUT_STARTED:
case OBS_WEBSOCKET_OUTPUT_RESUMED:
@@ -52,7 +38,7 @@ void EventHandler::HandleStreamStateChanged(ObsOutputState state)
{
json eventData;
eventData["outputActive"] = GetOutputStateActive(state);
- eventData["outputState"] = GetOutputStateString(state);
+ eventData["outputState"] = Utils::Obs::StringHelper::GetOutputState(state);
BroadcastEvent(EventSubscription::Outputs, "StreamStateChanged", eventData);
}
@@ -60,7 +46,7 @@ void EventHandler::HandleRecordStateChanged(ObsOutputState state)
{
json eventData;
eventData["outputActive"] = GetOutputStateActive(state);
- eventData["outputState"] = GetOutputStateString(state);
+ eventData["outputState"] = Utils::Obs::StringHelper::GetOutputState(state);
BroadcastEvent(EventSubscription::Outputs, "RecordStateChanged", eventData);
}
@@ -68,7 +54,7 @@ void EventHandler::HandleReplayBufferStateChanged(ObsOutputState state)
{
json eventData;
eventData["outputActive"] = GetOutputStateActive(state);
- eventData["outputState"] = GetOutputStateString(state);
+ eventData["outputState"] = Utils::Obs::StringHelper::GetOutputState(state);
BroadcastEvent(EventSubscription::Outputs, "ReplayBufferStateChanged", eventData);
}
@@ -76,7 +62,7 @@ void EventHandler::HandleVirtualcamStateChanged(ObsOutputState state)
{
json eventData;
eventData["outputActive"] = GetOutputStateActive(state);
- eventData["outputState"] = GetOutputStateString(state);
+ eventData["outputState"] = Utils::Obs::StringHelper::GetOutputState(state);
BroadcastEvent(EventSubscription::Outputs, "VirtualcamStateChanged", eventData);
}
diff --git a/src/utils/Obs.h b/src/utils/Obs.h
index 2ce8579e..310892a7 100644
--- a/src/utils/Obs.h
+++ b/src/utils/Obs.h
@@ -66,13 +66,14 @@ template T* GetCalldataPointer(const calldata_t *data, const char*
}
enum ObsOutputState {
+ OBS_WEBSOCKET_OUTPUT_UNKNOWN,
OBS_WEBSOCKET_OUTPUT_STARTING,
OBS_WEBSOCKET_OUTPUT_STARTED,
OBS_WEBSOCKET_OUTPUT_STOPPING,
OBS_WEBSOCKET_OUTPUT_STOPPED,
OBS_WEBSOCKET_OUTPUT_RECONNECTING,
OBS_WEBSOCKET_OUTPUT_PAUSED,
- OBS_WEBSOCKET_OUTPUT_RESUMED
+ OBS_WEBSOCKET_OUTPUT_RESUMED,
};
enum ObsMediaInputAction {
@@ -82,7 +83,7 @@ enum ObsMediaInputAction {
OBS_WEBSOCKET_MEDIA_INPUT_ACTION_STOP,
OBS_WEBSOCKET_MEDIA_INPUT_ACTION_RESTART,
OBS_WEBSOCKET_MEDIA_INPUT_ACTION_NEXT,
- OBS_WEBSOCKET_MEDIA_INPUT_ACTION_PREVIOUS
+ OBS_WEBSOCKET_MEDIA_INPUT_ACTION_PREVIOUS,
};
namespace Utils {
@@ -99,6 +100,7 @@ namespace Utils {
std::string GetLastReplayBufferFilePath();
std::string GetSceneItemBoundsType(enum obs_bounds_type type);
std::string DurationToTimecode(uint64_t);
+ std::string GetOutputState(ObsOutputState state);
}
namespace EnumHelper {
diff --git a/src/utils/Obs_StringHelper.cpp b/src/utils/Obs_StringHelper.cpp
index 3abf6c50..f437b5b5 100644
--- a/src/utils/Obs_StringHelper.cpp
+++ b/src/utils/Obs_StringHelper.cpp
@@ -152,3 +152,17 @@ std::string Utils::Obs::StringHelper::DurationToTimecode(uint64_t ms)
QString formatted = QString::asprintf("%02" PRIu64 ":%02" PRIu64 ":%02" PRIu64 ".%03" PRIu64, hoursPart, minutesPart, secsPart, msPart);
return formatted.toStdString();
}
+
+std::string Utils::Obs::StringHelper::GetOutputState(ObsOutputState state)
+{
+ switch (state) {
+ default:
+ CASE(OBS_WEBSOCKET_OUTPUT_UNKNOWN)
+ CASE(OBS_WEBSOCKET_OUTPUT_STARTING)
+ CASE(OBS_WEBSOCKET_OUTPUT_STARTED)
+ CASE(OBS_WEBSOCKET_OUTPUT_STOPPING)
+ CASE(OBS_WEBSOCKET_OUTPUT_STOPPED)
+ CASE(OBS_WEBSOCKET_OUTPUT_PAUSED)
+ CASE(OBS_WEBSOCKET_OUTPUT_RESUMED)
+ }
+}