Don't show video encoder index for vertical

This commit is contained in:
Exeldro 2024-08-02 08:01:36 +02:00
parent 07c83f9ef4
commit 4c9442e7bf
No known key found for this signature in database
GPG Key ID: 97269A83FC715751
3 changed files with 64 additions and 64 deletions

View File

@ -179,12 +179,12 @@ OBSBasicSettings::OBSBasicSettings(QMainWindow *parent) : QDialog(parent)
scrollArea->setWidgetResizable(true); scrollArea->setWidgetResizable(true);
scrollArea->setLineWidth(0); scrollArea->setLineWidth(0);
scrollArea->setFrameShape(QFrame::NoFrame); scrollArea->setFrameShape(QFrame::NoFrame);
auto helpInfoBox = ConfigUtils::generateSettingsGroupBox(QString::fromUtf8(obs_module_text("HelpTitle"))); auto helpInfoBox = ConfigUtils::generateSettingsGroupBox(QString::fromUtf8(obs_module_text("HelpTitle")));
helpInfoBox->setStyleSheet("padding-top: 12px"); helpInfoBox->setStyleSheet("padding-top: 12px");
auto helpLayout = new QVBoxLayout; auto helpLayout = new QVBoxLayout;
helpInfoBox->setLayout(helpLayout); helpInfoBox->setLayout(helpLayout);
auto helpLabel = new QLabel(QString::fromUtf8(obs_module_text("HelpText"))); auto helpLabel = new QLabel(QString::fromUtf8(obs_module_text("HelpText")));
helpLabel->setStyleSheet("font-size: 14px"); helpLabel->setStyleSheet("font-size: 14px");
helpLabel->setWordWrap(true); helpLabel->setWordWrap(true);
@ -192,9 +192,8 @@ OBSBasicSettings::OBSBasicSettings(QMainWindow *parent) : QDialog(parent)
helpLabel->setOpenExternalLinks(true); helpLabel->setOpenExternalLinks(true);
helpLayout->addWidget(helpLabel, 1); helpLayout->addWidget(helpLabel, 1);
helpPageLayout->addWidget(helpInfoBox, 1, Qt::AlignTop); helpPageLayout->addWidget(helpInfoBox, 1, Qt::AlignTop);
settingsPages->addWidget(scrollArea); settingsPages->addWidget(scrollArea);
//mainOutputsPage //mainOutputsPage
@ -215,17 +214,15 @@ OBSBasicSettings::OBSBasicSettings(QMainWindow *parent) : QDialog(parent)
connect(addButton, &QPushButton::clicked, [this] { connect(addButton, &QPushButton::clicked, [this] {
QStringList otherNames; QStringList otherNames;
auto outputs = obs_data_get_array(settings, "outputs"); auto outputs = obs_data_get_array(main_settings, "outputs");
obs_data_array_enum( obs_data_array_enum(
outputs, outputs,
[](obs_data_t *data, void *param) { [](obs_data_t *data2, void *param) {
auto otherNames = (QStringList *)param; ((QStringList *)param)->append(QString::fromUtf8(obs_data_get_string(data2, "name")));
otherNames->append(QString::fromUtf8(obs_data_get_string(data, "name")));
}, },
&otherNames); &otherNames);
obs_data_array_release(outputs); obs_data_array_release(outputs);
otherNames.removeDuplicates(); otherNames.removeDuplicates();
otherNames.removeOne(QString::fromUtf8(obs_data_get_string(settings, "name")));
auto outputDialog = new OutputDialog(this, otherNames); auto outputDialog = new OutputDialog(this, otherNames);
outputDialog->setWindowModality(Qt::WindowModal); outputDialog->setWindowModality(Qt::WindowModal);
@ -233,12 +230,12 @@ OBSBasicSettings::OBSBasicSettings(QMainWindow *parent) : QDialog(parent)
if (outputDialog->exec() == QDialog::Accepted) { if (outputDialog->exec() == QDialog::Accepted) {
// create a new output // create a new output
if (!settings) if (!main_settings)
return; return;
auto outputs = obs_data_get_array(settings, "outputs"); auto outputs = obs_data_get_array(main_settings, "outputs");
if (!outputs) { if (!outputs) {
outputs = obs_data_array_create(); outputs = obs_data_array_create();
obs_data_set_array(settings, "outputs", outputs); obs_data_set_array(main_settings, "outputs", outputs);
} }
auto s = obs_data_create(); auto s = obs_data_create();
@ -315,13 +312,11 @@ OBSBasicSettings::OBSBasicSettings(QMainWindow *parent) : QDialog(parent)
QStringList otherNames; QStringList otherNames;
obs_data_array_enum( obs_data_array_enum(
vertical_outputs, vertical_outputs,
[](obs_data_t *data, void *param) { [](obs_data_t *data2, void *param) {
auto otherNames = (QStringList *)param; ((QStringList *)param)->append(QString::fromUtf8(obs_data_get_string(data2, "name")));
otherNames->append(QString::fromUtf8(obs_data_get_string(data, "name")));
}, },
&otherNames); &otherNames);
otherNames.removeDuplicates(); otherNames.removeDuplicates();
otherNames.removeOne(QString::fromUtf8(obs_data_get_string(settings, "name")));
auto outputDialog = new OutputDialog(this, otherNames); auto outputDialog = new OutputDialog(this, otherNames);
outputDialog->setWindowModality(Qt::WindowModal); outputDialog->setWindowModality(Qt::WindowModal);
@ -595,29 +590,34 @@ void OBSBasicSettings::AddServer(QFormLayout *outputsLayout, obs_data_t *setting
videoEncoder->setCurrentIndex(0); videoEncoder->setCurrentIndex(0);
videoPageLayout->addRow(QString::fromUtf8(obs_module_text("VideoEncoder")), videoEncoder); videoPageLayout->addRow(QString::fromUtf8(obs_module_text("VideoEncoder")), videoEncoder);
const bool main = outputsLayout == mainOutputsLayout;
bool allEmpty = false; bool allEmpty = false;
auto videoEncoderIndex = new QComboBox; QComboBox *videoEncoderIndex = nullptr;
for (int i = 0; i < MAX_OUTPUT_VIDEO_ENCODERS; i++) { if (main) {
QString settingName = QString::fromUtf8("video_encoder_description") + QString::number(i); videoEncoderIndex = new QComboBox;
auto description = obs_data_get_string(this->settings, settingName.toUtf8().constData()); for (int i = 0; i < MAX_OUTPUT_VIDEO_ENCODERS; i++) {
if (!description || description[0] == '\0') { QString settingName = QString::fromUtf8("video_encoder_description") + QString::number(i);
if (i != 0 && !allEmpty) { auto description = obs_data_get_string(main_settings, settingName.toUtf8().constData());
break; if (!description || description[0] == '\0') {
if (i != 0 && !allEmpty) {
break;
}
allEmpty = true;
} }
allEmpty = true; videoEncoderIndex->addItem(QString::number(i + 1) + " " + description);
} }
videoEncoderIndex->addItem(QString::number(i + 1) + " " + description); videoEncoderIndex->setCurrentIndex((int)obs_data_get_int(settings, "video_encoder_index"));
}
videoEncoderIndex->setCurrentIndex(obs_data_get_int(settings, "video_encoder_index"));
connect(videoEncoderIndex, &QComboBox::currentIndexChanged, [videoEncoderIndex, settings] {
if (videoEncoderIndex->currentIndex() >= 0)
obs_data_set_int(settings, "video_encoder_index", videoEncoderIndex->currentIndex());
});
videoPageLayout->addRow(QString::fromUtf8(obs_module_text("VideoEncoderIndex")), videoEncoderIndex);
if (videoEncoderIndex->currentIndex() != 0 || connect(videoEncoderIndex, &QComboBox::currentIndexChanged, [videoEncoderIndex, settings] {
!config_get_bool(obs_frontend_get_profile_config(), "Stream1", "EnableMultitrackVideo")) if (videoEncoderIndex->currentIndex() >= 0)
videoPageLayout->setRowVisible(videoEncoderIndex, false); obs_data_set_int(settings, "video_encoder_index", videoEncoderIndex->currentIndex());
});
videoPageLayout->addRow(QString::fromUtf8(obs_module_text("VideoEncoderIndex")), videoEncoderIndex);
if (videoEncoderIndex->currentIndex() != 0 ||
!config_get_bool(obs_frontend_get_profile_config(), "Stream1", "EnableMultitrackVideo"))
videoPageLayout->setRowVisible(videoEncoderIndex, false);
}
auto videoEncoderGroup = new QWidget(); auto videoEncoderGroup = new QWidget();
videoEncoderGroup->setProperty("altColor", QVariant(true)); videoEncoderGroup->setProperty("altColor", QVariant(true));
@ -625,7 +625,6 @@ void OBSBasicSettings::AddServer(QFormLayout *outputsLayout, obs_data_t *setting
videoEncoderGroup->setLayout(videoEncoderGroupLayout); videoEncoderGroup->setLayout(videoEncoderGroupLayout);
videoPageLayout->addRow(videoEncoderGroup); videoPageLayout->addRow(videoEncoderGroup);
const bool main = outputsLayout == mainOutputsLayout;
if (main) { if (main) {
struct obs_video_info ovi; struct obs_video_info ovi;
obs_get_video_info(&ovi); obs_get_video_info(&ovi);
@ -723,7 +722,8 @@ void OBSBasicSettings::AddServer(QFormLayout *outputsLayout, obs_data_t *setting
auto encoder = encoder_string.constData(); auto encoder = encoder_string.constData();
obs_data_set_string(settings, "video_encoder", encoder); obs_data_set_string(settings, "video_encoder", encoder);
if (!encoder || encoder[0] == '\0') { if (!encoder || encoder[0] == '\0') {
if (config_get_bool(obs_frontend_get_profile_config(), "Stream1", "EnableMultitrackVideo")) { if (!videoEncoderIndex) {
} else if (config_get_bool(obs_frontend_get_profile_config(), "Stream1", "EnableMultitrackVideo")) {
videoPageLayout->setRowVisible(videoEncoderIndex, true); videoPageLayout->setRowVisible(videoEncoderIndex, true);
} else { } else {
videoPageLayout->setRowVisible(videoEncoderIndex, false); videoPageLayout->setRowVisible(videoEncoderIndex, false);
@ -732,7 +732,8 @@ void OBSBasicSettings::AddServer(QFormLayout *outputsLayout, obs_data_t *setting
} }
videoEncoderGroup->setVisible(false); videoEncoderGroup->setVisible(false);
} else { } else {
videoPageLayout->setRowVisible(videoEncoderIndex, false); if (videoEncoderIndex)
videoPageLayout->setRowVisible(videoEncoderIndex, false);
if (!videoEncoderGroup->isVisibleTo(videoPage)) if (!videoEncoderGroup->isVisibleTo(videoPage))
videoEncoderGroup->setVisible(true); videoEncoderGroup->setVisible(true);
auto t = video_encoder_properties.find(serverGroup); auto t = video_encoder_properties.find(serverGroup);
@ -792,7 +793,7 @@ void OBSBasicSettings::AddServer(QFormLayout *outputsLayout, obs_data_t *setting
for (int i = 0; i < 6; i++) { for (int i = 0; i < 6; i++) {
audioTrack->addItem(QString::number(i + 1)); audioTrack->addItem(QString::number(i + 1));
} }
audioTrack->setCurrentIndex(obs_data_get_int(settings, "audio_track")); audioTrack->setCurrentIndex((int)obs_data_get_int(settings, "audio_track"));
connect(audioTrack, &QComboBox::currentIndexChanged, [audioTrack, settings] { connect(audioTrack, &QComboBox::currentIndexChanged, [audioTrack, settings] {
if (audioTrack->currentIndex() >= 0) if (audioTrack->currentIndex() >= 0)
obs_data_set_int(settings, "audio_track", audioTrack->currentIndex()); obs_data_set_int(settings, "audio_track", audioTrack->currentIndex());
@ -803,7 +804,7 @@ void OBSBasicSettings::AddServer(QFormLayout *outputsLayout, obs_data_t *setting
for (int i = 0; i < MAX_OUTPUT_AUDIO_ENCODERS; i++) { for (int i = 0; i < MAX_OUTPUT_AUDIO_ENCODERS; i++) {
audioEncoderIndex->addItem(QString::number(i + 1)); audioEncoderIndex->addItem(QString::number(i + 1));
} }
audioEncoderIndex->setCurrentIndex(obs_data_get_int(settings, "audio_encoder_index")); audioEncoderIndex->setCurrentIndex((int)obs_data_get_int(settings, "audio_encoder_index"));
connect(audioEncoderIndex, &QComboBox::currentIndexChanged, [audioEncoderIndex, settings] { connect(audioEncoderIndex, &QComboBox::currentIndexChanged, [audioEncoderIndex, settings] {
if (audioEncoderIndex->currentIndex() >= 0) if (audioEncoderIndex->currentIndex() >= 0)
obs_data_set_int(settings, "audio_encoder_index", audioEncoderIndex->currentIndex()); obs_data_set_int(settings, "audio_encoder_index", audioEncoderIndex->currentIndex());
@ -882,9 +883,9 @@ void OBSBasicSettings::AddServer(QFormLayout *outputsLayout, obs_data_t *setting
advancedButton->setCheckable(true); advancedButton->setCheckable(true);
advancedButton->setChecked(advanced); advancedButton->setChecked(advanced);
connect(advancedButton, &QPushButton::clicked, [advancedButton, advancedGroup, settings] { connect(advancedButton, &QPushButton::clicked, [advancedButton, advancedGroup, settings] {
const bool advanced = advancedButton->isChecked(); const bool is_advanced = advancedButton->isChecked();
advancedGroup->setVisible(advanced); advancedGroup->setVisible(is_advanced);
obs_data_set_bool(settings, "advanced", advanced); obs_data_set_bool(settings, "advanced", is_advanced);
}); });
// Hook up // Hook up
@ -919,9 +920,8 @@ void OBSBasicSettings::AddServer(QFormLayout *outputsLayout, obs_data_t *setting
QStringList otherNames; QStringList otherNames;
obs_data_array_enum( obs_data_array_enum(
outputs, outputs,
[](obs_data_t *data, void *param) { [](obs_data_t *data2, void *param) {
auto otherNames = (QStringList *)param; ((QStringList *)param)->append(QString::fromUtf8(obs_data_get_string(data2, "name")));
otherNames->append(QString::fromUtf8(obs_data_get_string(data, "name")));
}, },
&otherNames); &otherNames);
otherNames.removeDuplicates(); otherNames.removeDuplicates();
@ -943,7 +943,7 @@ void OBSBasicSettings::AddServer(QFormLayout *outputsLayout, obs_data_t *setting
obs_data_set_string(settings, "stream_key", outputDialog->outputKey.toUtf8().constData()); obs_data_set_string(settings, "stream_key", outputDialog->outputKey.toUtf8().constData());
// Reload // Reload
LoadSettings(this->settings); LoadSettings(main_settings);
LoadVerticalSettings(false); LoadVerticalSettings(false);
} }
@ -988,9 +988,9 @@ void OBSBasicSettings::LoadVerticalSettings(bool load)
} }
obs_data_array_enum( obs_data_array_enum(
vertical_outputs, vertical_outputs,
[](obs_data_t *data, void *param) { [](obs_data_t *data2, void *param) {
auto d = (OBSBasicSettings *)param; auto d = (OBSBasicSettings *)param;
d->AddServer(d->verticalOutputsLayout, data, d->vertical_outputs); d->AddServer(d->verticalOutputsLayout, data2, d->vertical_outputs);
}, },
this); this);
} }
@ -1014,15 +1014,15 @@ void OBSBasicSettings::LoadSettings(obs_data_t *settings)
RemoveLayoutItem(i); RemoveLayoutItem(i);
mainOutputsLayout->removeRow(2); mainOutputsLayout->removeRow(2);
} }
this->settings = settings; main_settings = settings;
auto outputs = obs_data_get_array(settings, "outputs"); auto outputs = obs_data_get_array(settings, "outputs");
obs_data_array_enum( obs_data_array_enum(
outputs, outputs,
[](obs_data_t *data, void *param) { [](obs_data_t *data2, void *param) {
auto d = (OBSBasicSettings *)param; auto d = (OBSBasicSettings *)param;
auto outputs = obs_data_get_array(d->settings, "outputs"); auto outputs2 = obs_data_get_array(d->main_settings, "outputs");
d->AddServer(d->mainOutputsLayout, data, outputs); d->AddServer(d->mainOutputsLayout, data2, outputs2);
obs_data_array_release(outputs); obs_data_array_release(outputs2);
}, },
this); this);
obs_data_array_release(outputs); obs_data_array_release(outputs);
@ -1311,8 +1311,8 @@ void OBSBasicSettings::LoadOutputStats(std::vector<video_t *> *oldVideos)
} }
std::vector<std::tuple<video_t *, obs_encoder_t *, obs_output_t *>> refs; std::vector<std::tuple<video_t *, obs_encoder_t *, obs_output_t *>> refs;
obs_enum_outputs( obs_enum_outputs(
[](void *data, obs_output_t *output) { [](void *param, obs_output_t *output) {
auto refs = (std::vector<std::tuple<video_t *, obs_encoder_t *, obs_output_t *>> *)data; auto refs2 = (std::vector<std::tuple<video_t *, obs_encoder_t *, obs_output_t *>> *)param;
auto ec = 0; auto ec = 0;
for (size_t i = 0; i < MAX_OUTPUT_VIDEO_ENCODERS; i++) { for (size_t i = 0; i < MAX_OUTPUT_VIDEO_ENCODERS; i++) {
auto venc = obs_output_get_video_encoder2(output, i); auto venc = obs_output_get_video_encoder2(output, i);
@ -1323,11 +1323,11 @@ void OBSBasicSettings::LoadOutputStats(std::vector<video_t *> *oldVideos)
: obs_encoder_video(venc); : obs_encoder_video(venc);
if (!video) if (!video)
video = obs_output_video(output); video = obs_output_video(output);
refs->push_back(std::tuple<video_t *, obs_encoder_t *, obs_output_t *>(video, venc, output)); refs2->push_back(std::tuple<video_t *, obs_encoder_t *, obs_output_t *>(video, venc, output));
} }
if (!ec) { if (!ec) {
refs->push_back(std::tuple<video_t *, obs_encoder_t *, obs_output_t *>(obs_output_video(output), refs2->push_back(std::tuple<video_t *, obs_encoder_t *, obs_output_t *>(obs_output_video(output),
nullptr, output)); nullptr, output));
} }
return true; return true;
}, },

View File

@ -42,7 +42,7 @@ private:
void AddProperty(obs_properties_t *properties, obs_property_t *property, obs_data_t *settings, QFormLayout *layout); void AddProperty(obs_properties_t *properties, obs_property_t *property, obs_data_t *settings, QFormLayout *layout);
void RefreshProperties(obs_properties_t *properties, QFormLayout *layout); void RefreshProperties(obs_properties_t *properties, QFormLayout *layout);
obs_data_t *settings = nullptr; obs_data_t *main_settings = nullptr;
obs_data_array_t *vertical_outputs = nullptr; obs_data_array_t *vertical_outputs = nullptr;
std::map<obs_property_t *, QWidget *> encoder_property_widgets; std::map<obs_property_t *, QWidget *> encoder_property_widgets;

View File

@ -524,9 +524,9 @@ void MultistreamDock::LoadSettings()
obs_data_array_enum( obs_data_array_enum(
outputs, outputs,
[](obs_data_t *data, void *param) { [](obs_data_t *data2, void *param) {
auto d = (MultistreamDock *)param; auto d = (MultistreamDock *)param;
d->LoadOutput(data, false); d->LoadOutput(data2, false);
}, },
this); this);
obs_data_array_release(outputs); obs_data_array_release(outputs);
@ -971,9 +971,9 @@ void MultistreamDock::LoadVerticalOutputs(bool firstLoad)
obs_data_array_enum( obs_data_array_enum(
vertical_outputs, vertical_outputs,
[](obs_data_t *data, void *param) { [](obs_data_t *data2, void *param) {
auto d = (MultistreamDock *)param; auto d = (MultistreamDock *)param;
d->LoadOutput(data, true); d->LoadOutput(data2, true);
}, },
this); this);
} }