Improved internal decoder interface.

This commit is contained in:
LoRd_MuldeR 2015-05-18 18:56:33 +02:00
parent cda221f991
commit a915058dc2
42 changed files with 421 additions and 137 deletions

View File

@ -35,7 +35,7 @@
#define VER_LAMEXP_MINOR_LO 2 #define VER_LAMEXP_MINOR_LO 2
#define VER_LAMEXP_TYPE Alpha #define VER_LAMEXP_TYPE Alpha
#define VER_LAMEXP_PATCH 4 #define VER_LAMEXP_PATCH 4
#define VER_LAMEXP_BUILD 1737 #define VER_LAMEXP_BUILD 1741
#define VER_LAMEXP_CONFG 1700 #define VER_LAMEXP_CONFG 1700
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View File

@ -138,7 +138,18 @@ bool AACDecoder::isFormatSupported(const QString &containerType, const QString &
return false; return false;
} }
QStringList AACDecoder::supportedTypes(void) const AbstractDecoder::supportedType_t *AACDecoder::supportedTypes(void)
{ {
return QStringList() << "Advanced Audio Coding (*.aac *.mp4 *.m4a)"; static const char *exts[] =
{
"mp4", "m4a", "aac", NULL
};
static const supportedType_t s_supportedTypes[] =
{
{ "Advanced Audio Coding", exts },
{ NULL, NULL }
};
return s_supportedTypes;
} }

View File

@ -32,7 +32,7 @@ public:
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag); virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static QStringList supportedTypes(void); static const supportedType_t *supportedTypes(void);
private: private:
const QString m_binary; const QString m_binary;

View File

@ -152,8 +152,20 @@ bool AC3Decoder::isFormatSupported(const QString &containerType, const QString &
return false; return false;
} }
QStringList AC3Decoder::supportedTypes(void) const AbstractDecoder::supportedType_t *AC3Decoder::supportedTypes(void)
{ {
return QStringList() << "AC-3 / ATSC A/52 (*.ac3 *.eac3 *.wav)" << "Digital Theater System (*.dts)"; static const char *exts[][4] =
} {
{ "ac3", "eac3", "wav", NULL },
{ "dts", "wav", NULL }
};
static const supportedType_t s_supportedTypes[] =
{
{ "AC-3 / ATSC A/52", exts[0] },
{ "Digital Theater System", exts[1] },
{ NULL, NULL }
};
return s_supportedTypes;
}

View File

@ -32,7 +32,7 @@ public:
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag); virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static QStringList supportedTypes(void); static const supportedType_t *supportedTypes(void);
private: private:
const QString m_binary; const QString m_binary;

View File

@ -143,7 +143,22 @@ bool ADPCMDecoder::isFormatSupported(const QString &containerType, const QString
return false; return false;
} }
QStringList ADPCMDecoder::supportedTypes(void) const AbstractDecoder::supportedType_t *ADPCMDecoder::supportedTypes(void)
{ {
return QStringList() << "Microsoft ADPCM (*.wav)" << "Apple/SGI AIFF (*.aif *.aiff)" << "Sun/NeXT Au (*.au *.snd)"; static const char *exts[][3] =
{
{ "wav", NULL },
{ "aif", "aiff", NULL },
{ "au" , "snd", NULL }
};
static const supportedType_t s_supportedTypes[] =
{
{ "Microsoft ADPCM", exts[0] },
{ "Apple/SGI AIFF", exts[1] },
{ "Sun/NeXT Au", exts[2] },
{ NULL, NULL }
};
return s_supportedTypes;
} }

View File

@ -32,7 +32,7 @@ public:
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag); virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static QStringList supportedTypes(void); static const supportedType_t *supportedTypes(void);
private: private:
const QString m_binary; const QString m_binary;

View File

@ -146,7 +146,18 @@ bool ALACDecoder::isFormatSupported(const QString &containerType, const QString
return false; return false;
} }
QStringList ALACDecoder::supportedTypes(void) const AbstractDecoder::supportedType_t *ALACDecoder::supportedTypes(void)
{ {
return QStringList() << "Apple Lossless (*.mp4 *.m4a)"; static const char *exts[] =
{
"mp4", "m4a", NULL
};
static const supportedType_t s_supportedTypes[] =
{
{ "Apple Lossless", exts },
{ NULL, NULL }
};
return s_supportedTypes;
} }

View File

@ -32,7 +32,7 @@ public:
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag); virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static QStringList supportedTypes(void); static const supportedType_t *supportedTypes(void);
private: private:
const QString m_binary; const QString m_binary;

