CuteLogger
Fast and simple logging solution for Qt based applications
encodedock.h
1 /*
2  * Copyright (c) 2012-2022 Meltytech, LLC
3  *
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 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef ENCODEDOCK_H
19 #define ENCODEDOCK_H
20 
21 #include "settings.h"
22 
23 #include <QDockWidget>
24 #include <QDomElement>
25 #include <QStandardItemModel>
26 #include <QSortFilterProxyModel>
27 #include <MltProperties.h>
28 
29 class QTreeWidgetItem;
30 class QStringList;
31 namespace Ui {
32 class EncodeDock;
33 }
34 class AbstractJob;
35 class MeltJob;
36 namespace Mlt {
37 class Service;
38 class Producer;
39 }
40 
41 class PresetsProxyModel : public QSortFilterProxyModel
42 {
43 protected:
44  bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
45 };
46 
47 class EncodeDock : public QDockWidget
48 {
49  Q_OBJECT
50 
51 public:
52  explicit EncodeDock(QWidget *parent = 0);
53  ~EncodeDock();
54 
55  void loadPresetFromProperties(Mlt::Properties &);
56  bool isExportInProgress() const;
57 
58 signals:
59  void captureStateChanged(bool);
60 
61 public slots:
62  void onAudioChannelsChanged();
63  void onProducerOpened();
64  void onProfileChanged();
65  void on_hwencodeButton_clicked();
66  bool detectHardwareEncoders();
67 
68 private slots:
69  void on_presetsTree_clicked(const QModelIndex &index);
70  void on_presetsTree_activated(const QModelIndex &index);
71 
72  void on_encodeButton_clicked();
73 
74  void on_streamButton_clicked();
75 
76  void on_addPresetButton_clicked();
77 
78  void on_removePresetButton_clicked();
79 
80  void onFinished(AbstractJob *, bool isSuccess);
81 
82  void on_stopCaptureButton_clicked();
83 
84  void on_videoRateControlCombo_activated(int index);
85 
86  void on_audioRateControlCombo_activated(int index);
87 
88  void on_scanModeCombo_currentIndexChanged(int index);
89 
90  void on_presetsSearch_textChanged(const QString &search);
91 
92  void on_resetButton_clicked();
93 
94  void openCaptureFile();
95 
96  void on_formatCombo_currentIndexChanged(int index);
97 
98  void on_videoBufferDurationChanged();
99 
100  void on_gopSpinner_valueChanged(int value);
101 
102  void on_fromCombo_currentIndexChanged(int index);
103 
104  void on_videoCodecCombo_currentIndexChanged(int index);
105 
106  void on_audioCodecCombo_currentIndexChanged(int index);
107 
108  void setAudioChannels( int channels );
109 
110  void on_widthSpinner_editingFinished();
111 
112  void on_heightSpinner_editingFinished();
113 
114  void on_advancedButton_clicked(bool checked);
115 
116  void on_hwencodeCheckBox_clicked(bool checked);
117 
118  void on_advancedCheckBox_clicked(bool checked);
119 
120  void on_fpsSpinner_editingFinished();
121 
122  void on_fpsComboBox_activated(const QString &arg1);
123 
124  void on_videoQualitySpinner_valueChanged(int vq);
125 
126  void on_audioQualitySpinner_valueChanged(int aq);
127 
128  void on_parallelCheckbox_clicked(bool checked);
129 
130  void on_resolutionComboBox_activated(const QString &arg1);
131 
132 private:
133  enum {
134  RateControlAverage = 0,
135  RateControlConstant,
136  RateControlQuality,
137  RateControlConstrained
138  };
139  enum {
140  AudioChannels1 = 0,
141  AudioChannels2,
142  AudioChannels6,
143  };
144  Ui::EncodeDock *ui;
145  Mlt::Properties *m_presets;
146  QScopedPointer<MeltJob> m_immediateJob;
147  QString m_extension;
148  Mlt::Properties *m_profiles;
149  PresetsProxyModel m_presetsModel;
150  QStringList m_outputFilenames;
151  bool m_isDefaultSettings;
152  double m_fps;
153 
154  void loadPresets();
155  Mlt::Properties *collectProperties(int realtime, bool includeProfile = false);
156  void collectProperties(QDomElement &node, int realtime);
157  MeltJob *createMeltJob(Mlt::Producer *service, const QString &target, int realtime, int pass = 0,
158  const QThread::Priority priority = Settings.jobPriority());
159  void runMelt(const QString &target, int realtime = -1);
160  void enqueueAnalysis();
161  void enqueueMelt(const QStringList &targets, int realtime);
162  void encode(const QString &target);
163  void resetOptions();
164  Mlt::Producer *fromProducer() const;
165  static void filterX265Params(QStringList &other);
166  void onVideoCodecComboChanged(int index, bool ignorePreset = false);
167  bool checkForMissingFiles();
168  QString &defaultFormatExtension();
169 };
170 
171 #endif // ENCODEDOCK_H