/*****************************************************************************
 *
 *  transcoder.h -- Base class for transcoder interfaces.
 *
 *  Copyright (C) 2010 Starbuck <starbuck@labdv.com>
 *  All rights reserved.
 *
 *  This file is part of the JobManager module of the DVDx 4 application.
 *
 *  GNU Lesser General Public License Usage
 *  This file may be used under the terms of the GNU Lesser General
 *  Public License version 2.1 as published by the Free Software
 *  Foundation and appearing in the file LICENSE.LGPL included in the
 *  packaging of this file.  Please review the following information to
 *  ensure the GNU Lesser General Public License version 2.1 requirements
 *  will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
 *
 *  GNU General Public License Usage
 *  Alternatively, this file may be used under the terms of the GNU
 *  General Public License version 3.0 as published by the Free Software
 *  Foundation and appearing in the file LICENSE.GPL included in the
 *  packaging of this file.  Please review the following information to
 *  ensure the GNU General Public License version 3.0 requirements will be
 *  met: http://www.gnu.org/copyleft/gpl.html.
 *
 *****************************************************************************/

#ifndef TRANSCODER_H
#define TRANSCODER_H

#include "../main/console.h"
#include "iprocessor.h"
#include "processlatency.h"
#include <QHash>
#include <QMap>
#include <QObject>
#include <QString>
#include <QStringList>
#include <QTextEdit>

class Transcoder : public IProcessor 
{
	Q_OBJECT

public:
	// Constants
	enum State { Idle, Ready, Failed };

public:
	Transcoder();
	//~Transcoder();

	QStringList availableAudioEncoders();
	QStringList availableFormatEncoders();
	QStringList availableSubtitleEncoders();
	QStringList availableVideoEncoders();

	QString codecAudioLabel(QString codec);
	QString codecFormatLabel(QString codec);
	QString codecSubtitleLabel(QString codec);
	QString codecVideoLabel(QString codec);

	QString	interfaceExec();  // IProcessor interface
	QString	interfaceName();  // IProcessor interface
	QString	interfacePath();  // IProcessor interface
	virtual bool interfaceStart(const QString &path, const QString &libPath) = 0;  // IProcessor interface
	int		interfaceState();  // IProcessor interface
	QString	interfaceVersion();  // IProcessor interface

	bool isAvailableAudioEncoder(QString codec);
	bool isAvailableFormatEncoder(QString codec);
	bool isAvailableSubtitleEncoder(QString codec);
	bool isAvailableVideoEncoder(QString codec);

signals:

protected:
	bool run(QStringList *args, QString *stdOut, QString *stdErr, QString *err);

protected:
	Console	*m_console;

	QString			m_interfaceExec;
	ProcessLatency	m_interfaceLatency;
	QString			m_interfaceLibPath;
	QString			m_interfaceName;
	QString			m_interfacePath;
	int				m_interfaceState;
	QString			m_interfaceVersion;

	// Tables of codec->label
	QMap<QString, QString> m_availableAudioEncoders;
	QMap<QString, QString> m_availableFormatEncoders;
	QMap<QString, QString> m_availableSubtitleEncoders;
	QMap<QString, QString> m_availableVideoEncoders;
};

#endif
