2010-12-01 23:14:47 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// LameXP - Audio Encoder Front-End
|
2021-02-17 00:52:18 +01:00
|
|
|
// Copyright (C) 2004-2021 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
|
2020-03-28 15:31:01 +01:00
|
|
|
// it under the terms of the GNU GENERAL PUBLIC LICENSE as published by
|
2010-12-01 23:14:47 +01:00
|
|
|
// the Free Software Foundation; either version 2 of the License, or
|
2020-03-28 15:31:01 +01:00
|
|
|
// (at your option) any later version; always including the non-optional
|
|
|
|
// LAMEXP GNU GENERAL PUBLIC LICENSE ADDENDUM. See "License.txt" file!
|
2010-12-01 23:14:47 +01:00
|
|
|
//
|
|
|
|
// 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"
|
|
|
|
|
2015-05-18 18:56:33 +02:00
|
|
|
//Internal
|
2010-12-02 23:26:30 +01:00
|
|
|
#include "Decoder_AAC.h"
|
2011-01-18 22:07:30 +01:00
|
|
|
#include "Decoder_AC3.h"
|
2011-01-09 22:36:52 +01:00
|
|
|
#include "Decoder_ADPCM.h"
|
2011-01-21 00:10:51 +01:00
|
|
|
#include "Decoder_ALAC.h"
|
2011-05-19 23:07:46 +02:00
|
|
|
#include "Decoder_Avisynth.h"
|
2011-01-18 22:07:30 +01:00
|
|
|
#include "Decoder_FLAC.h"
|
2011-01-16 22:00:49 +01:00
|
|
|
#include "Decoder_MAC.h"
|
2010-12-01 23:14:47 +01:00
|
|
|
#include "Decoder_MP3.h"
|
2011-01-29 22:50:37 +01:00
|
|
|
#include "Decoder_Musepack.h"
|
2011-01-30 01:45:34 +01:00
|
|
|
#include "Decoder_Shorten.h"
|
2011-02-01 22:15:57 +01:00
|
|
|
#include "Decoder_Speex.h"
|
2011-01-18 22:07:30 +01:00
|
|
|
#include "Decoder_TTA.h"
|
2010-12-01 23:14:47 +01:00
|
|
|
#include "Decoder_Vorbis.h"
|
2010-12-19 00:50:22 +01:00
|
|
|
#include "Decoder_Wave.h"
|
2011-01-17 20:52:54 +01:00
|
|
|
#include "Decoder_WavPack.h"
|
2012-07-20 23:19:08 +02:00
|
|
|
#include "Decoder_Opus.h"
|
2011-01-18 22:07:30 +01:00
|
|
|
#include "Decoder_WMA.h"
|
2011-02-01 22:15:57 +01:00
|
|
|
#include "PlaylistImporter.h"
|
2013-01-18 01:08:58 +01:00
|
|
|
#include "Model_Settings.h"
|
2010-12-01 23:14:47 +01:00
|
|
|
|
2015-05-18 18:56:33 +02:00
|
|
|
//MUtils
|
|
|
|
#include <MUtils/Exception.h>
|
|
|
|
|
|
|
|
//Qt
|
2010-12-01 23:14:47 +01:00
|
|
|
#include <QString>
|
2010-12-20 22:13:01 +01:00
|
|
|
#include <QStringList>
|
2015-05-18 18:56:33 +02:00
|
|
|
#include <QMutex>
|
2010-12-20 22:13:01 +01:00
|
|
|
#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(); }
|
2015-05-18 18:56:33 +02:00
|
|
|
|
|
|
|
#define GET_FILETYPES(LIST, DEC) do \
|
|
|
|
{ \
|
|
|
|
if(DEC::isDecoderAvailable()) (LIST) << DEC::supportedTypes(); \
|
|
|
|
} \
|
|
|
|
while(0)
|
|
|
|
|
|
|
|
QMutex DecoderRegistry::m_lock(QMutex::Recursive);
|
|
|
|
QScopedPointer<QStringList> DecoderRegistry::m_supportedExts;
|
|
|
|
QScopedPointer<QStringList> DecoderRegistry::m_supportedTypes;
|
|
|
|
QScopedPointer<DecoderRegistry::typeList_t> DecoderRegistry::m_availableTypes;
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
// Public Functions
|
|
|
|
////////////////////////////////////////////////////////////
|
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);
|
2011-01-17 20:52:54 +01:00
|
|
|
PROBE_DECODER(WavPackDecoder);
|
2011-01-29 22:50:37 +01:00
|
|
|
PROBE_DECODER(MusepackDecoder);
|
2011-01-30 01:45:34 +01:00
|
|
|
PROBE_DECODER(ShortenDecoder);
|
2011-01-16 22:00:49 +01:00
|
|
|
PROBE_DECODER(MACDecoder);
|
2011-01-18 22:07:30 +01:00
|
|
|
PROBE_DECODER(TTADecoder);
|
2011-02-01 22:15:57 +01:00
|
|
|
PROBE_DECODER(SpeexDecoder);
|
2011-01-21 00:10:51 +01:00
|
|
|
PROBE_DECODER(ALACDecoder);
|
2010-12-12 19:25:06 +01:00
|
|
|
PROBE_DECODER(WMADecoder);
|
2011-01-09 22:36:52 +01:00
|
|
|
PROBE_DECODER(ADPCMDecoder);
|
2010-12-19 00:50:22 +01:00
|
|
|
PROBE_DECODER(WaveDecoder);
|
2012-07-20 23:19:08 +02:00
|
|
|
PROBE_DECODER(OpusDecoder);
|
2011-05-19 23:07:46 +02:00
|
|
|
PROBE_DECODER(AvisynthDecoder);
|
2011-01-17 20:52:54 +01:00
|
|
|
|
2010-12-01 23:14:47 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2015-05-18 18:56:33 +02:00
|
|
|
const QStringList &DecoderRegistry::getSupportedExts(void)
|
2010-12-20 22:13:01 +01:00
|
|
|
{
|
2015-05-18 18:56:33 +02:00
|
|
|
QMutexLocker locker(&m_lock);
|
|
|
|
|
|
|
|
if(!m_supportedExts.isNull())
|
|
|
|
{
|
|
|
|
return (*m_supportedExts);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_supportedExts.reset(new QStringList());
|
|
|
|
|
|
|
|
const typeList_t &types = getAvailableDecoderTypes();
|
|
|
|
for(QList<const AbstractDecoder::supportedType_t*>::ConstIterator iter = types.constBegin(); iter != types.constEnd(); iter++)
|
2010-12-20 22:13:01 +01:00
|
|
|
{
|
2015-05-18 18:56:33 +02:00
|
|
|
for(size_t i = 0; (*iter)[i].name; i++)
|
2010-12-20 22:13:01 +01:00
|
|
|
{
|
2015-05-18 18:56:33 +02:00
|
|
|
for(size_t j = 0; (*iter)[i].exts[j]; j++)
|
|
|
|
{
|
|
|
|
const QString ext = QString().sprintf("*.%s", (*iter)[i].exts[j]);
|
|
|
|
if(!m_supportedExts->contains(ext, Qt::CaseInsensitive))
|
|
|
|
{
|
|
|
|
(*m_supportedExts) << ext;
|
|
|
|
}
|
|
|
|
}
|
2010-12-20 22:13:01 +01:00
|
|
|
}
|
|
|
|
}
|
2011-01-30 22:19:53 +01:00
|
|
|
|
2015-05-22 19:37:45 +02:00
|
|
|
const char *const *const playlistPtr = PlaylistImporter::getSupportedExtensions();
|
|
|
|
for(size_t i = 0; playlistPtr[i]; i++)
|
|
|
|
{
|
|
|
|
const QString ext = QString().sprintf("*.%s", playlistPtr[i]);
|
|
|
|
if(!m_supportedExts->contains(ext, Qt::CaseInsensitive))
|
|
|
|
{
|
|
|
|
(*m_supportedExts) << ext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-18 18:56:33 +02:00
|
|
|
m_supportedExts->sort();
|
|
|
|
return (*m_supportedExts);
|
|
|
|
}
|
|
|
|
|
|
|
|
const QStringList &DecoderRegistry::getSupportedTypes(void)
|
|
|
|
{
|
|
|
|
QMutexLocker locker(&m_lock);
|
|
|
|
|
|
|
|
if(!m_supportedTypes.isNull())
|
2010-12-20 22:13:01 +01:00
|
|
|
{
|
2015-05-18 18:56:33 +02:00
|
|
|
return (*m_supportedTypes);
|
2010-12-20 22:13:01 +01:00
|
|
|
}
|
2011-01-30 22:19:53 +01:00
|
|
|
|
2015-05-18 18:56:33 +02:00
|
|
|
m_supportedTypes.reset(new QStringList());
|
2015-05-22 19:37:45 +02:00
|
|
|
(*m_supportedTypes) << QString("%1 (%2)").arg(tr("All supported types"), getSupportedExts().join(" "));
|
2015-05-18 18:56:33 +02:00
|
|
|
|
|
|
|
const typeList_t &types = getAvailableDecoderTypes();
|
|
|
|
for(QList<const AbstractDecoder::supportedType_t*>::ConstIterator iter = types.constBegin(); iter != types.constEnd(); iter++)
|
|
|
|
{
|
|
|
|
for(size_t i = 0; (*iter)[i].name; i++)
|
|
|
|
{
|
|
|
|
QStringList extList;
|
|
|
|
for(size_t j = 0; (*iter)[i].exts[j]; j++)
|
|
|
|
{
|
|
|
|
extList << QString().sprintf("*.%s", (*iter)[i].exts[j]);
|
|
|
|
}
|
|
|
|
if(!extList.isEmpty())
|
|
|
|
{
|
|
|
|
(*m_supportedTypes) << QString("%1 (%2)").arg(QString::fromLatin1((*iter)[i].name), extList.join(" "));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *const *const playlistPtr = PlaylistImporter::getSupportedExtensions();
|
2015-05-22 19:37:45 +02:00
|
|
|
QStringList playListExts;
|
2015-05-18 18:56:33 +02:00
|
|
|
for(size_t i = 0; playlistPtr[i]; i++)
|
|
|
|
{
|
2015-05-22 19:37:45 +02:00
|
|
|
const QString ext = QString().sprintf("*.%s", playlistPtr[i]);
|
|
|
|
if(!playListExts.contains(ext, Qt::CaseInsensitive))
|
|
|
|
{
|
|
|
|
playListExts << ext;
|
|
|
|
}
|
2015-05-18 18:56:33 +02:00
|
|
|
}
|
|
|
|
|
2015-05-22 19:37:45 +02:00
|
|
|
(*m_supportedTypes) << QString("%1 (%2)").arg(tr("Playlists"), playListExts.join(" "));
|
2015-05-18 18:56:33 +02:00
|
|
|
(*m_supportedTypes) << QString("%1 (*.*)").arg(tr("All files"));
|
|
|
|
|
|
|
|
return (*m_supportedTypes);
|
2010-12-20 22:13:01 +01:00
|
|
|
}
|
2013-01-18 01:08:58 +01:00
|
|
|
|
|
|
|
void DecoderRegistry::configureDecoders(const SettingsModel *settings)
|
|
|
|
{
|
|
|
|
OpusDecoder::setDisableResampling(settings->opusDisableResample());
|
|
|
|
}
|
2015-05-18 18:56:33 +02:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
// Private Functions
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
const DecoderRegistry::typeList_t &DecoderRegistry::getAvailableDecoderTypes(void)
|
|
|
|
{
|
|
|
|
if(!m_availableTypes.isNull())
|
|
|
|
{
|
|
|
|
return (*m_availableTypes);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_availableTypes.reset(new typeList_t());
|
|
|
|
|
|
|
|
GET_FILETYPES(*m_availableTypes, WaveDecoder);
|
|
|
|
GET_FILETYPES(*m_availableTypes, MP3Decoder);
|
|
|
|
GET_FILETYPES(*m_availableTypes, VorbisDecoder);
|
|
|
|
GET_FILETYPES(*m_availableTypes, AACDecoder);
|
|
|
|
GET_FILETYPES(*m_availableTypes, AC3Decoder);
|
|
|
|
GET_FILETYPES(*m_availableTypes, FLACDecoder);
|
|
|
|
GET_FILETYPES(*m_availableTypes, WavPackDecoder);
|
|
|
|
GET_FILETYPES(*m_availableTypes, MusepackDecoder);
|
|
|
|
GET_FILETYPES(*m_availableTypes, ShortenDecoder);
|
|
|
|
GET_FILETYPES(*m_availableTypes, MACDecoder);
|
|
|
|
GET_FILETYPES(*m_availableTypes, TTADecoder);
|
|
|
|
GET_FILETYPES(*m_availableTypes, SpeexDecoder);
|
|
|
|
GET_FILETYPES(*m_availableTypes, ALACDecoder);
|
|
|
|
GET_FILETYPES(*m_availableTypes, WMADecoder);
|
|
|
|
GET_FILETYPES(*m_availableTypes, ADPCMDecoder);
|
|
|
|
GET_FILETYPES(*m_availableTypes, OpusDecoder);
|
|
|
|
GET_FILETYPES(*m_availableTypes, AvisynthDecoder);
|
|
|
|
|
|
|
|
return (*m_availableTypes);
|
|
|
|
}
|