1
0

AutoConfigTestPage.hpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #pragma once
  2. #include <QPointer>
  3. #include <QWizardPage>
  4. #include <condition_variable>
  5. #include <mutex>
  6. #include <thread>
  7. class QFormLayout;
  8. class Ui_AutoConfigTestPage;
  9. class AutoConfigTestPage : public QWizardPage {
  10. Q_OBJECT
  11. friend class AutoConfig;
  12. QPointer<QFormLayout> results;
  13. std::unique_ptr<Ui_AutoConfigTestPage> ui;
  14. std::thread testThread;
  15. std::condition_variable cv;
  16. std::mutex m;
  17. bool cancel = false;
  18. bool started = false;
  19. enum class Stage {
  20. Starting,
  21. BandwidthTest,
  22. StreamEncoder,
  23. RecordingEncoder,
  24. Finished,
  25. };
  26. Stage stage = Stage::Starting;
  27. bool softwareTested = false;
  28. void StartBandwidthStage();
  29. void StartStreamEncoderStage();
  30. void StartRecordingEncoderStage();
  31. void FindIdealHardwareResolution();
  32. bool TestSoftwareEncoding();
  33. void TestBandwidthThread();
  34. void TestStreamEncoderThread();
  35. void TestRecordingEncoderThread();
  36. void FinalizeResults();
  37. struct ServerInfo {
  38. std::string name;
  39. std::string address;
  40. int bitrate = 0;
  41. int ms = -1;
  42. inline ServerInfo() {}
  43. inline ServerInfo(const char *name_, const char *address_) : name(name_), address(address_) {}
  44. };
  45. void GetServers(std::vector<ServerInfo> &servers);
  46. public:
  47. AutoConfigTestPage(QWidget *parent = nullptr);
  48. ~AutoConfigTestPage();
  49. virtual void initializePage() override;
  50. virtual void cleanupPage() override;
  51. virtual bool isComplete() const override;
  52. virtual int nextId() const override;
  53. public slots:
  54. void NextStage();
  55. void UpdateMessage(QString message);
  56. void Failure(QString message);
  57. void Progress(int percentage);
  58. };