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
|
/***************************************************************************
copyright : (C) 2005, 2006 by Martin Aumueller
email : aumuell@reserv.at
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library 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 *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
* MA 02110-1301 USA *
***************************************************************************/
#include <config.h>
// #include <debug.h>
#include <tqfile.h>
#include <kmimetype.h>
#include <taglib/fileref.h>
#include <taglib/tfile.h>
#ifdef HAVE_MP4V2
#include "mp4/taglib_mp4filetyperesolver.h"
#include "mp4/mp4file.h"
#else
#include "m4a/taglib_mp4filetyperesolver.h"
#include "m4a/mp4file.h"
#endif
#include "trueaudio/taglib_trueaudiofiletyperesolver.h"
#include "trueaudio/ttafile.h"
#include "wavpack/taglib_wavpackfiletyperesolver.h"
#include "wavpack/wvfile.h"
#include "speex/taglib_speexfiletyperesolver.h"
#include "speex/speexfile.h"
#include "asf/taglib_asffiletyperesolver.h"
#include "asf/asffile.h"
#include "rmff/taglib_realmediafiletyperesolver.h"
#include "rmff/taglib_realmediafile.h"
#include "audible/taglib_audiblefiletyperesolver.h"
#include "audible/taglib_audiblefile.h"
#include "wav/wavfiletyperesolver.h"
#include "wav/wavfile.h"
#include "aac/aacfiletyperesolver.h"
#include "ape/taglib_monkeysaudiofiletyperesolver.h"
#include "optimfrog/taglib_optimfrogfiletyperesolver.h"
#include <taglib/mpegfile.h>
#include <taglib/oggfile.h>
#include <taglib/oggflacfile.h>
#include <taglib/vorbisfile.h>
#include <taglib/flacfile.h>
#include <taglib/mpcfile.h>
class MimeTypeFileTypeResolver : public TagLib::FileRef::FileTypeResolver
{
TagLib::File *createFile(const char *fileName,
bool readAudioProperties,
TagLib::AudioProperties::ReadStyle audioPropertiesStyle) const;
};
TagLib::File *MimeTypeFileTypeResolver::createFile(const char *fileName,
bool readProperties,
TagLib::AudioProperties::ReadStyle propertiesStyle) const
{
TQString fn = TQFile::decodeName( fileName );
int accuracy = 0;
KMimeType::Ptr mimetype = KMimeType::findByFileContent( fn, &accuracy );
if( accuracy <= 0 )
mimetype = KMimeType::findByPath( fn );
if( mimetype->is( "audio/aac" )
|| mimetype->is( "audio/mpeg" )
|| mimetype->is( "audio/mpegurl" )
|| mimetype->is( "audio/x-mpegurl" )
|| mimetype->is( "audio/x-mp3" ))
{
return new TagLib::MPEG::File(fileName, readProperties, propertiesStyle);
}
else if( mimetype->is( "audio/mp4" ) || mimetype->is( "video/mp4" ) )
{
return new TagLib::MP4::File(fileName, readProperties, propertiesStyle);
}
else if( mimetype->is( "audio/x-ms-wma" )
|| mimetype->is( "video/x-ms-asf" )
|| mimetype->is( "video/x-msvideo" )
|| mimetype->is( "video/x-ms-wmv" ) )
{
return new TagLib::ASF::File(fileName, readProperties, propertiesStyle);
}
else if( mimetype->is( "audio/vnd.rn-realaudio" )
|| mimetype->is( "audio/x-pn-realaudio" )
|| mimetype->is( "audio/x-pn-realaudioplugin" )
|| mimetype->is( "audio/vnd.rn-realvideo" ) )
{
return new TagLib::RealMedia::File(fileName, readProperties, propertiesStyle);
}
else if( mimetype->is( "audio/vorbis" ) )
{
return new TagLib::Ogg::Vorbis::File(fileName, readProperties, propertiesStyle);
}
else if( mimetype->is( "audio/x-oggflac" ) )
{
return new TagLib::Ogg::FLAC::File(fileName, readProperties, propertiesStyle);
}
else if( mimetype->is( "audio/x-flac" ) )
{
return new TagLib::FLAC::File(fileName, readProperties, propertiesStyle);
}
else if( mimetype->is( "audio/x-musepack" ) )
{
return new TagLib::MPC::File(fileName, readProperties, propertiesStyle);
}
else if( mimetype->is( "audio/x-musepack" )
|| mimetype->is( "audio/x-ape" )
|| mimetype->is( "application/x-ofr" ) )
{
return new TagLib::MPC::File(fileName, readProperties, propertiesStyle);
}
// debug() << "kmimetype filetype guessing failed for" << fileName << endl;
return 0;
}
void registerTaglibPlugins()
{
//TagLib::FileRef::addFileTypeResolver(new MimeTypeFileTypeResolver);
TagLib::FileRef::addFileTypeResolver(new MP4FileTypeResolver);
TagLib::FileRef::addFileTypeResolver(new ASFFileTypeResolver);
TagLib::FileRef::addFileTypeResolver(new RealMediaFileTypeResolver);
TagLib::FileRef::addFileTypeResolver(new AudibleFileTypeResolver);
TagLib::FileRef::addFileTypeResolver(new AACFileTypeResolver);
TagLib::FileRef::addFileTypeResolver(new WavPackFileTypeResolver);
TagLib::FileRef::addFileTypeResolver(new SpeexFileTypeResolver);
TagLib::FileRef::addFileTypeResolver(new TTAFileTypeResolver);
TagLib::FileRef::addFileTypeResolver(new WavFileTypeResolver);
TagLib::FileRef::addFileTypeResolver(new MonkeysAudioFileTypeResolver);
TagLib::FileRef::addFileTypeResolver(new OptimFrogFileTypeResolver);
}
|