/*****************************************************************************
 *
 *  ffprobe.h -- FFprobe interface.
 *
 *  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 FFPROBE_H
#define FFPROBE_H

#include "analyzer.h"
#include <QObject>
#include <QHash>
#include <QMap>
#include <QString>
#include <QStringList>

class FFprobe : public Analyzer
{
	Q_OBJECT

public:
	FFprobe();
	//~FFprobe();

	static double fieldStringToDouble(const QString &field);

	bool getDataFormat(QString *value, const QString &field);
	int  getDataFormat(QHash<QString, QString> *valueList,
			QStringList *fieldList, QStringList *fieldNotFound=0);
	
	bool getDataStream(const int streamIndex, QString *value, const QString &field);
	int  getDataStream(const int streamIndex, QHash<QString, QString> *valueList, 
			QStringList *fieldList, QStringList *fieldNotFound=0);
	
	QList<int> getStreamIndexesAttachment();
	QList<int> getStreamIndexesAudio();
	QList<int> getStreamIndexesData();
	QList<int> getStreamIndexesSubtitle();
	QList<int> getStreamIndexesVideo();

	int getStreamNumber();

	void interfaceReset();
	bool interfaceStart(const QString &path="", const QString &libPath="");  // IProcessor interface

	bool load(const QString &mediaFile);

signals:
	void interfaceFailed();  // IProcessor interface
	void interfaceReady();  // IProcessor interface

protected:
	QString	parseDataField(const QString &field, QString *output, bool *ok);
	void	parseInterfaceVersion(QString *output);

protected:
	QString		m_dataFormat;
	QStringList	m_dataStream;
	bool		m_dataReady;
	QString		m_inputFile;

	QList<int> m_streamIndexesAttachment;
	QList<int> m_streamIndexesAudio;
	QList<int> m_streamIndexesData;
	QList<int> m_streamIndexesSubtitle;
	QList<int> m_streamIndexesVideo;
};

#endif
