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

Karl Heyes karl at xiph.org
Mon Feb 2 16:29:37 PST 2004



karl        04/02/02 19:29:37

  Modified:    src      format.c format_mp3.c
  Log:
  cleanup headers sent to listeners

Revision  Changes    Path
1.28      +37 -7     icecast/src/format.c

Index: format.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/format.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- format.c	29 Jan 2004 01:02:06 -0000	1.27
+++ format.c	3 Feb 2004 00:29:36 -0000	1.28
@@ -124,14 +124,44 @@
     /* iterate through source http headers and send to client */
     avl_tree_rlock(source->parser->vars);
     node = avl_get_first(source->parser->vars);
-    while (node) {
+    while (node)
+    {
         var = (http_var_t *)node->key;
-        if (strcasecmp(var->name, "ice-password") &&
-	    (!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;
+        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"))
+            {
+                bytes = 0;
+                if (!strncasecmp("ice-", var->name, 4))
+                {
+                    if (!strcasecmp("ice-bitrate", var->name))
+                        bytes += sock_write(client->con->sock, "icy-br:%s\r\n", var->value);
+                    else
+                        bytes = sock_write(client->con->sock, "icy%s:%s\r\n",
+                            var->name + 3, var->value);
+                            
+                }
+                if (!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);
     }

<p><p>1.28      +5 -36     icecast/src/format_mp3.c

Index: format_mp3.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/format_mp3.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- format_mp3.c	29 Jan 2004 01:02:06 -0000	1.27
+++ format_mp3.c	3 Feb 2004 00:29:36 -0000	1.28
@@ -405,47 +405,16 @@
             "Content-Type: %s\r\n", 
             format_get_mimetype(source->format->type));
 
-    if(bytes > 0) client->con->sent_bytes += bytes;
-
-    /* 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 (bytes > 0)
+        client->con->sent_bytes += bytes;
 
-    if (mp3data->use_metadata) {
+    if (mp3data->use_metadata)
+    {
         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;
+    format_send_general_headers(self, source, client);
 }
 

<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