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)
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) {

View File

@ -46,7 +46,8 @@ private:
obs_data_array_t *vertical_outputs = nullptr;
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 *verticalOutputsLayout;

View File

@ -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<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;
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);