View File

@ -22,7 +22,7 @@
#include "Decoder_Abstract.h" #include "Decoder_Abstract.h"
#include <QStringList> #include <MUtils/Exception.h>
AbstractDecoder::AbstractDecoder(void) AbstractDecoder::AbstractDecoder(void)
{ {
@ -46,7 +46,7 @@ bool AbstractDecoder::isDecoderAvailable(void)
return true; return true;
} }
QStringList AbstractDecoder::supportedTypes(void) const AbstractDecoder::supportedType_t *AbstractDecoder::supportedTypes(void)
{ {
return QStringList(); MUTILS_THROW("This function must be re-implemented in sub-classes!");
} }

View File

@ -32,10 +32,13 @@ public:
AbstractDecoder(void); AbstractDecoder(void);
virtual ~AbstractDecoder(void); virtual ~AbstractDecoder(void);
//Types
typedef struct { const char *const name; const char *const *const exts; } supportedType_t;
//Internal decoder API //Internal decoder API
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag) = 0; virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag) = 0;
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static bool isDecoderAvailable(void); static bool isDecoderAvailable(void);
static QStringList supportedTypes(void); static const supportedType_t *supportedTypes(void);
}; };

View File

@ -134,7 +134,18 @@ bool AvisynthDecoder::isFormatSupported(const QString &containerType, const QStr
return false; return false;
} }
QStringList AvisynthDecoder::supportedTypes(void) const AbstractDecoder::supportedType_t *AvisynthDecoder::supportedTypes(void)
{ {
return QStringList() << "Avisynth Script (*.avs)"; static const char *exts[] =
{
"avs", NULL
};
static const supportedType_t s_supportedTypes[] =
{
{ "Avisynth Script", exts },
{ NULL, NULL }
};
return s_supportedTypes;
} }

View File

@ -32,7 +32,7 @@ public:
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag); virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static QStringList supportedTypes(void); static const supportedType_t *supportedTypes(void);
private: private:
const QString m_binary; const QString m_binary;

View File

@ -132,7 +132,18 @@ bool FLACDecoder::isFormatSupported(const QString &containerType, const QString
return false; return false;
} }
QStringList FLACDecoder::supportedTypes(void) const AbstractDecoder::supportedType_t *FLACDecoder::supportedTypes(void)
{ {
return QStringList() << "Free Lossless Audio Codec (*.flac *.fla)"; static const char *exts[] =
{
"fla", "flac", NULL
};
static const supportedType_t s_supportedTypes[] =
{
{ "Free Lossless Audio Codec", exts },
{ NULL, NULL }
};
return s_supportedTypes;
} }

View File

@ -32,7 +32,7 @@ public:
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag); virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static QStringList supportedTypes(void); static const supportedType_t *supportedTypes(void);
private: private:
const QString m_binary; const QString m_binary;

View File

@ -137,7 +137,18 @@ bool MACDecoder::isFormatSupported(const QString &containerType, const QString &
return false; return false;
} }
QStringList MACDecoder::supportedTypes(void) const AbstractDecoder::supportedType_t *MACDecoder::supportedTypes(void)
{ {
return QStringList() << "Monkey's Audio (*.ape)"; static const char *exts[] =
{
"ape", NULL
};
static const supportedType_t s_supportedTypes[] =
{
{ "Monkey's Audio", exts },
{ NULL, NULL }
};
return s_supportedTypes;
} }

View File

@ -32,7 +32,7 @@ public:
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag); virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static QStringList supportedTypes(void); static const supportedType_t *supportedTypes(void);
private: private:
const QString m_binary; const QString m_binary;

View File

@ -153,8 +153,22 @@ bool MP3Decoder::isFormatSupported(const QString &containerType, const QString &
return false; return false;
} }
QStringList MP3Decoder::supportedTypes(void) const AbstractDecoder::supportedType_t *MP3Decoder::supportedTypes(void)
{ {
return QStringList() << "MPEG Audio Layer III (*.mp3 *.mpa)" << "MPEG Audio Layer II (*.mp2 *.mpa)" << "MPEG Audio Layer I ( *.mp1 *.mpa)"; static const char *exts[][3] =
} {
{ "mp3", "mpa", NULL },
{ "mp2", "mpa", NULL },
{ "mp1", "mpa", NULL }
};
static const supportedType_t s_supportedTypes[] =
{
{ "MPEG Audio Layer III", exts[0] },
{ "MPEG Audio Layer II", exts[1] },
{ "MPEG Audio Layer I", exts[2] },
{ NULL, NULL }
};
return s_supportedTypes;
}

