From 5d0a7a8a764d23974cf08205412055c8a9c57d9a Mon Sep 17 00:00:00 2001 From: Exeldro Date: Tue, 30 Jul 2024 21:10:13 +0200 Subject: [PATCH] Fix changing settings while streaming --- config-dialog.cpp | 20 +++++++++++--------- config-dialog.hpp | 3 ++- multistream.cpp | 23 ++++++++++++++++++++--- 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/config-dialog.cpp b/config-dialog.cpp index 640beb5..4a1f242 100644 --- a/config-dialog.cpp +++ b/config-dialog.cpp @@ -380,7 +380,9 @@ OBSBasicSettings::~OBSBasicSettings() { if (vertical_outputs) obs_data_array_release(vertical_outputs); - for (auto it = encoder_properties.begin(); it != encoder_properties.end(); it++) + for (auto it = video_encoder_properties.begin(); it != video_encoder_properties.end(); it++) + obs_properties_destroy(it->second); + for (auto it = audio_encoder_properties.begin(); it != audio_encoder_properties.end(); it++) obs_properties_destroy(it->second); } @@ -693,10 +695,10 @@ void OBSBasicSettings::AddServer(QFormLayout *outputsLayout, obs_data_t *setting videoPageLayout->setRowVisible(videoEncoderIndex, false); if (!videoEncoderGroup->isVisibleTo(videoPage)) videoEncoderGroup->setVisible(true); - auto t = encoder_properties.find(serverGroup); - if (t != encoder_properties.end()) { + auto t = video_encoder_properties.find(serverGroup); + if (t != video_encoder_properties.end()) { obs_properties_destroy(t->second); - encoder_properties.erase(t); + video_encoder_properties.erase(t); } for (int i = videoEncoderGroupLayout->rowCount() - 1; i >= (main ? 2 : 0); i--) { videoEncoderGroupLayout->removeRow(i); @@ -708,7 +710,7 @@ void OBSBasicSettings::AddServer(QFormLayout *outputsLayout, obs_data_t *setting obs_data_set_obj(settings, "video_encoder_settings", ves); } auto stream_encoder_properties = obs_get_encoder_properties(encoder); - encoder_properties[serverGroup] = stream_encoder_properties; + video_encoder_properties[serverGroup] = stream_encoder_properties; obs_property_t *property = obs_properties_first(stream_encoder_properties); while (property) { @@ -789,10 +791,10 @@ void OBSBasicSettings::AddServer(QFormLayout *outputsLayout, obs_data_t *setting audioPageLayout->setRowVisible(audioTrack, true); if (!audioEncoderGroup->isVisibleTo(audioPage)) audioEncoderGroup->setVisible(true); - auto t = encoder_properties.find(serverGroup); - if (t != encoder_properties.end()) { + auto t = audio_encoder_properties.find(serverGroup); + if (t != audio_encoder_properties.end()) { obs_properties_destroy(t->second); - encoder_properties.erase(t); + audio_encoder_properties.erase(t); } for (int i = audioEncoderGroupLayout->rowCount() - 1; i >= 0; i--) { audioEncoderGroupLayout->removeRow(i); @@ -804,7 +806,7 @@ void OBSBasicSettings::AddServer(QFormLayout *outputsLayout, obs_data_t *setting obs_data_set_obj(settings, "audio_encoder_settings", aes); } auto stream_encoder_properties = obs_get_encoder_properties(encoder); - encoder_properties[serverGroup] = stream_encoder_properties; + audio_encoder_properties[serverGroup] = stream_encoder_properties; obs_property_t *property = obs_properties_first(stream_encoder_properties); while (property) { diff --git a/config-dialog.hpp b/config-dialog.hpp index 4e15a64..4bc81d7 100644 --- a/config-dialog.hpp +++ b/config-dialog.hpp @@ -46,7 +46,8 @@ private: obs_data_array_t *vertical_outputs = nullptr; std::map encoder_property_widgets; - std::map encoder_properties; + std::map video_encoder_properties; + std::map audio_encoder_properties; QFormLayout *mainOutputsLayout; QFormLayout *verticalOutputsLayout; diff --git a/multistream.cpp b/multistream.cpp index 0b61976..d888e6b 100644 --- a/multistream.cpp +++ b/multistream.cpp @@ -526,8 +526,8 @@ void MultistreamDock::LoadSettings() void MultistreamDock::LoadOutput(obs_data_t *data, bool vertical) { - auto name = QString::fromUtf8(obs_data_get_string(data, "name")); - auto endpoint = QString::fromUtf8(obs_data_get_string(data, "stream_server")); + auto nameChars = obs_data_get_string(data, "name"); + auto name = QString::fromUtf8(nameChars); if (vertical) { for (int i = 0; i < verticalCanvasOutputLayout->count(); i++) { auto item = verticalCanvasOutputLayout->itemAt(i); @@ -545,6 +545,22 @@ void MultistreamDock::LoadOutput(obs_data_t *data, bool vertical) } } } + auto streamButton = new QPushButton; + for (auto it = outputs.begin(); it != outputs.end(); it++) { + if (std::get(*it) != nameChars) + continue; + if (obs_data_get_bool(data, "advanced")) { + auto output = std::get(*it); + auto video_encoder = obs_output_get_video_encoder(output); + if (video_encoder && + strcmp(obs_encoder_get_id(video_encoder), obs_data_get_string(data, "video_encoder")) == 0) { + auto ves = obs_data_get_obj(data, "video_encoder_settings"); + obs_encoder_update(video_encoder, ves); + obs_data_release(ves); + } + } + std::get(*it) = streamButton; + } auto streamGroup = new QGroupBox; streamGroup->setStyleSheet(outputGroupStyle); streamGroup->setObjectName(name); @@ -552,6 +568,7 @@ void MultistreamDock::LoadOutput(obs_data_t *data, bool vertical) auto l2 = new QHBoxLayout; + auto endpoint = QString::fromUtf8(obs_data_get_string(data, "stream_server")); auto platformIconLabel = new QLabel; auto platformIcon = ConfigUtils::getPlatformIconFromEndpoint(endpoint); @@ -560,7 +577,7 @@ void MultistreamDock::LoadOutput(obs_data_t *data, bool vertical) l2->addWidget(platformIconLabel); l2->addWidget(new QLabel(name), 1); - auto streamButton = new QPushButton; + streamButton->setMinimumHeight(30); streamButton->setObjectName(QStringLiteral("canvasStream")); streamButton->setIcon(streamInactiveIcon);