window-remux.hpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /******************************************************************************
  2. Copyright (C) 2014 by Ruwen Hahn <[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 <QPointer>
  16. #include <QThread>
  17. #include <memory>
  18. #include "ui_OBSRemux.h"
  19. #include <media-io/media-remux.h>
  20. #include <util/threading.h>
  21. class RemuxWorker;
  22. class OBSRemux : public QDialog {
  23. Q_OBJECT
  24. QThread remuxer;
  25. QPointer<RemuxWorker> worker;
  26. std::unique_ptr<Ui::OBSRemux> ui;
  27. const char *recPath;
  28. void BrowseInput();
  29. void BrowseOutput();
  30. void Remux();
  31. bool Stop();
  32. virtual void closeEvent(QCloseEvent *event) override;
  33. virtual void reject() override;
  34. public:
  35. explicit OBSRemux(const char *recPath, QWidget *parent = nullptr);
  36. virtual ~OBSRemux() override;
  37. using job_t = std::shared_ptr<struct media_remux_job>;
  38. private slots:
  39. void inputChanged(const QString &str);
  40. public slots:
  41. void updateProgress(float percent);
  42. void remuxFinished(bool success);
  43. signals:
  44. void remux();
  45. };
  46. class RemuxWorker : public QObject {
  47. Q_OBJECT
  48. OBSRemux::job_t job;
  49. os_event_t *stop;
  50. float lastProgress;
  51. void UpdateProgress(float percent);
  52. explicit RemuxWorker();
  53. virtual ~RemuxWorker();
  54. private slots:
  55. void remux();
  56. signals:
  57. void updateProgress(float percent);
  58. void remuxFinished(bool success);
  59. friend class OBSRemux;
  60. };