window-basic-settings.hpp 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. /******************************************************************************
  2. Copyright (C) 2013 by Hugh Bailey <[email protected]>
  3. Philippe Groarke <[email protected]>
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. ******************************************************************************/
  15. #pragma once
  16. #include <util/util.hpp>
  17. #include <QDialog>
  18. #include <memory>
  19. #include <string>
  20. #include <libff/ff-util.h>
  21. #include <obs.h>
  22. class OBSBasic;
  23. class QAbstractButton;
  24. class QComboBox;
  25. class OBSPropertiesView;
  26. #include "ui_OBSBasicSettings.h"
  27. class OBSFFDeleter
  28. {
  29. public:
  30. void operator()(const ff_format_desc *format)
  31. {
  32. ff_format_desc_free(format);
  33. }
  34. void operator()(const ff_codec_desc *codec)
  35. {
  36. ff_codec_desc_free(codec);
  37. }
  38. };
  39. using OBSFFCodecDesc = std::unique_ptr<const ff_codec_desc,
  40. OBSFFDeleter>;
  41. using OBSFFFormatDesc = std::unique_ptr<const ff_format_desc,
  42. OBSFFDeleter>;
  43. class OBSBasicSettings : public QDialog {
  44. Q_OBJECT
  45. private:
  46. OBSBasic *main;
  47. std::unique_ptr<Ui::OBSBasicSettings> ui;
  48. bool generalChanged = false;
  49. bool stream1Changed = false;
  50. bool outputsChanged = false;
  51. bool audioChanged = false;
  52. bool videoChanged = false;
  53. bool advancedChanged = false;
  54. int pageIndex = 0;
  55. bool loading = true;
  56. std::string savedTheme;
  57. OBSFFFormatDesc formats;
  58. OBSPropertiesView *streamProperties = nullptr;
  59. OBSPropertiesView *streamEncoderProps = nullptr;
  60. OBSPropertiesView *recordEncoderProps = nullptr;
  61. void SaveCombo(QComboBox *widget, const char *section,
  62. const char *value);
  63. void SaveComboData(QComboBox *widget, const char *section,
  64. const char *value);
  65. void SaveCheckBox(QAbstractButton *widget, const char *section,
  66. const char *value, bool invert = false);
  67. void SaveEdit(QLineEdit *widget, const char *section,
  68. const char *value);
  69. void SaveSpinBox(QSpinBox *widget, const char *section,
  70. const char *value);
  71. void SaveFormat(QComboBox *combo);
  72. void SaveEncoder(QComboBox *combo, const char *section,
  73. const char *value);
  74. inline bool Changed() const
  75. {
  76. return generalChanged || outputsChanged || stream1Changed ||
  77. audioChanged || videoChanged || advancedChanged;
  78. }
  79. inline void EnableApplyButton(bool en)
  80. {
  81. ui->buttonBox->button(QDialogButtonBox::Apply)->setEnabled(en);
  82. }
  83. inline void ClearChanged()
  84. {
  85. generalChanged = false;
  86. stream1Changed = false;
  87. outputsChanged = false;
  88. audioChanged = false;
  89. videoChanged = false;
  90. advancedChanged= false;
  91. EnableApplyButton(false);
  92. }
  93. void HookWidget(QWidget *widget, const char *signal, const char *slot);
  94. bool QueryChanges();
  95. void LoadServiceTypes();
  96. void LoadEncoderTypes();
  97. void LoadColorRanges();
  98. void LoadFormats();
  99. void ReloadCodecs(const ff_format_desc *formatDesc);
  100. void LoadGeneralSettings();
  101. void LoadStream1Settings();
  102. void LoadOutputSettings();
  103. void LoadAudioSettings();
  104. void LoadVideoSettings();
  105. void LoadAdvancedSettings();
  106. void LoadSettings(bool changedOnly);
  107. OBSPropertiesView *CreateEncoderPropertyView(const char *encoder,
  108. const char *path, bool changed = false);
  109. /* general */
  110. void LoadLanguageList();
  111. void LoadThemeList();
  112. /* output */
  113. void LoadSimpleOutputSettings();
  114. void LoadAdvOutputStreamingSettings();
  115. void LoadAdvOutputStreamingEncoderProperties();
  116. void LoadAdvOutputRecordingSettings();
  117. void LoadAdvOutputRecordingEncoderProperties();
  118. void LoadAdvOutputFFmpegSettings();
  119. void LoadAdvOutputAudioSettings();
  120. void SetAdvOutputFFmpegEnablement(
  121. ff_codec_type encoderType, bool enabled,
  122. bool enableEncode = false);
  123. /* audio */
  124. void LoadListValues(QComboBox *widget, obs_property_t *prop,
  125. const char *configName);
  126. void LoadAudioDevices();
  127. /* video */
  128. void LoadRendererList();
  129. void ResetDownscales(uint32_t cx, uint32_t cy,
  130. uint32_t out_cx, uint32_t out_cy);
  131. void LoadDownscaleFilters();
  132. void LoadResolutionLists();
  133. void LoadFPSData();
  134. void SaveGeneralSettings();
  135. void SaveStream1Settings();
  136. void SaveOutputSettings();
  137. void SaveAudioSettings();
  138. void SaveVideoSettings();
  139. void SaveAdvancedSettings();
  140. void SaveSettings();
  141. private slots:
  142. void on_theme_activated(int idx);
  143. void on_simpleOutUseBufsize_toggled(bool checked);
  144. void on_simpleOutputVBitrate_valueChanged(int val);
  145. void on_listWidget_itemSelectionChanged();
  146. void on_buttonBox_clicked(QAbstractButton *button);
  147. void on_streamType_currentIndexChanged(int idx);
  148. void on_simpleOutputBrowse_clicked();
  149. void on_advOutRecPathBrowse_clicked();
  150. void on_advOutFFPathBrowse_clicked();
  151. void on_advOutEncoder_currentIndexChanged(int idx);
  152. void on_advOutRecEncoder_currentIndexChanged(int idx);
  153. void on_advOutFFFormat_currentIndexChanged(int idx);
  154. void on_advOutFFAEncoder_currentIndexChanged(int idx);
  155. void on_advOutFFVEncoder_currentIndexChanged(int idx);
  156. void on_baseResolution_editTextChanged(const QString &text);
  157. void GeneralChanged();
  158. void AudioChanged();
  159. void AudioChangedRestart();
  160. void OutputsChanged();
  161. void Stream1Changed();
  162. void VideoChanged();
  163. void VideoChangedResolution();
  164. void VideoChangedRestart();
  165. void AdvancedChanged();
  166. void AdvancedChangedRestart();
  167. protected:
  168. virtual void closeEvent(QCloseEvent *event);
  169. public:
  170. OBSBasicSettings(QWidget *parent);
  171. };