[xiph-commits] r14045 - icecast/trunk/icecast/src

karl at svn.xiph.org karl at svn.xiph.org
Wed Oct 24 19:25:49 PDT 2007


Author: karl
Date: 2007-10-24 19:25:49 -0700 (Wed, 24 Oct 2007)
New Revision: 14045

Modified:
   icecast/trunk/icecast/src/admin.c
   icecast/trunk/icecast/src/cfgfile.c
   icecast/trunk/icecast/src/cfgfile.h
   icecast/trunk/icecast/src/connection.c
Log:
allow for multiple shoutcast style source clients to connect. They don't
provide a mountpoint so you specify a shoutcast-mount in the listen-socket
section. Specifying this will automatically define the port+1 with the same
settings however the original shoutcast-compat approach is maintained.


Modified: icecast/trunk/icecast/src/admin.c
===================================================================
--- icecast/trunk/icecast/src/admin.c	2007-10-25 01:03:47 UTC (rev 14044)
+++ icecast/trunk/icecast/src/admin.c	2007-10-25 02:25:49 UTC (rev 14045)
@@ -335,14 +335,22 @@
     if (command == COMMAND_SHOUTCAST_METADATA_UPDATE) {
 
         ice_config_t *config;
+        const char *sc_mount;
         const char *pass = httpp_get_query_param (client->parser, "pass");
+        listener_t *listener;
+
         if (pass == NULL)
         {
             client_send_400 (client, "missing pass parameter");
             return;
         }
         config = config_get_config ();
-        httpp_set_query_param (client->parser, "mount", (char *)config->shoutcast_mount);
+        sc_mount = config->shoutcast_mount;
+        listener = config_get_listen_sock (config, client->con);
+        if (listener && listener->shoutcast_mount)
+            sc_mount = listener->shoutcast_mount;
+
+        httpp_set_query_param (client->parser, "mount", sc_mount);
         httpp_setvar (client->parser, HTTPP_VAR_PROTOCOL, "ICY");
         httpp_setvar (client->parser, HTTPP_VAR_ICYPASSWORD, pass);
         config_release_config ();

Modified: icecast/trunk/icecast/src/cfgfile.c
===================================================================
--- icecast/trunk/icecast/src/cfgfile.c	2007-10-25 01:03:47 UTC (rev 14044)
+++ icecast/trunk/icecast/src/cfgfile.c	2007-10-25 02:25:49 UTC (rev 14045)
@@ -157,6 +157,7 @@
     {
         next = listener->next;
         if (listener->bind_address)     xmlFree (listener->bind_address);
+        if (listener->shoutcast_mount)  xmlFree (listener->shoutcast_mount);
         free (listener);
     }
     return next;
@@ -800,7 +801,13 @@
             listener->shoutcast_compat = atoi(tmp);
             if(tmp) xmlFree(tmp);
         }
+        else if (xmlStrcmp (node->name, XMLSTR("shoutcast-mount")) == 0) {
+            if (listener->shoutcast_mount) xmlFree (listener->shoutcast_mount);
+            listener->shoutcast_mount = (char *)xmlNodeListGetString(doc, 
+                    node->xmlChildrenNode, 1);
+        }
         else if (xmlStrcmp (node->name, XMLSTR("bind-address")) == 0) {
+            if (listener->bind_address) xmlFree (listener->bind_address);
             listener->bind_address = (char *)xmlNodeListGetString(doc, 
                     node->xmlChildrenNode, 1);
         }
@@ -809,6 +816,19 @@
     listener->next = configuration->listen_sock;
     configuration->listen_sock = listener;
     configuration->listen_sock_count++;
+    if (listener->shoutcast_mount)
+    {
+        listener_t *sc_port = calloc (1, sizeof (listener_t));
+        sc_port->port = listener->port+1;
+        sc_port->shoutcast_compat = 1;
+        sc_port->shoutcast_mount = (char*)xmlStrdup (XMLSTR(listener->shoutcast_mount));
+        if (listener->bind_address)
+            sc_port->bind_address = (char*)xmlStrdup (XMLSTR(listener->bind_address));
+
+        sc_port->next = configuration->listen_sock;
+        configuration->listen_sock = sc_port;
+        configuration->listen_sock_count++;
+    }
 }
 
 static void _parse_authentication(xmlDocPtr doc, xmlNodePtr node,

Modified: icecast/trunk/icecast/src/cfgfile.h
===================================================================
--- icecast/trunk/icecast/src/cfgfile.h	2007-10-25 01:03:47 UTC (rev 14044)
+++ icecast/trunk/icecast/src/cfgfile.h	2007-10-25 02:25:49 UTC (rev 14045)
@@ -103,6 +103,7 @@
     int port;
     char *bind_address;
     int shoutcast_compat;
+    char *shoutcast_mount;
     int ssl;
 } listener_t;
 

