Updated Web Updater binary. Now takes an additional "Checksum" argument.
[LameXP.git] / src / Thread_Process.h
blob8db2803863035051ede4bf20bb9cc884f2b5c31c
1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
3 // Copyright (C) 2004-2015 LoRd_MuldeR <MuldeR2@GMX.de>
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version, but always including the *additional*
9 // restrictions defined in the "License.txt" file.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this program; if not, write to the Free Software Foundation, Inc.,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 // http://www.gnu.org/licenses/gpl-2.0.txt
21 ///////////////////////////////////////////////////////////////////////////////
23 #pragma once
25 #include <QRunnable>
26 #include <QUuid>
27 #include <QStringList>
29 #include "Model_AudioFile.h"
30 #include "Encoder_Abstract.h"
32 class AbstractFilter;
33 class WaveProperties;
34 class QThreadPool;
35 class QCoreApplication;
37 class ProcessThread: public QObject, public QRunnable
39 Q_OBJECT
41 public:
42 ProcessThread(const AudioFileModel &audioFile, const QString &outputDirectory, const QString &tempDirectory, AbstractEncoder *encoder, const bool prependRelativeSourcePath);
43 ~ProcessThread(void);
45 bool init(void);
46 bool start(QThreadPool *const pool);
48 QUuid getId(void) { return m_jobId; }
49 void setRenamePattern(const QString &pattern);
50 void setRenameRegExp(const QString &search, const QString &replace);
51 void setRenameFileExt(const QString &fileExtension);
52 void setOverwriteMode(const bool &bSkipExistingFile, const bool &bReplacesExisting = false);
53 void addFilter(AbstractFilter *filter);
55 public slots:
56 void abort(void) { m_aborted = true; }
58 private slots:
59 void handleUpdate(int progress);
60 void handleMessage(const QString &line);
62 signals:
63 void processStateInitialized(const QUuid &jobId, const QString &jobName, const QString &jobInitialStatus, int jobInitialState);
64 void processStateChanged(const QUuid &jobId, const QString &newStatus, int newState);
65 void processStateFinished(const QUuid &jobId, const QString &outFileName, int success);
66 void processMessageLogged(const QUuid &jobId, const QString &line);
67 void processFinished(void);
69 protected:
70 virtual void run(void);
72 private:
73 enum ProcessStep
75 DecodingStep = 0,
76 AnalyzeStep = 1,
77 FilteringStep = 2,
78 EncodingStep = 3,
79 UnknownStep = 4
82 enum OverwriteMode
84 OverwriteMode_KeepBoth = 0,
85 OverwriteMode_SkipExisting = 1,
86 OverwriteMode_Overwrite = 2,
89 void processFile();
90 int generateOutFileName(QString &outFileName);
91 QString applyRenamePattern(const QString &baseName, const AudioFileModel_MetaInfo &metaInfo);
92 QString applyRegularExpression(const QString &fileName);
93 QString generateTempFileName(void);
94 void insertDownmixFilter(void);
95 void insertDownsampleFilter(void);
97 volatile bool m_aborted;
98 volatile int m_initialized;
100 const QUuid m_jobId;
101 AudioFileModel m_audioFile;
102 AbstractEncoder *m_encoder;
103 const QString m_outputDirectory;
104 const QString m_tempDirectory;
105 ProcessStep m_currentStep;
106 QStringList m_tempFiles;
107 const bool m_prependRelativeSourcePath;
108 QList<AbstractFilter*> m_filters;
109 QString m_renamePattern;
110 QString m_renameRegExp_Search;
111 QString m_renameRegExp_Replace;
112 QString m_renameFileExt;
113 int m_overwriteMode;
114 WaveProperties *m_propDetect;
115 QString m_outFileName;