From 680e56bf7b33b7b49f591bef1d55930ae5f7aa85 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Tue, 25 Feb 2003 09:40:34 +0000 Subject: [PATCH] mp3 metadata relaying now works (lots of bugs fixed) svn path=/trunk/icecast/; revision=4366 --- src/format_mp3.c | 15 +++++++-------- src/slave.c | 11 ++++++++++- src/source.c | 2 ++ src/util.c | 2 +- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/format_mp3.c b/src/format_mp3.c index 5de600f7..54905925 100644 --- a/src/format_mp3.c +++ b/src/format_mp3.c @@ -132,7 +132,6 @@ static int send_metadata(client_t *client, mp3_client_data *client_state, if (len > 1) { strncpy(buf+1, fullmetadata + client_state->metadata_offset, len-2); - DEBUG1("Sending metadata (%s)", buf+1); } thread_mutex_unlock(&(source_state->lock)); @@ -219,7 +218,7 @@ static int format_mp3_get_buffer(format_plugin_t *self, char *data, if(!data) return 0; - + if(state->inline_metadata_interval) { /* Source is sending metadata, handle it... */ @@ -257,6 +256,7 @@ static int format_mp3_get_buffer(format_plugin_t *self, char *data, /* According to the "spec"... this byte * 16 */ state->metadata_length = byte * 16; + if(state->metadata_length) { state->metadata_buffer = calloc(state->metadata_length + 1, 1); @@ -282,14 +282,13 @@ static int format_mp3_get_buffer(format_plugin_t *self, char *data, memcpy(state->metadata_buffer + state->metadata_offset, data, readable); + state->metadata_offset += readable; + data += readable; len -= readable; if(state->metadata_offset == state->metadata_length) { - state->offset = 0; - state->metadata_length = 0; - if(state->metadata_length) { thread_mutex_lock(&(state->lock)); @@ -300,6 +299,9 @@ static int format_mp3_get_buffer(format_plugin_t *self, char *data, state->metadata_raw = 1; thread_mutex_unlock(&(state->lock)); } + + state->offset = 0; + state->metadata_length = 0; } } } @@ -366,6 +368,3 @@ static void format_mp3_send_headers(format_plugin_t *self, } } - - - diff --git a/src/slave.c b/src/slave.c index 533f75eb..599912a1 100644 --- a/src/slave.c +++ b/src/slave.c @@ -86,7 +86,13 @@ static void create_relay_stream(char *server, int port, } con = create_connection(streamsock, NULL); if(mp3) { - sock_write(streamsock, "GET %s HTTP/1.0\r\nIcy-MetaData: 1\r\n", + /* Some mp3 servers are bitchy, send a user-agent string to make them + * send the right response. + */ + sock_write(streamsock, "GET %s HTTP/1.0\r\n" + "User-Agent: " ICECAST_VERSION_STRING "\r\n" + "Icy-MetaData: 1\r\n" + "\r\n", remotemount); } else { @@ -94,6 +100,7 @@ static void create_relay_stream(char *server, int port, } memset(header, 0, sizeof(header)); if (util_read_header(con->sock, header, 4096) == 0) { + WARN0("Header read failed"); connection_close(con); return; } @@ -114,8 +121,10 @@ static void create_relay_stream(char *server, int port, client = client_create(con, parser); if (!connection_create_source(client, con, parser, httpp_getvar(parser, HTTPP_VAR_URI))) { + DEBUG0("Failed to create source"); client_destroy(client); } + return; } diff --git a/src/source.c b/src/source.c index 2572ddbe..ab91b1e6 100644 --- a/src/source.c +++ b/src/source.c @@ -284,6 +284,8 @@ void *source_main(void *arg) } } + DEBUG0("Source creation complete"); + while (global.running == ICE_RUNNING && source->running) { if(!suppress_yp) { current_time = time(NULL); diff --git a/src/util.c b/src/util.c index 9e4a504a..4405ca64 100644 --- a/src/util.c +++ b/src/util.c @@ -94,7 +94,7 @@ int util_read_header(int sock, char *buff, unsigned long len) } } } else { - break; + break; } }