Updated copyright year.
[simple-x264-launcher.git] / src / thread_encode.h
blob2bdb156d7ab227da96ae11a377c9bdcffd66a926
1 ///////////////////////////////////////////////////////////////////////////////
2 // Simple x264 Launcher
3 // Copyright (C) 2004-2024 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.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License along
16 // with this program; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 // http://www.gnu.org/licenses/gpl-2.0.txt
20 ///////////////////////////////////////////////////////////////////////////////
22 #pragma once
24 #include "thread_abstract.h"
25 #include "model_status.h"
27 #include <QThread>
28 #include <QUuid>
29 #include <QMutex>
30 #include <QStringList>
31 #include <QSemaphore>
33 class SysinfoModel;
34 class PreferencesModel;
35 class OptionsModel;
36 class QProcess;
37 class JobObject;
38 class AbstractEncoder;
39 class AbstractSource;
41 class EncodeThread : public AbstractThread
43 Q_OBJECT
45 public:
46 EncodeThread(const QString &sourceFileName, const QString &outputFileName, const OptionsModel *options, const SysinfoModel *const sysinfo, const PreferencesModel *const m_preferences);
47 ~EncodeThread(void);
49 QUuid getId(void) { return this->m_jobId; };
50 const QString &sourceFileName(void) const { return this->m_sourceFileName; }
51 const QString &outputFileName(void) const { return this->m_outputFileName; }
52 const OptionsModel *options(void) const { return m_options; }
54 void pauseJob(void)
56 m_pause = true;
59 void resumeJob(void)
61 m_pause = false;
62 m_semaphorePaused.release();
65 void abortJob(void)
67 m_abort = true;
68 m_pause = false;
69 m_semaphorePaused.release();
72 protected:
73 //Globals
74 const SysinfoModel *const m_sysinfo;
75 const PreferencesModel *const m_preferences;
77 //Constants
78 const QUuid m_jobId;
79 const OptionsModel *m_options;
80 const QString m_sourceFileName;
81 const QString m_outputFileName;
83 //Flags
84 volatile bool m_abort;
85 volatile bool m_pause;
87 //Synchronization
88 QSemaphore m_semaphorePaused;
90 //Job Object
91 JobObject *m_jobObject;
93 //Internal status values
94 JobStatus m_status;
95 unsigned int m_progress;
96 QString m_details;
98 //Encoder and Source objects
99 AbstractEncoder *m_encoder;
100 AbstractSource *m_pipedSource;
102 //Entry point
103 virtual void run(void);
105 //Thread main
106 virtual int threadMain(void);
108 //Static functions
109 static QString getPasslogFile(const QString &outputFile);
111 signals:
112 void statusChanged(const QUuid &jobId, const JobStatus &newStatus);
113 void progressChanged(const QUuid &jobId, const unsigned int &newProgress);
114 void messageLogged(const QUuid &jobId, qint64, const QString &text);
115 void detailsChanged(const QUuid &jobId, const QString &details);
117 private slots:
118 void log(const QString &text);
119 void setStatus(const JobStatus &newStatus);
120 void setProgress(const unsigned int &newProgress);
121 void setDetails(const QString &text);
123 public slots:
124 void start(Priority priority = InheritPriority);