View File

@ -32,7 +32,7 @@ public:
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag); virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static QStringList supportedTypes(void); static const supportedType_t *supportedTypes(void);
private: private:
const QString m_binary; const QString m_binary;

View File

@ -138,7 +138,18 @@ bool MusepackDecoder::isFormatSupported(const QString &containerType, const QStr
return false; return false;
} }
QStringList MusepackDecoder::supportedTypes(void) const AbstractDecoder::supportedType_t *MusepackDecoder::supportedTypes(void)
{ {
return QStringList() << "Musepack (*.mpc *.mpp *.mp+)"; static const char *exts[] =
{
"mpc", "mpp", "mp+", NULL
};
static const supportedType_t s_supportedTypes[] =
{
{ "Musepack", exts },
{ NULL, NULL }
};
return s_supportedTypes;
} }

View File

@ -32,7 +32,7 @@ public:
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag); virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static QStringList supportedTypes(void); static const supportedType_t *supportedTypes(void);
private: private:
const QString m_binary; const QString m_binary;

View File

@ -146,8 +146,18 @@ bool OpusDecoder::isFormatSupported(const QString &containerType, const QString
return false; return false;
} }
QStringList OpusDecoder::supportedTypes(void) const AbstractDecoder::supportedType_t *OpusDecoder::supportedTypes(void)
{ {
return QStringList() << "Opus Audio Codec (*.opus *.ogg)"; static const char *exts[] =
} {
"opus", "ogg", NULL
};
static const supportedType_t s_supportedTypes[] =
{
{ "Opus Audio Codec", exts },
{ NULL, NULL }
};
return s_supportedTypes;
}

View File

@ -32,7 +32,7 @@ public:
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag); virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static QStringList supportedTypes(void); static const supportedType_t *supportedTypes(void);
static void setDisableResampling(bool disableResample) { m_disableResampling = disableResample; } static void setDisableResampling(bool disableResample) { m_disableResampling = disableResample; }

View File

@ -128,7 +128,18 @@ bool ShortenDecoder::isFormatSupported(const QString &containerType, const QStri
return false; return false;
} }
QStringList ShortenDecoder::supportedTypes(void) const AbstractDecoder::supportedType_t *ShortenDecoder::supportedTypes(void)
{ {
return QStringList() << "Shorten (*.shn)"; static const char *exts[] =
{
"shn", NULL
};
static const supportedType_t s_supportedTypes[] =
{
{ "Shorten", exts },
{ NULL, NULL }
};
return s_supportedTypes;
} }

View File

@ -32,7 +32,7 @@ public:
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag); virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static QStringList supportedTypes(void); static const supportedType_t *supportedTypes(void);
private: private:
const QString m_binary; const QString m_binary;

View File

@ -130,7 +130,18 @@ bool SpeexDecoder::isFormatSupported(const QString &containerType, const QString
return false; return false;
} }
QStringList SpeexDecoder::supportedTypes(void) const AbstractDecoder::supportedType_t *SpeexDecoder::supportedTypes(void)
{ {
return QStringList() << "Speex (*.spx *.ogg)"; static const char *exts[] =
{
"spx", "ogg", NULL
};
static const supportedType_t s_supportedTypes[] =
{
{ "Speex", exts },
{ NULL, NULL }
};
return s_supportedTypes;
} }

View File

@ -32,7 +32,7 @@ public:
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag); virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static QStringList supportedTypes(void); static const supportedType_t *supportedTypes(void);
private: private:
const QString m_binary; const QString m_binary;

View File

@ -133,7 +133,18 @@ bool TTADecoder::isFormatSupported(const QString &containerType, const QString &
return false; return false;
} }
QStringList TTADecoder::supportedTypes(void) const AbstractDecoder::supportedType_t *TTADecoder::supportedTypes(void)
{ {
return QStringList() << "The True Audio (*.tta)"; static const char *exts[] =
{
"tta", NULL
};
static const supportedType_t s_supportedTypes[] =
{
{ "The True Audio", exts },
{ NULL, NULL }
};
return s_supportedTypes;
} }

View File

@ -32,7 +32,7 @@ public:
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag); virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static QStringList supportedTypes(void); static const supportedType_t *supportedTypes(void);
private: private:
const QString m_binary; const QString m_binary;

