Fix changing settings while streaming

This commit is contained in:
Exeldro 2024-07-30 21:10:13 +02:00
parent 5e2a464410
commit 5d0a7a8a76
No known key found for this signature in database
GPG Key ID: 97269A83FC715751
3 changed files with 33 additions and 13 deletions

View File

@ -380,7 +380,9 @@ OBSBasicSettings::~OBSBasicSettings()
{ {
if (vertical_outputs) if (vertical_outputs)
obs_data_array_release(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); obs_properties_destroy(it->second);
} }
@ -693,10 +695,10 @@ void OBSBasicSettings::AddServer(QFormLayout *outputsLayout, obs_data_t *setting
videoPageLayout->setRowVisible(videoEncoderIndex, false); videoPageLayout->setRowVisible(videoEncoderIndex, false);
if (!videoEncoderGroup->isVisibleTo(videoPage)) if (!videoEncoderGroup->isVisibleTo(videoPage))
videoEncoderGroup->setVisible(true); videoEncoderGroup->setVisible(true);
auto t = encoder_properties.find(serverGroup); auto t = video_encoder_properties.find(serverGroup);
if (t != encoder_properties.end()) { if (t != video_encoder_properties.end()) {
obs_properties_destroy(t->second); 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--) { for (int i = videoEncoderGroupLayout->rowCount() - 1; i >= (main ? 2 : 0); i--) {
videoEncoderGroupLayout->removeRow(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); obs_data_set_obj(settings, "video_encoder_settings", ves);
} }
auto stream_encoder_properties = obs_get_encoder_properties(encoder); 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); obs_property_t *property = obs_properties_first(stream_encoder_properties);
while (property) { while (property) {
@ -789,10 +791,10 @@ void OBSBasicSettings::AddServer(QFormLayout *outputsLayout, obs_data_t *setting
audioPageLayout->setRowVisible(audioTrack, true); audioPageLayout->setRowVisible(audioTrack, true);
if (!audioEncoderGroup->isVisibleTo(audioPage)) if (!audioEncoderGroup->isVisibleTo(audioPage))
audioEncoderGroup->setVisible(true); audioEncoderGroup->setVisible(true);
auto t = encoder_properties.find(serverGroup); auto t = audio_encoder_properties.find(serverGroup);
if (t != encoder_properties.end()) { if (t != audio_encoder_properties.end()) {
obs_properties_destroy(t->second); obs_properties_destroy(t->second);
encoder_properties.erase(t); audio_encoder_properties.erase(t);
} }
for (int i = audioEncoderGroupLayout->rowCount() - 1; i >= 0; i--) { for (int i = audioEncoderGroupLayout->rowCount() - 1; i >= 0; i--) {
audioEncoderGroupLayout->removeRow(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); obs_data_set_obj(settings, "audio_encoder_settings", aes);
} }
auto stream_encoder_properties = obs_get_encoder_properties(encoder); 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); obs_property_t *property = obs_properties_first(stream_encoder_properties);
while (property) { while (property) {

View File

@ -46,7 +46,8 @@ private:
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;
std::map<QWidget *, obs_properties_t *> encoder_properties; std::map<QWidget *, obs_properties_t *> video_encoder_properties;
std::map<QWidget *, obs_properties_t *> audio_encoder_properties;
QFormLayout *mainOutputsLayout; QFormLayout *mainOutputsLayout;
QFormLayout *verticalOutputsLayout; QFormLayout *verticalOutputsLayout;

View File

@ -526,8 +526,8 @@ void MultistreamDock::LoadSettings()
void MultistreamDock::LoadOutput(obs_data_t *data, bool vertical) void MultistreamDock::LoadOutput(obs_data_t *data, bool vertical)
{ {
auto name = QString::fromUtf8(obs_data_get_string(data, "name")); auto nameChars = obs_data_get_string(data, "name");
auto endpoint = QString::fromUtf8(obs_data_get_string(data, "stream_server")); auto name = QString::fromUtf8(nameChars);
if (vertical) { if (vertical) {
for (int i = 0; i < verticalCanvasOutputLayout->count(); i++) { for (int i = 0; i < verticalCanvasOutputLayout->count(); i++) {
auto item = verticalCanvasOutputLayout->itemAt(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<std::string>(*it) != nameChars)
continue;
if (obs_data_get_bool(data, "advanced")) {
auto output = std::get<obs_output_t *>(*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<QPushButton *>(*it) = streamButton;
}
auto streamGroup = new QGroupBox; auto streamGroup = new QGroupBox;
streamGroup->setStyleSheet(outputGroupStyle); streamGroup->setStyleSheet(outputGroupStyle);
streamGroup->setObjectName(name); streamGroup->setObjectName(name);
@ -552,6 +568,7 @@ void MultistreamDock::LoadOutput(obs_data_t *data, bool vertical)
auto l2 = new QHBoxLayout; auto l2 = new QHBoxLayout;
auto endpoint = QString::fromUtf8(obs_data_get_string(data, "stream_server"));
auto platformIconLabel = new QLabel; auto platformIconLabel = new QLabel;
auto platformIcon = ConfigUtils::getPlatformIconFromEndpoint(endpoint); auto platformIcon = ConfigUtils::getPlatformIconFromEndpoint(endpoint);
@ -560,7 +577,7 @@ void MultistreamDock::LoadOutput(obs_data_t *data, bool vertical)
l2->addWidget(platformIconLabel); l2->addWidget(platformIconLabel);
l2->addWidget(new QLabel(name), 1); l2->addWidget(new QLabel(name), 1);
auto streamButton = new QPushButton;
streamButton->setMinimumHeight(30); streamButton->setMinimumHeight(30);
streamButton->setObjectName(QStringLiteral("canvasStream")); streamButton->setObjectName(QStringLiteral("canvasStream"));
streamButton->setIcon(streamInactiveIcon); streamButton->setIcon(streamInactiveIcon);