[xiph-cvs] cvs commit: icecast/src format.c format_mp3.c

Brendan brendan at xiph.org
Sun Jul 6 08:27:50 PDT 2003



brendan     03/07/06 11:27:50

  Modified:    src      format.c format_mp3.c
  Log:
  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?

Revision  Changes    Path
1.23      +5 -10     icecast/src/format.c

Index: format.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/format.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -p -u -r1.22 -r1.23
--- format.c	3 Jul 2003 01:39:59 -0000	1.22
+++ format.c	6 Jul 2003 15:27:50 -0000	1.23
@@ -109,16 +109,11 @@ void format_send_general_headers(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);
     }

<p><p>1.18      +37 -2     icecast/src/format_mp3.c

Index: format_mp3.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/format_mp3.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -p -u -r1.17 -r1.18
--- format_mp3.c	15 Mar 2003 02:10:17 -0000	1.17
+++ format_mp3.c	6 Jul 2003 15:27:50 -0000	1.18
@@ -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_da
 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(form
 
     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;
 }
 

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list