View File

@ -136,7 +136,18 @@ bool VorbisDecoder::isFormatSupported(const QString &containerType, const QStrin
return false; return false;
} }
QStringList VorbisDecoder::supportedTypes(void) const AbstractDecoder::supportedType_t *VorbisDecoder::supportedTypes(void)
{ {
return QStringList() << "Ogg Vorbis (*.ogg *.ogm)"; static const char *exts[] =
{
"ogg", "ogx", "ogm", NULL
};
static const supportedType_t s_supportedTypes[] =
{
{ "Ogg Vorbis", exts },
{ NULL, NULL }
};
return s_supportedTypes;
} }

View File

@ -32,7 +32,7 @@ public:
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag); virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static QStringList supportedTypes(void); static const supportedType_t *supportedTypes(void);
private: private:
const QString m_binary; const QString m_binary;

View File

@ -136,7 +136,18 @@ bool WMADecoder::isFormatSupported(const QString &containerType, const QString &
return false; return false;
} }
QStringList WMADecoder::supportedTypes(void) const AbstractDecoder::supportedType_t *WMADecoder::supportedTypes(void)
{ {
return QStringList() << "Windows Media Audio (*.wma)"; static const char *exts[] =
{
"wma", "asf", NULL
};
static const supportedType_t s_supportedTypes[] =
{
{ "Windows Media Audio", exts },
{ NULL, NULL }
};
return s_supportedTypes;
} }

View File

@ -34,7 +34,7 @@ public:
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag); virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static QStringList supportedTypes(void); static const supportedType_t *supportedTypes(void);
private: private:
const QString m_binary; const QString m_binary;

View File

@ -137,7 +137,18 @@ bool WavPackDecoder::isFormatSupported(const QString &containerType, const QStri
return false; return false;
} }
QStringList WavPackDecoder::supportedTypes(void) const AbstractDecoder::supportedType_t *WavPackDecoder::supportedTypes(void)
{ {
return QStringList() << "WavPack Hybrid Lossless Audio (*.wv)"; static const char *exts[] =
{
"wv", NULL
};
static const supportedType_t s_supportedTypes[] =
{
{ "WavPack Hybrid Lossless Audio", exts },
{ NULL, NULL }
};
return s_supportedTypes;
} }

View File

@ -32,7 +32,7 @@ public:
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag); virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static QStringList supportedTypes(void); static const supportedType_t *supportedTypes(void);
private: private:
const QString m_binary; const QString m_binary;

View File

