mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
EventHandler: Add Outputs events and other files
This commit is contained in:
parent
289d1ad69d
commit
6c03b86514
@ -80,6 +80,10 @@ set(obs-websocket_SOURCES
|
||||
src/eventhandler/EventHandler_Scenes.cpp
|
||||
src/eventhandler/EventHandler_Inputs.cpp
|
||||
src/eventhandler/EventHandler_Transitions.cpp
|
||||
src/eventhandler/EventHandler_Filters.cpp
|
||||
src/eventhandler/EventHandler_Outputs.cpp
|
||||
src/eventhandler/EventHandler_SceneItems.cpp
|
||||
src/eventhandler/EventHandler_MediaInputs.cpp
|
||||
src/requesthandler/RequestHandler.cpp
|
||||
src/requesthandler/RequestHandler_General.cpp
|
||||
src/requesthandler/rpc/Request.cpp
|
||||
|
@ -172,32 +172,46 @@ void EventHandler::OnFrontendEvent(enum obs_frontend_event event, void *private_
|
||||
|
||||
// Outputs
|
||||
case OBS_FRONTEND_EVENT_STREAMING_STARTING:
|
||||
eventHandler->HandleStreamStateChanged(OBS_WEBSOCKET_OUTPUT_STARTING);
|
||||
break;
|
||||
case OBS_FRONTEND_EVENT_STREAMING_STARTED:
|
||||
eventHandler->HandleStreamStateChanged(OBS_WEBSOCKET_OUTPUT_STARTED);
|
||||
break;
|
||||
case OBS_FRONTEND_EVENT_STREAMING_STOPPING:
|
||||
eventHandler->HandleStreamStateChanged(OBS_WEBSOCKET_OUTPUT_STOPPING);
|
||||
break;
|
||||
case OBS_FRONTEND_EVENT_STREAMING_STOPPED:
|
||||
eventHandler->HandleStreamStateChanged(OBS_WEBSOCKET_OUTPUT_STOPPED);
|
||||
break;
|
||||
case OBS_FRONTEND_EVENT_RECORDING_STARTING:
|
||||
eventHandler->HandleRecordStateChanged(OBS_WEBSOCKET_OUTPUT_STARTING);
|
||||
break;
|
||||
case OBS_FRONTEND_EVENT_RECORDING_STARTED:
|
||||
eventHandler->HandleRecordStateChanged(OBS_WEBSOCKET_OUTPUT_STARTED);
|
||||
break;
|
||||
case OBS_FRONTEND_EVENT_RECORDING_STOPPING:
|
||||
eventHandler->HandleRecordStateChanged(OBS_WEBSOCKET_OUTPUT_STOPPING);
|
||||
break;
|
||||
case OBS_FRONTEND_EVENT_RECORDING_STOPPED:
|
||||
eventHandler->HandleRecordStateChanged(OBS_WEBSOCKET_OUTPUT_STOPPED);
|
||||
break;
|
||||
case OBS_FRONTEND_EVENT_REPLAY_BUFFER_STARTING:
|
||||
eventHandler->HandleReplayBufferStateChanged(OBS_WEBSOCKET_OUTPUT_STARTING);
|
||||
break;
|
||||
case OBS_FRONTEND_EVENT_REPLAY_BUFFER_STARTED:
|
||||
eventHandler->HandleReplayBufferStateChanged(OBS_WEBSOCKET_OUTPUT_STARTED);
|
||||
break;
|
||||
case OBS_FRONTEND_EVENT_REPLAY_BUFFER_STOPPING:
|
||||
eventHandler->HandleReplayBufferStateChanged(OBS_WEBSOCKET_OUTPUT_STOPPING);
|
||||
break;
|
||||
case OBS_FRONTEND_EVENT_REPLAY_BUFFER_STOPPED:
|
||||
eventHandler->HandleReplayBufferStateChanged(OBS_WEBSOCKET_OUTPUT_STOPPED);
|
||||
break;
|
||||
case OBS_FRONTEND_EVENT_VIRTUALCAM_STARTED:
|
||||
eventHandler->HandleVirtualcamStateChanged(OBS_WEBSOCKET_OUTPUT_STARTED);
|
||||
break;
|
||||
case OBS_FRONTEND_EVENT_VIRTUALCAM_STOPPED:
|
||||
eventHandler->HandleVirtualcamStateChanged(OBS_WEBSOCKET_OUTPUT_STOPPED);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -8,6 +8,15 @@
|
||||
#include "../WebSocketServer.h"
|
||||
#include "types/EventSubscription.h"
|
||||
|
||||
enum ObsOutputState {
|
||||
OBS_WEBSOCKET_OUTPUT_STARTING,
|
||||
OBS_WEBSOCKET_OUTPUT_STARTED,
|
||||
OBS_WEBSOCKET_OUTPUT_STOPPING,
|
||||
OBS_WEBSOCKET_OUTPUT_STOPPED,
|
||||
OBS_WEBSOCKET_OUTPUT_PAUSED,
|
||||
OBS_WEBSOCKET_OUTPUT_RESUMED
|
||||
};
|
||||
|
||||
template <typename T> T* GetCalldataPointer(const calldata_t *data, const char* name) {
|
||||
void* ptr = nullptr;
|
||||
calldata_get_ptr(data, name, &ptr);
|
||||
@ -76,4 +85,10 @@ class EventHandler
|
||||
void HandleTransitionCreated(obs_source_t *source);
|
||||
void HandleTransitionRemoved(obs_source_t *source);
|
||||
void HandleTransitionNameChanged(obs_source_t *source, std::string oldTransitionName, std::string transitionName);
|
||||
|
||||
// Outputs
|
||||
void HandleStreamStateChanged(ObsOutputState state);
|
||||
void HandleRecordStateChanged(ObsOutputState state);
|
||||
void HandleReplayBufferStateChanged(ObsOutputState state);
|
||||
void HandleVirtualcamStateChanged(ObsOutputState state);
|
||||
};
|
||||
|
3
src/eventhandler/EventHandler_Filters.cpp
Normal file
3
src/eventhandler/EventHandler_Filters.cpp
Normal file
@ -0,0 +1,3 @@
|
||||
#include "EventHandler.h"
|
||||
|
||||
#include "../plugin-macros.generated.h"
|
3
src/eventhandler/EventHandler_MediaInputs.cpp
Normal file
3
src/eventhandler/EventHandler_MediaInputs.cpp
Normal file
@ -0,0 +1,3 @@
|
||||
#include "EventHandler.h"
|
||||
|
||||
#include "../plugin-macros.generated.h"
|
64
src/eventhandler/EventHandler_Outputs.cpp
Normal file
64
src/eventhandler/EventHandler_Outputs.cpp
Normal file
@ -0,0 +1,64 @@
|
||||
#include "EventHandler.h"
|
||||
|
||||
#include "../plugin-macros.generated.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) {
|
||||
switch(state) {
|
||||
case OBS_WEBSOCKET_OUTPUT_STARTED:
|
||||
case OBS_WEBSOCKET_OUTPUT_RESUMED:
|
||||
return true;
|
||||
case OBS_WEBSOCKET_OUTPUT_STARTING:
|
||||
case OBS_WEBSOCKET_OUTPUT_STOPPING:
|
||||
case OBS_WEBSOCKET_OUTPUT_STOPPED:
|
||||
case OBS_WEBSOCKET_OUTPUT_PAUSED:
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void EventHandler::HandleStreamStateChanged(ObsOutputState state)
|
||||
{
|
||||
json eventData;
|
||||
eventData["outputActive"] = GetOutputStateActive(state);
|
||||
eventData["outputState"] = GetOutputStateString(state);
|
||||
_webSocketServer->BroadcastEvent(EventSubscription::Outputs, "StreamStateChanged", eventData);
|
||||
}
|
||||
|
||||
void EventHandler::HandleRecordStateChanged(ObsOutputState state)
|
||||
{
|
||||
json eventData;
|
||||
eventData["outputActive"] = GetOutputStateActive(state);
|
||||
eventData["outputState"] = GetOutputStateString(state);
|
||||
_webSocketServer->BroadcastEvent(EventSubscription::Outputs, "RecordStateChanged", eventData);
|
||||
}
|
||||
|
||||
void EventHandler::HandleReplayBufferStateChanged(ObsOutputState state)
|
||||
{
|
||||
json eventData;
|
||||
eventData["outputActive"] = GetOutputStateActive(state);
|
||||
eventData["outputState"] = GetOutputStateString(state);
|
||||
_webSocketServer->BroadcastEvent(EventSubscription::Outputs, "ReplayBufferStateChanged", eventData);
|
||||
}
|
||||
|
||||
void EventHandler::HandleVirtualcamStateChanged(ObsOutputState state)
|
||||
{
|
||||
json eventData;
|
||||
eventData["outputActive"] = GetOutputStateActive(state);
|
||||
eventData["outputState"] = GetOutputStateString(state);
|
||||
_webSocketServer->BroadcastEvent(EventSubscription::Outputs, "VirtualcamStateChanged", eventData);
|
||||
}
|
3
src/eventhandler/EventHandler_SceneItems.cpp
Normal file
3
src/eventhandler/EventHandler_SceneItems.cpp
Normal file
@ -0,0 +1,3 @@
|
||||
#include "EventHandler.h"
|
||||
|
||||
#include "../plugin-macros.generated.h"
|
Loading…
Reference in New Issue
Block a user