Added update type TransitionDurationChanged

This commit is contained in:
Palakis 2017-02-27 13:24:25 +01:00
parent 42a80c6185
commit e30e982ef0
5 changed files with 35 additions and 10 deletions

@ -14,6 +14,7 @@ The protocol in general is based on the OBS Remote protocol created by Bill Hami
- ["SceneCollectionChanged"](#scenecollectionchanged)
- ["SceneCollectionListChanged"](#scenecollectionlistchanged)
- ["SwitchTransition"](#switchtransition)
- ["TransitionDurationChanged"](#transitiondurationchanged)
- ["TransitionListChanged"](#transitionlistchanged)
- ["ProfileChanged"](#profilechanged)
- ["ProfileListChanged"](#profilelistchanged)
@ -94,6 +95,12 @@ The active transition has been changed.
---
#### "TransitionDurationChanged"
Triggered when the transition duration has changed.
- **"new-duration"** (integer) : new transition duration
---
#### "TransitionListChanged"
The list of available transitions has been modified (Transitions have been added, removed, or renamed).

@ -209,14 +209,18 @@ obs_data_array_t* Utils::GetProfiles()
return list;
}
int Utils::GetTransitionDuration()
QSpinBox* Utils::GetTransitionDurationControl()
{
QMainWindow *window = (QMainWindow*)obs_frontend_get_main_window();
QSpinBox* durationControl = window->findChild<QSpinBox*>("transitionDuration");
return window->findChild<QSpinBox*>("transitionDuration");
}
if (durationControl)
int Utils::GetTransitionDuration()
{
QSpinBox* control = GetTransitionDurationControl();
if (control)
{
return durationControl->value();
return control->value();
}
else
{
@ -226,12 +230,11 @@ int Utils::GetTransitionDuration()
void Utils::SetTransitionDuration(int ms)
{
QMainWindow *window = (QMainWindow*)obs_frontend_get_main_window();
QSpinBox* durationControl = window->findChild<QSpinBox*>("transitionDuration");
QSpinBox* control = GetTransitionDurationControl();
if (durationControl && ms >= 0)
if (control && ms >= 0)
{
durationControl->setValue(ms);
control->setValue(ms);
}
}

@ -19,6 +19,7 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#ifndef UTILS_H
#define UTILS_H
#include <QSpinBox>
#include <stdio.h>
#include <obs-module.h>
@ -37,6 +38,7 @@ class Utils
static obs_data_array_t* GetSceneCollections();
static obs_data_array_t* GetProfiles();
static QSpinBox* GetTransitionDurationControl();
static int GetTransitionDuration();
static void SetTransitionDuration(int ms);

@ -19,7 +19,7 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#include <util/platform.h>
#include <QTimer>
#include "Utils.h"
#include "WSEvents.h"
WSEvents::WSEvents(WSServer *srv)
@ -27,6 +27,9 @@ WSEvents::WSEvents(WSServer *srv)
_srv = srv;
obs_frontend_add_event_callback(WSEvents::FrontendEventHandler, this);
QSpinBox* duration_control = Utils::GetTransitionDurationControl();
connect(duration_control, SIGNAL(valueChanged(int)), this, SLOT(TransitionDurationChanged(int)));
QTimer *statusTimer = new QTimer();
connect(statusTimer, SIGNAL(timeout()), this, SLOT(StreamStatus()));
statusTimer->start(2000); // equal to frontend's constant BITRATE_UPDATE_SECONDS
@ -340,3 +343,13 @@ void WSEvents::StreamStatus()
obs_data_release(data);
obs_output_release(stream_output);
}
void WSEvents::TransitionDurationChanged(int ms)
{
obs_data_t* fields = obs_data_create();
obs_data_set_int(fields, "new-duration", ms);
broadcastUpdate("TransitionDurationChanged", fields);
obs_data_release(fields);
}

@ -21,7 +21,6 @@ with this program. If not, see <https://www.gnu.org/licenses/>
#define WSEVENTS_H
#include <obs-frontend-api.h>
#include "WSServer.h"
class WSEvents : public QObject
@ -35,6 +34,7 @@ class WSEvents : public QObject
private Q_SLOTS:
void StreamStatus();
void TransitionDurationChanged(int ms);
private:
WSServer *_srv;