2010-12-01 23:14:47 +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-12-01 23:14:47 +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
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "Registry_Decoder.h"
|
|
|
|
|
2010-12-02 23:26:30 +01:00
|
|
|
#include "Decoder_AAC.h"
|
2010-12-01 23:14:47 +01:00
|
|
|
#include "Decoder_MP3.h"
|
|
|
|
#include "Decoder_Vorbis.h"
|
2010-12-15 19:57:51 +01:00
|
|
|
#include "Decoder_FLAC.h"
|
2010-12-19 23:09:26 +01:00
|
|
|
#include "Decoder_AC3.h"
|
2010-12-12 19:25:06 +01:00
|
|
|
#include "Decoder_WMA.h"
|
2010-12-19 00:50:22 +01:00
|
|
|
#include "Decoder_Wave.h"
|
2010-12-01 23:14:47 +01:00
|
|
|
|
|
|
|
#include <QString>
|
2010-12-20 22:13:01 +01:00
|
|
|
#include <QStringList>
|
|
|
|
#include <QRegExp>
|
2010-12-01 23:14:47 +01:00
|
|
|
|
2010-12-12 19:25:06 +01:00
|
|
|
#define PROBE_DECODER(DEC) if(DEC::isDecoderAvailable() && DEC::isFormatSupported(containerType, containerProfile, formatType, formatProfile, formatVersion)) { return new DEC(); }
|
2010-12-20 22:13:01 +01:00
|
|
|
#define GET_FILETYPES(DEC) (DEC::isDecoderAvailable() ? DEC::supportedTypes() : QStringList())
|
2010-12-01 23:14:47 +01:00
|
|
|
|
|
|
|
AbstractDecoder *DecoderRegistry::lookup(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
|
|
|
{
|
|
|
|
PROBE_DECODER(MP3Decoder);
|
|
|
|
PROBE_DECODER(VorbisDecoder);
|
2010-12-02 23:26:30 +01:00
|
|
|
PROBE_DECODER(AACDecoder);
|
2010-12-19 23:09:26 +01:00
|
|
|
PROBE_DECODER(AC3Decoder);
|
2010-12-15 19:57:51 +01:00
|
|
|
PROBE_DECODER(FLACDecoder);
|
2010-12-12 19:25:06 +01:00
|
|
|
PROBE_DECODER(WMADecoder);
|
2010-12-19 00:50:22 +01:00
|
|
|
PROBE_DECODER(WaveDecoder);
|
2010-12-01 23:14:47 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-12-20 22:13:01 +01:00
|
|
|
QStringList DecoderRegistry::getSupportedTypes(void)
|
|
|
|
{
|
|
|
|
QStringList types;
|
|
|
|
|
|
|
|
types << GET_FILETYPES(WaveDecoder);
|
|
|
|
types << GET_FILETYPES(MP3Decoder);
|
|
|
|
types << GET_FILETYPES(VorbisDecoder);
|
|
|
|
types << GET_FILETYPES(AACDecoder);
|
|
|
|
types << GET_FILETYPES(AC3Decoder);
|
|
|
|
types << GET_FILETYPES(FLACDecoder);
|
|
|
|
types << GET_FILETYPES(WMADecoder);
|
|
|
|
|
|
|
|
QStringList extensions;
|
|
|
|
QRegExp regExp("\\((.+)\\)", Qt::CaseInsensitive);
|
|
|
|
|
|
|
|
for(int i = 0; i < types.count(); i++)
|
|
|
|
{
|
|
|
|
if(regExp.lastIndexIn(types.at(i)) >= 0)
|
|
|
|
{
|
|
|
|
extensions << regExp.cap(1).split(" ", QString::SkipEmptyParts);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!extensions.empty())
|
|
|
|
{
|
|
|
|
extensions.removeDuplicates();
|
|
|
|
extensions.sort();
|
2011-01-02 01:09:05 +01:00
|
|
|
types.prepend(QString("%1 (%2)").arg(tr("All supported types"), extensions.join(" ")));
|
2010-12-20 22:13:01 +01:00
|
|
|
}
|
|
|
|
|
2011-01-02 01:09:05 +01:00
|
|
|
types << QString("%1 (*.*)").arg(tr("All files"));
|
2010-12-20 22:13:01 +01:00
|
|
|
return types;
|
|
|
|
}
|