Browse Source

UI: Add back auth for custom RTMP servers

This was a feature that was available when you chose custom RTMP server;
it was not considered when making the new version.  Note: it looks
unslightly, but it works for now.
jp9000 6 years ago
parent
commit
066c11c307

+ 3 - 0
UI/data/locale/en-US.ini

@@ -620,6 +620,9 @@ Basic.Settings.General.MultiviewLayout.Horizontal.Extended.Top="Horizontal, Top
 # basic mode 'stream' settings
 Basic.Settings.Stream="Stream"
 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 mode 'output' settings
 Basic.Settings.Output="Output"

+ 65 - 3
UI/forms/OBSBasicSettings.ui

@@ -146,7 +146,7 @@
               <x>0</x>
               <y>0</y>
               <width>801</width>
-              <height>836</height>
+              <height>931</height>
              </rect>
             </property>
             <layout class="QVBoxLayout" name="verticalLayout_19">
@@ -1052,6 +1052,68 @@
                </item>
               </layout>
              </item>
+             <item row="4" column="1">
+              <widget class="QCheckBox" name="useAuth">
+               <property name="text">
+                <string>Basic.Settings.Stream.Custom.UseAuthentication</string>
+               </property>
+              </widget>
+             </item>
+             <item row="5" column="1">
+              <widget class="QLineEdit" name="authUsername"/>
+             </item>
+             <item row="5" column="0">
+              <widget class="QLabel" name="authUsernameLabel">
+               <property name="text">
+                <string>Basic.Settings.Stream.Custom.Username</string>
+               </property>
+               <property name="buddy">
+                <cstring>authUsername</cstring>
+               </property>
+              </widget>
+             </item>
+             <item row="6" column="0">
+              <widget class="QLabel" name="authPwLabel">
+               <property name="text">
+                <string>Basic.Settings.Stream.Custom.Password</string>
+               </property>
+               <property name="buddy">
+                <cstring>authPw</cstring>
+               </property>
+              </widget>
+             </item>
+             <item row="6" column="1">
+              <widget class="QWidget" name="authPwWidget" native="true">
+               <layout class="QHBoxLayout" name="horizontalLayout_25">
+                <property name="leftMargin">
+                 <number>0</number>
+                </property>
+                <property name="topMargin">
+                 <number>0</number>
+                </property>
+                <property name="rightMargin">
+                 <number>0</number>
+                </property>
+                <property name="bottomMargin">
+                 <number>0</number>
+                </property>
+                <item>
+                 <widget class="QLineEdit" name="authPw">
+                  <property name="echoMode">
+                   <enum>QLineEdit::Password</enum>
+                  </property>
+                 </widget>
+                </item>
+                <item>
+                 <widget class="QPushButton" name="authPwShow">
+                  <property name="text">
+                   <string>Show</string>
+                  </property>
+                 </widget>
+                </item>
+               </layout>
+              </widget>
+             </item>
             </layout>
            </widget>
           </widget>
@@ -3783,8 +3845,8 @@
              <rect>
               <x>0</x>
               <y>0</y>
-              <width>98</width>
-              <height>28</height>
+              <width>63</width>
+              <height>16</height>
              </rect>
             </property>
            </widget>

+ 46 - 0
UI/window-basic-settings-stream.cpp

