0c198bee50
The radio buttons had been changed so "Streaming" would be selected by default, but it only sets the wizard's "type" to streaming if the user actually clicks the radio button themselves manually, so it would stay set to "Invalid" by mistake, causing settings to not be applied.
249 lines
4.6 KiB
C++
249 lines
4.6 KiB
C++
#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::Streaming;
|
|
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);
|
|
};
|