@ -68,24 +68,6 @@ bool WaveDecoder::decode(const QString &sourceFile, const QString &outputFile, v
return okay; return okay;
} }
bool WaveDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
{
if(containerType.compare("Wave", Qt::CaseInsensitive) == 0)
{
if(formatType.compare("PCM", Qt::CaseInsensitive) == 0)
{
return true;
}
}
return false;
}
QStringList WaveDecoder::supportedTypes(void)
{
return QStringList() << "Waveform Audio File (*.wav)";
}
bool WaveDecoder::progressHandler(const double &progress, void *const data) bool WaveDecoder::progressHandler(const double &progress, void *const data)
{ {
if(data) if(data)
@ -101,3 +83,32 @@ void WaveDecoder::updateProgress(const double &progress)
{ {
emit statusUpdated(qBound(0, qRound(progress * 100.0), 100)); emit statusUpdated(qBound(0, qRound(progress * 100.0), 100));
} }
bool WaveDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
{
if(containerType.compare("Wave", Qt::CaseInsensitive) == 0)
{
if(formatType.compare("PCM", Qt::CaseInsensitive) == 0)
{
return true;
}
}
return false;
}
const AbstractDecoder::supportedType_t *WaveDecoder::supportedTypes(void)
{
static const char *exts[] =
{
"wav", NULL
};
static const supportedType_t s_supportedTypes[] =
{
{ "Waveform Audio File", exts },
{ NULL, NULL }
};
return s_supportedTypes;
}

View File

@ -33,7 +33,7 @@ public:
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag); virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static QStringList supportedTypes(void); static const supportedType_t *supportedTypes(void);
static bool progressHandler(const double &progress, void *const data); static bool progressHandler(const double &progress, void *const data);
void updateProgress(const double &progress); void updateProgress(const double &progress);

View File

@ -2373,20 +2373,8 @@ void MainWindow::openFolderActionActivated(void)
return; return;
} }
QRegExp regExp("\\((.+)\\)", Qt::CaseInsensitive); QStringList filterItems = DecoderRegistry::getSupportedExts();
const QStringList supportedTypes = DecoderRegistry::getSupportedTypes(); filterItems.prepend("*.*");
QStringList filterItems("*.*");
for(QStringList::ConstIterator iter = supportedTypes.constBegin(); iter != supportedTypes.constEnd(); iter++)
{
if(regExp.lastIndexIn(*iter) >= 0)
{
const QStringList extensions = regExp.cap(1).split(' ', QString::SkipEmptyParts);
for(QStringList::ConstIterator iter2 = extensions.constBegin(); iter2 != extensions.constEnd(); iter2++)
{
if(!filterItems.contains((*iter2), Qt::CaseInsensitive)) filterItems << (*iter2);
}
}
}
bool okay; bool okay;
QString filterStr = QInputDialog::getItem(this, tr("Filter Files"), tr("Select filename filter:"), filterItems, 0, false, &okay).trimmed(); QString filterStr = QInputDialog::getItem(this, tr("Filter Files"), tr("Select filename filter:"), filterItems, 0, false, &okay).trimmed();
@ -2395,10 +2383,10 @@ void MainWindow::openFolderActionActivated(void)
return; return;
} }
QRegExp regExp2("\\*\\.([A-Za-z0-9]+)", Qt::CaseInsensitive); QRegExp regExp("\\*\\.([A-Za-z0-9]+)", Qt::CaseInsensitive);
if(regExp2.lastIndexIn(filterStr) >= 0) if(regExp.lastIndexIn(filterStr) >= 0)
{ {
filterStr = regExp2.cap(1).trimmed(); filterStr = regExp.cap(1).trimmed();
} }
else else
{ {

View File

@ -56,9 +56,6 @@ g_xmlEscapeSequence[] =
{NULL, NULL} {NULL, NULL}
}; };
const char *PlaylistImporter::supportedExtensions = "*.m3u *.m3u8 *.pls *.asx *.wpl";
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Public Functions // Public Functions
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
@ -378,3 +375,13 @@ QString &PlaylistImporter::unescapeXml(QString &str)
return str; return str;
} }
const char *const *const PlaylistImporter::getSupportedExtensions(void)
{
static const char *const s_supportedExtensions[] =
{
"m3u", "m3u8", "pls", "asx", "wpl", NULL
};
return s_supportedExtensions;
}

View File

@ -39,8 +39,8 @@ public:
wplPlaylist wplPlaylist
}; };
static const char *supportedExtensions;
static bool importPlaylist(QStringList &fileList, const QString &playlistFile); static bool importPlaylist(QStringList &fileList, const QString &playlistFile);
static const char *const *const getSupportedExtensions(void);
private: private:
PlaylistImporter(void) {} PlaylistImporter(void) {}

View File