@@ -75,6 +75,13 @@ void OBSBasicSettings::LoadStream1Settings()
 	if (strcmp(type, "rtmp_custom") == 0) {
 		ui->service->setCurrentIndex(0);
 		ui->customServer->setText(server);
+
+		bool use_auth = obs_data_get_bool(settings, "use_auth");
+		const char *username = obs_data_get_string(settings, "username");
+		const char *password = obs_data_get_string(settings, "password");
+		ui->authUsername->setText(QT_UTF8(username));
+		ui->authPw->setText(QT_UTF8(password));
+		ui->useAuth->setChecked(use_auth);
 	} else {
 		int idx = ui->service->findText(service);
 		if (idx == -1) {
@@ -134,6 +141,14 @@ void OBSBasicSettings::SaveStream1Settings()
 	} else {
 		obs_data_set_string(settings, "server",
 				QT_TO_UTF8(ui->customServer->text()));
+		obs_data_set_bool(settings, "use_auth",
+				ui->useAuth->isChecked());
+		if (ui->useAuth->isChecked()) {
+			obs_data_set_string(settings, "username",
+					QT_TO_UTF8(ui->authUsername->text()));
+			obs_data_set_string(settings, "password",
+					QT_TO_UTF8(ui->authPw->text()));
+		}
 	}
 
 	obs_data_set_string(settings, "key", QT_TO_UTF8(ui->key->text()));
@@ -267,6 +282,12 @@ void OBSBasicSettings::on_service_currentIndexChanged(int)
 	ui->connectAccount2->setVisible(false);
 #endif
 
+	ui->useAuth->setVisible(custom);
+	ui->authUsernameLabel->setVisible(custom);
+	ui->authUsername->setVisible(custom);
+	ui->authPwLabel->setVisible(custom);
+	ui->authPwWidget->setVisible(custom);
+
 	if (custom) {
 		ui->streamkeyPageLayout->insertRow(1, ui->serverLabel,
 				ui->serverStackedWidget);
@@ -274,6 +295,7 @@ void OBSBasicSettings::on_service_currentIndexChanged(int)
 		ui->serverStackedWidget->setCurrentIndex(1);
 		ui->serverStackedWidget->setVisible(true);
 		ui->serverLabel->setVisible(true);
+		on_useAuth_toggled();
 	} else {
 		ui->serverStackedWidget->setCurrentIndex(0);
 	}
@@ -337,6 +359,17 @@ void OBSBasicSettings::on_show_clicked()
 	}
 }
 
+void OBSBasicSettings::on_authPwShow_clicked()
+{
+	if (ui->authPw->echoMode() == QLineEdit::Password) {
+		ui->authPw->setEchoMode(QLineEdit::Normal);
+		ui->authPwShow->setText(QTStr("Hide"));
+	} else {
+		ui->authPw->setEchoMode(QLineEdit::Password);
+		ui->authPwShow->setText(QTStr("Show"));
+	}
+}
+
 OBSService OBSBasicSettings::SpawnTempService()
 {
 	bool custom = IsCustomService();
@@ -447,3 +480,16 @@ void OBSBasicSettings::on_useStreamKey_clicked()
 {
 	ui->streamStackWidget->setCurrentIndex((int)Section::StreamKey);
 }
+
+void OBSBasicSettings::on_useAuth_toggled()
+{
+	if (!IsCustomService())
+		return;
+
+	bool use_auth = ui->useAuth->isChecked();
+
+	ui->authUsernameLabel->setVisible(use_auth);
+	ui->authUsername->setVisible(use_auth);
+	ui->authPwLabel->setVisible(use_auth);
+	ui->authPwWidget->setVisible(use_auth);
+}

+ 3 - 0
UI/window-basic-settings.cpp

@@ -331,6 +331,9 @@ 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->useAuth,              CHECK_CHANGED,  STREAM1_CHANGED);
+	HookWidget(ui->authUsername,         EDIT_CHANGED,   STREAM1_CHANGED);
+	HookWidget(ui->authPw,               EDIT_CHANGED,   STREAM1_CHANGED);
 	HookWidget(ui->outputMode,           COMBO_CHANGED,  OUTPUTS_CHANGED);
 	HookWidget(ui->simpleOutputPath,     EDIT_CHANGED,   OUTPUTS_CHANGED);
 	HookWidget(ui->simpleNoSpace,        CHECK_CHANGED,  OUTPUTS_CHANGED);

+ 2 - 0
UI/window-basic-settings.hpp

@@ -222,9 +222,11 @@ private slots:
 	void UpdateServerList();
 	void UpdateKeyLink();
 	void on_show_clicked();
+	void on_authPwShow_clicked();
 	void on_connectAccount_clicked();
 	void on_disconnectAccount_clicked();
 	void on_useStreamKey_clicked();
+	void on_useAuth_toggled();
 private:
 
 	/* output */