Commit cbfb283e authored by brendan's avatar brendan

Move MP3 headers back into format_mp3.c per Mike's desire.

I removed icy- support from the generic send headers function, as it is my
understanding that only MP3 sources use icy headers. PLEASE correct me
if I am wrong.

I also added code in the mp3 function to convert ice-audio-info bitrate to
an icy-br header. ice-audio-info is for YP, icy-br for clients. Perhaps we
should send both to clients though?

svn path=/trunk/icecast/; revision=5079
parent 004152cf
......@@ -109,16 +109,11 @@ void format_send_general_headers(format_plugin_t *format,
while (node) {
var = (http_var_t *)node->key;
if (strcasecmp(var->name, "ice-password") &&
strcasecmp(var->name, "icy-metaint") &&
(!strncasecmp("ice-", var->name, 4) ||
!strncasecmp("icy-", var->name, 4))) {
if (source->format->type == FORMAT_TYPE_MP3)
bytes = sock_write(client->con->sock, "icy%s:%s\r\n",
var->name + 3, var->value);
else
bytes = sock_write(client->con->sock,
"%s: %s\r\n", var->name, var->value);
if(bytes > 0) client->con->sent_bytes += bytes;
(!strncasecmp("ice-", var->name, 4))) {
bytes = sock_write(client->con->sock,
"%s: %s\r\n", var->name, var->value);
if (bytes > 0)
client->con->sent_bytes += bytes;
}
node = avl_get_next(node);
}
......
/* -*- c-basic-offset: 4; -*- */
/* format_mp3.c
**
** format plugin for mp3
......@@ -347,6 +348,8 @@ static void *format_mp3_create_client_data(format_plugin_t *self,
static void format_mp3_send_headers(format_plugin_t *self,
source_t *source, client_t *client)
{
http_var_t *var;
avl_node *node;
int bytes;
client->respcode = 200;
......@@ -358,13 +361,45 @@ static void format_mp3_send_headers(format_plugin_t *self,
if(bytes > 0) client->con->sent_bytes += bytes;
format_send_general_headers(self, source, client);
/* iterate through source http headers and send to client */
avl_tree_rlock(source->parser->vars);
node = avl_get_first(source->parser->vars);
while (node) {
var = (http_var_t *)node->key;
if (!strcasecmp(var->name, "ice-audio-info")) {
/* convert ice-audio-info to icy-br */
char *brfield;
unsigned int bitrate;
brfield = strstr(var->value, "bitrate=");
if (brfield && sscanf(var->value, "bitrate=%u", &bitrate)) {
bytes = sock_write(client->con->sock, "icy-br:%u\r\n", bitrate);
if (bytes > 0)
client->con->sent_bytes += bytes;
}
} else if (strcasecmp(var->name, "ice-password") &&
strcasecmp(var->name, "icy-metaint") &&
(!strncasecmp("ice-", var->name, 4) ||
!strncasecmp("icy-", var->name, 4))) {
bytes = sock_write(client->con->sock, "icy%s:%s\r\n",
var->name + 3, var->value);
if (bytes > 0)
client->con->sent_bytes += bytes;
}
node = avl_get_next(node);
}
avl_tree_unlock(source->parser->vars);
if(((mp3_client_data *)(client->format_data))->use_metadata) {
int bytes = sock_write(client->con->sock, "icy-metaint: %d\r\n",
int bytes = sock_write(client->con->sock, "icy-metaint:%d\r\n",
ICY_METADATA_INTERVAL);
if(bytes > 0)
client->con->sent_bytes += bytes;
}
bytes = sock_write(client->con->sock,
"Server: %s\r\n", ICECAST_VERSION_STRING);
if (bytes > 0)
client->con->sent_bytes += bytes;
}
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