window-basic-main.hpp 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058
  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 <QBuffer>
  16. #include <QAction>
  17. #include <QWidgetAction>
  18. #include <QSystemTrayIcon>
  19. #include <QStyledItemDelegate>
  20. #include <obs.hpp>
  21. #include <vector>
  22. #include <memory>
  23. #include "window-main.hpp"
  24. #include "window-basic-interaction.hpp"
  25. #include "window-basic-properties.hpp"
  26. #include "window-basic-transform.hpp"
  27. #include "window-basic-adv-audio.hpp"
  28. #include "window-basic-filters.hpp"
  29. #include "window-projector.hpp"
  30. #include "window-basic-about.hpp"
  31. #include "auth-base.hpp"
  32. #include "log-viewer.hpp"
  33. #include <obs-frontend-internal.hpp>
  34. #include <util/platform.h>
  35. #include <util/threading.h>
  36. #include <util/util.hpp>
  37. #include <QPointer>
  38. class QMessageBox;
  39. class QListWidgetItem;
  40. class VolControl;
  41. class OBSBasicStats;
  42. #include "ui_OBSBasic.h"
  43. #include "ui_ColorSelect.h"
  44. #define DESKTOP_AUDIO_1 Str("DesktopAudioDevice1")
  45. #define DESKTOP_AUDIO_2 Str("DesktopAudioDevice2")
  46. #define AUX_AUDIO_1 Str("AuxAudioDevice1")
  47. #define AUX_AUDIO_2 Str("AuxAudioDevice2")
  48. #define AUX_AUDIO_3 Str("AuxAudioDevice3")
  49. #define AUX_AUDIO_4 Str("AuxAudioDevice4")
  50. #define SIMPLE_ENCODER_X264 "x264"
  51. #define SIMPLE_ENCODER_X264_LOWCPU "x264_lowcpu"
  52. #define SIMPLE_ENCODER_QSV "qsv"
  53. #define SIMPLE_ENCODER_NVENC "nvenc"
  54. #define SIMPLE_ENCODER_AMD "amd"
  55. #define PREVIEW_EDGE_SIZE 10
  56. struct BasicOutputHandler;
  57. enum class QtDataRole {
  58. OBSRef = Qt::UserRole,
  59. OBSSignals,
  60. };
  61. struct SavedProjectorInfo {
  62. ProjectorType type;
  63. int monitor;
  64. std::string geometry;
  65. std::string name;
  66. bool alwaysOnTop;
  67. bool alwaysOnTopOverridden;
  68. };
  69. struct QuickTransition {
  70. QPushButton *button = nullptr;
  71. OBSSource source;
  72. obs_hotkey_id hotkey = OBS_INVALID_HOTKEY_ID;
  73. int duration = 0;
  74. int id = 0;
  75. bool fadeToBlack = false;
  76. inline QuickTransition() {}
  77. inline QuickTransition(OBSSource source_, int duration_, int id_,
  78. bool fadeToBlack_ = false)
  79. : source(source_),
  80. duration(duration_),
  81. id(id_),
  82. fadeToBlack(fadeToBlack_),
  83. renamedSignal(std::make_shared<OBSSignal>(
  84. obs_source_get_signal_handler(source), "rename",
  85. SourceRenamed, this))
  86. {
  87. }
  88. private:
  89. static void SourceRenamed(void *param, calldata_t *data);
  90. std::shared_ptr<OBSSignal> renamedSignal;
  91. };
  92. class ColorSelect : public QWidget {
  93. public:
  94. explicit ColorSelect(QWidget *parent = 0);
  95. private:
  96. std::unique_ptr<Ui::ColorSelect> ui;
  97. };
  98. class OBSBasic : public OBSMainWindow {
  99. Q_OBJECT
  100. Q_PROPERTY(QIcon imageIcon READ GetImageIcon WRITE SetImageIcon
  101. DESIGNABLE true)
  102. Q_PROPERTY(QIcon colorIcon READ GetColorIcon WRITE SetColorIcon
  103. DESIGNABLE true)
  104. Q_PROPERTY(QIcon slideshowIcon READ GetSlideshowIcon WRITE
  105. SetSlideshowIcon DESIGNABLE true)
  106. Q_PROPERTY(QIcon audioInputIcon READ GetAudioInputIcon WRITE
  107. SetAudioInputIcon DESIGNABLE true)
  108. Q_PROPERTY(QIcon audioOutputIcon READ GetAudioOutputIcon WRITE
  109. SetAudioOutputIcon DESIGNABLE true)
  110. Q_PROPERTY(QIcon desktopCapIcon READ GetDesktopCapIcon WRITE
  111. SetDesktopCapIcon DESIGNABLE true)
  112. Q_PROPERTY(QIcon windowCapIcon READ GetWindowCapIcon WRITE
  113. SetWindowCapIcon DESIGNABLE true)
  114. Q_PROPERTY(QIcon gameCapIcon READ GetGameCapIcon WRITE SetGameCapIcon
  115. DESIGNABLE true)
  116. Q_PROPERTY(QIcon cameraIcon READ GetCameraIcon WRITE SetCameraIcon
  117. DESIGNABLE true)
  118. Q_PROPERTY(QIcon textIcon READ GetTextIcon WRITE SetTextIcon
  119. DESIGNABLE true)
  120. Q_PROPERTY(QIcon mediaIcon READ GetMediaIcon WRITE SetMediaIcon
  121. DESIGNABLE true)
  122. Q_PROPERTY(QIcon browserIcon READ GetBrowserIcon WRITE SetBrowserIcon
  123. DESIGNABLE true)
  124. Q_PROPERTY(QIcon groupIcon READ GetGroupIcon WRITE SetGroupIcon
  125. DESIGNABLE true)
  126. Q_PROPERTY(QIcon sceneIcon READ GetSceneIcon WRITE SetSceneIcon
  127. DESIGNABLE true)
  128. Q_PROPERTY(QIcon defaultIcon READ GetDefaultIcon WRITE SetDefaultIcon
  129. DESIGNABLE true)
  130. friend class OBSAbout;
  131. friend class OBSBasicPreview;
  132. friend class OBSBasicStatusBar;
  133. friend class OBSBasicSourceSelect;
  134. friend class OBSBasicSettings;
  135. friend class Auth;
  136. friend class AutoConfig;
  137. friend class AutoConfigStreamPage;
  138. friend class RecordButton;
  139. friend class ReplayBufferButton;
  140. friend class ExtraBrowsersModel;
  141. friend class ExtraBrowsersDelegate;
  142. friend class DeviceCaptureToolbar;
  143. friend class DeviceToolbarPropertiesThread;
  144. friend struct BasicOutputHandler;
  145. friend struct OBSStudioAPI;
  146. enum class MoveDir { Up, Down, Left, Right };
  147. enum DropType {
  148. DropType_RawText,
  149. DropType_Text,
  150. DropType_Image,
  151. DropType_Media,
  152. DropType_Html,
  153. DropType_Url,
  154. };
  155. private:
  156. obs_frontend_callbacks *api = nullptr;
  157. std::shared_ptr<Auth> auth;
  158. std::vector<VolControl *> volumes;
  159. std::vector<OBSSignal> signalHandlers;
  160. QList<QPointer<QDockWidget>> extraDocks;
  161. bool loaded = false;
  162. long disableSaving = 1;
  163. bool projectChanged = false;
  164. bool previewEnabled = true;
  165. std::list<const char *> copyStrings;
  166. const char *copyFiltersString = nullptr;
  167. bool copyVisible = true;
  168. bool closing = false;
  169. QScopedPointer<QThread> devicePropertiesThread;
  170. QScopedPointer<QThread> whatsNewInitThread;
  171. QScopedPointer<QThread> updateCheckThread;
  172. QScopedPointer<QThread> introCheckThread;
  173. QScopedPointer<QThread> logUploadThread;
  174. QPointer<OBSBasicInteraction> interaction;
  175. QPointer<OBSBasicProperties> properties;
  176. QPointer<OBSBasicTransform> transformWindow;
  177. QPointer<OBSBasicAdvAudio> advAudioWindow;
  178. QPointer<OBSBasicFilters> filters;
  179. QPointer<QDockWidget> statsDock;
  180. QPointer<OBSAbout> about;
  181. OBSLogViewer *logView = nullptr;
  182. QPointer<QTimer> cpuUsageTimer;
  183. QPointer<QTimer> diskFullTimer;
  184. os_cpu_usage_info_t *cpuUsageInfo = nullptr;
  185. OBSService service;
  186. std::unique_ptr<BasicOutputHandler> outputHandler;
  187. bool streamingStopping = false;
  188. bool recordingStopping = false;
  189. bool replayBufferStopping = false;
  190. gs_vertbuffer_t *box = nullptr;
  191. gs_vertbuffer_t *boxLeft = nullptr;
  192. gs_vertbuffer_t *boxTop = nullptr;
  193. gs_vertbuffer_t *boxRight = nullptr;
  194. gs_vertbuffer_t *boxBottom = nullptr;
  195. gs_vertbuffer_t *circle = nullptr;
  196. bool sceneChanging = false;
  197. int previewX = 0, previewY = 0;
  198. int previewCX = 0, previewCY = 0;
  199. float previewScale = 0.0f;
  200. ConfigFile basicConfig;
  201. std::vector<SavedProjectorInfo *> savedProjectorsArray;
  202. std::vector<OBSProjector *> projectors;
  203. QPointer<QWidget> stats;
  204. QPointer<QWidget> remux;
  205. QPointer<QWidget> extraBrowsers;
  206. QPointer<QWidget> importer;
  207. QPointer<QMenu> startStreamMenu;
  208. QPointer<QPushButton> transitionButton;
  209. QPointer<QPushButton> replayBufferButton;
  210. QPointer<QHBoxLayout> replayLayout;
  211. QScopedPointer<QPushButton> pause;
  212. QScopedPointer<QPushButton> replay;
  213. QPointer<QPushButton> vcamButton;
  214. bool vcamEnabled = false;
  215. QScopedPointer<QSystemTrayIcon> trayIcon;
  216. QPointer<QAction> sysTrayStream;
  217. QPointer<QAction> sysTrayRecord;
  218. QPointer<QAction> sysTrayReplayBuffer;
  219. QPointer<QAction> sysTrayVirtualCam;
  220. QPointer<QAction> showHide;
  221. QPointer<QAction> exit;
  222. QPointer<QMenu> trayMenu;
  223. QPointer<QMenu> previewProjector;
  224. QPointer<QMenu> studioProgramProjector;
  225. QPointer<QMenu> multiviewProjectorMenu;
  226. QPointer<QMenu> previewProjectorSource;
  227. QPointer<QMenu> previewProjectorMain;
  228. QPointer<QMenu> sceneProjectorMenu;
  229. QPointer<QMenu> sourceProjector;
  230. QPointer<QMenu> scaleFilteringMenu;
  231. QPointer<QMenu> colorMenu;
  232. QPointer<QWidgetAction> colorWidgetAction;
  233. QPointer<ColorSelect> colorSelect;
  234. QPointer<QMenu> deinterlaceMenu;
  235. QPointer<QMenu> perSceneTransitionMenu;
  236. QPointer<QObject> shortcutFilter;
  237. QPointer<QAction> renameScene;
  238. QPointer<QAction> renameSource;
  239. QPointer<QWidget> programWidget;
  240. QPointer<QVBoxLayout> programLayout;
  241. QPointer<QLabel> programLabel;
  242. QScopedPointer<QThread> patronJsonThread;
  243. std::string patronJson;
  244. void UpdateMultiviewProjectorMenu();
  245. void DrawBackdrop(float cx, float cy);
  246. void SetupEncoders();
  247. void CreateFirstRunSources();
  248. void CreateDefaultScene(bool firstStart);
  249. void UpdateVolumeControlsDecayRate();
  250. void UpdateVolumeControlsPeakMeterType();
  251. void ClearVolumeControls();
  252. void UploadLog(const char *subdir, const char *file, const bool crash);
  253. void Save(const char *file);
  254. void Load(const char *file);
  255. void InitHotkeys();
  256. void CreateHotkeys();
  257. void ClearHotkeys();
  258. bool InitService();
  259. bool InitBasicConfigDefaults();
  260. void InitBasicConfigDefaults2();
  261. bool InitBasicConfig();
  262. void InitOBSCallbacks();
  263. void InitPrimitives();
  264. void OnFirstLoad();
  265. OBSSceneItem GetSceneItem(QListWidgetItem *item);
  266. OBSSceneItem GetCurrentSceneItem();
  267. bool QueryRemoveSource(obs_source_t *source);
  268. void TimedCheckForUpdates();
  269. void CheckForUpdates(bool manualUpdate);
  270. void GetFPSCommon(uint32_t &num, uint32_t &den) const;
  271. void GetFPSInteger(uint32_t &num, uint32_t &den) const;
  272. void GetFPSFraction(uint32_t &num, uint32_t &den) const;
  273. void GetFPSNanoseconds(uint32_t &num, uint32_t &den) const;
  274. void GetConfigFPS(uint32_t &num, uint32_t &den) const;
  275. void UpdatePreviewScalingMenu();
  276. void LoadSceneListOrder(obs_data_array_t *array);
  277. obs_data_array_t *SaveSceneListOrder();
  278. void ChangeSceneIndex(bool relative, int idx, int invalidIdx);
  279. void TempFileOutput(const char *path, int vBitrate, int aBitrate);
  280. void TempStreamOutput(const char *url, const char *key, int vBitrate,
  281. int aBitrate);
  282. void CloseDialogs();
  283. void ClearSceneData();
  284. void ClearProjectors();
  285. void Nudge(int dist, MoveDir dir);
  286. OBSProjector *OpenProjector(obs_source_t *source, int monitor,
  287. ProjectorType type);
  288. void GetAudioSourceFilters();
  289. void GetAudioSourceProperties();
  290. void VolControlContextMenu();
  291. void ToggleVolControlLayout();
  292. void ToggleMixerLayout(bool vertical);
  293. void RefreshSceneCollections();
  294. void ChangeSceneCollection();
  295. void LogScenes();
  296. void LoadProfile();
  297. void ResetProfileData();
  298. bool AddProfile(bool create_new, const char *title, const char *text,
  299. const char *init_text = nullptr, bool rename = false);
  300. void DeleteProfile(const char *profile_name, const char *profile_dir);
  301. void RefreshProfiles();
  302. void ChangeProfile();
  303. void CheckForSimpleModeX264Fallback();
  304. void SaveProjectNow();
  305. int GetTopSelectedSourceItem();
  306. QModelIndexList GetAllSelectedSourceItems();
  307. obs_hotkey_pair_id streamingHotkeys, recordingHotkeys, pauseHotkeys,
  308. replayBufHotkeys, vcamHotkeys, togglePreviewHotkeys,
  309. contextBarHotkeys;
  310. obs_hotkey_id forceStreamingStopHotkey;
  311. void InitDefaultTransitions();
  312. void InitTransition(obs_source_t *transition);
  313. obs_source_t *FindTransition(const char *name);
  314. OBSSource GetCurrentTransition();
  315. obs_data_array_t *SaveTransitions();
  316. void LoadTransitions(obs_data_array_t *transitions);
  317. obs_source_t *fadeTransition;
  318. obs_source_t *cutTransition;
  319. void CreateProgramDisplay();
  320. void CreateProgramOptions();
  321. int TransitionCount();
  322. int AddTransitionBeforeSeparator(const QString &name,
  323. obs_source_t *source);
  324. void AddQuickTransitionId(int id);
  325. void AddQuickTransition();
  326. void AddQuickTransitionHotkey(QuickTransition *qt);
  327. void RemoveQuickTransitionHotkey(QuickTransition *qt);
  328. void LoadQuickTransitions(obs_data_array_t *array);
  329. obs_data_array_t *SaveQuickTransitions();
  330. void ClearQuickTransitionWidgets();
  331. void RefreshQuickTransitions();
  332. void DisableQuickTransitionWidgets();
  333. void EnableTransitionWidgets(bool enable);
  334. void CreateDefaultQuickTransitions();
  335. QMenu *CreatePerSceneTransitionMenu();
  336. QuickTransition *GetQuickTransition(int id);
  337. int GetQuickTransitionIdx(int id);
  338. QMenu *CreateTransitionMenu(QWidget *parent, QuickTransition *qt);
  339. void ClearQuickTransitions();
  340. void QuickTransitionClicked();
  341. void QuickTransitionChange();
  342. void QuickTransitionChangeDuration(int value);
  343. void QuickTransitionRemoveClicked();
  344. void SetPreviewProgramMode(bool enabled);
  345. void ResizeProgram(uint32_t cx, uint32_t cy);
  346. void SetCurrentScene(obs_scene_t *scene, bool force = false);
  347. static void RenderProgram(void *data, uint32_t cx, uint32_t cy);
  348. std::vector<QuickTransition> quickTransitions;
  349. QPointer<QWidget> programOptions;
  350. QPointer<OBSQTDisplay> program;
  351. OBSWeakSource lastScene;
  352. OBSWeakSource swapScene;
  353. OBSWeakSource programScene;
  354. bool editPropertiesMode = false;
  355. bool sceneDuplicationMode = true;
  356. bool swapScenesMode = true;
  357. volatile bool previewProgramMode = false;
  358. obs_hotkey_id togglePreviewProgramHotkey = 0;
  359. obs_hotkey_id transitionHotkey = 0;
  360. obs_hotkey_id statsHotkey = 0;
  361. obs_hotkey_id screenshotHotkey = 0;
  362. obs_hotkey_id sourceScreenshotHotkey = 0;
  363. int quickTransitionIdCounter = 1;
  364. bool overridingTransition = false;
  365. int programX = 0, programY = 0;
  366. int programCX = 0, programCY = 0;
  367. float programScale = 0.0f;
  368. int disableOutputsRef = 0;
  369. inline void OnActivate();
  370. inline void OnDeactivate();
  371. void AddDropSource(const char *file, DropType image);
  372. void AddDropURL(const char *url, QString &name, obs_data_t *settings,
  373. const obs_video_info &ovi);
  374. void ConfirmDropUrl(const QString &url);
  375. void dragEnterEvent(QDragEnterEvent *event) override;
  376. void dragLeaveEvent(QDragLeaveEvent *event) override;
  377. void dragMoveEvent(QDragMoveEvent *event) override;
  378. void dropEvent(QDropEvent *event) override;
  379. void ReplayBufferClicked();
  380. bool sysTrayMinimizeToTray();
  381. void EnumDialogs();
  382. QList<QDialog *> visDialogs;
  383. QList<QDialog *> modalDialogs;
  384. QList<QMessageBox *> visMsgBoxes;
  385. QList<QPoint> visDlgPositions;
  386. QByteArray startingDockLayout;
  387. obs_data_array_t *SaveProjectors();
  388. void LoadSavedProjectors(obs_data_array_t *savedProjectors);
  389. void ReceivedIntroJson(const QString &text);
  390. void ShowWhatsNew(const QString &url);
  391. #ifdef BROWSER_AVAILABLE
  392. QList<QSharedPointer<QDockWidget>> extraBrowserDocks;
  393. QList<QSharedPointer<QAction>> extraBrowserDockActions;
  394. QStringList extraBrowserDockTargets;
  395. void ClearExtraBrowserDocks();
  396. void LoadExtraBrowserDocks();
  397. void SaveExtraBrowserDocks();
  398. void ManageExtraBrowserDocks();
  399. void AddExtraBrowserDock(const QString &title, const QString &url,
  400. bool firstCreate);
  401. #endif
  402. QIcon imageIcon;
  403. QIcon colorIcon;
  404. QIcon slideshowIcon;
  405. QIcon audioInputIcon;
  406. QIcon audioOutputIcon;
  407. QIcon desktopCapIcon;
  408. QIcon windowCapIcon;
  409. QIcon gameCapIcon;
  410. QIcon cameraIcon;
  411. QIcon textIcon;
  412. QIcon mediaIcon;
  413. QIcon browserIcon;
  414. QIcon groupIcon;
  415. QIcon sceneIcon;
  416. QIcon defaultIcon;
  417. QIcon GetImageIcon() const;
  418. QIcon GetColorIcon() const;
  419. QIcon GetSlideshowIcon() const;
  420. QIcon GetAudioInputIcon() const;
  421. QIcon GetAudioOutputIcon() const;
  422. QIcon GetDesktopCapIcon() const;
  423. QIcon GetWindowCapIcon() const;
  424. QIcon GetGameCapIcon() const;
  425. QIcon GetCameraIcon() const;
  426. QIcon GetTextIcon() const;
  427. QIcon GetMediaIcon() const;
  428. QIcon GetBrowserIcon() const;
  429. QIcon GetDefaultIcon() const;
  430. QSlider *tBar;
  431. bool tBarActive = false;
  432. OBSSource GetOverrideTransition(OBSSource source);
  433. int GetOverrideTransitionDuration(OBSSource source);
  434. void UpdateProjectorHideCursor();
  435. void UpdateProjectorAlwaysOnTop(bool top);
  436. void ResetProjectors();
  437. QPointer<QObject> screenshotData;
  438. public slots:
  439. void DeferSaveBegin();
  440. void DeferSaveEnd();
  441. void DisplayStreamStartError();
  442. void StartStreaming();
  443. void StopStreaming();
  444. void ForceStopStreaming();
  445. void StreamDelayStarting(int sec);
  446. void StreamDelayStopping(int sec);
  447. void StreamingStart();
  448. void StreamStopping();
  449. void StreamingStop(int errorcode, QString last_error);
  450. void StartRecording();
  451. void StopRecording();
  452. void RecordingStart();
  453. void RecordStopping();
  454. void RecordingStop(int code, QString last_error);
  455. void ShowReplayBufferPauseWarning();
  456. void StartReplayBuffer();
  457. void StopReplayBuffer();
  458. void ReplayBufferStart();
  459. void ReplayBufferSave();
  460. void ReplayBufferSaved();
  461. void ReplayBufferStopping();
  462. void ReplayBufferStop(int code);
  463. void StartVirtualCam();
  464. void StopVirtualCam();
  465. void OnVirtualCamStart();
  466. void OnVirtualCamStop(int code);
  467. void SaveProjectDeferred();
  468. void SaveProject();
  469. void SetTransition(OBSSource transition);
  470. void OverrideTransition(OBSSource transition);
  471. void TransitionToScene(OBSScene scene, bool force = false);
  472. void TransitionToScene(OBSSource scene, bool force = false,
  473. bool quickTransition = false,
  474. int quickDuration = 0, bool black = false,
  475. bool manual = false);
  476. void SetCurrentScene(OBSSource scene, bool force = false);
  477. bool AddSceneCollection(bool create_new,
  478. const QString &name = QString());
  479. void UpdatePatronJson(const QString &text, const QString &error);
  480. void ShowContextBar();
  481. void HideContextBar();
  482. void PauseRecording();
  483. void UnpauseRecording();
  484. private slots:
  485. void AddSceneItem(OBSSceneItem item);
  486. void AddScene(OBSSource source);
  487. void RemoveScene(OBSSource source);
  488. void RenameSources(OBSSource source, QString newName, QString prevName);
  489. void ActivateAudioSource(OBSSource source);
  490. void DeactivateAudioSource(OBSSource source);
  491. void DuplicateSelectedScene();
  492. void RemoveSelectedScene();
  493. void RemoveSelectedSceneItem();
  494. void ToggleAlwaysOnTop();
  495. void ReorderSources(OBSScene scene);
  496. void RefreshSources(OBSScene scene);
  497. void ProcessHotkey(obs_hotkey_id id, bool pressed);
  498. void AddTransition(QString id);
  499. void RenameTransition();
  500. void TransitionClicked();
  501. void TransitionStopped();
  502. void TransitionFullyStopped();
  503. void TriggerQuickTransition(int id);
  504. void SetDeinterlacingMode();
  505. void SetDeinterlacingOrder();
  506. void SetScaleFilter();
  507. void IconActivated(QSystemTrayIcon::ActivationReason reason);
  508. void SetShowing(bool showing);
  509. void ToggleShowHide();
  510. void HideAudioControl();
  511. void UnhideAllAudioControls();
  512. void ToggleHideMixer();
  513. void MixerRenameSource();
  514. void on_vMixerScrollArea_customContextMenuRequested();
  515. void on_hMixerScrollArea_customContextMenuRequested();
  516. void on_actionCopySource_triggered();
  517. void on_actionPasteRef_triggered();
  518. void on_actionPasteDup_triggered();
  519. void on_actionCopyFilters_triggered();
  520. void on_actionPasteFilters_triggered();
  521. void ColorChange();
  522. SourceTreeItem *GetItemWidgetFromSceneItem(obs_sceneitem_t *sceneItem);
  523. void on_actionShowAbout_triggered();
  524. void AudioMixerCopyFilters();
  525. void AudioMixerPasteFilters();
  526. void EnablePreview();
  527. void DisablePreview();
  528. void SceneCopyFilters();
  529. void ScenePasteFilters();
  530. void CheckDiskSpaceRemaining();
  531. void OpenSavedProjector(SavedProjectorInfo *info);
  532. void ScenesReordered();
  533. void ResetStatsHotkey();
  534. void SetImageIcon(const QIcon &icon);
  535. void SetColorIcon(const QIcon &icon);
  536. void SetSlideshowIcon(const QIcon &icon);
  537. void SetAudioInputIcon(const QIcon &icon);
  538. void SetAudioOutputIcon(const QIcon &icon);
  539. void SetDesktopCapIcon(const QIcon &icon);
  540. void SetWindowCapIcon(const QIcon &icon);
  541. void SetGameCapIcon(const QIcon &icon);
  542. void SetCameraIcon(const QIcon &icon);
  543. void SetTextIcon(const QIcon &icon);
  544. void SetMediaIcon(const QIcon &icon);
  545. void SetBrowserIcon(const QIcon &icon);
  546. void SetGroupIcon(const QIcon &icon);
  547. void SetSceneIcon(const QIcon &icon);
  548. void SetDefaultIcon(const QIcon &icon);
  549. void TBarChanged(int value);
  550. void TBarReleased();
  551. void LockVolumeControl(bool lock);
  552. private:
  553. /* OBS Callbacks */
  554. static void SceneReordered(void *data, calldata_t *params);
  555. static void SceneRefreshed(void *data, calldata_t *params);
  556. static void SceneItemAdded(void *data, calldata_t *params);
  557. static void SourceCreated(void *data, calldata_t *params);
  558. static void SourceRemoved(void *data, calldata_t *params);
  559. static void SourceActivated(void *data, calldata_t *params);
  560. static void SourceDeactivated(void *data, calldata_t *params);
  561. static void SourceAudioActivated(void *data, calldata_t *params);
  562. static void SourceAudioDeactivated(void *data, calldata_t *params);
  563. static void SourceRenamed(void *data, calldata_t *params);
  564. static void RenderMain(void *data, uint32_t cx, uint32_t cy);
  565. void ResizePreview(uint32_t cx, uint32_t cy);
  566. void AddSource(const char *id);
  567. QMenu *CreateAddSourcePopupMenu();
  568. void AddSourcePopupMenu(const QPoint &pos);
  569. void copyActionsDynamicProperties();
  570. static void HotkeyTriggered(void *data, obs_hotkey_id id, bool pressed);
  571. void AutoRemux();
  572. void UpdatePause(bool activate = true);
  573. void UpdateReplayBuffer(bool activate = true);
  574. bool OutputPathValid();
  575. void OutputPathInvalidMessage();
  576. bool LowDiskSpace();
  577. void DiskSpaceMessage();
  578. OBSSource prevFTBSource = nullptr;
  579. public:
  580. OBSSource GetProgramSource();
  581. OBSScene GetCurrentScene();
  582. void SysTrayNotify(const QString &text, QSystemTrayIcon::MessageIcon n);
  583. inline OBSSource GetCurrentSceneSource()
  584. {
  585. OBSScene curScene = GetCurrentScene();
  586. return OBSSource(obs_scene_get_source(curScene));
  587. }
  588. obs_service_t *GetService();
  589. void SetService(obs_service_t *service);
  590. int GetTransitionDuration();
  591. inline bool IsPreviewProgramMode() const
  592. {
  593. return os_atomic_load_bool(&previewProgramMode);
  594. }
  595. inline bool VCamEnabled() const { return vcamEnabled; }
  596. bool StreamingActive() const;
  597. bool Active() const;
  598. void ResetUI();
  599. int ResetVideo();
  600. bool ResetAudio();
  601. void AddVCamButton();
  602. void ResetOutputs();
  603. void ResetAudioDevice(const char *sourceId, const char *deviceId,
  604. const char *deviceDesc, int channel);
  605. void NewProject();
  606. void LoadProject();
  607. inline void GetDisplayRect(int &x, int &y, int &cx, int &cy)
  608. {
  609. x = previewX;
  610. y = previewY;
  611. cx = previewCX;
  612. cy = previewCY;
  613. }
  614. inline bool SavingDisabled() const { return disableSaving; }
  615. inline double GetCPUUsage() const
  616. {
  617. return os_cpu_usage_info_query(cpuUsageInfo);
  618. }
  619. void SaveService();
  620. bool LoadService();
  621. inline Auth *GetAuth() { return auth.get(); }
  622. inline void EnableOutputs(bool enable)
  623. {
  624. if (enable) {
  625. if (--disableOutputsRef < 0)
  626. disableOutputsRef = 0;
  627. } else {
  628. disableOutputsRef++;
  629. }
  630. }
  631. QMenu *AddDeinterlacingMenu(QMenu *menu, obs_source_t *source);
  632. QMenu *AddScaleFilteringMenu(QMenu *menu, obs_sceneitem_t *item);
  633. QMenu *AddBackgroundColorMenu(QMenu *menu, QWidgetAction *widgetAction,
  634. ColorSelect *select,
  635. obs_sceneitem_t *item);
  636. void CreateSourcePopupMenu(int idx, bool preview);
  637. void UpdateTitleBar();
  638. void UpdateSceneSelection(OBSSource source);
  639. void SystemTrayInit();
  640. void SystemTray(bool firstStarted);
  641. void OpenSavedProjectors();
  642. void CreateInteractionWindow(obs_source_t *source);
  643. void CreatePropertiesWindow(obs_source_t *source);
  644. void CreateFiltersWindow(obs_source_t *source);
  645. QAction *AddDockWidget(QDockWidget *dock);
  646. static OBSBasic *Get();
  647. const char *GetCurrentOutputPath();
  648. void DeleteProjector(OBSProjector *projector);
  649. void AddProjectorMenuMonitors(QMenu *parent, QObject *target,
  650. const char *slot);
  651. QIcon GetSourceIcon(const char *id) const;
  652. QIcon GetGroupIcon() const;
  653. QIcon GetSceneIcon() const;
  654. OBSWeakSource copyFilter = nullptr;
  655. protected:
  656. virtual void closeEvent(QCloseEvent *event) override;
  657. virtual void changeEvent(QEvent *event) override;
  658. private slots:
  659. void on_actionFullscreenInterface_triggered();
  660. void on_actionShow_Recordings_triggered();
  661. void on_actionRemux_triggered();
  662. void on_action_Settings_triggered();
  663. void on_actionAdvAudioProperties_triggered();
  664. void on_advAudioProps_clicked();
  665. void on_advAudioProps_destroyed();
  666. void on_actionShowLogs_triggered();
  667. void on_actionUploadCurrentLog_triggered();
  668. void on_actionUploadLastLog_triggered();
  669. void on_actionViewCurrentLog_triggered();
  670. void on_actionCheckForUpdates_triggered();
  671. void on_actionShowCrashLogs_triggered();
  672. void on_actionUploadLastCrashLog_triggered();
  673. void on_actionEditTransform_triggered();
  674. void on_actionCopyTransform_triggered();
  675. void on_actionPasteTransform_triggered();
  676. void on_actionRotate90CW_triggered();
  677. void on_actionRotate90CCW_triggered();
  678. void on_actionRotate180_triggered();
  679. void on_actionFlipHorizontal_triggered();
  680. void on_actionFlipVertical_triggered();
  681. void on_actionFitToScreen_triggered();
  682. void on_actionStretchToScreen_triggered();
  683. void on_actionCenterToScreen_triggered();
  684. void on_actionVerticalCenter_triggered();
  685. void on_actionHorizontalCenter_triggered();
  686. void on_customContextMenuRequested(const QPoint &pos);
  687. void on_scenes_currentItemChanged(QListWidgetItem *current,
  688. QListWidgetItem *prev);
  689. void on_scenes_customContextMenuRequested(const QPoint &pos);
  690. void on_actionGridMode_triggered();
  691. void on_actionAddScene_triggered();
  692. void on_actionRemoveScene_triggered();
  693. void on_actionSceneUp_triggered();
  694. void on_actionSceneDown_triggered();
  695. void on_sources_customContextMenuRequested(const QPoint &pos);
  696. void on_scenes_itemDoubleClicked(QListWidgetItem *item);
  697. void on_actionAddSource_triggered();
  698. void on_actionRemoveSource_triggered();
  699. void on_actionInteract_triggered();
  700. void on_actionSourceProperties_triggered();
  701. void on_actionSourceUp_triggered();
  702. void on_actionSourceDown_triggered();
  703. void on_actionMoveUp_triggered();
  704. void on_actionMoveDown_triggered();
  705. void on_actionMoveToTop_triggered();
  706. void on_actionMoveToBottom_triggered();
  707. void on_actionLockPreview_triggered();
  708. void on_scalingMenu_aboutToShow();
  709. void on_actionScaleWindow_triggered();
  710. void on_actionScaleCanvas_triggered();
  711. void on_actionScaleOutput_triggered();
  712. void on_streamButton_clicked();
  713. void on_recordButton_clicked();
  714. void VCamButtonClicked();
  715. void on_settingsButton_clicked();
  716. void Screenshot(OBSSource source_ = nullptr);
  717. void ScreenshotSelectedSource();
  718. void ScreenshotProgram();
  719. void ScreenshotScene();
  720. void on_actionHelpPortal_triggered();
  721. void on_actionWebsite_triggered();
  722. void on_actionDiscord_triggered();
  723. void on_preview_customContextMenuRequested(const QPoint &pos);
  724. void on_program_customContextMenuRequested(const QPoint &pos);
  725. void PreviewDisabledMenu(const QPoint &pos);
  726. void on_actionNewSceneCollection_triggered();
  727. void on_actionDupSceneCollection_triggered();
  728. void on_actionRenameSceneCollection_triggered();
  729. void on_actionRemoveSceneCollection_triggered();
  730. void on_actionImportSceneCollection_triggered();
  731. void on_actionExportSceneCollection_triggered();
  732. void on_actionNewProfile_triggered();
  733. void on_actionDupProfile_triggered();
  734. void on_actionRenameProfile_triggered();
  735. void on_actionRemoveProfile_triggered();
  736. void on_actionImportProfile_triggered();
  737. void on_actionExportProfile_triggered();
  738. void on_actionShowSettingsFolder_triggered();
  739. void on_actionShowProfileFolder_triggered();
  740. void on_actionAlwaysOnTop_triggered();
  741. void on_toggleListboxToolbars_toggled(bool visible);
  742. void on_toggleContextBar_toggled(bool visible);
  743. void on_toggleStatusBar_toggled(bool visible);
  744. void on_toggleSourceIcons_toggled(bool visible);
  745. void on_transitions_currentIndexChanged(int index);
  746. void on_transitionRemove_clicked();
  747. void on_transitionProps_clicked();
  748. void on_transitionDuration_valueChanged(int value);
  749. void on_modeSwitch_clicked();
  750. // Source Context Buttons
  751. void on_sourcePropertiesButton_clicked();
  752. void on_sourceFiltersButton_clicked();
  753. void on_sourceInteractButton_clicked();
  754. void on_autoConfigure_triggered();
  755. void on_stats_triggered();
  756. void on_resetUI_triggered();
  757. void on_lockUI_toggled(bool lock);
  758. void PauseToggled();
  759. void logUploadFinished(const QString &text, const QString &error);
  760. void crashUploadFinished(const QString &text, const QString &error);
  761. void openLogDialog(const QString &text, const bool crash);
  762. void updateCheckFinished();
  763. void AddSourceFromAction();
  764. void MoveSceneToTop();
  765. void MoveSceneToBottom();
  766. void EditSceneName();
  767. void EditSceneItemName();
  768. void SceneNameEdited(QWidget *editor,
  769. QAbstractItemDelegate::EndEditHint endHint);
  770. void OpenSceneFilters();
  771. void OpenFilters();
  772. void EnablePreviewDisplay(bool enable);
  773. void TogglePreview();
  774. void NudgeUp();
  775. void NudgeDown();
  776. void NudgeLeft();
  777. void NudgeRight();
  778. void OpenStudioProgramProjector();
  779. void OpenPreviewProjector();
  780. void OpenSourceProjector();
  781. void OpenMultiviewProjector();
  782. void OpenSceneProjector();
  783. void OpenStudioProgramWindow();
  784. void OpenPreviewWindow();
  785. void OpenSourceWindow();
  786. void OpenMultiviewWindow();
  787. void OpenSceneWindow();
  788. void DeferredSysTrayLoad(int requeueCount);
  789. void StackedMixerAreaContextMenuRequested();
  790. void ResizeOutputSizeOfSource();
  791. public slots:
  792. void on_actionResetTransform_triggered();
  793. bool StreamingActive();
  794. bool RecordingActive();
  795. bool ReplayBufferActive();
  796. void ClearContextBar();
  797. void UpdateContextBar(bool force = false);
  798. void UpdateContextBarDeferred(bool force = false);
  799. public:
  800. explicit OBSBasic(QWidget *parent = 0);
  801. virtual ~OBSBasic();
  802. virtual void OBSInit() override;
  803. virtual config_t *Config() const override;
  804. virtual int GetProfilePath(char *path, size_t size,
  805. const char *file) const override;
  806. static void InitBrowserPanelSafeBlock();
  807. private:
  808. std::unique_ptr<Ui::OBSBasic> ui;
  809. };
  810. class SceneRenameDelegate : public QStyledItemDelegate {
  811. Q_OBJECT
  812. public:
  813. SceneRenameDelegate(QObject *parent);
  814. virtual void setEditorData(QWidget *editor,
  815. const QModelIndex &index) const override;
  816. protected:
  817. virtual bool eventFilter(QObject *editor, QEvent *event) override;
  818. };