Merge pull request #1502 from DDRBoxman/decklinkoutui
Decklink: Add UI to control output
This commit is contained in:
commit
e60023daf5
@ -1 +1,2 @@
|
||||
add_subdirectory(decklink-output-ui)
|
||||
add_subdirectory(frontend-tools)
|
||||
|
55
UI/frontend-plugins/decklink-output-ui/CMakeLists.txt
Normal file
55
UI/frontend-plugins/decklink-output-ui/CMakeLists.txt
Normal file
@ -0,0 +1,55 @@
|
||||
project(decklink-output-ui)
|
||||
|
||||
if(APPLE)
|
||||
find_library(COCOA Cocoa)
|
||||
include_directories(${COCOA})
|
||||
endif()
|
||||
|
||||
if(UNIX AND NOT APPLE)
|
||||
find_package(X11 REQUIRED)
|
||||
link_libraries(${X11_LIBRARIES})
|
||||
include_directories(${X11_INCLUDE_DIR})
|
||||
endif()
|
||||
|
||||
set(decklink-ouput-ui_HEADERS
|
||||
${decklink-ouput-ui_HEADERS}
|
||||
../../properties-view.hpp
|
||||
../../properties-view.moc.hpp
|
||||
../../vertical-scroll-area.hpp
|
||||
../../double-slider.hpp
|
||||
./DecklinkOutputUI.h
|
||||
decklink-ui-main.h
|
||||
)
|
||||
set(decklink-ouput-ui_SOURCES
|
||||
${decklink-ouput-ui_SOURCES}
|
||||
../../properties-view.cpp
|
||||
../../vertical-scroll-area.cpp
|
||||
../../double-slider.cpp
|
||||
./DecklinkOutputUI.cpp
|
||||
decklink-ui-main.cpp
|
||||
)
|
||||
set(decklink-ouput-ui_UI
|
||||
${decklink-ouput-ui_UI}
|
||||
forms/output.ui
|
||||
)
|
||||
|
||||
if(APPLE)
|
||||
set(decklink-ouput-ui_PLATFORM_LIBS
|
||||
${COCOA})
|
||||
endif()
|
||||
|
||||
qt5_wrap_ui(decklink-ouput-ui_UI_HEADERS
|
||||
${decklink-ouput-ui_UI})
|
||||
|
||||
add_library(decklink-ouput-ui MODULE
|
||||
${decklink-ouput-ui_HEADERS}
|
||||
${decklink-ouput-ui_SOURCES}
|
||||
${decklink-ouput-ui_UI_HEADERS}
|
||||
)
|
||||
target_link_libraries(decklink-ouput-ui
|
||||
${frontend-tools_PLATFORM_LIBS}
|
||||
obs-frontend-api
|
||||
Qt5::Widgets
|
||||
libobs)
|
||||
|
||||
install_obs_plugin_with_data(decklink-ouput-ui data)
|
75
UI/frontend-plugins/decklink-output-ui/DecklinkOutputUI.cpp
Normal file
75
UI/frontend-plugins/decklink-output-ui/DecklinkOutputUI.cpp
Normal file
@ -0,0 +1,75 @@
|
||||
#include "DecklinkOutputUI.h"
|
||||
#include <obs-module.h>
|
||||
#include <util/platform.h>
|
||||
#include "decklink-ui-main.h"
|
||||
|
||||
DecklinkOutputUI::DecklinkOutputUI(QWidget *parent)
|
||||
: QDialog(parent),
|
||||
ui(new Ui_Output)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
propertiesView = nullptr;
|
||||
|
||||
connect(ui->startOutput, SIGNAL(released()), this, SLOT(StartOutput()));
|
||||
connect(ui->stopOutput, SIGNAL(released()), this, SLOT(StopOutput()));
|
||||
}
|
||||
|
||||
void DecklinkOutputUI::ShowHideDialog()
|
||||
{
|
||||
SetupPropertiesView();
|
||||
|
||||
setVisible(!isVisible());
|
||||
}
|
||||
|
||||
void DecklinkOutputUI::SetupPropertiesView()
|
||||
{
|
||||
if (propertiesView)
|
||||
delete propertiesView;
|
||||
|
||||
obs_data_t *settings = obs_data_create();
|
||||
|
||||
OBSData data = load_settings();
|
||||
if (data)
|
||||
obs_data_apply(settings, data);
|
||||
|
||||
propertiesView = new OBSPropertiesView(settings,
|
||||
"decklink_output",
|
||||
(PropertiesReloadCallback) obs_get_output_properties,
|
||||
170);
|
||||
|
||||
ui->propertiesLayout->addWidget(propertiesView);
|
||||
obs_data_release(settings);
|
||||
|
||||
connect(propertiesView, SIGNAL(Changed()), this, SLOT(PropertiesChanged()));
|
||||
}
|
||||
|
||||
void DecklinkOutputUI::SaveSettings()
|
||||
{
|
||||
char *modulePath = obs_module_get_config_path(obs_current_module(), "");
|
||||
|
||||
os_mkdirs(modulePath);
|
||||
|
||||
char *path = obs_module_get_config_path(obs_current_module(),
|
||||
"decklinkOutputProps.json");
|
||||
|
||||
obs_data_t *settings = propertiesView->GetSettings();
|
||||
if (settings)
|
||||
obs_data_save_json_safe(settings, path, "tmp", "bak");
|
||||
}
|
||||
|
||||
void DecklinkOutputUI::StartOutput()
|
||||
{
|
||||
SaveSettings();
|
||||
output_start();
|
||||
}
|
||||
|
||||
void DecklinkOutputUI::StopOutput()
|
||||
{
|
||||
output_stop();
|
||||
}
|
||||
|
||||
void DecklinkOutputUI::PropertiesChanged()
|
||||
{
|
||||
SaveSettings();
|
||||
}
|
25
UI/frontend-plugins/decklink-output-ui/DecklinkOutputUI.h
Normal file
25
UI/frontend-plugins/decklink-output-ui/DecklinkOutputUI.h
Normal file
@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include "ui_output.h"
|
||||
#include "../../UI/properties-view.hpp"
|
||||
|
||||
class DecklinkOutputUI : public QDialog {
|
||||
Q_OBJECT
|
||||
private:
|
||||
OBSPropertiesView *propertiesView;
|
||||
|
||||
public slots:
|
||||
void StartOutput();
|
||||
void StopOutput();
|
||||
void PropertiesChanged();
|
||||
|
||||
public:
|
||||
std::unique_ptr<Ui_Output> ui;
|
||||
DecklinkOutputUI(QWidget *parent);
|
||||
|
||||
void ShowHideDialog();
|
||||
void SetupPropertiesView();
|
||||
void SaveSettings();
|
||||
};
|
0
UI/frontend-plugins/decklink-output-ui/data/.keepme
Normal file
0
UI/frontend-plugins/decklink-output-ui/data/.keepme
Normal file
93
UI/frontend-plugins/decklink-output-ui/decklink-ui-main.cpp
Normal file
93
UI/frontend-plugins/decklink-output-ui/decklink-ui-main.cpp
Normal file
@ -0,0 +1,93 @@
|
||||
#include <obs-module.h>
|
||||
#include <obs-frontend-api.h>
|
||||
#include <QMainWindow>
|
||||
#include <QAction>
|
||||
#include <util/util.hpp>
|
||||
#include <util/platform.h>
|
||||
#include "DecklinkOutputUI.h"
|
||||
|
||||
OBS_DECLARE_MODULE()
|
||||
OBS_MODULE_USE_DEFAULT_LOCALE("decklink-output-ui", "en-US")
|
||||
|
||||
DecklinkOutputUI *doUI;
|
||||
|
||||
bool main_output_running = false;
|
||||
|
||||
obs_output_t *output;
|
||||
|
||||
OBSData load_settings()
|
||||
{
|
||||
char *path = obs_module_get_config_path(obs_current_module(),
|
||||
"decklinkOutputProps.json");
|
||||
BPtr<char> jsonData = os_quick_read_utf8_file(path);
|
||||
if (!!jsonData) {
|
||||
obs_data_t *data = obs_data_create_from_json(jsonData);
|
||||
OBSData dataRet(data);
|
||||
obs_data_release(data);
|
||||
|
||||
return dataRet;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void output_start()
|
||||
{
|
||||
if (!main_output_running) {
|
||||
OBSData settings = load_settings();
|
||||
|
||||
if (settings != nullptr) {
|
||||
output = obs_output_create("decklink_output",
|
||||
"decklink_output", settings, NULL);
|
||||
|
||||
obs_output_start(output);
|
||||
obs_data_release(settings);
|
||||
|
||||
main_output_running = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void output_stop()
|
||||
{
|
||||
if (main_output_running) {
|
||||
obs_output_stop(output);
|
||||
obs_output_release(output);
|
||||
main_output_running = false;
|
||||
}
|
||||
}
|
||||
|
||||
void addOutputUI(void)
|
||||
{
|
||||
QAction *action = (QAction*)obs_frontend_add_tools_menu_qaction(
|
||||
obs_module_text("Decklink Output"));
|
||||
|
||||
QMainWindow *window = (QMainWindow*)obs_frontend_get_main_window();
|
||||
|
||||
doUI = new DecklinkOutputUI(window);
|
||||
|
||||
auto cb = []() {
|
||||
doUI->ShowHideDialog();
|
||||
};
|
||||
|
||||
action->connect(action, &QAction::triggered, cb);
|
||||
}
|
||||
|
||||
static void OBSEvent(enum obs_frontend_event event, void *)
|
||||
{
|
||||
if (event == OBS_FRONTEND_EVENT_FINISHED_LOADING) {
|
||||
OBSData settings = load_settings();
|
||||
|
||||
if (settings && obs_data_get_bool(settings, "auto_start"))
|
||||
output_start();
|
||||
}
|
||||
}
|
||||
|
||||
bool obs_module_load(void)
|
||||
{
|
||||
addOutputUI();
|
||||
|
||||
obs_frontend_add_event_callback(OBSEvent, nullptr);
|
||||
|
||||
return true;
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
void output_start();
|
||||
void output_stop();
|
||||
OBSData load_settings();
|
56
UI/frontend-plugins/decklink-output-ui/forms/output.ui
Normal file
56
UI/frontend-plugins/decklink-output-ui/forms/output.ui
Normal file
@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Output</class>
|
||||
<widget class="QDialog" name="Output">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>793</width>
|
||||
<height>292</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Decklink Output</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="verticalLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>10</y>
|
||||
<width>751</width>
|
||||
<height>221</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="propertiesLayout"/>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="startOutput">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>520</x>
|
||||
<y>250</y>
|
||||
<width>113</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Start</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="stopOutput">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>650</x>
|
||||
<y>250</y>
|
||||
<width>113</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Stop</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
x
Reference in New Issue
Block a user