1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
3 // Copyright (C) 2004-2013 LoRd_MuldeR <MuldeR2@GMX.de>
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License along
16 // with this program; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 // http://www.gnu.org/licenses/gpl-2.0.txt
20 ///////////////////////////////////////////////////////////////////////////////
22 #include "Registry_Decoder.h"
24 #include "Decoder_AAC.h"
25 #include "Decoder_AC3.h"
26 #include "Decoder_ADPCM.h"
27 #include "Decoder_ALAC.h"
28 #include "Decoder_Avisynth.h"
29 #include "Decoder_FLAC.h"
30 #include "Decoder_MAC.h"
31 #include "Decoder_MP3.h"
32 #include "Decoder_Musepack.h"
33 #include "Decoder_Shorten.h"
34 #include "Decoder_Speex.h"
35 #include "Decoder_TTA.h"
36 #include "Decoder_Vorbis.h"
37 #include "Decoder_Wave.h"
38 #include "Decoder_WavPack.h"
39 #include "Decoder_Opus.h"
40 #include "Decoder_WMA.h"
41 #include "PlaylistImporter.h"
42 #include "Model_Settings.h"
45 #include <QStringList>
48 #define PROBE_DECODER(DEC) if(DEC::isDecoderAvailable() && DEC::isFormatSupported(containerType, containerProfile, formatType, formatProfile, formatVersion)) { return new DEC(); }
49 #define GET_FILETYPES(DEC) (DEC::isDecoderAvailable() ? DEC::supportedTypes() : QStringList())
51 AbstractDecoder
*DecoderRegistry::lookup(const QString
&containerType
, const QString
&containerProfile
, const QString
&formatType
, const QString
&formatProfile
, const QString
&formatVersion
)
53 PROBE_DECODER(MP3Decoder
);
54 PROBE_DECODER(VorbisDecoder
);
55 PROBE_DECODER(AACDecoder
);
56 PROBE_DECODER(AC3Decoder
);
57 PROBE_DECODER(FLACDecoder
);
58 PROBE_DECODER(WavPackDecoder
);
59 PROBE_DECODER(MusepackDecoder
);
60 PROBE_DECODER(ShortenDecoder
);
61 PROBE_DECODER(MACDecoder
);
62 PROBE_DECODER(TTADecoder
);
63 PROBE_DECODER(SpeexDecoder
);
64 PROBE_DECODER(ALACDecoder
);
65 PROBE_DECODER(WMADecoder
);
66 PROBE_DECODER(ADPCMDecoder
);
67 PROBE_DECODER(WaveDecoder
);
68 PROBE_DECODER(OpusDecoder
);
69 PROBE_DECODER(AvisynthDecoder
);
74 QStringList
DecoderRegistry::getSupportedTypes(void)
78 types
<< GET_FILETYPES(WaveDecoder
);
79 types
<< GET_FILETYPES(MP3Decoder
);
80 types
<< GET_FILETYPES(VorbisDecoder
);
81 types
<< GET_FILETYPES(AACDecoder
);
82 types
<< GET_FILETYPES(AC3Decoder
);
83 types
<< GET_FILETYPES(FLACDecoder
);
84 types
<< GET_FILETYPES(WavPackDecoder
);
85 types
<< GET_FILETYPES(MusepackDecoder
);
86 types
<< GET_FILETYPES(ShortenDecoder
);
87 types
<< GET_FILETYPES(MACDecoder
);
88 types
<< GET_FILETYPES(TTADecoder
);
89 types
<< GET_FILETYPES(SpeexDecoder
);
90 types
<< GET_FILETYPES(ALACDecoder
);
91 types
<< GET_FILETYPES(WMADecoder
);
92 types
<< GET_FILETYPES(ADPCMDecoder
);
93 types
<< GET_FILETYPES(OpusDecoder
);
94 types
<< GET_FILETYPES(AvisynthDecoder
);
96 QStringList extensions
;
97 extensions
<< QString(PlaylistImporter::supportedExtensions
).split(" ", QString::SkipEmptyParts
);
98 QRegExp
regExp("\\((.+)\\)", Qt::CaseInsensitive
);
100 for(int i
= 0; i
< types
.count(); i
++)
102 if(regExp
.lastIndexIn(types
.at(i
)) >= 0)
104 extensions
<< regExp
.cap(1).split(" ", QString::SkipEmptyParts
);
108 if(!extensions
.empty())
110 extensions
.removeDuplicates();
112 types
.prepend(QString("%1 (%2)").arg(tr("All supported types"), extensions
.join(" ")));
115 types
<< QString("%1 (%2)").arg(tr("Playlists"), PlaylistImporter::supportedExtensions
);
116 types
<< QString("%1 (*.*)").arg(tr("All files"));
121 void DecoderRegistry::configureDecoders(const SettingsModel
*settings
)
123 OpusDecoder::setDisableResampling(settings
->opusDisableResample());