@ -22,6 +22,7 @@
#include "Registry_Decoder.h" #include "Registry_Decoder.h"
//Internal
#include "Decoder_AAC.h" #include "Decoder_AAC.h"
#include "Decoder_AC3.h" #include "Decoder_AC3.h"
#include "Decoder_ADPCM.h" #include "Decoder_ADPCM.h"
@ -42,12 +43,31 @@
#include "PlaylistImporter.h" #include "PlaylistImporter.h"
#include "Model_Settings.h" #include "Model_Settings.h"
//MUtils
#include <MUtils/Exception.h>
//Qt
#include <QString> #include <QString>
#include <QStringList> #include <QStringList>
#include <QMutex>
#include <QRegExp> #include <QRegExp>
#define PROBE_DECODER(DEC) if(DEC::isDecoderAvailable() && DEC::isFormatSupported(containerType, containerProfile, formatType, formatProfile, formatVersion)) { return new DEC(); } #define PROBE_DECODER(DEC) if(DEC::isDecoderAvailable() && DEC::isFormatSupported(containerType, containerProfile, formatType, formatProfile, formatVersion)) { return new DEC(); }
#define GET_FILETYPES(DEC) (DEC::isDecoderAvailable() ? DEC::supportedTypes() : QStringList())
#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
////////////////////////////////////////////////////////////
AbstractDecoder *DecoderRegistry::lookup(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion) AbstractDecoder *DecoderRegistry::lookup(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
{ {
@ -72,54 +92,114 @@ AbstractDecoder *DecoderRegistry::lookup(const QString &containerType, const QSt
return NULL; return NULL;
} }
QStringList DecoderRegistry::getSupportedTypes(void) const QStringList &DecoderRegistry::getSupportedExts(void)
{ {
QStringList types; QMutexLocker locker(&m_lock);
types << GET_FILETYPES(WaveDecoder); if(!m_supportedExts.isNull())
types << GET_FILETYPES(MP3Decoder);
types << GET_FILETYPES(VorbisDecoder);
types << GET_FILETYPES(AACDecoder);
types << GET_FILETYPES(AC3Decoder);
types << GET_FILETYPES(FLACDecoder);
types << GET_FILETYPES(WavPackDecoder);
types << GET_FILETYPES(MusepackDecoder);
types << GET_FILETYPES(ShortenDecoder);
types << GET_FILETYPES(MACDecoder);
types << GET_FILETYPES(TTADecoder);
types << GET_FILETYPES(SpeexDecoder);
types << GET_FILETYPES(ALACDecoder);
types << GET_FILETYPES(WMADecoder);
types << GET_FILETYPES(ADPCMDecoder);
types << GET_FILETYPES(OpusDecoder);
types << GET_FILETYPES(AvisynthDecoder);
QStringList extensions;
extensions << QString(PlaylistImporter::supportedExtensions).split(" ", QString::SkipEmptyParts);
QRegExp regExp("\\((.+)\\)", Qt::CaseInsensitive);
for(int i = 0; i < types.count(); i++)
{ {
if(regExp.lastIndexIn(types.at(i)) >= 0) 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++)
{
for(size_t i = 0; (*iter)[i].name; i++)
{ {
extensions << regExp.cap(1).split(" ", QString::SkipEmptyParts); 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;
}
}
} }
} }
if(!extensions.empty()) m_supportedExts->sort();
return (*m_supportedExts);
}
const QStringList &DecoderRegistry::getSupportedTypes(void)
{
QMutexLocker locker(&m_lock);
if(!m_supportedTypes.isNull())
{ {
extensions.removeDuplicates(); return (*m_supportedTypes);
extensions.sort();
types.prepend(QString("%1 (%2)").arg(tr("All supported types"), extensions.join(" ")));
} }
types << QString("%1 (%2)").arg(tr("Playlists"), PlaylistImporter::supportedExtensions); m_supportedTypes.reset(new QStringList());
types << QString("%1 (*.*)").arg(tr("All files"));
return types; 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(" "));
}
}
}
QStringList playlistExts;
const char *const *const playlistPtr = PlaylistImporter::getSupportedExtensions();
for(size_t i = 0; playlistPtr[i]; i++)
{
playlistExts << QString().sprintf("*.%s", playlistPtr[i]);
}
(*m_supportedTypes) << QString("%1 (%2)").arg(tr("Playlists"), playlistExts.join(" "));
(*m_supportedTypes) << QString("%1 (*.*)").arg(tr("All files"));
m_supportedTypes->prepend(QString("%1 (%2 %3)").arg(tr("All supported types"), getSupportedExts().join(" "), playlistExts.join(" ")));
return (*m_supportedTypes);
} }
void DecoderRegistry::configureDecoders(const SettingsModel *settings) void DecoderRegistry::configureDecoders(const SettingsModel *settings)
{ {
OpusDecoder::setDisableResampling(settings->opusDisableResample()); OpusDecoder::setDisableResampling(settings->opusDisableResample());
} }
////////////////////////////////////////////////////////////
// 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);
}

View File

@ -23,10 +23,11 @@
#pragma once #pragma once
#include <QObject> #include <QObject>
#include "Decoder_AAC.h"
class QString; class QString;
class QStringList; class QStringList;
class AbstractDecoder; class QMutex;
class SettingsModel; class SettingsModel;
class DecoderRegistry : public QObject class DecoderRegistry : public QObject
@ -36,5 +37,16 @@ class DecoderRegistry : public QObject
public: public:
static void configureDecoders(const SettingsModel *settings); static void configureDecoders(const SettingsModel *settings);
static AbstractDecoder *lookup(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion); static AbstractDecoder *lookup(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
static QStringList getSupportedTypes(void); static const QStringList &getSupportedExts(void);
static const QStringList &getSupportedTypes(void);
private:
typedef QList<const AbstractDecoder::supportedType_t*> typeList_t;
static QMutex m_lock;
static QScopedPointer<QStringList> m_supportedExts;
static QScopedPointer<QStringList> m_supportedTypes;
static QScopedPointer<typeList_t> m_availableTypes;
static const typeList_t &getAvailableDecoderTypes(void);
}; };