Modified: icecast/trunk/icecast/src/connection.c
===================================================================
--- icecast/trunk/icecast/src/connection.c	2007-10-25 01:03:47 UTC (rev 14044)
+++ icecast/trunk/icecast/src/connection.c	2007-10-25 02:25:49 UTC (rev 14045)
@@ -87,6 +87,7 @@
     int offset;
     int stream_offset;
     int shoutcast;
+    char *shoutcast_mount;
     struct client_queue_tag *next;
 } client_queue_t;
 
@@ -758,6 +759,8 @@
                     node->shoutcast = 1;
                 if (listener->ssl && ssl_ok)
                     connection_uses_ssl (client->con);
+                if (listener->shoutcast_mount)
+                    node->shoutcast_mount = strdup (listener->shoutcast_mount);
             }
             config_release_config();
 
@@ -1096,7 +1099,6 @@
 
 static void _handle_get_request (client_t *client, char *passed_uri)
 {
-    int fileserve;
     int port;
     char *serverhost = NULL;
     int serverport = 0;
@@ -1106,7 +1108,6 @@
     listener_t *listen_sock;
 
     config = config_get_config();
-    fileserve = config->fileserve;
     port = config->port;
 
     listen_sock = config_get_listen_sock (config, client->con);
@@ -1160,10 +1161,15 @@
     char *shoutcast_mount;
     client_t *client = node->client;
 
+    if (node->shoutcast_mount)
+        shoutcast_mount = node->shoutcast_mount;
+    else
+        shoutcast_mount = config->shoutcast_mount;
+
     if (node->shoutcast == 1)
     {
         char *source_password, *ptr, *headers;
-        mount_proxy *mountinfo = config_find_mount (config, config->shoutcast_mount);
+        mount_proxy *mountinfo = config_find_mount (config, shoutcast_mount);
 
         if (mountinfo && mountinfo->password)
             source_password = strdup (mountinfo->password);
@@ -1192,6 +1198,7 @@
         {
             client_destroy (client);
             free (source_password);
+            free (node->shoutcast_mount);
             free (node);
             return;
         }
@@ -1215,10 +1222,12 @@
             INFO1 ("password does not match \"%s\"", client->refbuf->data);
         client_destroy (client);
         free (source_password);
+        free (node->shoutcast_mount);
         free (node);
         return;
     }
-    shoutcast_mount = strdup (config->shoutcast_mount);
+    /* actually make a copy as we are dropping the config lock */
+    shoutcast_mount = strdup (shoutcast_mount);
     config_release_config();
     /* Here we create a valid HTTP request based of the information
        that was passed in via the non-HTTP style protocol above. This
@@ -1249,6 +1258,7 @@
     }
     free (http_compliant);
     free (shoutcast_mount);
+    free (node->shoutcast_mount);
     free (node);
     return;
 }
@@ -1295,6 +1305,14 @@
                     client->refbuf->len = node->offset - node->stream_offset;
                     memmove (ptr, ptr + node->stream_offset, client->refbuf->len);
                 }
+
+                rawuri = httpp_getvar(parser, HTTPP_VAR_URI);
+
+                /* assign a port-based shoutcast mountpoint if required */
+                if (node->shoutcast_mount && strcmp (rawuri, "/admin.cgi") == 0)
+                    httpp_set_query_param (client->parser, "mount", node->shoutcast_mount);
+
+                free (node->shoutcast_mount);
                 free (node);
                 
                 if (strcmp("ICE",  httpp_getvar(parser, HTTPP_VAR_PROTOCOL)) &&
@@ -1304,7 +1322,6 @@
                     continue;
                 }
 
-                rawuri = httpp_getvar(parser, HTTPP_VAR_URI);
                 uri = util_normalise_uri(rawuri);
 
                 if (uri == NULL)



More information about the commits mailing list