aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/Input/modplug/settingsdialog.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/Input/modplug/settingsdialog.h')
0 files changed, 0 insertions, 0 deletions
+0000 committer trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> 2012-07-31 16:20:57 +0000 fixed FSF headers' href='/qmmp/commit/src/plugins/Input/ffmpeg/decoderffmpegfactory.cpp?id=a8bf072ec18a3ecfd6110a1dcfdef7f7e0daf4bd'>a8bf072ec
33b3fdd2f

2d622fd9b
e8d99698c
2d622fd9b
2ee8fd4c1
ea7b63826
ea7b63826
db5f3f8b4
a1f385f90
2e50594a7

e231bb970
e8d99698c
2d622fd9b
2d622fd9b




1dd7b2517






2d622fd9b

aa3f57c02
e8d99698c


013ee07b5
e8d99698c
11b7655bb
2d622fd9b

d489c39c0
2d622fd9b
aa3f57c02
d489c39c0

6a5a5359f
d489c39c0


6a5a5359f
11b7655bb
d489c39c0


11b7655bb
d489c39c0
038c5112b

961485569
013ee07b5
961485569
013ee07b5
961485569
6a5a5359f
961485569
6a5a5359f
961485569


3f6b469fa
11b7655bb
2d622fd9b

75719b8c8
c6d40b3e6
ae75e5707
2b4c4d7eb
2a9593b20
2b4c4d7eb
639c76276
2a9593b20






639c76276
639c76276
2a9593b20


639c76276
2a9593b20













75719b8c8
2b4c4d7eb
aa3f57c02
2b4c4d7eb
855778271
aa3f57c02
855778271
aa3f57c02
d75bbe5a8
aa3f57c02
0a29533bd
3f6b469fa

aa3f57c02


7b1cb9167
aa3f57c02
3f6b469fa
6a5a5359f




ecc490d2a
013ee07b5

11b7655bb
c031570b3
afd64439f
c6d40b3e6
2d622fd9b
e231bb970
2d622fd9b
7683057b2
2d622fd9b

26724c66d
2d622fd9b
e48a196c8
7683057b2
2e50594a7
db5f3f8b4
5c583bfdd

e48a196c8
5c583bfdd
e48a196c8
be4ee17cb
5c583bfdd
26724c66d

db5f3f8b4
6e7107f38
db5f3f8b4

6e7107f38
db5f3f8b4




2ee8fd4c1
db5f3f8b4
f73b33648
db5f3f8b4

6e7107f38
db5f3f8b4
6e7107f38
db5f3f8b4
2ee8fd4c1














26724c66d
e48a196c8
2783c49ba
e48a196c8

2d622fd9b

e231bb970
2d622fd9b
e231bb970
2d622fd9b

e8d99698c




2d622fd9b




a1f385f90



e8d99698c




a1f385f90



7d2e0f57b
2d622fd9b




f0a1d05ed
2d622fd9b



a52daae90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
                                                                            
                                                                            














                                                                            
                                                                            

                                                                             
                
                    
 
           
                                 
                               
                           
                             

 
                                
                           
                           




                                 






                                            

                                                                
                                                 


                                                                       
                        
     
                 

 
                                                        
 
                                               

                    
                                                          


                                                                          
                                       
                     


                                                       
                     
     

                                                                 
                                                                      
                    
                                                                      
                    
                                                                       
                    
                                                                      
                    


                                                                      
                    
                 

 
                                                                
 
                                                                 
                        
                                                                                                   
                                                                       
 






                                             
                                           
                                   


                                                                                   
                                   













                                               
                                 
                                          
                                 
                                                  
                                 
                                                    
                                 
                                                
                                 
                                                               
                                 

                                                            


                                                                                
                                               
     
                                 




                                                                         
                                    

                                  
                               
                             
                      
 
 
                                                                            
 
                                          

 
                                                                                                 
 
                           
                            
 
                                                                              

                                                            
                    
     
                                            
                                     
 

                    
                                                                         
                  

                                                                           
                   




                                                                             
                 
                                                        
                 

                                                                         
                  
                                                             
                  
                                                                   














                                                                                          
     
                                               
                              

                 

 
                                                                                              
 
                                                

 




                                                        




                                                                



                                                        




                                                       



                                                            
                                                                              




                                                                    
                                              



                                                           
                                             
