~vanvugt/ubuntu/oneiric/mediatomb/fix-770964-784431

« back to all changes in this revision

Viewing changes to src/metadata_handler.cc

  • Committer: Bazaar Package Importer
  • Author(s): Andres Mejia
  • Date: 2009-04-22 21:39:19 UTC
  • mto: (4.2.1 sid)
  • mto: This revision was merged to the branch mainline in revision 9.
  • Revision ID: james.westby@ubuntu.com-20090422213919-52m015y6gcpv1m1g
Tags: upstream-0.12.0~svn2018
ImportĀ upstreamĀ versionĀ 0.12.0~svn2018

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
    Copyright (C) 2005 Gena Batyan <bgeradz@mediatomb.cc>,
8
8
                       Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc>
9
9
    
10
 
    Copyright (C) 2006-2008 Gena Batyan <bgeradz@mediatomb.cc>,
 
10
    Copyright (C) 2006-2009 Gena Batyan <bgeradz@mediatomb.cc>,
11
11
                            Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc>,
12
12
                            Leonhard Wimmer <leo@mediatomb.cc>
13
13
    
24
24
    version 2 along with MediaTomb; if not, write to the Free Software
25
25
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
26
26
    
27
 
    $Id: metadata_handler.cc 1723 2008-03-01 22:34:27Z jin_eld $
 
27
    $Id: metadata_handler.cc 2010 2009-01-11 19:10:43Z lww $
28
28
*/
29
29
 
30
30
/// \file metadata_handler.cc
46
46
#ifdef HAVE_TAGLIB
47
47
#include "metadata/taglib_handler.h"
48
48
#else
49
 
#ifdef HAVE_ID3 // we only want ID3 if taglib was not found
 
49
#ifdef HAVE_ID3LIB // we only want ID3 if taglib was not found
50
50
#include "metadata/id3_handler.h"
51
 
#endif // HAVE_ID3
 
51
#endif // HAVE_ID3LIB
52
52
#endif // HAVE_TAGLIB
53
53
 
 
54
#ifdef HAVE_LIBMP4V2
 
55
#include "metadata/libmp4v2_handler.h"
 
56
#endif
54
57
 
55
58
#ifdef HAVE_FFMPEG
56
59
#include "metadata/ffmpeg_handler.h"
57
60
#endif
58
61
 
59
 
#ifdef HAVE_EXTRACTOR
 
62
#ifdef HAVE_LIBEXTRACTOR
60
63
#include "metadata/extractor_handler.h"
61
64
#endif
62
65
 
63
 
#ifdef HAVE_EXIF
 
66
#ifdef HAVE_LIBEXIF
64
67
#include "metadata/libexif_handler.h"
65
68
#endif
66
69
 
 
70
#ifdef HAVE_LIBDVDNAV
 
71
#include "metadata/dvd_handler.h"
 
72
#endif
 
73
 
67
74
using namespace zmm;
68
75
 
69
76
mt_key MT_KEYS[] = {
78
85
    { "M_ALBUMARTURI", "upnp:albumArtURI"},
79
86
    { "M_REGION", "upnp:region"},
80
87
    { "M_AUTHOR", "upnp:author"},
81
 
    { "M_DIRECTOR", "upnp:director"}
82
 
//    , { "M_OPUS", "upnp:opus"}
 
88
    { "M_DIRECTOR", "upnp:director"},
 
89
    { "M_PUBLISHER", "dc:publisher"},
 
90
    { "M_RATING", "upnp:rating"},
 
91
    { "M_ACTOR", "upnp:actor"},
 
92
    { "M_PRODUCER", "upnp:producer"},
83
93
};
84
94
 
85
95
res_key RES_KEYS[] = {
120
130
    Ref<Dictionary> mappings = ConfigManager::getInstance()->getDictionaryOption(CFG_IMPORT_MAPPINGS_MIMETYPE_TO_CONTENTTYPE_LIST);
121
131
 
122
132
    String content_type = mappings->get(mimetype);
123
 
    
 
133
   
124
134
    if ((content_type == CONTENT_TYPE_OGG) && (isTheora(item->getLocation())))
125
135
            item->setFlag(OBJECT_FLAG_OGG_THEORA);
126
136
 
136
146
            break;
137
147
        }
138
148
#else
139
 
#ifdef HAVE_ID3
 
149
#ifdef HAVE_ID3LIB
140
150
        if (content_type == CONTENT_TYPE_MP3)
141
151
        {
142
152
            handler = Ref<MetadataHandler>(new Id3Handler());
143
153
            break;
144
154
        }
145
 
#endif // HAVE_ID3
 
155
#endif // HAVE_ID3LIB
146
156
#endif // HAVE_TAGLIB
147
157
 
148
158
 
