aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/General/udisks
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/General/udisks')
0 files changed, 0 insertions, 0 deletions
:57 +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/flac/decoderflacfactory.cpp?id=a8bf072ec18a3ecfd6110a1dcfdef7f7e0daf4bd'>a8bf072ec
33b3fdd2f

6dd05311d


2d622fd9b

a3e55825c
e6cdd7a53
a3e55825c

5638a2a1b



a3e55825c
2d622fd9b
362d4e2b4
2d622fd9b

2d622fd9b

afd64439f
2d622fd9b
0b7152dfe






11b7655bb
2d622fd9b

75719b8c8
c6d40b3e6
75719b8c8
afd64439f
aa3f57c02
afd64439f
2bfa1b1ab
ecc490d2a
aa3f57c02
013ee07b5
11b7655bb
afd64439f
c6d40b3e6
2d622fd9b
362d4e2b4
2d622fd9b
362d4e2b4
2d622fd9b

f91f63b99
2d622fd9b
e6cdd7a53


2e50594a7
e6cdd7a53


47f1be7e4
1bc607cb6

47f1be7e4


1bc607cb6
f91f63b99
1bc607cb6










5638a2a1b
0a4dd6515
5638a2a1b

a116edf23
e6cdd7a53
5638a2a1b


0a4dd6515
5638a2a1b
e6cdd7a53


a116edf23
e6cdd7a53
5638a2a1b


bf0735a1b
5638a2a1b
e6cdd7a53




2e50594a7
e6cdd7a53
2e50594a7

5f4a1ef29
013ee07b5
5f4a1ef29
013ee07b5
5f4a1ef29
013ee07b5
5f4a1ef29
013ee07b5
5f4a1ef29
013ee07b5
5f4a1ef29

2e50594a7
e6cdd7a53
c515397c5
013ee07b5
526e04b8b

2aa6a2255

526e04b8b




c515397c5

e6cdd7a53



c515397c5

e6cdd7a53


b66a8c518

27cf45564
e6cdd7a53

27cf45564
e6cdd7a53

27cf45564
a3e55825c
e6cdd7a53

c515397c5
e6cdd7a53



5f4a1ef29
2d622fd9b

362d4e2b4
2d622fd9b
d460e7652



2d622fd9b








41c8a60a2
2d622fd9b




f0a1d05ed
2d622fd9b



362d4e2b4
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
                                                                            
                                                                            
                                                                            













                                                                            
                                                                            

                                                                             


                      

                           
                            
                               

                               



                                                                                              
                      
                         
                              

                               

                     
                                                          
 






                                                                          
                 

 
                                                              
 
                                 
                                        
                                              
                                              
                                                              
                                  
                                   
                               
                                   
                      
 
 
                                                                      
 
                                    

 
                                                                                                                          
 


                                      
 


                                             
                                           

                                


                                       
                                                      
                                                        










                                                                 
                                                                                              
                                                                 

      
                                                       
     


                                                                                              
                                                                       
      


                                                        
                                                           
     


                                                                                              
                                                                               
      




                                                   
 
                                            

                               
                                      
                                                                                     
                                       
                                                                                      
                                        
                                                                                       
                                      
                                                                                     
                                      
                                                                                     

                                                     
 
                                                     
         
                                                                                                   

                                                                                           

                                                                           




                                                                                           

                                           



                                   

                        


                               

                                                                 
                                                                                        

                                                              
                                                                                        

                                                                
                                                                                        
     

                                      
                 



                           
                

 
                                                                                           
 



                                                            








                                                              
                                                                         




                                                                  
                                              



                                                         
                                         
