Paul Hindt ce3ae8e423
aja: Capture and Output plugin for AJA Video Systems IO devices
* aja: Initial commit of AJA capture/output plugin

* aja: Fix clang-format on aja-output-ui code

* aja: Remove script used during dev/testing

* aja: Address pull request feedback from @RytoEX

* aja: Remove the SDK sources and update CMakeLists to point to new headers-only/static libs dependency distribution.

* aja: Only build AJA plugin on x64 on macOS for now

* aja: Remove the non-English placeholder locale files. The english strings/files will be produced via crowdin, according to @ddrboxman.

* aja: Add FindLibAJANTV2.cmake script to locate the ajantv2 headers and static libs in the OBS external deps package(s). Tested on Windows x64. macOS and Linux x64 TBD.

* aja: Add ajantv2/includes to FindLibAJANTV2 include search paths

* aja: Remove commented code from aja CMakeLists

* aja: Remove debug code and comments that are no longer needed.

* aja: Fix indentation

* aja: Remove disablement of clang-format in routing table and SDIWireFormat map

* aja: Use spaces for all indentation in widget crosspoint arrays where we disable clang-format

* aja: Address code style comments made by @RytoEX

* aja: Fix uneven indentation

* aja: More fixes to if/else placement and remove superfluous comments.

* aja: Rename 'dwns' to 'deactivateWhileNotShowing' for clarity. The DeckLink plugin still uses the variable name 'dwns' and should be changed, if desired, in a separate PR.

* aja: Remove X11Extras dependency from AJA Output frontend plugin

* aja: Add patch from Jim to find AJA release/debug libs

* aja: Improve AV sync of queued video/audio sent to the AJA card in the AJA Output plugin.
2021-11-23 20:31:11 -06:00

170 lines
4.4 KiB
C++

#include "AJAOutputUI.h"
#include "aja-ui-main.h"
#include "../../../plugins/aja/aja-ui-props.hpp"
#include "../../../plugins/aja/aja-enums.hpp"
#include <ajantv2/includes/ntv2enums.h>
#include <obs-module.h>
#include <util/platform.h>
#include <util/util.hpp>
AJAOutputUI::AJAOutputUI(QWidget *parent) : QDialog(parent), ui(new Ui_Output)
{
ui->setupUi(this);
setSizeGripEnabled(true);
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
propertiesView = nullptr;
previewPropertiesView = nullptr;
}
void AJAOutputUI::ShowHideDialog()
{
SetupPropertiesView();
SetupPreviewPropertiesView();
setVisible(!isVisible());
}
void AJAOutputUI::SetupPropertiesView()
{
if (propertiesView)
delete propertiesView;
obs_data_t *settings = obs_data_create();
OBSData data = load_settings(kProgramPropsFilename);
if (data) {
obs_data_apply(settings, data);
} else {
// apply default settings
obs_data_set_int(settings, kUIPropOutput.id,
static_cast<long long>(IOSelection::Invalid));
obs_data_set_int(settings, kUIPropVideoFormatSelect.id,
static_cast<long long>(NTV2_FORMAT_720p_5994));
obs_data_set_int(settings, kUIPropPixelFormatSelect.id,
static_cast<long long>(NTV2_FBF_8BIT_YCBCR));
obs_data_set_int(settings, kUIPropSDI4KTransport.id,
static_cast<long long>(
SDI4KTransport::TwoSampleInterleave));
}
// Assign an ID to the program output plugin instance for channel usage tracking
obs_data_set_string(settings, kUIPropAJAOutputID.id, kProgramOutputID);
propertiesView = new OBSPropertiesView(
settings, "aja_output",
(PropertiesReloadCallback)obs_get_output_properties, 170);
ui->propertiesLayout->addWidget(propertiesView);
obs_data_release(settings);
connect(propertiesView, SIGNAL(Changed()), this,
SLOT(PropertiesChanged()));
}
void AJAOutputUI::SaveSettings(const char *filename, obs_data_t *settings)
{
BPtr<char> modulePath =
obs_module_get_config_path(obs_current_module(), "");
os_mkdirs(modulePath);
BPtr<char> path =
obs_module_get_config_path(obs_current_module(), filename);
if (settings)
obs_data_save_json_safe(settings, path, "tmp", "bak");
}
void AJAOutputUI::SetupPreviewPropertiesView()
{
if (previewPropertiesView)
delete previewPropertiesView;
obs_data_t *settings = obs_data_create();
OBSData data = load_settings(kPreviewPropsFilename);
if (data) {
obs_data_apply(settings, data);
} else {
// apply default settings
obs_data_set_int(settings, kUIPropOutput.id,
static_cast<long long>(IOSelection::Invalid));
obs_data_set_int(settings, kUIPropVideoFormatSelect.id,
static_cast<long long>(NTV2_FORMAT_720p_5994));
obs_data_set_int(settings, kUIPropPixelFormatSelect.id,
static_cast<long long>(NTV2_FBF_8BIT_YCBCR));
obs_data_set_int(settings, kUIPropSDI4KTransport.id,
static_cast<long long>(
SDI4KTransport::TwoSampleInterleave));
}
// Assign an ID to the program output plugin instance for channel usage tracking
obs_data_set_string(settings, kUIPropAJAOutputID.id, kPreviewOutputID);
previewPropertiesView = new OBSPropertiesView(
settings, "aja_output",
(PropertiesReloadCallback)obs_get_output_properties, 170);
ui->previewPropertiesLayout->addWidget(previewPropertiesView);
obs_data_release(settings);
connect(previewPropertiesView, SIGNAL(Changed()), this,
SLOT(PreviewPropertiesChanged()));
}
void AJAOutputUI::on_outputButton_clicked()
{
SaveSettings(kProgramPropsFilename, propertiesView->GetSettings());
output_toggle();
}
void AJAOutputUI::PropertiesChanged()
{
SaveSettings(kProgramPropsFilename, propertiesView->GetSettings());
}
void AJAOutputUI::OutputStateChanged(bool active)
{
QString text;
if (active) {
text = QString(obs_module_text("Stop"));
} else {
text = QString(obs_module_text("Start"));
}
ui->outputButton->setChecked(active);
ui->outputButton->setText(text);
}
void AJAOutputUI::on_previewOutputButton_clicked()
{
SaveSettings(kPreviewPropsFilename,
previewPropertiesView->GetSettings());
preview_output_toggle();
}
void AJAOutputUI::PreviewPropertiesChanged()
{
SaveSettings(kPreviewPropsFilename,
previewPropertiesView->GetSettings());
}
void AJAOutputUI::PreviewOutputStateChanged(bool active)
{
QString text;
if (active) {
text = QString(obs_module_text("Stop"));
} else {
text = QString(obs_module_text("Start"));
}
ui->previewOutputButton->setChecked(active);
ui->previewOutputButton->setText(text);
}