diff --git a/src/Makefile.am b/src/Makefile.am index 197ab9d4..b3008350 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -8,10 +8,11 @@ bin_PROGRAMS = icecast noinst_HEADERS = config.h os.h logging.h sighandler.h connection.h global.h\ util.h source.h stats.h refbuf.h client.h format.h format_vorbis.h\ - compat.h + compat.h format_mp3.h icecast_SOURCES = config.c main.c logging.c sighandler.c connection.c global.c\ - util.c source.c stats.c refbuf.c client.c format.c format_vorbis.c - + util.c source.c stats.c refbuf.c client.c format.c format_vorbis.c\ + format_mp3.c + icecast_LDADD = net/libicenet.la thread/libicethread.la httpp/libicehttpp.la\ log/libicelog.la avl/libiceavl.la timing/libicetiming.la diff --git a/src/format.c b/src/format.c index 1fa9afdb..e1c5ddd4 100644 --- a/src/format.c +++ b/src/format.c @@ -14,13 +14,14 @@ #include "format.h" #include "format_vorbis.h" +#include "format_mp3.h" format_type_t format_get_type(char *contenttype) { if(strcmp(contenttype, "application/x-ogg") == 0) return FORMAT_TYPE_VORBIS; -/* else if(strcmp(contenttype, "audio/mpeg") == 0) - return FORMAT_TYPE_MP3; */ + else if(strcmp(contenttype, "audio/mpeg") == 0) + return FORMAT_TYPE_MP3; else return -1; } @@ -34,6 +35,10 @@ format_plugin_t *format_get_plugin(format_type_t type, char *mount) plugin = format_vorbis_get_plugin(); if (plugin) plugin->mount = mount; break; + case FORMAT_TYPE_MP3: + plugin = format_mp3_get_plugin(); + if (plugin) plugin->mount = mount; + break; default: plugin = NULL; break; diff --git a/src/format_mp3.c b/src/format_mp3.c new file mode 100644 index 00000000..d21e3ee2 --- /dev/null +++ b/src/format_mp3.c @@ -0,0 +1,64 @@ +/* format_mp3.c +** +** format plugin for mp3 (no metadata) +** +*/ + +#include +#include +#include + +#include "refbuf.h" + +#include "stats.h" +#include "format.h" + +void format_mp3_free_plugin(format_plugin_t *self); +int format_mp3_get_buffer(format_plugin_t *self, char *data, unsigned long len, refbuf_t **buffer); +refbuf_queue_t *format_mp3_get_predata(format_plugin_t *self); + +format_plugin_t *format_mp3_get_plugin(void) +{ + format_plugin_t *plugin; + + plugin = (format_plugin_t *)malloc(sizeof(format_plugin_t)); + + plugin->type = FORMAT_TYPE_MP3; + plugin->has_predata = 0; + plugin->get_buffer = format_mp3_get_buffer; + plugin->get_predata = format_mp3_get_predata; + plugin->free_plugin = format_mp3_free_plugin; + + plugin->_state = NULL; + + return plugin; +} + +void format_mp3_free_plugin(format_plugin_t *self) +{ + /* free the plugin instance */ + free(self); +} + +int format_mp3_get_buffer(format_plugin_t *self, char *data, unsigned long len, refbuf_t **buffer) +{ + refbuf_t *refbuf; + if(!data) { + *buffer = NULL; + return 0; + } + refbuf = refbuf_new(len); + + memcpy(refbuf->data, data, len); + + *buffer = refbuf; + return 0; +} + +refbuf_queue_t *format_mp3_get_predata(format_plugin_t *self) +{ + return NULL; +} + + + diff --git a/src/format_mp3.h b/src/format_mp3.h new file mode 100644 index 00000000..dda2c9d5 --- /dev/null +++ b/src/format_mp3.h @@ -0,0 +1,11 @@ +/* format_mp3.h +** +** mp3 format plugin +** +*/ +#ifndef __FORMAT_MP3_H__ +#define __FORMAT_MP3_H__ + +format_plugin_t *format_mp3_get_plugin(void); + +#endif /* __FORMAT_MP3_H__ */ diff --git a/src/logging.c b/src/logging.c index ee7a7d94..56ca5d15 100644 --- a/src/logging.c +++ b/src/logging.c @@ -16,8 +16,8 @@ #endif /* the global log descriptors */ -int errorlog; -int accesslog; +int errorlog = 0; +int accesslog = 0; /* ** ADDR USER AUTH DATE REQUEST CODE BYTES REFERER AGENT [TIME] diff --git a/src/main.c b/src/main.c index 489f6d90..53578042 100644 --- a/src/main.c +++ b/src/main.c @@ -172,7 +172,7 @@ static void _server_proc(void) /* chroot the process. Watch out - we need to do this before starting other * threads. Change uid as well, after figuring out uid _first_ */ -static void _ch_root_uid__setup(void) +static void _ch_root_uid_setup(void) { ice_config_t *conf = config_get_config(); #ifdef CHUID @@ -289,7 +289,7 @@ int main(int argc, char **argv) _server_proc_init(); /* Bind socket, before we change userid */ - _ch_root_uid__setup(); /* Change user id and root if requested/possible */ + _ch_root_uid_setup(); /* Change user id and root if requested/possible */ stats_initialize(); /* We have to do this later on because of threading */