From 51bfb9d8991201ff52fe75b3336ccaac341a5f45 Mon Sep 17 00:00:00 2001 From: derrod Date: Sat, 9 Mar 2019 02:54:41 +0100 Subject: [PATCH] UI: Add checkbox for Twitch bandwidth test mode --- UI/auth-oauth.cpp | 9 ++++++++- UI/data/locale/en-US.ini | 1 + UI/forms/OBSBasicSettings.ui | 17 ++++++++++++----- UI/window-basic-settings-stream.cpp | 10 ++++++++++ UI/window-basic-settings.cpp | 1 + 5 files changed, 32 insertions(+), 6 deletions(-) diff --git a/UI/auth-oauth.cpp b/UI/auth-oauth.cpp index 98b8869eb..1799ba3fa 100644 --- a/UI/auth-oauth.cpp +++ b/UI/auth-oauth.cpp @@ -297,7 +297,14 @@ void OAuthStreamKey::OnStreamConfig() obs_data_t *settings = obs_service_get_settings(service); - obs_data_set_string(settings, "key", key_.c_str()); + bool bwtest = obs_data_get_bool(settings, "bwtest"); + + if (bwtest && strcmp(this->service(), "Twitch") == 0) + obs_data_set_string(settings, "key", + key_.append("?bandwidthtest=true").c_str()); + else + obs_data_set_string(settings, "key", key_.c_str()); + obs_service_update(service, settings); obs_data_release(settings); diff --git a/UI/data/locale/en-US.ini b/UI/data/locale/en-US.ini index 571b6fb72..596ea625a 100644 --- a/UI/data/locale/en-US.ini +++ b/UI/data/locale/en-US.ini @@ -628,6 +628,7 @@ Basic.Settings.Stream.StreamType="Stream Type" Basic.Settings.Stream.Custom.UseAuthentication="Use authentication" Basic.Settings.Stream.Custom.Username="Username" Basic.Settings.Stream.Custom.Password="Password" +Basic.Settings.Stream.BandwidthTestMode="Enable Bandwidth Test Mode" # basic mode 'output' settings Basic.Settings.Output="Output" diff --git a/UI/forms/OBSBasicSettings.ui b/UI/forms/OBSBasicSettings.ui index a6b087147..4ffe7996e 100644 --- a/UI/forms/OBSBasicSettings.ui +++ b/UI/forms/OBSBasicSettings.ui @@ -1062,17 +1062,17 @@ - + Basic.Settings.Stream.Custom.UseAuthentication - + - + Basic.Settings.Stream.Custom.Username @@ -1082,7 +1082,7 @@ - + Basic.Settings.Stream.Custom.Password @@ -1092,7 +1092,7 @@ - + @@ -1124,6 +1124,13 @@ + + + + Basic.Settings.Stream.BandwidthTestMode + + + diff --git a/UI/window-basic-settings-stream.cpp b/UI/window-basic-settings-stream.cpp index 0be96457f..69862447b 100644 --- a/UI/window-basic-settings-stream.cpp +++ b/UI/window-basic-settings-stream.cpp @@ -36,6 +36,7 @@ void OBSBasicSettings::InitStreamPage() { ui->connectAccount2->setVisible(false); ui->disconnectAccount->setVisible(false); + ui->bandwidthTestEnable->setVisible(false); int vertSpacing = ui->topStreamLayout->verticalSpacing(); @@ -90,6 +91,9 @@ void OBSBasicSettings::LoadStream1Settings() idx = 1; } ui->service->setCurrentIndex(idx); + + bool bw_test = obs_data_get_bool(settings, "bwtest"); + ui->bandwidthTestEnable->setChecked(bw_test); } UpdateServerList(); @@ -151,6 +155,7 @@ void OBSBasicSettings::SaveStream1Settings() } } + obs_data_set_bool(settings, "bwtest", ui->bandwidthTestEnable->isChecked()); obs_data_set_string(settings, "key", QT_TO_UTF8(ui->key->text())); OBSService newService = obs_service_create(service_id, @@ -260,6 +265,7 @@ void OBSBasicSettings::on_service_currentIndexChanged(int) bool custom = IsCustomService(); ui->disconnectAccount->setVisible(false); + ui->bandwidthTestEnable->setVisible(false); #ifdef BROWSER_AVAILABLE if (cef) { @@ -411,6 +417,9 @@ void OBSBasicSettings::OnOAuthStreamKeyConnected() ui->streamKeyLabel->setVisible(false); ui->connectAccount2->setVisible(false); ui->disconnectAccount->setVisible(true); + + if (strcmp(a->service(), "Twitch") == 0) + ui->bandwidthTestEnable->setVisible(true); } ui->streamStackWidget->setCurrentIndex((int)Section::StreamKey); @@ -473,6 +482,7 @@ void OBSBasicSettings::on_disconnectAccount_clicked() ui->streamKeyLabel->setVisible(true); ui->connectAccount2->setVisible(true); ui->disconnectAccount->setVisible(false); + ui->bandwidthTestEnable->setVisible(false); ui->key->setText(""); } diff --git a/UI/window-basic-settings.cpp b/UI/window-basic-settings.cpp index 37f13c09e..91cf81834 100644 --- a/UI/window-basic-settings.cpp +++ b/UI/window-basic-settings.cpp @@ -334,6 +334,7 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent) HookWidget(ui->server, COMBO_CHANGED, STREAM1_CHANGED); HookWidget(ui->customServer, EDIT_CHANGED, STREAM1_CHANGED); HookWidget(ui->key, EDIT_CHANGED, STREAM1_CHANGED); + HookWidget(ui->bandwidthTestEnable, CHECK_CHANGED, STREAM1_CHANGED); HookWidget(ui->useAuth, CHECK_CHANGED, STREAM1_CHANGED); HookWidget(ui->authUsername, EDIT_CHANGED, STREAM1_CHANGED); HookWidget(ui->authPw, EDIT_CHANGED, STREAM1_CHANGED);