1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2025-01-03 14:56:34 -05:00

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
This commit is contained in:
brendan 2003-07-06 15:27:50 +00:00
parent 004152cf7a
commit cbfb283e6f
2 changed files with 42 additions and 12 deletions

View File

@ -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);
}

View File

@ -1,3 +1,4 @@
/* -*- 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;
}