window-basic-main.hpp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /******************************************************************************
  2. Copyright (C) 2013-2014 by Hugh Bailey <[email protected]>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ******************************************************************************/
  14. #pragma once
  15. #include <obs.hpp>
  16. #include <unordered_map>
  17. #include <memory>
  18. #include "window-main.hpp"
  19. #include "window-basic-properties.hpp"
  20. #include <util/util.hpp>
  21. class QListWidgetItem;
  22. #include "ui_OBSBasic.h"
  23. class OBSBasic : public OBSMainWindow {
  24. Q_OBJECT
  25. private:
  26. std::unordered_map<obs_source_t, int> sourceSceneRefs;
  27. obs_output_t outputTest;
  28. bool sceneChanging;
  29. int previewX, previewY;
  30. float previewScale;
  31. int resizeTimer;
  32. ConfigFile basicConfig;
  33. OBSBasicProperties *properties;
  34. void GetFPSCommon(uint32_t &num, uint32_t &den) const;
  35. void GetFPSInteger(uint32_t &num, uint32_t &den) const;
  36. void GetFPSFraction(uint32_t &num, uint32_t &den) const;
  37. void GetFPSNanoseconds(uint32_t &num, uint32_t &den) const;
  38. void GetConfigFPS(uint32_t &num, uint32_t &den) const;
  39. bool InitBasicConfigDefaults();
  40. bool InitBasicConfig();
  41. OBSScene GetCurrentScene();
  42. OBSSceneItem GetCurrentSceneItem();
  43. void UpdateSources(OBSScene scene);
  44. void InsertSceneItem(obs_sceneitem_t item);
  45. public slots:
  46. void OutputStart(int errorcode);
  47. private slots:
  48. void AddSceneItem(OBSSceneItem item);
  49. void RemoveSceneItem(OBSSceneItem item);
  50. void AddScene(OBSSource source);
  51. void RemoveScene(OBSSource source);
  52. void UpdateSceneSelection(OBSSource source);
  53. private:
  54. /* OBS Callbacks */
  55. static void SceneItemAdded(void *data, calldata_t params);
  56. static void SceneItemRemoved(void *data, calldata_t params);
  57. static void SourceAdded(void *data, calldata_t params);
  58. static void SourceRemoved(void *data, calldata_t params);
  59. static void ChannelChanged(void *data, calldata_t params);
  60. static void RenderMain(void *data, uint32_t cx, uint32_t cy);
  61. void ResizePreview(uint32_t cx, uint32_t cy);
  62. void AddSource(obs_scene_t scene, const char *id);
  63. void AddSourcePopupMenu(const QPoint &pos);
  64. public:
  65. bool ResetVideo();
  66. bool ResetAudio();
  67. void ResetAudioDevice(const char *sourceId, const char *deviceName,
  68. int channel);
  69. void ResetAudioDevices();
  70. void NewProject();
  71. void SaveProject();
  72. void LoadProject();
  73. void UnloadProperties();
  74. protected:
  75. virtual void closeEvent(QCloseEvent *event) override;
  76. virtual void changeEvent(QEvent *event) override;
  77. virtual void resizeEvent(QResizeEvent *event) override;
  78. virtual void timerEvent(QTimerEvent *event) override;
  79. private slots:
  80. void on_action_New_triggered();
  81. void on_action_Open_triggered();
  82. void on_action_Save_triggered();
  83. void on_scenes_currentItemChanged(QListWidgetItem *current,
  84. QListWidgetItem *prev);
  85. void on_scenes_customContextMenuRequested(const QPoint &pos);
  86. void on_actionAddScene_triggered();
  87. void on_actionRemoveScene_triggered();
  88. void on_actionSceneProperties_triggered();
  89. void on_actionSceneUp_triggered();
  90. void on_actionSceneDown_triggered();
  91. void on_sources_currentItemChanged(QListWidgetItem *current,
  92. QListWidgetItem *prev);
  93. void on_sources_customContextMenuRequested(const QPoint &pos);
  94. void on_actionAddSource_triggered();
  95. void on_actionRemoveSource_triggered();
  96. void on_actionSourceProperties_triggered();
  97. void on_actionSourceUp_triggered();
  98. void on_actionSourceDown_triggered();
  99. void on_streamButton_clicked();
  100. void on_settingsButton_clicked();
  101. public:
  102. explicit OBSBasic(QWidget *parent = 0);
  103. virtual ~OBSBasic();
  104. virtual void OBSInit() override;
  105. virtual config_t Config() const override;
  106. private:
  107. std::unique_ptr<Ui::OBSBasic> ui;
  108. };