From ff2bace1bff90fa58ea5b8eeb8f158e890f84c35 Mon Sep 17 00:00:00 2001 From: Brendan Hagan Date: Mon, 5 Dec 2016 23:00:35 -0600 Subject: [PATCH] [Protocol] Add OnTransitionChange/OnTransitionListChange (Fixes #19) --- PROTOCOL.md | 17 ++++++++++++----- WSEvents.cpp | 23 +++++++++++++++++++++++ WSEvents.h | 3 +++ 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/PROTOCOL.md b/PROTOCOL.md index 20b5864e..d6af0f63 100644 --- a/PROTOCOL.md +++ b/PROTOCOL.md @@ -26,6 +26,13 @@ OBS is switching to another scene. #### "ScenesChanged" The scene list has been modified (Scenes have been added, removed, or renamed). +#### "SwitchTransition" +The active transition has been changed. +- **transition-name** (string) : The name of the active transition. + +#### "TransitionListChanged" +The list of available transitions has been modified (Transitions have been added, removed, or renamed). + #### "StreamStarting" A request to start streaming has been issued. - **preview-only** (bool) : Always false. @@ -50,7 +57,7 @@ A request to start recording has been issued. Recording started successfully. *New in OBS Studio* -#### "RecordingStopping" +#### "RecordingStopping" A request to stop streaming has been issued. *New in OBS Studio* @@ -93,7 +100,7 @@ Depending on the request type additional fields may be present (see the "[Reques ### Request Types #### "GetVersion" -Returns the latest version of the plugin and the API. +Returns the latest version of the plugin and the API. __Request fields__ : none __Response__ : always OK, with these additional fields : @@ -165,12 +172,12 @@ Toggle streaming on or off. __Request fields__ : none __Response__ : always OK. No additional fields. -#### "StartStopRecording" +#### "StartStopRecording" Toggle recording on or off. __Request fields__ : none __Response__ : always OK. No additional fields. -*New in OBS Studio* +*New in OBS Studio* #### "GetStreamingStatus" Get current streaming and recording status. @@ -211,7 +218,7 @@ __Response__ : OK if specified transition exists, error otherwise. *New in OBS Studio* -### Authentication +### Authentication A call to `GetAuthRequired` gives the client two elements : - A challenge : a random string that will be used to generate the auth response - A salt : applied to the password when generating the auth response diff --git a/WSEvents.cpp b/WSEvents.cpp index 1365a070..d87e63b2 100644 --- a/WSEvents.cpp +++ b/WSEvents.cpp @@ -43,6 +43,12 @@ void WSEvents::FrontendEventHandler(enum obs_frontend_event event, void *private else if (event == OBS_FRONTEND_EVENT_SCENE_LIST_CHANGED) { owner->OnSceneListChange(); } + else if (event == OBS_FRONTEND_EVENT_TRANSITION_CHANGED) { + owner->OnTransitionChange(); + } + else if (event == OBS_FRONTEND_EVENT_TRANSITION_LIST_CHANGED) { + owner->OnTransitionListChange(); + } else if (event == OBS_FRONTEND_EVENT_STREAMING_STARTING) { owner->OnStreamStarting(); } @@ -126,6 +132,23 @@ void WSEvents::OnSceneListChange() { broadcastUpdate("ScenesChanged"); } +void WSEvents::OnTransitionChange() { + obs_source_t *transition = obs_frontend_get_current_transition(); + const char *transition_name = obs_source_get_name(transition); + + obs_data_t *data = obs_data_create(); + obs_data_set_string(data, "transition-name", transition_name); + + broadcastUpdate("SwitchTransition", data); + + obs_data_release(data); + obs_source_release(transition); +} + +void WSEvents::OnTransitionListChange() { + broadcastUpdate("TransitionListChanged"); +} + void WSEvents::OnStreamStarting() { // Implements an existing update type from bilhamil's OBS Remote obs_data_t *data = obs_data_create(); diff --git a/WSEvents.h b/WSEvents.h index ae31f4fe..360585b5 100644 --- a/WSEvents.h +++ b/WSEvents.h @@ -47,6 +47,9 @@ class WSEvents : public QObject void OnSceneChange(); void OnSceneListChange(); + void OnTransitionChange(); + void OnTransitionListChange(); + void OnStreamStarting(); void OnStreamStarted(); void OnStreamStopping();