/***************************************************************************
 *   Copyright (C) 2008-2016 by Ilya Kotov                                 *
 *   forkotov02@ya.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 <QMessageBox>
#include <QTranslator>
#include <QtPlugin>
#include <taglib/tag.h>
#include <taglib/fileref.h>
#include <taglib/flacfile.h>
#include <taglib/oggflacfile.h>
#include <taglib/xiphcomment.h>
#include <taglib/tmap.h>
#if (TAGLIB_MAJOR_VERSION > 1) || ((TAGLIB_MAJOR_VERSION == 1) && (TAGLIB_MINOR_VERSION >= 8))
#include <taglib/tfilestream.h>
#include <taglib/id3v2framefactory.h>
#endif
#include "cueparser.h"
#include "decoder_flac.h"
#include "flacmetadatamodel.h"
#include "decoderflacfactory.h"

// DecoderFLACFactory

bool DecoderFLACFactory::canDecode(QIODevice *input) const
{
    char buf[36];
    if (input->peek(buf, 36) != 36)
        return false;
    if(!memcmp(buf, "fLaC", 4)) //native flac
        return true;
    if(!memcmp(buf, "OggS", 4) && !memcmp(buf + 29, "FLAC", 4)) //ogg flac
        return true;
    return false;
}

const DecoderProperties DecoderFLACFactory::properties() const
{
    DecoderProperties properties;
    properties.name = tr("FLAC Plugin");
    properties.filters << "*.flac" << "*.oga";
    properties.description = tr("FLAC Files");
    properties.contentTypes << "audio/x-flac" << "audio/flac";
    properties.shortName = "flac";
    properties.protocols << "flac";
    properties.hasAbout = true;
    properties.hasSettings = false;
    return properties;
}

Decoder *DecoderFLACFactory::create(const QString &path, QIODevice *i)
{
    return new DecoderFLAC(path, i);
}

QList<FileInfo *> DecoderFLACFactory::createPlayList(const QString &fileName, bool useMetaData, QStringList *ignoredFiles)
{
    QList <FileInfo*> list;
    TagLib::Ogg::XiphComment *tag = 0;
    TagLib::FLAC::Properties *ap = 0;

    TagLib::FLAC::File *flacFile = 0;
    TagLib::Ogg::FLAC::File *oggFlacFile = 0;

    //extract metadata of the one cue track
    if(fileName.contains("://"))
    {
        QString path = fileName;
        path.remove("flac://");
        path.remove(QRegExp("#\\d+$"));
        int track = fileName.section("#", -1).toInt();
        list = createPlayList(path, true, ignoredFiles);
        if (list.isEmpty() || track <= 0 || track > list.count())
        {
            qDeleteAll(list);
            list.clear();
            return list;
        }
        FileInfo *info = list.takeAt(track - 1);
        qDeleteAll(list);
        return QList<FileInfo *>() << info;
    }

#if (TAGLIB_MAJOR_VERSION > 1) || ((TAGLIB_MAJOR_VERSION == 1) && (TAGLIB_MINOR_VERSION >= 8))
    TagLib::FileStream stream(QStringToFileName(fileName), true);
#endif

    if(fileName.endsWith(".flac", Qt::CaseInsensitive))
    {
#if (TAGLIB_MAJOR_VERSION > 1) || ((TAGLIB_MAJOR_VERSION == 1) && (TAGLIB_MINOR_VERSION >= 8))
        flacFile = new TagLib::FLAC::File(&stream, TagLib::ID3v2::FrameFactory::instance());
#else
        flacFile = new TagLib::FLAC::File(QStringToFileName(fileName));
#endif
        tag = useMetaData ? flacFile->xiphComment() : 0;
        ap = flacFile->audioProperties();
    }
    else if(fileName.endsWith(".oga", Qt::CaseInsensitive))
    {
#if (TAGLIB_MAJOR_VERSION > 1) || ((TAGLIB_MAJOR_VERSION == 1) && (TAGLIB_MINOR_VERSION >= 8))
        oggFlacFile = new TagLib::Ogg::FLAC::File(&stream);
#else
        oggFlacFile = new TagLib::Ogg::FLAC::File(QStringToFileName(fileName));
#endif
        tag = useMetaData ? oggFlacFile->tag() : 0;
        ap = oggFlacFile->audioProperties();
    }
    else
        return list;

    FileInfo *info = new FileInfo(fileName);
    if (tag && !tag->isEmpty())
    {
        info->setMetaData(Qmmp::ALBUM,