Commit 680e56bf authored by Michael Smith's avatar Michael Smith

mp3 metadata relaying now works (lots of bugs fixed)

svn path=/trunk/icecast/; revision=4366
parent 47b1d160
......@@ -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,
}
}
......@@ -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;
}
......
......@@ -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);
......
......@@ -94,7 +94,7 @@ int util_read_header(int sock, char *buff, unsigned long len)
}
}
} else {
break;
break;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment