From bc80d0ca95a3c79cf1f4bc24df437f4ace125e30 Mon Sep 17 00:00:00 2001 From: tytan652 Date: Sun, 22 May 2022 13:18:28 +0200 Subject: [PATCH] UI: Hide network features if a non-RTMP service is set Only rtmp_output has those features implemented. --- UI/data/locale/en-US.ini | 1 + UI/forms/OBSBasicSettings.ui | 21 ++++++++++++++------- UI/streaming-helpers.cpp | 18 ++++++++++++++++++ UI/streaming-helpers.hpp | 2 ++ UI/window-basic-settings-stream.cpp | 5 +++++ UI/window-basic-settings.cpp | 15 +++++++++++++++ UI/window-basic-settings.hpp | 2 ++ 7 files changed, 57 insertions(+), 7 deletions(-) diff --git a/UI/data/locale/en-US.ini b/UI/data/locale/en-US.ini index bb4962675..aae9569c3 100644 --- a/UI/data/locale/en-US.ini +++ b/UI/data/locale/en-US.ini @@ -1069,6 +1069,7 @@ Basic.Settings.Advanced.StreamDelay.Duration="Duration" Basic.Settings.Advanced.StreamDelay.Preserve="Preserve cutoff point (increase delay) when reconnecting" Basic.Settings.Advanced.StreamDelay.MemoryUsage="Estimated Memory Usage: %1 MB" Basic.Settings.Advanced.Network="Network" +Basic.Settings.Advanced.Network.Disabled="The currently selected streaming protocol does not support changing network settings." Basic.Settings.Advanced.Network.BindToIP="Bind to IP" Basic.Settings.Advanced.Network.EnableNewSocketLoop="Enable network optimizations" Basic.Settings.Advanced.Network.EnableLowLatencyMode="Enable TCP pacing" diff --git a/UI/forms/OBSBasicSettings.ui b/UI/forms/OBSBasicSettings.ui index 3f1cdfa47..c247ff055 100644 --- a/UI/forms/OBSBasicSettings.ui +++ b/UI/forms/OBSBasicSettings.ui @@ -5590,8 +5590,15 @@ 2 - - + + + + Basic.Settings.Advanced.Network.Disabled + + + + + Basic.Settings.Advanced.Network.BindToIP @@ -5600,17 +5607,17 @@ - + - + Basic.Settings.Advanced.Network.EnableNewSocketLoop - + false @@ -5620,7 +5627,7 @@ - + Qt::Horizontal @@ -5633,7 +5640,7 @@ - + Basic.Settings.Output.DynamicBitrate.TT diff --git a/UI/streaming-helpers.cpp b/UI/streaming-helpers.cpp index 763f9d233..24ffedc5e 100644 --- a/UI/streaming-helpers.cpp +++ b/UI/streaming-helpers.cpp @@ -68,6 +68,24 @@ Json get_service_from_json(const Json &root, const char *name) return Json(); } +bool StreamSettingsUI::IsServiceOutputHasNetworkFeatures() +{ + if (IsCustomService()) + return ui_customServer->text().startsWith("rtmp"); + + Json service = get_service_from_json( + GetServicesJson(), QT_TO_UTF8(ui_service->currentText())); + + if (!service["recommended"]["output"].is_string()) + return true; + + if (service["recommended"]["output"].string_value().compare( + "rtmp_output") == 0) + return true; + + return false; +} + void StreamSettingsUI::UpdateMoreInfoLink() { if (IsCustomService()) { diff --git a/UI/streaming-helpers.hpp b/UI/streaming-helpers.hpp index 170ef3282..d314d0054 100644 --- a/UI/streaming-helpers.hpp +++ b/UI/streaming-helpers.hpp @@ -63,6 +63,8 @@ public: inline const QString &LastService() const { return lastService; } + bool IsServiceOutputHasNetworkFeatures(); + public slots: void UpdateMoreInfoLink(); void UpdateKeyLink(); diff --git a/UI/window-basic-settings-stream.cpp b/UI/window-basic-settings-stream.cpp index 62cf6b6f6..bbc97dc3b 100644 --- a/UI/window-basic-settings-stream.cpp +++ b/UI/window-basic-settings-stream.cpp @@ -92,6 +92,11 @@ void OBSBasicSettings::InitStreamPage() SLOT(UpdateResFPSLimits())); connect(ui->service, SIGNAL(currentIndexChanged(int)), &streamUi, SLOT(UpdateMoreInfoLink())); + + connect(ui->service, SIGNAL(currentIndexChanged(int)), this, + SLOT(UpdateAdvNetworkGroup())); + connect(ui->customServer, SIGNAL(textChanged(const QString &)), this, + SLOT(UpdateAdvNetworkGroup())); } void OBSBasicSettings::LoadStream1Settings() diff --git a/UI/window-basic-settings.cpp b/UI/window-basic-settings.cpp index 02adf9777..3c7811ebd 100644 --- a/UI/window-basic-settings.cpp +++ b/UI/window-basic-settings.cpp @@ -5386,3 +5386,18 @@ void OBSBasicSettings::RecreateOutputResolutionWidget() ui->outputResolution->lineEdit()->setValidator( ui->baseResolution->lineEdit()->validator()); } + +void OBSBasicSettings::UpdateAdvNetworkGroup() +{ + bool enabled = streamUi.IsServiceOutputHasNetworkFeatures(); + + ui->advNetworkDisabled->setVisible(!enabled); + + ui->bindToIPLabel->setVisible(enabled); + ui->bindToIP->setVisible(enabled); + ui->dynBitrate->setVisible(enabled); +#ifdef _WIN32 + ui->enableNewSocketLoop->setVisible(enabled); + ui->enableLowLatencyMode->setVisible(enabled); +#endif +} diff --git a/UI/window-basic-settings.hpp b/UI/window-basic-settings.hpp index ded4bd430..c15da2436 100644 --- a/UI/window-basic-settings.hpp +++ b/UI/window-basic-settings.hpp @@ -390,6 +390,8 @@ private slots: void UpdateStreamDelayEstimate(); + void UpdateAdvNetworkGroup(); + void UpdateAutomaticReplayBufferCheckboxes(); void AdvOutSplitFileChanged();