UI: Add auto-configuration wizard

The auto-configuration wizard is designed to allow first-time or
novice/uneducated users or to set up video and encoding settings in a
very quick and easy way.  It'll automatically perform a bandwidth test,
and/or test the user's video settings to determine the most ideal
settings for streaming and recording (assuming a 1-pc setup).
master
jp9000 2017-05-06 12:13:56 -07:00
parent 51e5f5fc64
commit 4049a5a882
13 changed files with 2812 additions and 3 deletions

View File

@ -135,8 +135,10 @@ set(obs_SOURCES
window-basic-settings.cpp
window-basic-interaction.cpp
window-basic-properties.cpp
window-basic-auto-config.cpp
window-basic-main-outputs.cpp
window-basic-source-select.cpp
window-basic-auto-config-test.cpp
window-basic-main-scene-collections.cpp
window-basic-main-transitions.cpp
window-basic-main-dropfiles.cpp
@ -181,6 +183,7 @@ set(obs_HEADERS
window-basic-settings.hpp
window-basic-interaction.hpp
window-basic-properties.hpp
window-basic-auto-config.hpp
window-basic-main-outputs.hpp
window-basic-source-select.hpp
window-license-agreement.hpp
@ -217,6 +220,10 @@ set(obs_HEADERS
set(obs_UI
forms/NameDialog.ui
forms/AutoConfigStartPage.ui
forms/AutoConfigVideoPage.ui
forms/AutoConfigStreamPage.ui
forms/AutoConfigTestPage.ui
forms/OBSLicenseAgreement.ui
forms/OBSLogReply.ui
forms/OBSBasic.ui

View File

@ -74,6 +74,63 @@ RemuxRecordings="Remux Recordings"
Copy.Filters="Copy Filters"
Paste.Filters="Paste Filters"
# bandwidth test
BandwidthTest.Region="Region"
BandwidthTest.Region.US="United States"
BandwidthTest.Region.EU="Europe"
BandwidthTest.Region.Asia="Asia"
BandwidthTest.Region.Other="Other"
# first time startup
Basic.FirstStartup.RunWizard="Would you like to run the auto-configuration wizard? You can also manually configure your settings by clicking the Settings button in the main window."
Basic.FirstStartup.RunWizard.BetaWarning="(Note: The auto-configuration wizard is currently in beta)"
Basic.FirstStartup.RunWizard.NoClicked="If you change your mind, you can run the auto-configuration wizard any time again from the Tools menu."
# auto config wizard
Basic.AutoConfig="Auto-Configuration Wizard"
Basic.AutoConfig.Beta="Auto-Configuration Wizard (Beta)"
Basic.AutoConfig.ApplySettings="Apply Settings"
Basic.AutoConfig.StartPage="Usage Information"
Basic.AutoConfig.StartPage.SubTitle="Specify what you want to to use the program for"
Basic.AutoConfig.StartPage.PrioritizeStreaming="Optimize for streaming, recording is secondary"
Basic.AutoConfig.StartPage.PrioritizeRecording="Optimize just for recording, I will not be streaming"
Basic.AutoConfig.VideoPage="Video Settings"
Basic.AutoConfig.VideoPage.SubTitle="Specify the desired video settings you would like to use"
Basic.AutoConfig.VideoPage.BaseResolution.UseCurrent="Use Current (%1x%2)"
Basic.AutoConfig.VideoPage.BaseResolution.Display="Display %1 (%2x%3)"
Basic.AutoConfig.VideoPage.FPS.UseCurrent="Use Current (%1)"
Basic.AutoConfig.VideoPage.FPS.PreferHighFPS="Either 60 or 30, but prefer 60 when possible"
Basic.AutoConfig.VideoPage.FPS.PreferHighRes="Either 60 or 30, but prefer high resolution"
Basic.AutoConfig.VideoPage.CanvasExplanation="Note: The canvas (base) resolution is not necessarily the same as the resolution you will stream or record with. Your actual stream/recording resolution may be scaled down from the canvas resolution to reduce resource usage or bitrate requirements."
Basic.AutoConfig.StreamPage="Stream Information"
Basic.AutoConfig.StreamPage.SubTitle="Please enter your stream information"
Basic.AutoConfig.StreamPage.Service="Service"
Basic.AutoConfig.StreamPage.Service.ShowAll="Show All..."
Basic.AutoConfig.StreamPage.Server="Server"
Basic.AutoConfig.StreamPage.StreamKey="Stream Key"
Basic.AutoConfig.StreamPage.StreamKey.LinkToSite="(Link)"
Basic.AutoConfig.StreamPage.PerformBandwidthTest="Estimate bitrate with bandwidth test (may take a few minutes)"
Basic.AutoConfig.StreamPage.PreferHardwareEncoding="Prefer hardware encoding"
Basic.AutoConfig.StreamPage.PreferHardwareEncoding.ToolTip="Hardware Encoding eliminates most CPU usage, but may require more bitrate to obtain the same level of quality."
Basic.AutoConfig.StreamPage.StreamWarning.Title="Stream warning"
Basic.AutoConfig.StreamPage.StreamWarning.Text="The bandwidth test is about to stream randomized video data without audio to your channel. If you're able, it's recommended to temporarily turn off saving videos of streams and set the stream to private until after the test has completed. Continue?"
Basic.AutoConfig.TestPage="Final Results"
Basic.AutoConfig.TestPage.SubTitle.Testing="The program is now executing a set of tests to estimate the most ideal settings"
Basic.AutoConfig.TestPage.SubTitle.Complete="Testing complete"
Basic.AutoConfig.TestPage.TestingBandwidth="Performing bandwidth test, this may take a few minutes..."
Basic.AutoConfig.TestPage.TestingBandwidth.Connecting="Connecting to: %1..."
Basic.AutoConfig.TestPage.TestingBandwidth.ConnectFailed="Failed to connect to any servers, please check your internet connection and try again."
Basic.AutoConfig.TestPage.TestingBandwidth.Server="Testing bandwidth for: %1"
Basic.AutoConfig.TestPage.TestingStreamEncoder="Testing stream encoder, this may take a minute..."
Basic.AutoConfig.TestPage.TestingRecordingEncoder="Testing recording encoder, this may take a minute..."
Basic.AutoConfig.TestPage.TestingRes="Testing resolutions, this may take a few minutes..."
Basic.AutoConfig.TestPage.TestingRes.Fail="Failed to start up encoder"
Basic.AutoConfig.TestPage.TestingRes.Resolution="Testing %1x%2 %3 FPS..."
Basic.AutoConfig.TestPage.Result.StreamingEncoder="Streaming Encoder"
Basic.AutoConfig.TestPage.Result.RecordingEncoder="Recording Encoder"
Basic.AutoConfig.TestPage.Result.Header="The program has determined that these estimated settings are the most ideal for you:"
Basic.AutoConfig.TestPage.Result.Footer="To use these settings, click Apply Settings. To reconfigure the wizard and try again, click Back. To manually configure settings yourself, click Cancel and open Settings."
# updater
Updater.Title="New update available"
Updater.Text="There is a new update available:"

View File

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AutoConfigFinishPage</class>
<widget class="QWidget" name="AutoConfigFinishPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true"/>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AutoConfigStartPage</class>
<widget class="QWidget" name="AutoConfigStartPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true"/>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="prioritizeStreaming">
<property name="text">
<string>Basic.AutoConfig.StartPage.PrioritizeStreaming</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="prioritizeRecording">
<property name="text">
<string>Basic.AutoConfig.StartPage.PrioritizeRecording</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,252 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AutoConfigStreamPage</class>
<widget class="QWidget" name="AutoConfigStreamPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>566</width>
<height>335</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true"/>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<property name="labelAlignment">
<set>Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing</set>
</property>
<item row="1" column="0">
<widget class="QLabel" name="serviceLabel">
<property name="text">
<string>Basic.AutoConfig.StreamPage.Service</string>
</property>
<property name="buddy">
<cstring>service</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="service"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="streamKeyLabel">
<property name="text">
<string>Basic.AutoConfig.StreamPage.StreamKey</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="buddy">
<cstring>key</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="key">
<property name="inputMask">
<string notr="true"/>
</property>
<property name="text">
<string notr="true"/>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="show">
<property name="text">
<string>Show</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="6" column="1">
<widget class="QCheckBox" name="doBandwidthTest">
<property name="text">
<string>Basic.AutoConfig.StreamPage.PerformBandwidthTest</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QCheckBox" name="preferHardware">
<property name="text">
<string>Basic.AutoConfig.StreamPage.PreferHardwareEncoding</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>90</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0">
<widget class="QLabel" name="serverLabel">
<property name="text">
<string>Basic.AutoConfig.StreamPage.Server</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Basic.Settings.Stream.StreamType</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="streamType"/>
</item>
<item row="2" column="1">
<widget class="QStackedWidget" name="serverStackedWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="servicePage">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<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="QComboBox" name="server"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="customPage">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<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="customServer"/>
</item>
</layout>
</widget>
</widget>
</item>
<item row="7" column="1">
<widget class="QGroupBox" name="region">
<property name="title">
<string>BandwidthTest.Region</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<widget class="QCheckBox" name="regionAsia">
<property name="text">
<string>BandwidthTest.Region.Asia</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="regionUS">
<property name="text">
<string>BandwidthTest.Region.US</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="regionEU">
<property name="text">
<string>BandwidthTest.Region.EU</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="regionOther">
<property name="text">
<string>BandwidthTest.Region.Other</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="4" column="1">
<widget class="QSpinBox" name="bitrate">
<property name="suffix">
<string notr="true"/>
</property>
<property name="minimum">
<number>500</number>
</property>
<property name="maximum">
<number>10000</number>
</property>
<property name="value">
<number>2500</number>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="bitrateLabel">
<property name="text">
<string>Basic.Settings.Output.VideoBitrate</string>
</property>
<property name="buddy">
<cstring>bitrate</cstring>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>streamType</tabstop>
<tabstop>service</tabstop>
<tabstop>server</tabstop>
<tabstop>customServer</tabstop>
<tabstop>key</tabstop>
<tabstop>show</tabstop>
<tabstop>preferHardware</tabstop>
<tabstop>doBandwidthTest</tabstop>
<tabstop>regionUS</tabstop>
<tabstop>regionEU</tabstop>
<tabstop>regionAsia</tabstop>
<tabstop>regionOther</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,141 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AutoConfigTestPage</class>
<widget class="QWidget" name="AutoConfigTestPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true"/>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<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="QStackedWidget" name="stackedWidget">
<property name="currentIndex">
<number>2</number>
</property>
<widget class="QWidget" name="testPage">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="progressLabel">
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="subProgressLabel">
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="progressBar">
<property name="value">
<number>24</number>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="finishPage">
<layout class="QVBoxLayout" name="finishPageLayout">
<item>
<widget class="QLabel" name="finalResultLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Basic.AutoConfig.TestPage.Result.Header</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="finalResultLabel_2">
<property name="text">
<string>Basic.AutoConfig.TestPage.Result.Footer</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="errorPage">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="errorLabel">
<property name="text">
<string notr="true"/>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AutoConfigVideoPage</class>
<widget class="QWidget" name="AutoConfigVideoPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>470</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true"/>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QFormLayout" name="formLayout_2">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<property name="labelAlignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Basic.Settings.Video.BaseResolution</string>
</property>
<property name="buddy">
<cstring>canvasRes</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="canvasRes"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Basic.Settings.Video.FPS</string>
</property>
<property name="buddy">
<cstring>fps</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="fps"/>
</item>
<item row="3" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>87</width>
<height>17</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="warningLabel">
<property name="text">
<string>Basic.AutoConfig.VideoPage.CanvasExplanation</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -983,12 +983,11 @@
<addaction name="toggleStatusBar"/>
</widget>
<widget class="QMenu" name="menuTools">
<property name="enabled">
<bool>false</bool>
</property>
<property name="title">
<string>Basic.MainMenu.Tools</string>
</property>
<addaction name="autoConfigure"/>
<addaction name="separator"/>
</widget>
<addaction name="menu_File"/>
<addaction name="menuBasic_MainMenu_Edit"/>
@ -1462,6 +1461,16 @@
<string>PasteDuplicate</string>
</property>
</action>
<action name="autoConfigure2">
<property name="text">
<string>Basic.AutoConfig</string>
</property>
</action>
<action name="autoConfigure">
<property name="text">
<string>Basic.AutoConfig.Beta</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,795 @@
#include "window-basic-auto-config.hpp"
#include "window-basic-main.hpp"
#include "qt-wrappers.hpp"
#include "obs-app.hpp"
#include <QMessageBox>
#include <QScreen>
#include <obs.hpp>
#include "ui_AutoConfigStartPage.h"
#include "ui_AutoConfigVideoPage.h"
#include "ui_AutoConfigStreamPage.h"
#define wiz reinterpret_cast<AutoConfig*>(wizard())
/* ------------------------------------------------------------------------- */
#define SERVICE_PATH "service.json"
static OBSData OpenServiceSettings(std::string &type)
{
char serviceJsonPath[512];
int ret = GetProfilePath(serviceJsonPath, sizeof(serviceJsonPath),
SERVICE_PATH);
if (ret <= 0)
return OBSData();
OBSData data = obs_data_create_from_json_file_safe(serviceJsonPath,
"bak");
obs_data_release(data);
obs_data_set_default_string(data, "type", "rtmp_common");
type = obs_data_get_string(data, "type");
OBSData settings = obs_data_get_obj(data, "settings");
obs_data_release(settings);
return settings;
}
static void GetServiceInfo(std::string &type, std::string &service,
std::string &server, std::string &key)
{
OBSData settings = OpenServiceSettings(type);
service = obs_data_get_string(settings, "service");
server = obs_data_get_string(settings, "server");
key = obs_data_get_string(settings, "key");
}
/* ------------------------------------------------------------------------- */
AutoConfigStartPage::AutoConfigStartPage(QWidget *parent)
: QWizardPage (parent),
ui (new Ui_AutoConfigStartPage)
{
ui->setupUi(this);
setTitle(QTStr("Basic.AutoConfig.StartPage"));
setSubTitle(QTStr("Basic.AutoConfig.StartPage.SubTitle"));
}
AutoConfigStartPage::~AutoConfigStartPage()
{
delete ui;
}
int AutoConfigStartPage::nextId() const
{
return AutoConfig::VideoPage;
}
void AutoConfigStartPage::on_prioritizeStreaming_clicked()
{
wiz->type = AutoConfig::Type::Streaming;
}
void AutoConfigStartPage::on_prioritizeRecording_clicked()
{
wiz->type = AutoConfig::Type::Recording;
}
/* ------------------------------------------------------------------------- */
#define RES_TEXT(x) "Basic.AutoConfig.VideoPage." x
#define RES_USE_CURRENT RES_TEXT("BaseResolution.UseCurrent")
#define RES_USE_DISPLAY RES_TEXT("BaseResolution.Display")
#define FPS_USE_CURRENT RES_TEXT("FPS.UseCurrent")
#define FPS_PREFER_HIGH_FPS RES_TEXT("FPS.PreferHighFPS")
#define FPS_PREFER_HIGH_RES RES_TEXT("FPS.PreferHighRes")
AutoConfigVideoPage::AutoConfigVideoPage(QWidget *parent)
: QWizardPage (parent),
ui (new Ui_AutoConfigVideoPage)
{
ui->setupUi(this);
setTitle(QTStr("Basic.AutoConfig.VideoPage"));
setSubTitle(QTStr("Basic.AutoConfig.VideoPage.SubTitle"));
obs_video_info ovi;
obs_get_video_info(&ovi);
long double fpsVal =
(long double)ovi.fps_num / (long double)ovi.fps_den;
QString fpsStr = (ovi.fps_den > 1)
? QString::number(fpsVal, 'f', 2)
: QString::number(fpsVal, 'g', 2);
ui->fps->addItem(QTStr(FPS_PREFER_HIGH_FPS),
(int)AutoConfig::FPSType::PreferHighFPS);
ui->fps->addItem(QTStr(FPS_PREFER_HIGH_RES),
(int)AutoConfig::FPSType::PreferHighRes);
ui->fps->addItem(QTStr(FPS_USE_CURRENT).arg(fpsStr),
(int)AutoConfig::FPSType::UseCurrent);
ui->fps->addItem(QStringLiteral("30"), (int)AutoConfig::FPSType::fps30);
ui->fps->addItem(QStringLiteral("60"), (int)AutoConfig::FPSType::fps60);
ui->fps->setCurrentIndex(0);
QString cxStr = QString::number(ovi.base_width);
QString cyStr = QString::number(ovi.base_height);
int encRes = int(ovi.base_width << 16) | int(ovi.base_height);
ui->canvasRes->addItem(QTStr(RES_USE_CURRENT).arg(cxStr, cyStr),
(int)encRes);
QList<QScreen*> screens = QGuiApplication::screens();
for (int i = 0; i < screens.size(); i++) {
QScreen *screen = screens[i];
QSize as = screen->size();
encRes = int(as.width() << 16) | int(as.height());
QString str = QTStr(RES_USE_DISPLAY)
.arg(QString::number(i + 1),
QString::number(as.width()),
QString::number(as.height()));
ui->canvasRes->addItem(str, encRes);
}
auto addRes = [&] (int cx, int cy)
{
encRes = (cx << 16) | cy;
QString str = QString("%1x%2").arg(
QString::number(cx),
QString::number(cy));
ui->canvasRes->addItem(str, encRes);
};
addRes(1920, 1080);
addRes(1280, 720);
ui->canvasRes->setCurrentIndex(0);
}
AutoConfigVideoPage::~AutoConfigVideoPage()
{
delete ui;
}
int AutoConfigVideoPage::nextId() const
{
return wiz->type == AutoConfig::Type::Recording
? AutoConfig::TestPage
: AutoConfig::StreamPage;
}
bool AutoConfigVideoPage::validatePage()
{
int encRes = ui->canvasRes->currentData().toInt();
wiz->baseResolutionCX = encRes >> 16;
wiz->baseResolutionCY = encRes & 0xFFFF;
wiz->fpsType = (AutoConfig::FPSType)ui->fps->currentData().toInt();
obs_video_info ovi;
obs_get_video_info(&ovi);
switch (wiz->fpsType) {
case AutoConfig::FPSType::PreferHighFPS:
wiz->specificFPSNum = 0;
wiz->specificFPSDen = 0;
wiz->preferHighFPS = true;
break;
case AutoConfig::FPSType::PreferHighRes:
wiz->specificFPSNum = 0;
wiz->specificFPSDen = 0;
wiz->preferHighFPS = false;
break;
case AutoConfig::FPSType::UseCurrent:
wiz->specificFPSNum = ovi.fps_num;
wiz->specificFPSDen = ovi.fps_den;
wiz->preferHighFPS = false;
break;
case AutoConfig::FPSType::fps30:
wiz->specificFPSNum = 30;
wiz->specificFPSDen = 1;
wiz->preferHighFPS = false;
break;
case AutoConfig::FPSType::fps60:
wiz->specificFPSNum = 60;
wiz->specificFPSDen = 1;
wiz->preferHighFPS = false;
break;
}
return true;
}
/* ------------------------------------------------------------------------- */
AutoConfigStreamPage::AutoConfigStreamPage(QWidget *parent)
: QWizardPage (parent),
ui (new Ui_AutoConfigStreamPage)
{
ui->setupUi(this);
ui->bitrateLabel->setVisible(false);
ui->bitrate->setVisible(false);
ui->streamType->addItem(obs_service_get_display_name("rtmp_common"));
ui->streamType->addItem(obs_service_get_display_name("rtmp_custom"));
setTitle(QTStr("Basic.AutoConfig.StreamPage"));
setSubTitle(QTStr("Basic.AutoConfig.StreamPage.SubTitle"));
LoadServices(false);
connect(ui->streamType, SIGNAL(currentIndexChanged(int)),
this, SLOT(ServiceChanged()));
connect(ui->service, SIGNAL(currentIndexChanged(int)),
this, SLOT(ServiceChanged()));
connect(ui->customServer, SIGNAL(textChanged(const QString &)),
this, SLOT(ServiceChanged()));
connect(ui->doBandwidthTest, SIGNAL(toggled(bool)),
this, SLOT(ServiceChanged()));
connect(ui->service, SIGNAL(currentIndexChanged(int)),
this, SLOT(UpdateServerList()));
connect(ui->streamType, SIGNAL(currentIndexChanged(int)),
this, SLOT(UpdateKeyLink()));
connect(ui->service, SIGNAL(currentIndexChanged(int)),
this, SLOT(UpdateKeyLink()));
connect(ui->key, SIGNAL(textChanged(const QString &)),
this, SLOT(UpdateCompleted()));
connect(ui->regionUS, SIGNAL(toggled(bool)),
this, SLOT(UpdateCompleted()));
connect(ui->regionEU, SIGNAL(toggled(bool)),
this, SLOT(UpdateCompleted()));
connect(ui->regionAsia, SIGNAL(toggled(bool)),
this, SLOT(UpdateCompleted()));
connect(ui->regionOther, SIGNAL(toggled(bool)),
this, SLOT(UpdateCompleted()));
}
AutoConfigStreamPage::~AutoConfigStreamPage()
{
delete ui;
}
bool AutoConfigStreamPage::isComplete() const
{
return ready;
}
int AutoConfigStreamPage::nextId() const
{
return AutoConfig::TestPage;
}
bool AutoConfigStreamPage::validatePage()
{
OBSData service_settings = obs_data_create();
obs_data_release(service_settings);
obs_data_set_string(service_settings, "service",
QT_TO_UTF8(ui->service->currentText()));
OBSService service = obs_service_create("rtmp_common", "temp_service",
service_settings, nullptr);
obs_service_release(service);
wiz->customServer = ui->streamType->currentIndex() == 1;
int bitrate = 6000;
if (!ui->doBandwidthTest->isChecked()) {
bitrate = ui->bitrate->value();
wiz->idealBitrate = bitrate;
}
OBSData settings = obs_data_create();
obs_data_release(settings);
obs_data_set_int(settings, "bitrate", bitrate);
obs_service_apply_encoder_settings(service, settings, nullptr);
if (wiz->customServer) {
QString server = ui->customServer->text();
wiz->server = wiz->serverName = QT_TO_UTF8(server);
} else {
wiz->serverName = QT_TO_UTF8(ui->server->currentText());
wiz->server = QT_TO_UTF8(ui->server->currentData().toString());
}
wiz->bandwidthTest = ui->doBandwidthTest->isChecked();
wiz->startingBitrate = (int)obs_data_get_int(settings, "bitrate");
wiz->idealBitrate = wiz->startingBitrate;
wiz->regionUS = ui->regionUS->isChecked();
wiz->regionEU = ui->regionEU->isChecked();
wiz->regionAsia = ui->regionAsia->isChecked();
wiz->regionOther = ui->regionOther->isChecked();
wiz->serviceName = QT_TO_UTF8(ui->service->currentText());
if (ui->preferHardware)
wiz->preferHardware = ui->preferHardware->isChecked();
wiz->key = QT_TO_UTF8(ui->key->text());
if (!wiz->customServer) {
if (wiz->serviceName == "Twitch")
wiz->service = AutoConfig::Service::Twitch;
else if (wiz->serviceName == "hitbox.tv")
wiz->service = AutoConfig::Service::Hitbox;
else if (wiz->serviceName == "beam.pro")
wiz->service = AutoConfig::Service::Beam;
else
wiz->service = AutoConfig::Service::Other;
} else {
wiz->service = AutoConfig::Service::Other;
}
if (wiz->service != AutoConfig::Service::Twitch && wiz->bandwidthTest) {
QMessageBox::StandardButton button;
#define WARNING_TEXT(x) QTStr("Basic.AutoConfig.StreamPage.StreamWarning." x)
button = QMessageBox::question(this,
WARNING_TEXT("Title"),
WARNING_TEXT("Text"));
#undef WARNING_TEXT
if (button == QMessageBox::No)
return false;
}
return true;
}
void AutoConfigStreamPage::on_show_clicked()
{
if (ui->key->echoMode() == QLineEdit::Password) {
ui->key->setEchoMode(QLineEdit::Normal);
ui->show->setText(QTStr("Hide"));
} else {
ui->key->setEchoMode(QLineEdit::Password);
ui->show->setText(QTStr("Show"));
}
}
void AutoConfigStreamPage::ServiceChanged()
{
bool showMore = ui->service->currentData().toBool();
if (showMore)
return;
std::string service = QT_TO_UTF8(ui->service->currentText());
bool regionBased = service == "Twitch" ||
service == "hitbox.tv" ||
service == "beam.pro";
bool testBandwidth = ui->doBandwidthTest->isChecked();
bool custom = ui->streamType->currentIndex() == 1;
ui->service->setVisible(!custom);
ui->serviceLabel->setVisible(!custom);
ui->formLayout->removeWidget(ui->serviceLabel);
ui->formLayout->removeWidget(ui->service);
ui->formLayout->removeWidget(ui->serverLabel);
ui->formLayout->removeWidget(ui->serverStackedWidget);
if (custom) {
ui->formLayout->insertRow(1, ui->serverLabel,
ui->serverStackedWidget);
ui->region->setVisible(false);
ui->serverStackedWidget->setCurrentIndex(1);
ui->serverStackedWidget->setVisible(true);
ui->serverLabel->setVisible(true);
} else {
ui->formLayout->insertRow(1, ui->serviceLabel, ui->service);
if (!testBandwidth)
ui->formLayout->insertRow(2, ui->serverLabel,
ui->serverStackedWidget);
ui->region->setVisible(regionBased && testBandwidth);
ui->serverStackedWidget->setCurrentIndex(0);
ui->serverStackedWidget->setHidden(testBandwidth);
ui->serverLabel->setHidden(testBandwidth);
}
wiz->testRegions = regionBased && testBandwidth;
ui->bitrateLabel->setHidden(testBandwidth);
ui->bitrate->setHidden(testBandwidth);
UpdateCompleted();
}
void AutoConfigStreamPage::UpdateKeyLink()
{
bool custom = ui->streamType->currentIndex() == 1;
QString serviceName = ui->service->currentText();
if (custom)
serviceName = "";
QString text = QTStr("Basic.AutoConfig.StreamPage.StreamKey");
if (serviceName == "Twitch") {
text += " <a href=\"https://";
text += "www.twitch.tv/broadcast/dashboard/streamkey";
text += "\">";
text += QTStr("Basic.AutoConfig.StreamPage.StreamKey.LinkToSite");
text += "</a>";
} else if (serviceName == "YouTube / YouTube Gaming") {
text += " <a href=\"https://";
text += "www.youtube.com/live_dashboard";
text += "\">";
text += QTStr("Basic.AutoConfig.StreamPage.StreamKey.LinkToSite");
text += "</a>";
}
ui->streamKeyLabel->setText(text);
}
void AutoConfigStreamPage::LoadServices(bool showAll)
{
obs_properties_t *props = obs_get_service_properties("rtmp_common");
OBSData settings = obs_data_create();
obs_data_release(settings);
obs_data_set_bool(settings, "show_all", showAll);
obs_property_t *prop = obs_properties_get(props, "show_all");
obs_property_modified(prop, settings);
ui->service->blockSignals(true);
ui->service->clear();
QStringList names;
obs_property_t *services = obs_properties_get(props, "service");
size_t services_count = obs_property_list_item_count(services);
for (size_t i = 0; i < services_count; i++) {
const char *name = obs_property_list_item_string(services, i);
names.push_back(name);
}
if (showAll)
names.sort();
for (QString &name : names)
ui->service->addItem(name);
if (!lastService.isEmpty()) {
int idx = ui->service->findText(lastService);
if (idx != -1)
ui->service->setCurrentIndex(idx);
}
if (!showAll) {
ui->service->addItem(
QTStr("Basic.AutoConfig.StreamPage.Service.ShowAll"),
QVariant(true));
}
obs_properties_destroy(props);
ui->service->blockSignals(false);
}
void AutoConfigStreamPage::UpdateServerList()
{
QString serviceName = ui->service->currentText();
bool showMore = ui->service->currentData().toBool();
if (showMore) {
LoadServices(true);
ui->service->showPopup();
return;
} else {
lastService = serviceName;
}
obs_properties_t *props = obs_get_service_properties("rtmp_common");
obs_property_t *services = obs_properties_get(props, "service");
OBSData settings = obs_data_create();
obs_data_release(settings);
obs_data_set_string(settings, "service", QT_TO_UTF8(serviceName));
obs_property_modified(services, settings);
obs_property_t *servers = obs_properties_get(props, "server");
ui->server->clear();
size_t servers_count = obs_property_list_item_count(servers);
for (size_t i = 0; i < servers_count; i++) {
const char *name = obs_property_list_item_name(servers, i);
const char *server = obs_property_list_item_string(servers, i);
ui->server->addItem(name, server);
}
obs_properties_destroy(props);
}
void AutoConfigStreamPage::UpdateCompleted()
{
if (ui->key->text().isEmpty()) {
ready = false;
} else {
bool custom = ui->streamType->currentIndex() == 1;
if (custom) {
ready = !ui->customServer->text().isEmpty();
} else {
ready = !wiz->testRegions ||
ui->regionUS->isChecked() ||
ui->regionEU->isChecked() ||
ui->regionAsia->isChecked() ||
ui->regionOther->isChecked();
}
}
emit completeChanged();
}
/* ------------------------------------------------------------------------- */
AutoConfig::AutoConfig(QWidget *parent)
: QWizard(parent)
{
OBSBasic *main = reinterpret_cast<OBSBasic*>(parent);
main->EnableOutputs(false);
installEventFilter(CreateShortcutFilter());
std::string serviceType;
GetServiceInfo(serviceType, serviceName, server, key);
#ifdef _WIN32
setWizardStyle(QWizard::ModernStyle);
#endif
AutoConfigStreamPage *streamPage = new AutoConfigStreamPage();
setPage(StartPage, new AutoConfigStartPage());
setPage(VideoPage, new AutoConfigVideoPage());
setPage(StreamPage, streamPage);
setPage(TestPage, new AutoConfigTestPage());
setWindowTitle(QTStr("Basic.AutoConfig.Beta"));
obs_video_info ovi;
obs_get_video_info(&ovi);
baseResolutionCX = ovi.base_width;
baseResolutionCY = ovi.base_height;
/* ----------------------------------------- */
/* load service/servers */
customServer = serviceType == "rtmp_custom";
QComboBox *serviceList = streamPage->ui->service;
if (!serviceName.empty()) {
serviceList->blockSignals(true);
int count = serviceList->count();
bool found = false;
for (int i = 0; i < count; i++) {
QString name = serviceList->itemText(i);
if (name == serviceName.c_str()) {
serviceList->setCurrentIndex(i);
found = true;
break;
}
}
if (!found) {
serviceList->insertItem(0, serviceName.c_str());
serviceList->setCurrentIndex(0);
}
serviceList->blockSignals(false);
}
streamPage->UpdateServerList();
streamPage->UpdateKeyLink();
if (!customServer) {
QComboBox *serverList = streamPage->ui->server;
int idx = serverList->findData(QString(server.c_str()));
if (idx == -1)
idx = 0;
serverList->setCurrentIndex(idx);
} else {
streamPage->ui->customServer->setText(server.c_str());
streamPage->ui->streamType->setCurrentIndex(1);
}
if (!key.empty())
streamPage->ui->key->setText(key.c_str());
int bitrate = config_get_int(main->Config(), "SimpleOutput", "VBitrate");
streamPage->ui->bitrate->setValue(bitrate);
streamPage->ServiceChanged();
streamPage->ui->preferHardware->setChecked(os_get_physical_cores() <= 4);
TestHardwareEncoding();
if (!hardwareEncodingAvailable) {
delete streamPage->ui->preferHardware;
streamPage->ui->preferHardware = nullptr;
}
setOptions(0);
setButtonText(QWizard::FinishButton,
QTStr("Basic.AutoConfig.ApplySettings"));
}
AutoConfig::~AutoConfig()
{
OBSBasic *main = reinterpret_cast<OBSBasic*>(App()->GetMainWindow());
main->EnableOutputs(true);
}
void AutoConfig::TestHardwareEncoding()
{
size_t idx = 0;
const char *id;
while (obs_enum_encoder_types(idx++, &id)) {
if (strcmp(id, "ffmpeg_nvenc") == 0)
hardwareEncodingAvailable = nvencAvailable = true;
else if (strcmp(id, "obs_qsv11") == 0)
hardwareEncodingAvailable = qsvAvailable = true;
else if (strcmp(id, "amd_amf_h264") == 0)
hardwareEncodingAvailable = vceAvailable = true;
}
}
bool AutoConfig::CanTestServer(const char *server)
{
if (!testRegions || (regionUS && regionEU && regionAsia && regionOther))
return true;
if (service == Service::Twitch) {
if (astrcmp_n(server, "US West:", 8) == 0 ||
astrcmp_n(server, "US East:", 8) == 0 ||
astrcmp_n(server, "US Central:", 11) == 0) {
return regionUS;
} else if (astrcmp_n(server, "EU:", 3) == 0) {
return regionEU;
} else if (astrcmp_n(server, "Asia:", 5) == 0) {
return regionAsia;
} else if (regionOther) {
return true;
}
} else if (service == Service::Hitbox) {
if (strcmp(server, "Default") == 0) {
return true;
} else if (astrcmp_n(server, "US-West:", 8) == 0 ||
astrcmp_n(server, "US-East:", 8) == 0) {
return regionUS;
} else if (astrcmp_n(server, "EU-", 3) == 0) {
return regionEU;
} else if (astrcmp_n(server, "South Korea:", 12) == 0 ||
astrcmp_n(server, "Asia:", 5) == 0 ||
astrcmp_n(server, "China:", 6) == 0) {
return regionAsia;
} else if (regionOther) {
return true;
}
} else if (service == Service::Beam) {
if (astrcmp_n(server, "US:", 3) == 0) {
return regionUS;
} else if (astrcmp_n(server, "EU:", 3) == 0) {
return regionEU;
} else if (astrcmp_n(server, "South Korea:", 12) == 0 ||
astrcmp_n(server, "Asia:", 5) == 0) {
return regionAsia;
} else if (regionOther) {
return true;
}
} else {
return true;
}
return false;
}
void AutoConfig::done(int result)
{
QWizard::done(result);
if (result == QDialog::Accepted) {
if (type == Type::Streaming)
SaveStreamSettings();
SaveSettings();
}
}
inline const char *AutoConfig::GetEncoderId(Encoder enc)
{
switch (enc) {
case Encoder::NVENC:
return SIMPLE_ENCODER_NVENC;
case Encoder::QSV:
return SIMPLE_ENCODER_QSV;
case Encoder::AMD:
return SIMPLE_ENCODER_AMD;
default:
return SIMPLE_ENCODER_X264;
}
};
void AutoConfig::SaveStreamSettings()
{
OBSBasic *main = reinterpret_cast<OBSBasic*>(App()->GetMainWindow());
/* ---------------------------------- */
/* save service */
const char *service_id = customServer
? "rtmp_custom"
: "rtmp_common";
obs_service_t *oldService = main->GetService();
OBSData hotkeyData = obs_hotkeys_save_service(oldService);
obs_data_release(hotkeyData);
OBSData settings = obs_data_create();
obs_data_release(settings);
if (!customServer)
obs_data_set_string(settings, "service", serviceName.c_str());
obs_data_set_string(settings, "server", server.c_str());
obs_data_set_string(settings, "key", key.c_str());
OBSService newService = obs_service_create(service_id,
"default_service", settings, hotkeyData);
obs_service_release(newService);
if (!newService)
return;
main->SetService(newService);
main->SaveService();
/* ---------------------------------- */
/* save stream settings */
config_set_int(main->Config(), "SimpleOutput", "VBitrate",
idealBitrate);
config_set_string(main->Config(), "SimpleOutput", "StreamEncoder",
GetEncoderId(streamingEncoder));
}
void AutoConfig::SaveSettings()
{
OBSBasic *main = reinterpret_cast<OBSBasic*>(App()->GetMainWindow());
if (recordingEncoder != Encoder::Stream)
config_set_string(main->Config(), "SimpleOutput", "RecEncoder",
GetEncoderId(recordingEncoder));
const char *quality = recordingQuality == Quality::High
? "Small"
: "Stream";
config_set_string(main->Config(), "Output", "Mode", "Simple");
config_set_string(main->Config(), "SimpleOutput", "RecQuality", quality);
config_set_int(main->Config(), "Video", "BaseCX", baseResolutionCX);
config_set_int(main->Config(), "Video", "BaseCY", baseResolutionCY);
config_set_int(main->Config(), "Video", "OutputCX", idealResolutionCX);
config_set_int(main->Config(), "Video", "OutputCY", idealResolutionCY);
if (fpsType != FPSType::UseCurrent) {
config_set_uint(main->Config(), "Video", "FPSType", 0);
config_set_string(main->Config(), "Video", "FPSCommon",
std::to_string(idealFPSNum).c_str());
}
main->ResetVideo();
main->ResetOutputs();
config_save_safe(main->Config(), "tmp", nullptr);
}

View File

@ -0,0 +1,248 @@
#pragma once
#include <QWizard>
#include <QPointer>
#include <QFormLayout>
#include <QWizardPage>
#include <condition_variable>
#include <utility>
#include <thread>
#include <vector>
#include <string>
#include <mutex>
class Ui_AutoConfigStartPage;
class Ui_AutoConfigVideoPage;
class Ui_AutoConfigStreamPage;
class Ui_AutoConfigTestPage;
class AutoConfig : public QWizard {
Q_OBJECT
friend class AutoConfigStartPage;
friend class AutoConfigVideoPage;
friend class AutoConfigStreamPage;
friend class AutoConfigTestPage;
enum class Type {
Invalid,
Streaming,
Recording
};
enum class Service {
Twitch,
Hitbox,
Beam,
Other
};
enum class Encoder {
x264,
NVENC,
QSV,
AMD,
Stream
};
enum class Quality {
Stream,
High
};
enum class FPSType : int {
PreferHighFPS,
PreferHighRes,
UseCurrent,
fps30,
fps60
};
static inline const char *GetEncoderId(Encoder enc);
Service service = Service::Other;
Quality recordingQuality = Quality::Stream;
Encoder recordingEncoder = Encoder::Stream;
Encoder streamingEncoder = Encoder::x264;
Type type = Type::Invalid;
FPSType fpsType = FPSType::PreferHighFPS;
int idealBitrate = 2500;
int baseResolutionCX = 1920;
int baseResolutionCY = 1080;
int idealResolutionCX = 1280;
int idealResolutionCY = 720;
int idealFPSNum = 60;
int idealFPSDen = 1;
std::string serviceName;
std::string serverName;
std::string server;
std::string key;
bool hardwareEncodingAvailable = false;
bool nvencAvailable = false;
bool qsvAvailable = false;
bool vceAvailable = false;
int startingBitrate = 2500;
bool customServer = false;
bool bandwidthTest = false;
bool testRegions = true;
bool regionUS = true;
bool regionEU = true;
bool regionAsia = true;
bool regionOther = true;
bool preferHighFPS = false;
bool preferHardware = false;
int specificFPSNum = 0;
int specificFPSDen = 0;
void TestHardwareEncoding();
bool CanTestServer(const char *server);
virtual void done(int result) override;
void SaveStreamSettings();
void SaveSettings();
public:
AutoConfig(QWidget *parent);
~AutoConfig();
enum Page {
StartPage,
VideoPage,
StreamPage,
TestPage
};
};
class AutoConfigStartPage : public QWizardPage {
Q_OBJECT
friend class AutoConfig;
Ui_AutoConfigStartPage *ui;
public:
AutoConfigStartPage(QWidget *parent = nullptr);
~AutoConfigStartPage();
virtual int nextId() const override;
public slots:
void on_prioritizeStreaming_clicked();
void on_prioritizeRecording_clicked();
};
class AutoConfigVideoPage : public QWizardPage {
Q_OBJECT
friend class AutoConfig;
Ui_AutoConfigVideoPage *ui;
public:
AutoConfigVideoPage(QWidget *parent = nullptr);
~AutoConfigVideoPage();
virtual int nextId() const override;
virtual bool validatePage() override;
};
class AutoConfigStreamPage : public QWizardPage {
Q_OBJECT
friend class AutoConfig;
Ui_AutoConfigStreamPage *ui;
QString lastService;
bool ready = false;
void LoadServices(bool showAll);
public:
AutoConfigStreamPage(QWidget *parent = nullptr);
~AutoConfigStreamPage();
virtual bool isComplete() const override;
virtual int nextId() const override;
virtual bool validatePage() override;
public slots:
void on_show_clicked();
void ServiceChanged();
void UpdateKeyLink();
void UpdateServerList();
void UpdateCompleted();
};
class AutoConfigTestPage : public QWizardPage {
Q_OBJECT
friend class AutoConfig;
QPointer<QFormLayout> results;
Ui_AutoConfigTestPage *ui;
std::thread testThread;
std::condition_variable cv;
std::mutex m;
bool cancel = false;
bool started = false;
enum class Stage {
Starting,
BandwidthTest,
StreamEncoder,
RecordingEncoder,
Finished
};
Stage stage = Stage::Starting;
bool softwareTested = false;
void StartBandwidthStage();
void StartStreamEncoderStage();
void StartRecordingEncoderStage();
void FindIdealHardwareResolution();
bool TestSoftwareEncoding();
void TestBandwidthThread();
void TestStreamEncoderThread();
void TestRecordingEncoderThread();
void FinalizeResults();
struct ServerInfo {
std::string name;
std::string address;
int bitrate = 0;
int ms = -1;
inline ServerInfo() {}
inline ServerInfo(const char *name_, const char *address_)
: name(name_), address(address_)
{
}
};
void GetServers(std::vector<ServerInfo> &servers);
public:
AutoConfigTestPage(QWidget *parent = nullptr);
~AutoConfigTestPage();
virtual void initializePage() override;
virtual void cleanupPage() override;
virtual bool isComplete() const override;
virtual int nextId() const override;
public slots:
void NextStage();
void UpdateMessage(QString message);
void Failure(QString message);
void Progress(int percentage);
};

View File

@ -40,6 +40,7 @@
#include "item-widget-helpers.hpp"
#include "window-basic-settings.hpp"
#include "window-namedialog.hpp"
#include "window-basic-auto-config.hpp"
#include "window-basic-source-select.hpp"
#include "window-basic-main.hpp"
#include "window-basic-main-outputs.hpp"
@ -1422,6 +1423,36 @@ void OBSBasic::OBSInit()
SystemTray(true);
OpenSavedProjectors();
bool has_last_version = config_has_user_value(App()->GlobalConfig(),
"General", "LastVersion");
bool first_run = config_get_bool(App()->GlobalConfig(), "General",
"FirstRun");
if (!first_run) {
config_set_bool(App()->GlobalConfig(), "General", "FirstRun",
true);
config_save_safe(App()->GlobalConfig(), "tmp", nullptr);
}
if (!first_run && !has_last_version && !Active()) {
QString msg;
msg = QTStr("Basic.FirstStartup.RunWizard");
msg += "\n\n";
msg += QTStr("Basic.FirstStartup.RunWizard.BetaWarning");
QMessageBox::StandardButton button =
QMessageBox::question(this, QTStr("Basic.AutoConfig"),
msg);
if (button == QMessageBox::Yes) {
on_autoConfigure_triggered();
} else {
msg = QTStr("Basic.FirstStartup.RunWizard.NoClicked");
QMessageBox::information(this,
QTStr("Basic.AutoConfig"), msg);
}
}
}
void OBSBasic::InitHotkeys()
@ -3976,6 +4007,7 @@ inline void OBSBasic::OnActivate()
{
if (ui->profileMenu->isEnabled()) {
ui->profileMenu->setEnabled(false);
ui->autoConfigure->setEnabled(false);
App()->IncrementSleepInhibition();
UpdateProcessPriority();
@ -3988,6 +4020,7 @@ inline void OBSBasic::OnDeactivate()
{
if (!outputHandler->Active() && !ui->profileMenu->isEnabled()) {
ui->profileMenu->setEnabled(true);
ui->autoConfigure->setEnabled(true);
App()->DecrementSleepInhibition();
ClearProcessPriority();
@ -5445,3 +5478,11 @@ void OBSBasic::on_actionPasteFilters_triggered()
obs_source_copy_filters(dstSource, source);
}
void OBSBasic::on_autoConfigure_triggered()
{
AutoConfig test(this);
test.setModal(true);
test.show();
test.exec();
}

View File

@ -613,6 +613,8 @@ private slots:
void on_modeSwitch_clicked();
void on_autoConfigure_triggered();
void logUploadFinished(const QString &text, const QString &error);
void updateCheckFinished();