From 16da97e4c80b375f6976690e0a04102eff0a6bbd Mon Sep 17 00:00:00 2001 From: Warren Dukes Date: Tue, 1 Jun 2004 12:50:15 +0000 Subject: parsing mp3 id3v2 tags on the fly for streams git-svn-id: https://svn.musicpd.org/mpd/trunk@1281 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- src/tag.c | 49 ++++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 23 deletions(-) (limited to 'src/tag.c') diff --git a/src/tag.c b/src/tag.c index ae9d41040..50c1dcd86 100644 --- a/src/tag.c +++ b/src/tag.c @@ -37,13 +37,6 @@ #include #include #endif -#ifdef HAVE_ID3TAG -#ifdef USE_MPD_ID3TAG -#include "libid3tag/id3tag.h" -#else -#include -#endif -#endif void printMpdTag(FILE * fp, MpdTag * tag) { if(tag->artist) myfprintf(fp,"Artist: %s\n",tag->artist); @@ -95,25 +88,11 @@ char * getID3Info(struct id3_tag * tag, char * id) { } #endif -MpdTag * id3Dup(char * file) { - MpdTag * ret = NULL; #ifdef HAVE_ID3TAG - struct id3_file * id3_file; - struct id3_tag * tag; +MpdTag * parseId3Tag(struct id3_tag * tag) { + MpdTag * ret = NULL; char * str; - id3_file = id3_file_open(file, ID3_FILE_MODE_READONLY); - - if(!id3_file) { - return NULL; - } - - tag = id3_file_tag(id3_file); - if(!tag) { - id3_file_close(id3_file); - return NULL; - } - str = getID3Info(tag,ID3_FRAME_ARTIST); if(str) { if(!ret) ret = newMpdTag(); @@ -142,6 +121,30 @@ MpdTag * id3Dup(char * file) { ret->track = str; } + return ret; +} +#endif + +MpdTag * id3Dup(char * file) { + MpdTag * ret = NULL; +#ifdef HAVE_ID3TAG + struct id3_file * id3_file; + struct id3_tag * tag; + + id3_file = id3_file_open(file, ID3_FILE_MODE_READONLY); + + if(!id3_file) { + return NULL; + } + + tag = id3_file_tag(id3_file); + if(!tag) { + id3_file_close(id3_file); + return NULL; + } + + ret = parseId3Tag(tag); + id3_file_close(id3_file); #endif -- cgit v1.2.3