diff --git a/CREDITS b/CREDITS index f7240674..b2e506c1 100644 --- a/CREDITS +++ b/CREDITS @@ -30,3 +30,7 @@ David Imhoff (6219@thrijswijk.nl) James Turner (jmturner@users.sourceforge.net) * Fixes for OSX 10.2 * configure.in suggestions + +Hiren Joshi (hirenj@mooh.org) + * Dynamic art code (!!) + diff --git a/ChangeLog b/ChangeLog index d8706a9c..cedd83ee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,14 @@ -2004-04-04 Ron Pedde +2004-04-13 Ron Pedde + + * src/dynamic-art.c: merged in patch from Hiren Joshi + (hirenj@mooh.org) to allow .jpg files to be transparently + streamed into the id3 tag. ubercool. + +2004-04-11 Ron Pedde + + * src/err.c: add in support for a logfile. Feature request #916153 + +2004-04-04 Ron Pedde * src/mp3-scanner.c: add support for MPEG v 2 and 2.5. Feature request #916151 diff --git a/contrib/mt-daapd.conf b/contrib/mt-daapd.conf index 8cba0cfb..4d6b2e02 100644 --- a/contrib/mt-daapd.conf +++ b/contrib/mt-daapd.conf @@ -119,5 +119,21 @@ extensions .mp3,.m4a,.m4p #logfile /var/log/mt-daapd.log +# +# art_filename (optional) +# +# There is (experimental!) support thanks to Hiren Joshi +# (hirenj@mooh.org) for dynamically adding art to the id3v2 +# header as it is streamed (!!). If you were using a music system +# like zina or andromeda, for example, with cover art called +# "_folderOpenImage.jpg", you could use the parameter +# art_file _folderOpenImage.jpg and if the file _folderOpenImage.jpg +# was located in the same folder as the .mp3 file, it would appear +# in iTunes. Cool, eh? +# + +#art_filename _folderOpenImage.jpg + + diff --git a/src/Makefile.am b/src/Makefile.am index 60855374..646bf5f0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -23,7 +23,7 @@ mt_daapd_SOURCES = main.c daapd.h rend.h uici.c uici.h webserver.c \ daap-proto.c daap-proto.h daap.c daap.h db-gdbm.c db-memory.h \ mp3-scanner.h mp3-scanner.c playlist.c playlist.h rend-unix.c \ rend-unix.h lexer.l parser.y strcasestr.c strcasestr.h strsep.c \ - redblack.c redblack.h \ + redblack.c redblack.h dynamic-art.c dynamic-art.h \ $(PRENDSRC) $(ORENDSRC) $(HRENDSRC) EXTRA_DIST = mDNS.c mDNSClientAPI.h mDNSDebug.h mDNSPosix.c \ diff --git a/src/configfile.c b/src/configfile.c index 4fba4785..fc7535ff 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -109,6 +109,7 @@ CONFIGELEMENT config_elements[] = { { 0,0,0,CONFIG_TYPE_SPECIAL,"readonly",(void*)NULL,config_emit_readonly }, { 0,0,0,CONFIG_TYPE_SPECIAL,"version",(void*)NULL,config_emit_version }, { 0,0,0,CONFIG_TYPE_SPECIAL,"system",(void*)NULL,config_emit_system }, + { 1,0,0,CONFIG_TYPE_STRING,"art_filename",(void*)&config.artfilename,config_emit_string }, { 0,0,0,CONFIG_TYPE_SPECIAL,"flags",(void*)NULL,config_emit_flags }, { -1,1,0,CONFIG_TYPE_STRING,NULL,NULL,NULL } }; @@ -164,6 +165,7 @@ int config_read(char *file) { config.mp3dir=NULL; config.playlist=NULL; config.runas=NULL; + config.artfilename=NULL; config.logfile=NULL; config.extensions=".mp3"; diff --git a/src/daapd.h b/src/daapd.h index 04aa3d66..72ba086d 100644 --- a/src/daapd.h +++ b/src/daapd.h @@ -44,6 +44,7 @@ typedef struct tag_config { char *runas; char *dbdir; char *extensions; + char *artfilename; char *logfile; STATS stats; } CONFIG; diff --git a/src/main.c b/src/main.c index 23e4af71..eb4796a7 100644 --- a/src/main.c +++ b/src/main.c @@ -49,6 +49,7 @@ #include "rend.h" #include "webserver.h" #include "playlist.h" +#include "dynamic-art.h" #define DEFAULT_CONFIGFILE "/etc/mt-daapd.conf" @@ -105,6 +106,8 @@ void daap_handler(WS_CONNINFO *pwsc) { int file_fd; int session_id=0; + int img_fd; + off_t offset=0; off_t file_len; @@ -278,13 +281,21 @@ void daap_handler(WS_CONNINFO *pwsc) { config_set_status(pwsc,session_id,"Streaming file '%s'",pmp3->fname); DPRINTF(ERR_LOG,"Session %d: Streaming file '%s' to %s\n",session_id, pmp3->fname, pwsc->hostname); + + if(!offset) + config.stats.songs_served++; /* FIXME: remove stat races */ - config.stats.songs_served++; /* FIXME: remove stat races */ - - if(offset) { - DPRINTF(ERR_INFO,"Seeking to offset %d\n",offset); - lseek(file_fd,offset,SEEK_SET); + if((config.artfilename) && (img_fd=da_get_image_fd(pmp3->path)) && (!offset)) { + DPRINTF(ERR_INFO,"Dynamically attaching artwork to %s\n",pmp3->fname); + da_attach_image(img_fd, pwsc->fd, file_fd, offset); + r_close(img_fd); + } else { + if(offset) { + DPRINTF(ERR_INFO,"Seeking to offset %d\n",offset); + lseek(file_fd,offset,SEEK_SET); + } } + if(copyfile(file_fd,pwsc->fd)) { DPRINTF(ERR_INFO,"Error copying file to remote... %s\n", strerror(errno));