New upstream version 26.1.0+dfsg1
This commit is contained in:
parent
040dcc3fc2
commit
013818c4af
594 changed files with 19576 additions and 4478 deletions
44
UI/frontend-plugins/decklink-captions/CMakeLists.txt
Normal file
44
UI/frontend-plugins/decklink-captions/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
project(decklink-captions)
|
||||
|
||||
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-captions_HEADERS
|
||||
decklink-captions.h
|
||||
)
|
||||
set(decklink-captions_SOURCES
|
||||
decklink-captions.cpp
|
||||
)
|
||||
set(decklink-captions_UI
|
||||
forms/captions.ui
|
||||
)
|
||||
|
||||
if(APPLE)
|
||||
set(decklink-captions_PLATFORM_LIBS
|
||||
${COCOA})
|
||||
endif()
|
||||
|
||||
qt5_wrap_ui(decklink-captions_UI_HEADERS
|
||||
${decklink-captions_UI})
|
||||
|
||||
add_library(decklink-captions MODULE
|
||||
${decklink-captions_HEADERS}
|
||||
${decklink-captions_SOURCES}
|
||||
${decklink-captions_UI_HEADERS}
|
||||
)
|
||||
target_link_libraries(decklink-captions
|
||||
${frontend-tools_PLATFORM_LIBS}
|
||||
obs-frontend-api
|
||||
Qt5::Widgets
|
||||
libobs)
|
||||
set_target_properties(decklink-captions PROPERTIES FOLDER "plugins/decklink")
|
||||
|
||||
install_obs_plugin_with_data(decklink-captions data)
|
||||
0
UI/frontend-plugins/decklink-captions/data/.keepme
Normal file
0
UI/frontend-plugins/decklink-captions/data/.keepme
Normal file
159
UI/frontend-plugins/decklink-captions/decklink-captions.cpp
Normal file
159
UI/frontend-plugins/decklink-captions/decklink-captions.cpp
Normal file
|
|
@ -0,0 +1,159 @@
|
|||
#include <obs-frontend-api.h>
|
||||
#include <QMainWindow>
|
||||
#include <QAction>
|
||||
#include <obs.hpp>
|
||||
#include "decklink-captions.h"
|
||||
|
||||
OBS_DECLARE_MODULE()
|
||||
OBS_MODULE_USE_DEFAULT_LOCALE("decklink-captons", "en-US")
|
||||
|
||||
struct obs_captions {
|
||||
std::string source_name;
|
||||
OBSWeakSource source;
|
||||
|
||||
void start();
|
||||
void stop();
|
||||
|
||||
obs_captions();
|
||||
inline ~obs_captions() { stop(); }
|
||||
};
|
||||
|
||||
obs_captions::obs_captions() {}
|
||||
|
||||
static obs_captions *captions = nullptr;
|
||||
|
||||
DecklinkCaptionsUI::DecklinkCaptionsUI(QWidget *parent)
|
||||
: QDialog(parent), ui(new Ui_CaptionsDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
setSizeGripEnabled(true);
|
||||
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
|
||||
auto cb = [this](obs_source_t *source) {
|
||||
uint32_t caps = obs_source_get_output_flags(source);
|
||||
QString name = obs_source_get_name(source);
|
||||
|
||||
if (caps & OBS_SOURCE_CEA_708)
|
||||
ui->source->addItem(name);
|
||||
|
||||
OBSWeakSource weak = OBSGetWeakRef(source);
|
||||
if (weak == captions->source)
|
||||
ui->source->setCurrentText(name);
|
||||
return true;
|
||||
};
|
||||
|
||||
using cb_t = decltype(cb);
|
||||
|
||||
ui->source->blockSignals(true);
|
||||
ui->source->addItem(QStringLiteral(""));
|
||||
ui->source->setCurrentIndex(0);
|
||||
obs_enum_sources(
|
||||
[](void *data, obs_source_t *source) {
|
||||
return (*static_cast<cb_t *>(data))(source);
|
||||
},
|
||||
&cb);
|
||||
ui->source->blockSignals(false);
|
||||
}
|
||||
|
||||
void DecklinkCaptionsUI::on_source_currentIndexChanged(int)
|
||||
{
|
||||
captions->stop();
|
||||
|
||||
captions->source_name = ui->source->currentText().toUtf8().constData();
|
||||
captions->source = GetWeakSourceByName(captions->source_name.c_str());
|
||||
|
||||
captions->start();
|
||||
}
|
||||
|
||||
static void caption_callback(void *param, obs_source_t *source,
|
||||
const struct obs_source_cea_708 *captions)
|
||||
{
|
||||
UNUSED_PARAMETER(param);
|
||||
UNUSED_PARAMETER(source);
|
||||
obs_output *output = obs_frontend_get_streaming_output();
|
||||
if (output) {
|
||||
if (obs_frontend_streaming_active() &&
|
||||
obs_output_active(output)) {
|
||||
obs_output_caption(output, captions);
|
||||
}
|
||||
obs_output_release(output);
|
||||
}
|
||||
}
|
||||
|
||||
void obs_captions::start()
|
||||
{
|
||||
OBSSource s = OBSGetStrongRef(source);
|
||||
if (!s) {
|
||||
//warn("Source invalid");
|
||||
return;
|
||||
}
|
||||
obs_source_add_caption_callback(s, caption_callback, nullptr);
|
||||
}
|
||||
|
||||
void obs_captions::stop()
|
||||
{
|
||||
OBSSource s = OBSGetStrongRef(source);
|
||||
if (s)
|
||||
obs_source_remove_caption_callback(s, caption_callback,
|
||||
nullptr);
|
||||
}
|
||||
|
||||
static void save_decklink_caption_data(obs_data_t *save_data, bool saving,
|
||||
void *)
|
||||
{
|
||||
if (saving) {
|
||||
obs_data_t *obj = obs_data_create();
|
||||
|
||||
obs_data_set_string(obj, "source",
|
||||
captions->source_name.c_str());
|
||||
|
||||
obs_data_set_obj(save_data, "decklink_captions", obj);
|
||||
obs_data_release(obj);
|
||||
} else {
|
||||
captions->stop();
|
||||
|
||||
obs_data_t *obj =
|
||||
obs_data_get_obj(save_data, "decklink_captions");
|
||||
if (!obj)
|
||||
obj = obs_data_create();
|
||||
|
||||
captions->source_name = obs_data_get_string(obj, "source");
|
||||
captions->source =
|
||||
GetWeakSourceByName(captions->source_name.c_str());
|
||||
obs_data_release(obj);
|
||||
|
||||
captions->start();
|
||||
}
|
||||
}
|
||||
|
||||
void addOutputUI(void)
|
||||
{
|
||||
QAction *action = (QAction *)obs_frontend_add_tools_menu_qaction(
|
||||
obs_module_text("Decklink Captions"));
|
||||
|
||||
captions = new obs_captions;
|
||||
|
||||
auto cb = []() {
|
||||
obs_frontend_push_ui_translation(obs_module_get_string);
|
||||
|
||||
QWidget *window = (QWidget *)obs_frontend_get_main_window();
|
||||
|
||||
DecklinkCaptionsUI dialog(window);
|
||||
dialog.exec();
|
||||
|
||||
obs_frontend_pop_ui_translation();
|
||||
};
|
||||
|
||||
obs_frontend_add_save_callback(save_decklink_caption_data, nullptr);
|
||||
|
||||
action->connect(action, &QAction::triggered, cb);
|
||||
}
|
||||
|
||||
bool obs_module_load(void)
|
||||
{
|
||||
addOutputUI();
|
||||
|
||||
return true;
|
||||
}
|
||||
30
UI/frontend-plugins/decklink-captions/decklink-captions.h
Normal file
30
UI/frontend-plugins/decklink-captions/decklink-captions.h
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#include <QDialog>
|
||||
#include <obs-module.h>
|
||||
#include <util/platform.h>
|
||||
#include <obs.hpp>
|
||||
#include <memory>
|
||||
#include "ui_captions.h"
|
||||
|
||||
class DecklinkCaptionsUI : public QDialog {
|
||||
Q_OBJECT
|
||||
private:
|
||||
public:
|
||||
std::unique_ptr<Ui_CaptionsDialog> ui;
|
||||
DecklinkCaptionsUI(QWidget *parent);
|
||||
|
||||
public slots:
|
||||
void on_source_currentIndexChanged(int idx);
|
||||
};
|
||||
|
||||
static inline OBSWeakSource GetWeakSourceByName(const char *name)
|
||||
{
|
||||
OBSWeakSource weak;
|
||||
obs_source_t *source = obs_get_source_by_name(name);
|
||||
if (source) {
|
||||
weak = obs_source_get_weak_source(source);
|
||||
obs_weak_source_release(weak);
|
||||
obs_source_release(source);
|
||||
}
|
||||
|
||||
return weak;
|
||||
}
|
||||
115
UI/frontend-plugins/decklink-captions/forms/captions.ui
Normal file
115
UI/frontend-plugins/decklink-captions/forms/captions.ui
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CaptionsDialog</class>
|
||||
<widget class="QDialog" name="CaptionsDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>519</width>
|
||||
<height>104</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Captions</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="labelAlignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Captions.Source</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>source</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="source">
|
||||
<property name="insertPolicy">
|
||||
<enum>QComboBox::InsertAlphabetically</enum>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToContents</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="accept">
|
||||
<property name="text">
|
||||
<string>OK</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>accept</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>CaptionsDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>268</x>
|
||||
<y>331</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>229</x>
|
||||
<y>-11</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
Loading…
Add table
Add a link
Reference in a new issue