157
167
*/
158
168
#endif
159
169
 
160
 
#ifdef HAVE_EXIF
 
170
#ifdef HAVE_LIBEXIF
161
171
        if (content_type == CONTENT_TYPE_JPG)
162
172
        {
163
173
            handler = Ref<MetadataHandler>(new LibExifHandler());
165
175
        }
166
176
#else
167
177
        
168
 
#ifndef HAVE_EXTRACTOR
 
178
#ifndef HAVE_LIBEXTRACTOR
169
179
        if (content_type == CONTENT_TYPE_JPG)
170
180
        {
171
181
            set_jpeg_resolution_resource(item, 0);
172
182
        }
173
 
#endif // EXTRACTOR
 
183
#endif // LIBEXTRACTOR
174
184
        
175
 
#endif // HAVE_EXIF
 
185
#endif // HAVE_LIBEXIF
 
186
 
 
187
#if defined(HAVE_LIBMP4V2)
 
188
#if !defined(HAVE_FFMPEG)
 
189
        if (content_type == CONTENT_TYPE_MP4)
 
190
#else // FFMPEG available 
 
191
        if ((content_type == CONTENT_TYPE_MP4) && 
 
192
            (!item->getMimeType().startsWith(_("video"))))
 
193
#endif // !defined(HAVE_FFMPEG)            
 
194
        {
 
195
            handler = Ref<MetadataHandler>(new LibMP4V2Handler());
 
196
            break;
 
197
        }
 
198
#endif // defined(HAVE_LIBMP4V2)
176
199
 
177
200
#ifdef HAVE_FFMPEG
178
 
        if ((content_type != CONTENT_TYPE_PLAYLIST) &&
179
 
            ((content_type == CONTENT_TYPE_OGG) &&
180
 
             (item->getFlag(OBJECT_FLAG_OGG_THEORA)) ||
181
 
            (item->getMimeType().startsWith(_("video"))) ||
182
 
            (item->getMimeType().startsWith(_("audio")))))
 
201
        if (content_type != CONTENT_TYPE_PLAYLIST &&
 
202
            ((content_type == CONTENT_TYPE_OGG &&
 
203
             item->getFlag(OBJECT_FLAG_OGG_THEORA)) ||
 
204
            item->getMimeType().startsWith(_("video")) ||
 
205
            item->getMimeType().startsWith(_("audio"))))
183
206
        {
184
207
            handler = Ref<MetadataHandler>(new FfmpegHandler());
185
208
            break;
196
219
        }
197
220
 
198
221
#endif // HAVE_FFMPEG
199
 
 
200
 
#ifdef HAVE_EXTRACTOR
 
222
 
 
223
#ifdef HAVE_LIBDVDNAV
 
224
        if (content_type == CONTENT_TYPE_DVD)
 
225
        {
 
226
            handler = Ref<MetadataHandler>(new DVDHandler());
 
227
            break;
 
228
        }
 
229
#endif
 
230
 
 
231
#ifdef HAVE_LIBEXTRACTOR
201
232
        {
202
233
            handler = Ref<MetadataHandler>(new ExtractorHandler());
203
234
            break;
204
235
        }
205
 
#endif // HAVE_EXTRACTOR
 
236
#endif // HAVE_LIBEXTRACTOR
 
237
 
206
238
 
207
239
    }
208
240
    while (false);
226
258
{
227
259
    switch(handlerType)
228
260
    {
229
 
#ifdef HAVE_EXIF
 
261
#ifdef HAVE_LIBEXIF
230
262
        case CH_LIBEXIF:
231
263
            return Ref<MetadataHandler>(new LibExifHandler());
232
264
#endif
233
 
#ifdef HAVE_ID3
 
265
#ifdef HAVE_ID3LIB
234
266
        case CH_ID3:
235
267
            return Ref<MetadataHandler>(new Id3Handler());
236
268
#elif HAVE_TAGLIB
237
269
        case CH_ID3:
238
270
            return Ref<MetadataHandler>(new TagHandler());
239
271
#endif
 
272
#ifdef HAVE_LIBMP4V2
 
273
        case CH_MP4:
 
274
            return Ref<MetadataHandler>(new LibMP4V2Handler());
 
275
#endif
 
276
#if defined(HAVE_FFMPEG) && defined(HAVE_FFMPEGTHUMBNAILER)
 
277
        case CH_FFTH:
 
278
            return Ref<MetadataHandler>(new FfmpegHandler());
 
279
#endif
240
280
        default:
241
281
            throw _Exception(_("unknown content handler ID: ") + handlerType);
242
282
    }
243
283
}
 
284
 
 
285
String MetadataHandler::getMimeType()
 
286
{
 
287
    return _(MIMETYPE_DEFAULT);
 
288
}