/***************************************************************************
 *   Copyright (C) 2008-2013 by Ilya Kotov                                 *
 *   forkotov02@hotmail.ru                                                 *
 *                                                                         *
 *   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.         *
 ***************************************************************************/

#include <QtGui>
#include <QSettings>

extern "C"{
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libavutil/dict.h>
#include <libavutil/avutil.h>
}

#include "ffmpegmetadatamodel.h"
#include "settingsdialog.h"
#include "decoder_ffmpeg.h"
#include "decoderffmpegfactory.h"


// DecoderFFmpegFactory

DecoderFFmpegFactory::DecoderFFmpegFactory()
{
    avcodec_register_all();
    avformat_network_init();
    av_register_all();
}

bool DecoderFFmpegFactory::supports(const QString &source) const
{
    foreach(QString filter, properties().filters)
    {
        QRegExp regexp(filter, Qt::CaseInsensitive, QRegExp::Wildcard);
        if (regexp.exactMatch(source))
            return true;
    }
    return false;
}

bool DecoderFFmpegFactory::canDecode(QIODevice *i) const
{
    QStringList filters = properties().filters;

    AVProbeData  pd;
    uint8_t buf[PROBE_BUFFER_SIZE + AVPROBE_PADDING_SIZE];
    pd.filename = 0;
    pd.buf_size = i->peek((char*)buf, sizeof(buf) - AVPROBE_PADDING_SIZE);
    pd.buf = buf;
    if(pd.buf_size < PROBE_BUFFER_SIZE)
        return false;
    AVInputFormat *fmt = av_probe_input_format(&pd, 1);
    if(!fmt)
    {
        return false;
    }
    if(filters.contains("*.wma") && !memcmp(fmt->name, "asf", 3))
        return true;
    else if(filters.contains("*.mp3") && !memcmp(fmt->name, "mp3", 3))
        return true;
    else if(filters.contains("*.aac") && !memcmp(fmt->name, "aac", 3))
        return true;
    else if(filters.contains("*.ac3") && !memcmp(fmt->name, "eac3", 4))
        return true;
    else if(filters.contains("*.dts") && !memcmp(fmt->name, "dts", 3))
        return true;
    else if(filters.contains("*.mka") && !memcmp(fmt->name, "mka", 3))
        return true;
    else if(filters.contains("*.vqf") && !memcmp(fmt->name, "vqf", 3))
        return true;
    return false;
}

