aboutsummaryrefslogtreecommitdiff
path: root/src/qmmpui/jumptotrackdialog.cpp
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2016-04-06 05:49:52 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2016-04-06 05:49:52 +0000
commite2ea8990c3dc6b3c7f69b3be59ad54b4537df5ba (patch)
tree6bc5376204dd5f62684d583cda169d704c3ab303 /src/qmmpui/jumptotrackdialog.cpp
parentaec123d86747244df9c6733af60910fd1235a55d (diff)
downloadqmmp-e2ea8990c3dc6b3c7f69b3be59ad54b4537df5ba.tar.gz
qmmp-e2ea8990c3dc6b3c7f69b3be59ad54b4537df5ba.tar.bz2
qmmp-e2ea8990c3dc6b3c7f69b3be59ad54b4537df5ba.zip
fixed regression
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@6234 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/qmmpui/jumptotrackdialog.cpp')
0 files changed, 0 insertions, 0 deletions
00 ported some code to QRegularExpression' href='/qmmp/commit/src/plugins/Input/ffmpeg/ffmpegmetadatamodel.cpp?id=b55c45843527655a14af6ab1f67164244aa6b411'>b55c45843
fe35d45c8
07aabef41



fe35d45c8
23f851634
fe35d45c8
e231bb970
ea7b63826
fe35d45c8
2d622fd9b
07aabef41
fe35d45c8
aab3498cd


fe35d45c8

aab3498cd
707762b07

fe35d45c8

707762b07
aab3498cd
3f525068c
fe35d45c8
3f525068c
fe35d45c8
3f525068c
2d622fd9b
2d622fd9b
07aabef41



80fc271b9
07aabef41
85472238d
07aabef41

07aabef41
68662a3db
07aabef41










23f851634
fe35d45c8













07aabef41


fe35d45c8










07aabef41



23f851634
fe35d45c8

























































































































































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
257
258
259
260
261
262
263
264
                                                                            
                                                                            
                                                                            













                                                                            
                                                                            
                                                                             
 
                             
                  



                                 
                           
                   
                                 
                                
 
                                                                                                      
 
                                  
                  


                                    

                                                    
     

                                      

                                                    
     
 
               
                                                                                    
     
                                                                                         
      
               
 



                                               
 
                                       
 

                                                       
                                           
 










                                                                                        
     













                                                                               


                                           










                                                   



                                          
 

























































































































































                                                                                   
/***************************************************************************
 *   Copyright (C) 2009-2021 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 <QRegularExpression>
#include <QtDebug>
extern "C" {
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
}
#include <taglib/apefile.h>
#include <stdint.h>
#include <qmmp/metadatamanager.h>
#include "ffmpegmetadatamodel.h"

FFmpegMetaDataModel::FFmpegMetaDataModel(const QString &path, bool readOnly) : MetaDataModel(readOnly)
{
    AVFormatContext *in = nullptr;
    m_path = path;

    if(path.startsWith("ffmpeg://"))
    {
        m_path.remove("ffmpeg://");
        m_path.remove(QRegularExpression("#\\d+$"));
    }
    else if(path.startsWith("m4b://"))
    {
        m_path.remove("m4b://");
        m_path.remove(QRegularExpression("#\\d+$"));
    }

#ifdef Q_OS_WIN
    if (avformat_open_input(&in, m_path.toUtf8().constData(), nullptr, nullptr) < 0)
#else
    if (avformat_open_input(&in, m_path.toLocal8Bit().constData(), nullptr, nullptr) < 0)
#endif
        return;

    if(in)
    {
        avformat_find_stream_info(in, nullptr);
        av_read_play(in);

        AVCodecParameters *c = nullptr;

        for (uint idx = 0; idx < in->nb_streams; idx++)
        {
            c = in->streams[idx]->codecpar;

            if (c->codec_type == AVMEDIA_TYPE_VIDEO && c->codec_id == AV_CODEC_ID_MJPEG)
                break;
        }
        if (c)
        {
            AVPacket pkt;
            av_read_frame(in, &pkt);
            m_pixmap.loadFromData(QByteArray((const char*)pkt.data, pkt.size));
        }

        avformat_close_input(&in);
    }

    if(!readOnly && m_path.endsWith(".ape", Qt::CaseInsensitive))
    {
        m_stream = new TagLib::FileStream(QStringToFileName(m_path), readOnly);
        m_file = new TagLib::APE::File(m_stream);
        m_tag = m_file->APETag();
        m_tags << new ApeTagModel(m_file);
        setReadOnly(m_file->readOnly());
        setDialogHints(MetaDataModel::IsCueEditable);
    }
    else
    {
        setReadOnly(true);
    }
}

FFmpegMetaDataModel::~FFmpegMetaDataModel()
{
    qDeleteAll(m_tags);
    m_tags.clear();
    delete m_file;
    delete m_stream;
}

QList<TagModel *> FFmpegMetaDataModel::tags() const
{
    return m_tags;
}

QPixmap FFmpegMetaDataModel::cover() const
{
    return m_pixmap;
}

QString FFmpegMetaDataModel::coverPath() const
{
    return MetaDataManager::instance()->findCoverFile(m_path);
}

QString FFmpegMetaDataModel::cue() const
{
    if(m_tag && m_tag->itemListMap().contains("CUESHEET"))
        return TStringToQString(m_tag->itemListMap()["CUESHEET"].toString());

    return QString();
}

void FFmpegMetaDataModel::setCue(const QString &content)
{
    if(!m_tag)
        m_tag = m_file->APETag(true);

    m_tag->addValue("CUESHEET", QStringToTString(content));
    m_file->save();
    m_tag = m_file->APETag();
}

void FFmpegMetaDataModel::removeCue()
{
    if(m_tag)
    {
        m_tag->removeItem("CUESHEET");
        m_file->save();
        m_tag = m_file->APETag();
    }
}

ApeTagModel::ApeTagModel(TagLib::APE::File *file) : m_file(file)
{}

ApeTagModel::~ApeTagModel()
{}

QString ApeTagModel::name() const
{
    return QLatin1String("APE");
}

QList<Qmmp::MetaData> ApeTagModel::keys() const
{
    QList<Qmmp::MetaData> list = TagModel::keys();
    list.removeAll(Qmmp::DISCNUMBER);
    return list;
}

QString ApeTagModel::value(Qmmp::MetaData key) const
{
    TagLib::APE::Tag *tag = m_file->APETag(false);
    if(!tag)
        return QString();

    switch(key)
    {
    case Qmmp::TITLE:
        return TStringToQString(tag->title());
    case Qmmp::ARTIST:
        return TStringToQString(tag->artist());
    case Qmmp::ALBUMARTIST: