2010-11-18 00:32:46 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// LameXP - Audio Encoder Front-End
|
2011-01-01 17:04:25 +01:00
|
|
|
// Copyright (C) 2004-2011 LoRd_MuldeR <MuldeR2@GMX.de>
|
2010-11-18 00:32:46 +01:00
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation; either version 2 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License along
|
|
|
|
// with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
//
|
|
|
|
// http://www.gnu.org/licenses/gpl-2.0.txt
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QThread>
|
2010-11-18 22:37:35 +01:00
|
|
|
#include <QUuid>
|
2010-12-01 23:14:47 +01:00
|
|
|
#include <QStringList>
|
2010-11-18 00:32:46 +01:00
|
|
|
|
2010-11-19 21:11:54 +01:00
|
|
|
#include "Model_AudioFile.h"
|
2010-11-20 02:14:22 +01:00
|
|
|
#include "Encoder_Abstract.h"
|
2010-11-19 21:11:54 +01:00
|
|
|
|
2010-11-20 22:14:10 +01:00
|
|
|
class QMutex;
|
2011-01-25 23:12:56 +01:00
|
|
|
class AbstractFilter;
|
2010-11-20 22:14:10 +01:00
|
|
|
|
2010-11-18 00:32:46 +01:00
|
|
|
class ProcessThread: public QThread
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2011-02-25 22:03:39 +01:00
|
|
|
ProcessThread(const AudioFileModel &audioFile, const QString &outputDirectory, const QString &tempDirectory, AbstractEncoder *encoder, const bool prependRelativeSourcePath);
|
2010-11-18 00:32:46 +01:00
|
|
|
~ProcessThread(void);
|
2010-11-26 00:29:53 +01:00
|
|
|
|
2010-11-18 00:32:46 +01:00
|
|
|
void run();
|
2010-11-26 00:29:53 +01:00
|
|
|
|
2010-11-18 00:32:46 +01:00
|
|
|
void abort() { m_aborted = true; }
|
2010-11-19 21:11:54 +01:00
|
|
|
QUuid getId() { return m_jobId; }
|
2011-08-04 23:26:38 +02:00
|
|
|
void setRenamePattern(const QString &pattern);
|
2011-01-25 23:12:56 +01:00
|
|
|
void addFilter(AbstractFilter *filter);
|
2010-11-18 00:32:46 +01:00
|
|
|
|
2010-11-20 02:14:22 +01:00
|
|
|
private slots:
|
|
|
|
void handleUpdate(int progress);
|
2010-11-22 21:45:00 +01:00
|
|
|
void handleMessage(const QString &line);
|
2010-11-20 02:14:22 +01:00
|
|
|
|
2010-11-18 00:32:46 +01:00
|
|
|
signals:
|
2010-11-18 22:37:35 +01:00
|
|
|
void processStateInitialized(const QUuid &jobId, const QString &jobName, const QString &jobInitialStatus, int jobInitialState);
|
|
|
|
void processStateChanged(const QUuid &jobId, const QString &newStatus, int newState);
|
2010-11-20 22:14:10 +01:00
|
|
|
void processStateFinished(const QUuid &jobId, const QString &outFileName, bool success);
|
2010-11-22 21:45:00 +01:00
|
|
|
void processMessageLogged(const QUuid &jobId, const QString &line);
|
2010-11-18 00:32:46 +01:00
|
|
|
|
|
|
|
private:
|
2010-12-01 23:14:47 +01:00
|
|
|
enum ProcessStep
|
|
|
|
{
|
|
|
|
DecodingStep = 0,
|
|
|
|
FilteringStep = 1,
|
|
|
|
EncodingStep = 2,
|
|
|
|
UnknownStep = 3
|
|
|
|
};
|
|
|
|
|
2010-11-26 00:29:53 +01:00
|
|
|
void processFile();
|
2010-11-20 02:14:22 +01:00
|
|
|
QString generateOutFileName(void);
|
2010-12-01 23:14:47 +01:00
|
|
|
QString generateTempFileName(void);
|
2011-05-06 17:51:49 +02:00
|
|
|
void insertDownsampleFilter(void);
|
2011-08-06 18:56:09 +02:00
|
|
|
void insertDownmixFilter(void);
|
2010-11-20 02:14:22 +01:00
|
|
|
|
2010-11-18 22:37:35 +01:00
|
|
|
const QUuid m_jobId;
|
2010-11-19 21:11:54 +01:00
|
|
|
AudioFileModel m_audioFile;
|
2010-11-20 02:14:22 +01:00
|
|
|
AbstractEncoder *m_encoder;
|
|
|
|
const QString m_outputDirectory;
|
2011-02-25 22:03:39 +01:00
|
|
|
const QString m_tempDirectory;
|
2010-11-18 00:32:46 +01:00
|
|
|
volatile bool m_aborted;
|
2010-12-01 23:14:47 +01:00
|
|
|
ProcessStep m_currentStep;
|
|
|
|
QStringList m_tempFiles;
|
2010-12-14 01:25:13 +01:00
|
|
|
const bool m_prependRelativeSourcePath;
|
2011-01-25 23:12:56 +01:00
|
|
|
QList<AbstractFilter*> m_filters;
|
2011-08-04 23:26:38 +02:00
|
|
|
QString m_renamePattern;
|
2010-11-20 22:14:10 +01:00
|
|
|
|
|
|
|
static QMutex *m_mutex_genFileName;
|
2010-11-18 00:32:46 +01:00
|
|
|
};
|