const DecoderProperties DecoderFFmpegFactory::properties() const
{
    QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
    QStringList filters;
    filters << "*.wma" << "*.ape" << "*.tta" << "*.m4a" << "*.ra" << "*.shn" << "*.vqf" << "*.ac3";
    filters = settings.value("FFMPEG/filters", filters).toStringList();

    //removed unsupported filters
    if(!avcodec_find_decoder(CODEC_ID_WMAV1))
        filters.removeAll("*.wma");
    if(!avcodec_find_decoder(CODEC_ID_APE))
        filters.removeAll("*.ape");
    if(!avcodec_find_decoder(CODEC_ID_TTA))
        filters.removeAll("*.tta");
    if(!avcodec_find_decoder(CODEC_ID_AAC))
        filters.removeAll("*.aac");
    if(!avcodec_find_decoder(CODEC_ID_MP3))
        filters.removeAll("*.mp3");
    if(!avcodec_find_decoder(CODEC_ID_AAC) && !avcodec_find_decoder(CODEC_ID_ALAC))
        filters.removeAll("*.m4a");
    if(!avcodec_find_decoder(CODEC_ID_RA_288))
        filters.removeAll("*.ra");
    if(!avcodec_find_decoder(CODEC_ID_SHORTEN))
        filters.removeAll("*.shn");
    if(!avcodec_find_decoder(CODEC_ID_EAC3))
        filters.removeAll("*.ac3");
    if(!avcodec_find_decoder(CODEC_ID_DTS))
        filters.removeAll("*.dts");
    if(!avcodec_find_decoder(CODEC_ID_TRUEHD))
        filters.removeAll("*.mka");
    if(!avcodec_find_decoder(CODEC_ID_TWINVQ))
        filters.removeAll("*.vqf");


    DecoderProperties properties;
    properties.name = tr("FFmpeg Plugin");
    properties.filters = filters;
    properties.description = tr("FFmpeg Formats");
    if(filters.contains("*.wma"))
        properties.contentTypes << "audio/x-ms-wma";
    if(filters.contains("*.mp3"))
        properties.contentTypes << "audio/mpeg";
    if(filters.contains("*.aac"))
        properties.contentTypes << "audio/aac" << "audio/aacp";
    if(filters.contains("*.shn"))
        properties.contentTypes << "audio/x-ffmpeg-shorten";
    if(filters.contains("*.m4a"))
    {
        properties.contentTypes << "audio/3gpp" << "audio/3gpp2" << "audio/mp4";
        properties.contentTypes << "audio/MP4A-LATM" << "audio/mpeg4-generic";
        properties.contentTypes << "audio/m4a";
    }
    if(filters.contains("*.ac3"))
        properties.contentTypes << "audio/ac3" << "audio/eac3";
    if(filters.contains("*.dts"))
        properties.contentTypes << "audio/dts";
    if(filters.contains("*.mka"))
        properties.contentTypes << "audio/true-hd" << "audio/x-matroska";
    properties.shortName = "ffmpeg";
    properties.hasAbout = true;
    properties.hasSettings = true;
    properties.noInput = false;
    properties.priority = 10;
    return properties;
}

Decoder *DecoderFFmpegFactory::create(const QString &path, QIODevice *input)
{
    return new DecoderFFmpeg(path, input);
}

QList<FileInfo *> DecoderFFmpegFactory::createPlayList(const QString &fileName, bool useMetaData)
{
    QList <FileInfo*> list;
    AVFormatContext *in = 0;

    if (avformat_open_input(&in,fileName.toLocal8Bit().constData(), 0, 0) < 0)
    {
        qDebug("DecoderFFmpegFactory: unable to open file");
        return list;
    }
    FileInfo *info = new FileInfo(fileName);
    avformat_find_stream_info(in, 0);

    if (useMetaData)
    {
        AVDictionaryEntry *album = av_dict_get(in->metadata,"album",0,0);
        if(!album)
            album = av_dict_get(in->metadata,"WM/AlbumTitle",0,0);
        AVDictionaryEntry *artist = av_dict_get(in->metadata,"artist",0,0);
        if(!artist)
            artist = av_dict_get(in->metadata,"author",0,0);
        AVDictionaryEntry *comment = av_dict_get(in->metadata,"comment",0,0);
        AVDictionaryEntry *genre = av_dict_get(in->metadata,"genre",0,0);
        AVDictionaryEntry *title = av_dict_get(in->metadata,"title",0,0);
        AVDictionaryEntry *year = av_dict_get(in->metadata,"WM/Year",0,0);
        if(!year)
            year = av_dict_get(in->metadata,"year",0,0);
        if(!year)
            year = av_dict_get(in->metadata,"date",0,0);
        AVDictionaryEntry *track = av_dict_get(in->metadata,"track",0,0);
        if(!track)
            track = av_dict_get(in->metadata,"WM/Track",0,0);
        if(!track)
            track = av_dict_get(in->metadata,"WM/TrackNumber",0,0);

        if(album)
            info->setMetaData(Qmmp::ALBUM, QString::fromUtf8(album->value).trimmed());
        if(artist)
            info->setMetaData(Qmmp::ARTIST, QString::fromUtf8(artist->value).trimmed());
        if(comment)