2019-08-10 18:07:43 +01:00
|
|
|
#ifndef TSMUXER_H_
|
|
|
|
#define TSMUXER_H_
|
|
|
|
|
2020-01-11 23:46:04 +01:00
|
|
|
#include <QHeaderView>
|
2019-08-10 18:07:43 +01:00
|
|
|
#include <QProcess>
|
2020-01-11 23:46:04 +01:00
|
|
|
#include <QTimer>
|
2020-03-01 00:35:31 +01:00
|
|
|
#include <QTranslator>
|
2020-01-14 21:56:44 +01:00
|
|
|
#include <QWidget>
|
|
|
|
|
2021-11-12 17:15:19 +00:00
|
|
|
#if QT_MULTIMEDIA_LIB
|
|
|
|
#include <QSoundEffect>
|
|
|
|
#endif
|
|
|
|
|
2020-01-14 21:56:44 +01:00
|
|
|
#include "codecinfo.h"
|
2020-01-11 23:46:04 +01:00
|
|
|
|
|
|
|
class QFileDialog;
|
|
|
|
class QTableWidgetItem;
|
|
|
|
class QComboBox;
|
2020-02-08 20:48:41 +01:00
|
|
|
class QCheckBox;
|
2019-08-10 18:07:43 +01:00
|
|
|
|
2020-01-11 23:46:04 +01:00
|
|
|
class MuxForm;
|
2020-01-14 21:56:44 +01:00
|
|
|
namespace Ui
|
|
|
|
{
|
2020-01-11 23:46:04 +01:00
|
|
|
class TsMuxerWindow;
|
|
|
|
}
|
|
|
|
|
|
|
|
class QnCheckBoxedHeaderView;
|
2021-11-01 17:29:50 +01:00
|
|
|
class FontSettingsTableModel;
|
2022-05-15 22:53:32 +02:00
|
|
|
class LangCodesModel;
|
2019-12-07 19:37:10 +01:00
|
|
|
|
|
|
|
typedef QList<double> ChapterList;
|
|
|
|
|
2020-01-14 21:56:44 +01:00
|
|
|
enum MplsType
|
|
|
|
{
|
2019-12-07 19:37:10 +01:00
|
|
|
MPLS_NONE,
|
|
|
|
MPLS_PRIMARY,
|
|
|
|
MPLS_M2TS,
|
|
|
|
};
|
|
|
|
|
2020-01-14 21:56:44 +01:00
|
|
|
class TsMuxerWindow : public QWidget
|
2019-08-10 18:07:43 +01:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2020-01-14 21:56:44 +01:00
|
|
|
public:
|
|
|
|
TsMuxerWindow();
|
2020-07-02 00:10:49 +02:00
|
|
|
~TsMuxerWindow() override;
|
2019-08-10 18:07:43 +01:00
|
|
|
|
|
|
|
void addFiles(const QList<QUrl>& files);
|
2020-01-14 21:56:44 +01:00
|
|
|
signals:
|
|
|
|
void tsMuxerSuccessFinished();
|
|
|
|
void codecListReady();
|
|
|
|
void fileAdded();
|
|
|
|
void fileAppended();
|
2020-03-01 00:35:31 +01:00
|
|
|
|
|
|
|
private:
|
2020-09-18 00:19:53 +02:00
|
|
|
template <typename F>
|
|
|
|
void showAddFilesDialog(QString&& windowTitle, F&& windowOkFn);
|
2020-01-14 21:56:44 +01:00
|
|
|
void onAddBtnClick();
|
|
|
|
void readFromStdout();
|
|
|
|
void readFromStderr();
|
|
|
|
void onProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
|
|
|
|
void onProcessError(QProcess::ProcessError error);
|
|
|
|
void trackLVItemSelectionChanged();
|
|
|
|
void inputFilesLVChanged();
|
|
|
|
void trackLVItemChanged(QTableWidgetItem* item);
|
|
|
|
void onVideoCheckBoxChanged(int state);
|
|
|
|
void onPulldownCheckBoxChanged(int state);
|
|
|
|
void onVideoComboBoxChanged(int index);
|
|
|
|
void onAudioSubtitlesParamsChanged();
|
|
|
|
void onEditDelayChanged(int i);
|
|
|
|
void onFontBtnClicked();
|
|
|
|
void onColorBtnClicked();
|
|
|
|
void onGeneralCheckboxClicked();
|
|
|
|
void onGeneralSpinboxValueChanged();
|
|
|
|
void onChapterParamsChanged();
|
|
|
|
void onSplitCutParamsChanged();
|
2019-08-10 18:07:43 +01:00
|
|
|
void onSavedParamChanged();
|
2020-01-14 21:56:44 +01:00
|
|
|
void onFontParamsChanged();
|
|
|
|
void onRemoveBtnClick();
|
|
|
|
void onAppendButtonClick();
|
|
|
|
void onRemoveTrackButtonClick();
|
|
|
|
void onMoveUpButtonCLick();
|
|
|
|
void onMoveDownButtonCLick();
|
|
|
|
void RadioButtonMuxClick();
|
|
|
|
void outFileNameChanged();
|
|
|
|
void saveFileDialog();
|
|
|
|
void startMuxing();
|
|
|
|
void saveMetaFileBtnClick();
|
|
|
|
void continueAppendFile();
|
|
|
|
void continueAddFile();
|
|
|
|
void onTsMuxerCodecInfoReceived();
|
|
|
|
void addFile();
|
|
|
|
void appendFile();
|
|
|
|
void onOpacityTimer();
|
2019-08-10 18:07:43 +01:00
|
|
|
void updateMetaLines();
|
|
|
|
void at_sectionCheckstateChanged(Qt::CheckState state);
|
|
|
|
void updateMuxTime1();
|
|
|
|
void updateMuxTime2();
|
2020-03-01 00:35:31 +01:00
|
|
|
void onLanguageComboBoxIndexChanged(int);
|
2020-09-18 00:19:53 +02:00
|
|
|
template <typename OnCodecListReadyFn, typename PostActionSignal, typename PostActionFn>
|
|
|
|
void processAddFileList(OnCodecListReadyFn onCodecListReady, PostActionSignal postActionSignal,
|
|
|
|
PostActionFn postActionFn);
|
2020-01-14 21:56:44 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void closeEvent(QCloseEvent* event) override;
|
2020-03-01 00:35:31 +01:00
|
|
|
void changeEvent(QEvent* event) override;
|
2020-01-14 21:56:44 +01:00
|
|
|
bool eventFilter(QObject* obj, QEvent* event) override;
|
2019-08-10 18:07:43 +01:00
|
|
|
void updateMaxOffsets();
|
|
|
|
void updateCustomChapters();
|
2019-12-07 19:37:10 +01:00
|
|
|
|
|
|
|
void writeSettings();
|
|
|
|
bool readSettings();
|
2020-01-11 18:28:31 +01:00
|
|
|
bool readGeneralSettings(const QString& prefix);
|
2019-12-07 19:37:10 +01:00
|
|
|
QString getOutputDir() const;
|
2020-01-14 21:56:44 +01:00
|
|
|
|
|
|
|
private:
|
2019-12-07 19:37:10 +01:00
|
|
|
struct MPLSFileInfo
|
|
|
|
{
|
2020-01-14 21:56:44 +01:00
|
|
|
MPLSFileInfo(const QString& _name, double _duration) : name(_name), duration(_duration) {}
|
|
|
|
MPLSFileInfo() : duration(0) {}
|
2019-12-07 19:37:10 +01:00
|
|
|
QString name;
|
2019-08-10 18:07:43 +01:00
|
|
|
double duration;
|
|
|
|
};
|
|
|
|
|
|
|
|
bool checkFileDuplicate(const QString& fileName);
|
2019-12-07 19:37:10 +01:00
|
|
|
void tsMuxerExecute(const QStringList& args);
|
2019-08-10 18:07:43 +01:00
|
|
|
void addLines(const QByteArray& arr, QList<QString>& outList, bool isError);
|
2020-01-14 21:56:44 +01:00
|
|
|
void doAppendInt(const QString& fileName, const QString& parentFileName, double duration, bool doublePrefix,
|
|
|
|
MplsType mplsRole);
|
2019-08-10 18:07:43 +01:00
|
|
|
bool isDiskOutput() const;
|
|
|
|
QString getMuxOpts();
|
|
|
|
QString getFileList(QtvCodecInfo* codecInfo);
|
|
|
|
QString getAudioMetaInfo(QtvCodecInfo* codecInfo);
|
|
|
|
QString getVideoMetaInfo(QtvCodecInfo* codecInfo);
|
|
|
|
QString getFileList();
|
|
|
|
QString getSrtParams();
|
|
|
|
int findLangByCode(const QString& code);
|
|
|
|
void setComboBoxText(QComboBox* comboBox, const QString& text);
|
2020-01-11 23:46:04 +01:00
|
|
|
QtvCodecInfo* getCodecInfo(int idx);
|
2019-08-10 18:07:43 +01:00
|
|
|
QtvCodecInfo* getCurrentCodec();
|
|
|
|
void delTracksByFileName(const QString& fileName);
|
|
|
|
void deleteTrack(int idx);
|
|
|
|
void updateNum();
|
|
|
|
void modifyOutFileName(const QString fileName);
|
|
|
|
void moveRow(int index, int index2);
|
|
|
|
bool saveMetaFile(const QString& metaName);
|
|
|
|
void updateBtns(QWidget* w);
|
|
|
|
double getRendererAnimationTime() const;
|
|
|
|
void setRendererAnimationTime(double value);
|
|
|
|
void setTextItemColor(QString str);
|
2019-12-07 19:37:10 +01:00
|
|
|
QString getDefaultOutputFileName() const;
|
2019-08-10 18:07:43 +01:00
|
|
|
void updateCurrentColor(int dr, int dg, int db, int rowIndex);
|
|
|
|
void colorizeCurrentRow(const QtvCodecInfo* codecInfo, int rowIndex = -1);
|
|
|
|
|
2020-02-08 20:48:41 +01:00
|
|
|
void addTrackToDefaultComboBox(int trackRowIdx);
|
|
|
|
void removeTrackFromDefaultComboBox(int trackRowIdx);
|
2020-02-09 10:16:04 +01:00
|
|
|
void removeTrackFromDefaultComboBox(QComboBox*, QCheckBox*, int comboBoxIdx, int trackRowIdx);
|
2020-02-08 20:48:41 +01:00
|
|
|
void updateTracksComboBox(QComboBox*);
|
|
|
|
void moveTrackInDefaultComboBox(int oldIndex, int newIndex);
|
|
|
|
void postMoveComboBoxUpdate(QComboBox*, const QVariant& preMoveIndex, int oldIndex, int newIndex);
|
2020-03-06 00:20:05 +01:00
|
|
|
void setUiMetaItemsData();
|
2020-02-08 20:48:41 +01:00
|
|
|
|
2019-08-10 18:07:43 +01:00
|
|
|
QString metaName;
|
2020-01-11 23:46:04 +01:00
|
|
|
Ui::TsMuxerWindow* ui;
|
2019-08-10 18:07:43 +01:00
|
|
|
QFileDialog* openFileDialog;
|
|
|
|
int disableUpdatesCnt;
|
|
|
|
bool processFinished;
|
|
|
|
int processExitCode;
|
|
|
|
QProcess::ExitStatus processExitStatus;
|
|
|
|
QProcess::ProcessError processError;
|
|
|
|
QList<MPLSFileInfo> mplsFileList;
|
|
|
|
QProcess proc;
|
|
|
|
QList<QString> procStdOutput;
|
|
|
|
QList<QString> procErrOutput;
|
|
|
|
bool outFileNameModified;
|
|
|
|
QString oldFileName;
|
|
|
|
bool outFileNameDisableChange;
|
2020-03-01 19:32:53 +01:00
|
|
|
QString mSaveDialogFilter;
|
2020-01-11 23:46:04 +01:00
|
|
|
MuxForm* muxForm;
|
2019-08-10 18:07:43 +01:00
|
|
|
QString newFileName;
|
|
|
|
QList<QtvCodecInfo> codecList;
|
|
|
|
ChapterList chapters;
|
|
|
|
double fileDuration;
|
|
|
|
bool runInMuxMode;
|
|
|
|
QString lastInputDir;
|
|
|
|
QString lastOutputDir;
|
2020-01-14 21:56:44 +01:00
|
|
|
QList<QUrl> addFileList;
|
2019-08-10 18:07:43 +01:00
|
|
|
QTimer opacityTimer;
|
|
|
|
bool m_updateMeta;
|
|
|
|
bool m_3dMode;
|
|
|
|
QnCheckBoxedHeaderView* m_header;
|
|
|
|
QString lastSourceDir;
|
|
|
|
|
2020-03-01 00:35:31 +01:00
|
|
|
QTranslator qtCoreTranslator;
|
|
|
|
QTranslator tsMuxerTranslator;
|
|
|
|
|
2020-01-14 21:56:44 +01:00
|
|
|
void dragEnterEvent(QDragEnterEvent* event) override;
|
|
|
|
void dropEvent(QDropEvent* event) override;
|
|
|
|
void dragMoveEvent(QDragMoveEvent* event) override;
|
|
|
|
void dragLeaveEvent(QDragLeaveEvent* event) override;
|
2019-08-10 18:07:43 +01:00
|
|
|
|
2021-11-12 17:15:19 +00:00
|
|
|
#if QT_MULTIMEDIA_LIB
|
2020-03-03 21:57:01 +01:00
|
|
|
QSoundEffect sound;
|
2021-11-12 17:15:19 +00:00
|
|
|
#endif
|
2020-01-14 21:56:44 +01:00
|
|
|
void myPlaySound(const QString& fileName);
|
|
|
|
bool isVideoCropped();
|
2021-11-01 17:29:50 +01:00
|
|
|
|
|
|
|
FontSettingsTableModel* fontSettingsModel;
|
2022-05-15 22:53:32 +02:00
|
|
|
LangCodesModel* langCodesModel;
|
2019-08-10 18:07:43 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
Q_DECLARE_METATYPE(ChapterList);
|
2019-12-07 19:37:10 +01:00
|
|
|
|
|
|
|
#endif
|