CuteLogger
Fast and simple logging solution for Qt based applications
encodedock.h
1 /*
2  * Copyright (c) 2012-2021 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 <QDockWidget>
22 #include <QDomElement>
23 #include <QStandardItemModel>
24 #include <QSortFilterProxyModel>
25 #include <MltProperties.h>
26 
27 class QTreeWidgetItem;
28 class QStringList;
29 namespace Ui {
30  class EncodeDock;
31 }
32 class AbstractJob;
33 class MeltJob;
34 namespace Mlt {
35  class Service;
36  class Producer;
37 }
38 
39 class PresetsProxyModel : public QSortFilterProxyModel
40 {
41 protected:
42  bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
43 };
44 
45 class EncodeDock : public QDockWidget
46 {
47  Q_OBJECT
48 
49 public:
50  explicit EncodeDock(QWidget *parent = 0);
51  ~EncodeDock();
52 
53  void loadPresetFromProperties(Mlt::Properties&);
54  bool isExportInProgress() const;
55 
56 signals:
57  void captureStateChanged(bool);
58 
59 public slots:
60  void onAudioChannelsChanged();
61  void onProducerOpened();
62  void onProfileChanged();
63  void on_hwencodeButton_clicked();
64  bool detectHardwareEncoders();
65 
66 private slots:
67  void on_presetsTree_clicked(const QModelIndex &index);
68  void on_presetsTree_activated(const QModelIndex &index);
69 
70  void on_encodeButton_clicked();
71 
72  void on_streamButton_clicked();
73 
74  void on_addPresetButton_clicked();
75 
76  void on_removePresetButton_clicked();
77 
78  void onFinished(AbstractJob*, bool isSuccess);
79 
80  void on_stopCaptureButton_clicked();
81 
82  void on_videoRateControlCombo_activated(int index);
83 
84  void on_audioRateControlCombo_activated(int index);
85 
86  void on_scanModeCombo_currentIndexChanged(int index);
87 
88  void on_presetsSearch_textChanged(const QString &search);
89 
90  void on_resetButton_clicked();
91 
92  void openCaptureFile();
93 
94  void on_formatCombo_currentIndexChanged(int index);
95 
96  void on_videoBufferDurationChanged();
97 
98  void on_gopSpinner_valueChanged(int value);
99 
100  void on_fromCombo_currentIndexChanged(int index);
101 
102  void on_videoCodecCombo_currentIndexChanged(int index);
103 
104  void on_audioCodecCombo_currentIndexChanged(int index);
105 
106  void setAudioChannels( int channels );
107 
108  void on_widthSpinner_editingFinished();
109 
110  void on_heightSpinner_editingFinished();
111 
112  void on_advancedButton_clicked(bool checked);
113 
114  void on_hwencodeCheckBox_clicked(bool checked);
115 
116  void on_advancedCheckBox_clicked(bool checked);
117 
118  void on_fpsSpinner_editingFinished();
119 
120  void on_fpsComboBox_activated(const QString &arg1);
121 
122  void on_videoQualitySpinner_valueChanged(int vq);
123 
124  void on_audioQualitySpinner_valueChanged(int aq);
125 
126  void on_parallelCheckbox_clicked(bool checked);
127 
128  void on_resolutionComboBox_activated(const QString &arg1);
129 
130 private:
131  enum {
132  RateControlAverage = 0,
133  RateControlConstant,
134  RateControlQuality,
135  RateControlConstrained
136  };
137  enum {
138  AudioChannels1 = 0,
139  AudioChannels2,
140  AudioChannels6,
141  };
142  Ui::EncodeDock *ui;
143  Mlt::Properties *m_presets;
144  QScopedPointer<MeltJob> m_immediateJob;
145  QString m_extension;
146  Mlt::Properties *m_profiles;
147  PresetsProxyModel m_presetsModel;
148  QStringList m_outputFilenames;
149  bool m_isDefaultSettings;
150  double m_fps;
151 
152  void loadPresets();
153  Mlt::Properties* collectProperties(int realtime, bool includeProfile = false);
154  void collectProperties(QDomElement& node, int realtime);
155  MeltJob* createMeltJob(Mlt::Producer* service, const QString& target, int realtime, int pass = 0);
156  void runMelt(const QString& target, int realtime = -1);
157  void enqueueAnalysis();
158  void enqueueMelt(const QStringList& targets, int realtime);
159  void encode(const QString& target);
160  void resetOptions();
161  Mlt::Producer* fromProducer() const;
162  static void filterX265Params(QStringList& other);
163  void onVideoCodecComboChanged(int index, bool ignorePreset = false);
164  bool checkForMissingFiles();
165 };
166 
167 #endif // ENCODEDOCK_H