frontend-plugins: Refactor Decklink out UI
This commit is contained in:
parent
ad1f74e312
commit
fa9dccb7be
@ -15,14 +15,6 @@ DecklinkOutputUI::DecklinkOutputUI(QWidget *parent)
|
||||
|
||||
propertiesView = nullptr;
|
||||
previewPropertiesView = nullptr;
|
||||
|
||||
connect(ui->startOutput, SIGNAL(released()), this, SLOT(StartOutput()));
|
||||
connect(ui->stopOutput, SIGNAL(released()), this, SLOT(StopOutput()));
|
||||
|
||||
connect(ui->startPreviewOutput, SIGNAL(released()), this,
|
||||
SLOT(StartPreviewOutput()));
|
||||
connect(ui->stopPreviewOutput, SIGNAL(released()), this,
|
||||
SLOT(StopPreviewOutput()));
|
||||
}
|
||||
|
||||
void DecklinkOutputUI::ShowHideDialog()
|
||||
@ -106,15 +98,10 @@ void DecklinkOutputUI::SavePreviewSettings()
|
||||
obs_data_save_json_safe(settings, path, "tmp", "bak");
|
||||
}
|
||||
|
||||
void DecklinkOutputUI::StartOutput()
|
||||
void DecklinkOutputUI::on_outputButton_clicked()
|
||||
{
|
||||
SaveSettings();
|
||||
output_start();
|
||||
}
|
||||
|
||||
void DecklinkOutputUI::StopOutput()
|
||||
{
|
||||
output_stop();
|
||||
output_toggle();
|
||||
}
|
||||
|
||||
void DecklinkOutputUI::PropertiesChanged()
|
||||
@ -126,24 +113,19 @@ void DecklinkOutputUI::OutputStateChanged(bool active)
|
||||
{
|
||||
QString text;
|
||||
if (active) {
|
||||
text = QString(obs_module_text("OutputState.Active"));
|
||||
text = QString(obs_module_text("Stop"));
|
||||
} else {
|
||||
text = QString(obs_module_text("OutputState.Idle"));
|
||||
text = QString(obs_module_text("Start"));
|
||||
}
|
||||
|
||||
QMetaObject::invokeMethod(ui->outputStatus, "setText",
|
||||
Q_ARG(QString, text));
|
||||
ui->outputButton->setChecked(active);
|
||||
ui->outputButton->setText(text);
|
||||
}
|
||||
|
||||
void DecklinkOutputUI::StartPreviewOutput()
|
||||
void DecklinkOutputUI::on_previewOutputButton_clicked()
|
||||
{
|
||||
SavePreviewSettings();
|
||||
preview_output_start();
|
||||
}
|
||||
|
||||
void DecklinkOutputUI::StopPreviewOutput()
|
||||
{
|
||||
preview_output_stop();
|
||||
preview_output_toggle();
|
||||
}
|
||||
|
||||
void DecklinkOutputUI::PreviewPropertiesChanged()
|
||||
@ -155,11 +137,11 @@ void DecklinkOutputUI::PreviewOutputStateChanged(bool active)
|
||||
{
|
||||
QString text;
|
||||
if (active) {
|
||||
text = QString(obs_module_text("OutputState.Active"));
|
||||
text = QString(obs_module_text("Stop"));
|
||||
} else {
|
||||
text = QString(obs_module_text("OutputState.Idle"));
|
||||
text = QString(obs_module_text("Start"));
|
||||
}
|
||||
|
||||
QMetaObject::invokeMethod(ui->previewOutputStatus, "setText",
|
||||
Q_ARG(QString, text));
|
||||
ui->previewOutputButton->setChecked(active);
|
||||
ui->previewOutputButton->setText(text);
|
||||
}
|
||||
|
@ -12,16 +12,12 @@ private:
|
||||
OBSPropertiesView *previewPropertiesView;
|
||||
|
||||
public slots:
|
||||
void StartOutput();
|
||||
void StopOutput();
|
||||
void on_outputButton_clicked();
|
||||
void PropertiesChanged();
|
||||
|
||||
void OutputStateChanged(bool);
|
||||
|
||||
void StartPreviewOutput();
|
||||
void StopPreviewOutput();
|
||||
void on_previewOutputButton_clicked();
|
||||
void PreviewPropertiesChanged();
|
||||
|
||||
void PreviewOutputStateChanged(bool);
|
||||
|
||||
public:
|
||||
|
@ -51,34 +51,40 @@ OBSData load_settings()
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void output_stop()
|
||||
{
|
||||
obs_output_stop(output);
|
||||
obs_output_release(output);
|
||||
main_output_running = false;
|
||||
doUI->OutputStateChanged(false);
|
||||
}
|
||||
|
||||
void output_start()
|
||||
{
|
||||
if (!main_output_running) {
|
||||
OBSData settings = load_settings();
|
||||
OBSData settings = load_settings();
|
||||
|
||||
if (settings != nullptr) {
|
||||
output = obs_output_create("decklink_output",
|
||||
"decklink_output", settings,
|
||||
NULL);
|
||||
if (settings != nullptr) {
|
||||
output = obs_output_create("decklink_output", "decklink_output",
|
||||
settings, NULL);
|
||||
|
||||
obs_output_start(output);
|
||||
obs_data_release(settings);
|
||||
bool started = obs_output_start(output);
|
||||
obs_data_release(settings);
|
||||
|
||||
main_output_running = true;
|
||||
main_output_running = started;
|
||||
|
||||
doUI->OutputStateChanged(true);
|
||||
}
|
||||
doUI->OutputStateChanged(started);
|
||||
|
||||
if (!started)
|
||||
output_stop();
|
||||
}
|
||||
}
|
||||
|
||||
void output_stop()
|
||||
void output_toggle()
|
||||
{
|
||||
if (main_output_running) {
|
||||
obs_output_stop(output);
|
||||
obs_output_release(output);
|
||||
main_output_running = false;
|
||||
doUI->OutputStateChanged(false);
|
||||
}
|
||||
if (main_output_running)
|
||||
output_stop();
|
||||
else
|
||||
output_start();
|
||||
}
|
||||
|
||||
OBSData load_preview_settings()
|
||||
@ -100,90 +106,93 @@ OBSData load_preview_settings()
|
||||
void on_preview_scene_changed(enum obs_frontend_event event, void *param);
|
||||
void render_preview_source(void *param, uint32_t cx, uint32_t cy);
|
||||
|
||||
void preview_output_stop()
|
||||
{
|
||||
obs_output_stop(context.output);
|
||||
obs_output_release(context.output);
|
||||
video_output_stop(context.video_queue);
|
||||
|
||||
obs_remove_main_render_callback(render_preview_source, &context);
|
||||
obs_frontend_remove_event_callback(on_preview_scene_changed, &context);
|
||||
|
||||
obs_source_release(context.current_source);
|
||||
|
||||
obs_enter_graphics();
|
||||
gs_stagesurface_destroy(context.stagesurface);
|
||||
gs_texrender_destroy(context.texrender);
|
||||
obs_leave_graphics();
|
||||
|
||||
video_output_close(context.video_queue);
|
||||
|
||||
preview_output_running = false;
|
||||
doUI->PreviewOutputStateChanged(false);
|
||||
}
|
||||
|
||||
void preview_output_start()
|
||||
{
|
||||
if (!preview_output_running) {
|
||||
OBSData settings = load_preview_settings();
|
||||
OBSData settings = load_preview_settings();
|
||||
|
||||
if (settings != nullptr) {
|
||||
context.output = obs_output_create(
|
||||
"decklink_output", "decklink_preview_output",
|
||||
settings, NULL);
|
||||
if (settings != nullptr) {
|
||||
context.output = obs_output_create("decklink_output",
|
||||
"decklink_preview_output",
|
||||
settings, NULL);
|
||||
|
||||
obs_get_video_info(&context.ovi);
|
||||
obs_get_video_info(&context.ovi);
|
||||
|
||||
uint32_t width = context.ovi.base_width;
|
||||
uint32_t height = context.ovi.base_height;
|
||||
uint32_t width = context.ovi.base_width;
|
||||
uint32_t height = context.ovi.base_height;
|
||||
|
||||
obs_enter_graphics();
|
||||
context.texrender =
|
||||
gs_texrender_create(GS_BGRA, GS_ZS_NONE);
|
||||
context.stagesurface =
|
||||
gs_stagesurface_create(width, height, GS_BGRA);
|
||||
obs_leave_graphics();
|
||||
obs_enter_graphics();
|
||||
context.texrender = gs_texrender_create(GS_BGRA, GS_ZS_NONE);
|
||||
context.stagesurface =
|
||||
gs_stagesurface_create(width, height, GS_BGRA);
|
||||
obs_leave_graphics();
|
||||
|
||||
const video_output_info *mainVOI =
|
||||
video_output_get_info(obs_get_video());
|
||||
const video_output_info *mainVOI =
|
||||
video_output_get_info(obs_get_video());
|
||||
|
||||
video_output_info vi = {0};
|
||||
vi.format = VIDEO_FORMAT_BGRA;
|
||||
vi.width = width;
|
||||
vi.height = height;
|
||||
vi.fps_den = context.ovi.fps_den;
|
||||
vi.fps_num = context.ovi.fps_num;
|
||||
vi.cache_size = 16;
|
||||
vi.colorspace = mainVOI->colorspace;
|
||||
vi.range = mainVOI->range;
|
||||
vi.name = "decklink_preview_output";
|
||||
video_output_info vi = {0};
|
||||
vi.format = VIDEO_FORMAT_BGRA;
|
||||
vi.width = width;
|
||||
vi.height = height;
|
||||
vi.fps_den = context.ovi.fps_den;
|
||||
vi.fps_num = context.ovi.fps_num;
|
||||
vi.cache_size = 16;
|
||||
vi.colorspace = mainVOI->colorspace;
|
||||
vi.range = mainVOI->range;
|
||||
vi.name = "decklink_preview_output";
|
||||
|
||||
video_output_open(&context.video_queue, &vi);
|
||||
video_output_open(&context.video_queue, &vi);
|
||||
|
||||
obs_frontend_add_event_callback(
|
||||
on_preview_scene_changed, &context);
|
||||
if (obs_frontend_preview_program_mode_active()) {
|
||||
context.current_source =
|
||||
obs_frontend_get_current_preview_scene();
|
||||
} else {
|
||||
context.current_source =
|
||||
obs_frontend_get_current_scene();
|
||||
}
|
||||
obs_add_main_render_callback(render_preview_source,
|
||||
&context);
|
||||
|
||||
obs_output_set_media(context.output,
|
||||
context.video_queue,
|
||||
obs_get_audio());
|
||||
obs_output_start(context.output);
|
||||
|
||||
preview_output_running = true;
|
||||
doUI->PreviewOutputStateChanged(true);
|
||||
obs_frontend_add_event_callback(on_preview_scene_changed,
|
||||
&context);
|
||||
if (obs_frontend_preview_program_mode_active()) {
|
||||
context.current_source =
|
||||
obs_frontend_get_current_preview_scene();
|
||||
} else {
|
||||
context.current_source =
|
||||
obs_frontend_get_current_scene();
|
||||
}
|
||||
obs_add_main_render_callback(render_preview_source, &context);
|
||||
|
||||
obs_output_set_media(context.output, context.video_queue,
|
||||
obs_get_audio());
|
||||
bool started = obs_output_start(context.output);
|
||||
|
||||
preview_output_running = started;
|
||||
doUI->PreviewOutputStateChanged(started);
|
||||
|
||||
if (!started)
|
||||
preview_output_stop();
|
||||
}
|
||||
}
|
||||
|
||||
void preview_output_stop()
|
||||
void preview_output_toggle()
|
||||
{
|
||||
if (preview_output_running) {
|
||||
obs_output_stop(context.output);
|
||||
video_output_stop(context.video_queue);
|
||||
|
||||
obs_remove_main_render_callback(render_preview_source,
|
||||
&context);
|
||||
obs_frontend_remove_event_callback(on_preview_scene_changed,
|
||||
&context);
|
||||
|
||||
obs_source_release(context.current_source);
|
||||
|
||||
obs_enter_graphics();
|
||||
gs_stagesurface_destroy(context.stagesurface);
|
||||
gs_texrender_destroy(context.texrender);
|
||||
obs_leave_graphics();
|
||||
|
||||
video_output_close(context.video_queue);
|
||||
|
||||
preview_output_running = false;
|
||||
doUI->PreviewOutputStateChanged(false);
|
||||
}
|
||||
if (preview_output_running)
|
||||
preview_output_stop();
|
||||
else
|
||||
preview_output_start();
|
||||
}
|
||||
|
||||
void on_preview_scene_changed(enum obs_frontend_event event, void *param)
|
||||
|
@ -1,8 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
void output_start();
|
||||
void output_stop();
|
||||
void output_toggle();
|
||||
OBSData load_settings();
|
||||
void preview_output_start();
|
||||
void preview_output_stop();
|
||||
OBSData load_preview_settings();
|
||||
void preview_output_toggle();
|
||||
OBSData load_preview_settings();
|
||||
|
@ -58,23 +58,12 @@
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="outputStatus">
|
||||
<property name="text">
|
||||
<string>OutputState.Idle</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="startOutput">
|
||||
<widget class="QPushButton" name="outputButton">
|
||||
<property name="text">
|
||||
<string>Start</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="stopOutput">
|
||||
<property name="text">
|
||||
<string>Stop</string>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -106,28 +95,30 @@
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="previewOutputStatus">
|
||||
<property name="text">
|
||||
<string>OutputState.Idle</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="startPreviewOutput">
|
||||
<widget class="QPushButton" name="previewOutputButton">
|
||||
<property name="text">
|
||||
<string>Start</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="stopPreviewOutput">
|
||||
<property name="text">
|
||||
<string>Stop</string>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="keyerLabel">
|
||||
<property name="text">
|
||||
|
Loading…
x
Reference in New Issue
Block a user