diff options
author | phintuka <phintuka> | 2010-02-23 18:30:07 +0000 |
---|---|---|
committer | phintuka <phintuka> | 2010-02-23 18:30:07 +0000 |
commit | f1708770ceb1eba6cbdd68c251dabeac2fc543e7 (patch) | |
tree | 6af9d219a5994fca847d22e324f0a433ae09badd | |
parent | 9e9176af02487b51278f020cad4182759dab155d (diff) | |
download | xineliboutput-f1708770ceb1eba6cbdd68c251dabeac2fc543e7.tar.gz xineliboutput-f1708770ceb1eba6cbdd68c251dabeac2fc543e7.tar.bz2 |
Added support for libextractor 0.6.0 API (Thanks to Martin Knoll)
-rw-r--r-- | tools/playlist.c | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/tools/playlist.c b/tools/playlist.c index 01e032f1..a026601e 100644 --- a/tools/playlist.c +++ b/tools/playlist.c @@ -4,7 +4,7 @@ * See the main source file 'xineliboutput.c' for copyright information and * how to reach the author. * - * $Id: playlist.c,v 1.25 2010-02-03 11:23:11 phintuka Exp $ + * $Id: playlist.c,v 1.26 2010-02-23 18:30:07 phintuka Exp $ * */ @@ -132,6 +132,38 @@ static const char *shell_escape(char *buf, int buflen, const cString& src, char } #endif +#if defined(HAVE_LIBEXTRACTOR) && EXTRACTOR_VERSION >= 0x00060000 +static int extractor_callback_id3(void *Item, + const char *plugin_name, + enum EXTRACTOR_MetaType type, + enum EXTRACTOR_MetaFormat format, + const char *data_mime_type, + const char *data, + size_t data_len) +{ + if (format == EXTRACTOR_METAFORMAT_UTF8) { + switch (type) { + case EXTRACTOR_METATYPE_TITLE: + ((cPlaylistItem*)Item)->Title = strdup(data); + break; + case EXTRACTOR_METATYPE_ARTIST: + ((cPlaylistItem*)Item)->Artist = strdup(data); + break; + case EXTRACTOR_METATYPE_ALBUM: + ((cPlaylistItem*)Item)->Album = strdup(data); + break; + case EXTRACTOR_METATYPE_TRACK_NUMBER: + ((cPlaylistItem*)Item)->Tracknumber = cString::sprintf("%s%s", strlen(data) == 1 ? "0" : "", data); + break; + default: + break; + } + } + return 0; +} +#endif // defined(HAVE_LIBEXTRACTOR) && EXTRACTOR_VERSION >= 0x00060000 + + class cID3Scanner : public cThread { public: @@ -169,6 +201,12 @@ class cID3Scanner : public cThread if(xc.IsAudioFile(Item->Filename)) { LOGDBG("Scanning metainfo for file %s", *Item->Filename); #ifdef HAVE_LIBEXTRACTOR +# if EXTRACTOR_VERSION >= 0x00060000 + EXTRACTOR_PluginList * plugins; + plugins = EXTRACTOR_plugin_add_defaults(EXTRACTOR_OPTION_DEFAULT_POLICY); + EXTRACTOR_extract(plugins, *Item->Filename, NULL, 0, (EXTRACTOR_MetaDataProcessor)&extractor_callback_id3, Item); + EXTRACTOR_plugin_remove_all(plugins); /* unload plugins */ +# else // EXTRACTOR_VERSION >= 0x00060000 EXTRACTOR_ExtractorList * plugins; EXTRACTOR_KeywordList * md_list; plugins = EXTRACTOR_loadDefaultLibraries(); @@ -189,7 +227,8 @@ class cID3Scanner : public cThread } EXTRACTOR_freeKeywords(md_list); EXTRACTOR_removeAll(plugins); /* unload plugins */ -#else +# endif // EXTRACTOR_VERSION >= 0x00060000 +#else // HAVE_LIBEXTRACTOR char buf[4096]; cString Cmd = ""; if(!strcasecmp((Item->Filename) + strlen(Item->Filename) - 5, ".flac")) @@ -224,7 +263,7 @@ class cID3Scanner : public cThread Item->Tracknumber = cString::sprintf("%s%s", strlen(pt) == 13 ? "0" : "", (pt+12)); } } -#endif +#endif // HAVE_LIBEXTRACTOR } } LOGDBG("ID3Scanner Done."); |