1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-11-03 04:17:17 -05:00

MP3 support for icecast2.

- no title/metadata support
- requires modifications to source clients.

svn path=/trunk/icecast/; revision=3713
This commit is contained in:
Michael Smith 2002-07-23 15:15:11 +00:00
parent 0d5bd4b2b0
commit 638ccabd55
6 changed files with 90 additions and 9 deletions

View File

@ -8,9 +8,10 @@ bin_PROGRAMS = icecast
noinst_HEADERS = config.h os.h logging.h sighandler.h connection.h global.h\ 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\ 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\ 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\ icecast_LDADD = net/libicenet.la thread/libicethread.la httpp/libicehttpp.la\
log/libicelog.la avl/libiceavl.la timing/libicetiming.la log/libicelog.la avl/libiceavl.la timing/libicetiming.la

View File

@ -14,13 +14,14 @@
#include "format.h" #include "format.h"
#include "format_vorbis.h" #include "format_vorbis.h"
#include "format_mp3.h"
format_type_t format_get_type(char *contenttype) format_type_t format_get_type(char *contenttype)
{ {
if(strcmp(contenttype, "application/x-ogg") == 0) if(strcmp(contenttype, "application/x-ogg") == 0)
return FORMAT_TYPE_VORBIS; return FORMAT_TYPE_VORBIS;
/* else if(strcmp(contenttype, "audio/mpeg") == 0) else if(strcmp(contenttype, "audio/mpeg") == 0)
return FORMAT_TYPE_MP3; */ return FORMAT_TYPE_MP3;
else else
return -1; return -1;
} }
@ -34,6 +35,10 @@ format_plugin_t *format_get_plugin(format_type_t type, char *mount)
plugin = format_vorbis_get_plugin(); plugin = format_vorbis_get_plugin();
if (plugin) plugin->mount = mount; if (plugin) plugin->mount = mount;
break; break;
case FORMAT_TYPE_MP3:
plugin = format_mp3_get_plugin();
if (plugin) plugin->mount = mount;
break;
default: default:
plugin = NULL; plugin = NULL;
break; break;

64
src/format_mp3.c Normal file
View File

@ -0,0 +1,64 @@
/* format_mp3.c
**
** format plugin for mp3 (no metadata)
**
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#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;
}

11
src/format_mp3.h Normal file
View File

@ -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__ */

View File

@ -16,8 +16,8 @@
#endif #endif
/* the global log descriptors */ /* the global log descriptors */
int errorlog; int errorlog = 0;
int accesslog; int accesslog = 0;
/* /*
** ADDR USER AUTH DATE REQUEST CODE BYTES REFERER AGENT [TIME] ** ADDR USER AUTH DATE REQUEST CODE BYTES REFERER AGENT [TIME]

View File

@ -172,7 +172,7 @@ static void _server_proc(void)
/* chroot the process. Watch out - we need to do this before starting other /* chroot the process. Watch out - we need to do this before starting other
* threads. Change uid as well, after figuring out uid _first_ */ * 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(); ice_config_t *conf = config_get_config();
#ifdef CHUID #ifdef CHUID
@ -289,7 +289,7 @@ int main(int argc, char **argv)
_server_proc_init(); /* Bind socket, before we change userid */ _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 */ stats_initialize(); /* We have to do this later on because of threading */