[xiph-commits] r8213 - in icecast/trunk/icecast: conf doc src web

karl at motherfish-iii.xiph.org karl at motherfish-iii.xiph.org
Wed Nov 17 08:02:05 PST 2004


Author: karl
Date: 2004-11-17 08:02:04 -0800 (Wed, 17 Nov 2004)
New Revision: 8213

Modified:
   icecast/trunk/icecast/conf/icecast.xml.in
   icecast/trunk/icecast/doc/icecast2_config_file.html
   icecast/trunk/icecast/src/admin.c
   icecast/trunk/icecast/src/cfgfile.c
   icecast/trunk/icecast/src/cfgfile.h
   icecast/trunk/icecast/src/connection.c
   icecast/trunk/icecast/src/source.c
   icecast/trunk/icecast/src/yp.c
   icecast/trunk/icecast/web/status.xsl
Log:
add <shoutcast-mount>. drop the hardcoded mountpoint hacks for NSV


Modified: icecast/trunk/icecast/conf/icecast.xml.in
===================================================================
--- icecast/trunk/icecast/conf/icecast.xml.in	2004-11-17 14:12:39 UTC (rev 8212)
+++ icecast/trunk/icecast/conf/icecast.xml.in	2004-11-17 16:02:04 UTC (rev 8213)
@@ -99,6 +99,12 @@
 
     <fileserve>1</fileserve>
 
+    <!-- set the mountpoint for a shoutcast source to use, the default if not
+         specified is /stream but you can change it here if an alternative is
+         wanted or an extension is required
+    <shoutcast-mount>/live.nsv</shoutcast-mount>
+    -->
+
     <paths>
 		<!-- basedir is only used if chroot is enabled -->
         <basedir>@pkgdatadir@</basedir>

Modified: icecast/trunk/icecast/doc/icecast2_config_file.html
===================================================================
--- icecast/trunk/icecast/doc/icecast2_config_file.html	2004-11-17 14:12:39 UTC (rev 8212)
+++ icecast/trunk/icecast/doc/icecast2_config_file.html	2004-11-17 16:02:04 UTC (rev 8213)
@@ -164,6 +164,7 @@
     &lt;/listen-socket&gt;
 
     &lt;fileserve&gt;1&lt;/fileserve&gt;
+    &lt;shoutcast-mount&gt;/live.nsv&lt;/shoutcast-mount&gt;
 </pre>
 <p>This section contains miscellaneous server settings.  Note that multiple listen-socket sections may be configured in order to have icecast2 listen on multiple network interfaces.  If a bind-address is not specified for a particular listen-socket, then the hostname parameter will be used to specify the address that will be bound.
 </p>
@@ -183,6 +184,12 @@
 <div class="indentedbox">
 This flag turns on the icecast2 fileserver from which static files can be served.  All files are served relative to the path specified in the &lt;paths&gt;&lt;webroot&gt; configuration setting.
 </div>
+<h4>shoutcast-mount</h4>
+<div class="indentedbox">
+An optional mountpoint to use when shoutcast DSP compatible clients connect. The default is /stream but can
+be overridden here to use an alternative name which may include an extension that some clients require for
+certain formats.
+</div>
 <p>
 <br />
 <br />

Modified: icecast/trunk/icecast/src/admin.c
===================================================================
--- icecast/trunk/icecast/src/admin.c	2004-11-17 14:12:39 UTC (rev 8212)
+++ icecast/trunk/icecast/src/admin.c	2004-11-17 16:02:04 UTC (rev 8213)
@@ -299,33 +299,16 @@
         return;
     }
 
-    mount = httpp_get_query_param(client->parser, "mount");
-
     if (command == COMMAND_SHOUTCAST_METADATA_UPDATE) {
-        source_t *source;
 
-        mount = "/";
+        ice_config_t *config = config_get_config ();
+        httpp_set_query_param (client->parser, "mount", config->shoutcast_mount);
+        config_release_config ();
         noauth = 1;
-        avl_tree_rlock(global.source_tree);
-        source = source_find_mount_raw(mount);
-        if (source == NULL) {
-            WARN2("Admin command %s on non-existent source %s", 
-                    command_string, mount);
-            avl_tree_unlock(global.source_tree);
-            client_send_400(client, "Mount / does not exist");
-            return;
-        }
-        else {
-            if (source->shoutcast_compat == 0) {
-                ERROR0("Illegal call to change metadata, source not shoutcast compatible");
-                avl_tree_unlock (global.source_tree);
-                client_send_400 (client, "Illegal metadata call");
-                return;
-            }
-        }
-        avl_tree_unlock(global.source_tree);
     }
 
+    mount = httpp_get_query_param(client->parser, "mount");
+
     if(mount != NULL) {
         source_t *source;
 

Modified: icecast/trunk/icecast/src/cfgfile.c
===================================================================
--- icecast/trunk/icecast/src/cfgfile.c	2004-11-17 14:12:39 UTC (rev 8212)
+++ icecast/trunk/icecast/src/cfgfile.c	2004-11-17 16:02:04 UTC (rev 8213)
@@ -38,6 +38,7 @@
 #define CONFIG_DEFAULT_SOURCE_TIMEOUT 10
 #define CONFIG_DEFAULT_SOURCE_PASSWORD "changeme"
 #define CONFIG_DEFAULT_RELAY_PASSWORD "changeme"
+#define CONFIG_DEFAULT_SHOUTCAST_MOUNT "/stream"
 #define CONFIG_DEFAULT_ICE_LOGIN 0
 #define CONFIG_DEFAULT_FILESERVE 1
 #define CONFIG_DEFAULT_TOUCH_FREQ 5
@@ -156,6 +157,8 @@
         xmlFree(c->access_log);
     if (c->error_log && c->error_log != CONFIG_DEFAULT_ERROR_LOG) 
         xmlFree(c->error_log);
+    if (c->shoutcast_mount && c->shoutcast_mount != CONFIG_DEFAULT_SHOUTCAST_MOUNT)
+        xmlFree(c->shoutcast_mount);
     for(i=0; i < MAX_LISTEN_SOCKETS; i++) {
         if (c->listeners[i].bind_address) xmlFree(c->listeners[i].bind_address);
     }
@@ -316,6 +319,7 @@
     configuration->header_timeout = CONFIG_DEFAULT_HEADER_TIMEOUT;
     configuration->source_timeout = CONFIG_DEFAULT_SOURCE_TIMEOUT;
     configuration->source_password = CONFIG_DEFAULT_SOURCE_PASSWORD;
+    configuration->shoutcast_mount = CONFIG_DEFAULT_SHOUTCAST_MOUNT;
     configuration->ice_login = CONFIG_DEFAULT_ICE_LOGIN;
     configuration->fileserve = CONFIG_DEFAULT_FILESERVE;
     configuration->touch_interval = CONFIG_DEFAULT_TOUCH_FREQ;
@@ -412,6 +416,11 @@
             tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
             configuration->master_update_interval = atoi(tmp);
             xmlFree (tmp);
+        } else if (strcmp(node->name, "shoutcast-mount") == 0) {
+            if (configuration->shoutcast_mount &&
+                    configuration->shoutcast_mount != CONFIG_DEFAULT_SHOUTCAST_MOUNT)
+                xmlFree(configuration->shoutcast_mount);
+            configuration->shoutcast_mount = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
         } else if (strcmp(node->name, "limits") == 0) {
             _parse_limits(doc, node->xmlChildrenNode, configuration);
         } else if (strcmp(node->name, "relay") == 0) {

Modified: icecast/trunk/icecast/src/cfgfile.h
===================================================================
--- icecast/trunk/icecast/src/cfgfile.h	2004-11-17 14:12:39 UTC (rev 8212)
+++ icecast/trunk/icecast/src/cfgfile.h	2004-11-17 16:02:04 UTC (rev 8213)
@@ -96,6 +96,7 @@
     int ice_login;
     int fileserve;
 
+    char *shoutcast_mount;
     char *source_password;
     char *admin_username;
     char *admin_password;

Modified: icecast/trunk/icecast/src/connection.c
===================================================================
--- icecast/trunk/icecast/src/connection.c	2004-11-17 14:12:39 UTC (rev 8212)
+++ icecast/trunk/icecast/src/connection.c	2004-11-17 16:02:04 UTC (rev 8213)
@@ -988,9 +988,8 @@
     if (uri != passed_uri) free (uri);
 }
 
-void _handle_shoutcast_compatible(connection_t *con, char *source_password) {
+void _handle_shoutcast_compatible(connection_t *con, char *mount, char *source_password) {
     char shoutcast_password[256];
-    char shoutcast_source[256];
     char *http_compliant;
     int http_compliant_len = 0;
     char header[4096];
@@ -1031,18 +1030,14 @@
     /* Here we create a valid HTTP request based of the information
        that was passed in via the non-HTTP style protocol above. This
        means we can use some of our existing code to handle this case */
-    memset(shoutcast_source, 0, sizeof (shoutcast_source));
-    strcpy(shoutcast_source, "SOURCE / HTTP/1.0\r\n");
-    http_compliant_len = strlen(shoutcast_source) + 
-                         strlen(header) + 1;
+    http_compliant_len = strlen(header) + strlen(mount) + 20;
     http_compliant = (char *)calloc(1, http_compliant_len);
-    sprintf(http_compliant, "%s%s", shoutcast_source, 
-        header);
+    snprintf (http_compliant, http_compliant_len,
+            "SOURCE %s HTTP/1.0\r\n%s", mount, header);
     parser = httpp_create_parser();
     httpp_initialize(parser, NULL);
-    if (httpp_parse(parser, http_compliant, 
-        strlen(http_compliant))) {
-        _handle_source_request(con, parser, "/", SHOUTCAST_SOURCE_AUTH);
+    if (httpp_parse(parser, http_compliant, strlen(http_compliant))) {
+        _handle_source_request(con, parser, mount, SHOUTCAST_SOURCE_AUTH);
         free(http_compliant);
         return;
     }
@@ -1097,10 +1092,12 @@
                 if(global.serversock[i] == con->serversock) {
                     config = config_get_config();
                     if (config->listeners[i].shoutcast_compat) {
+                        char *shoutcast_mount = strdup (config->shoutcast_mount);
                         source_password = strdup(config->source_password);
                         config_release_config();
-                        _handle_shoutcast_compatible(con, source_password);
+                        _handle_shoutcast_compatible(con, shoutcast_mount, source_password);
                         free(source_password);
+                        free (shoutcast_mount);
                         continue_flag = 1;
                         break;
                     }

Modified: icecast/trunk/icecast/src/source.c
===================================================================
--- icecast/trunk/icecast/src/source.c	2004-11-17 14:12:39 UTC (rev 8212)
+++ icecast/trunk/icecast/src/source.c	2004-11-17 16:02:04 UTC (rev 8213)
@@ -485,20 +485,15 @@
     char *listenurl, *str;
     int listen_url_size;
     char *s;
-    char *extra = "";
 
-    if (source->format->type == FORMAT_TYPE_NSV) {
-        extra = "?file=stream.nsv";
-    }
-
     /* 6 for max size of port */
     listen_url_size = strlen("http://") + strlen(config->hostname) +
-        strlen(":") + 6 + strlen(source->mount) + strlen(extra) + 1;
+        strlen(":") + 6 + strlen(source->mount) + 1;
 
     listenurl = malloc (listen_url_size);
     memset (listenurl, '\000', listen_url_size);
-    snprintf (listenurl, listen_url_size, "http://%s:%d%s%s",
-            config->hostname, config->port, source->mount, extra);
+    snprintf (listenurl, listen_url_size, "http://%s:%d%s",
+            config->hostname, config->port, source->mount);
     config_release_config();
 
     do

Modified: icecast/trunk/icecast/src/yp.c
===================================================================
--- icecast/trunk/icecast/src/yp.c	2004-11-17 14:12:39 UTC (rev 8212)
+++ icecast/trunk/icecast/src/yp.c	2004-11-17 16:02:04 UTC (rev 8213)
@@ -479,22 +479,12 @@
         if (url == NULL)
             break;
         config = config_get_config();
-        if (source->format->type == FORMAT_TYPE_NSV) {
-            ret = snprintf (url, len, "http://%s:%d%s?stream.nsv", config->hostname, config->port, source->mount);
-        }
-        else {
-            ret = snprintf (url, len, "http://%s:%d%s", config->hostname, config->port, source->mount);
-        }
+        ret = snprintf (url, len, "http://%s:%d%s", config->hostname, config->port, source->mount);
         if (ret >= (signed)len)
         {
             s = realloc (url, ++ret);
             if (s) url = s;
-            if (source->format->type == FORMAT_TYPE_NSV) {
-                snprintf (url, ret, "http://%s:%d%s?file=stream.nsv", config->hostname, config->port, source->mount);
-            }
-            else {
-                snprintf (url, ret, "http://%s:%d%s", config->hostname, config->port, source->mount);
-            }
+            snprintf (url, ret, "http://%s:%d%s", config->hostname, config->port, source->mount);
         }
         config_release_config();
         yp->listen_url = util_url_escape (url);

Modified: icecast/trunk/icecast/web/status.xsl
===================================================================
--- icecast/trunk/icecast/web/status.xsl	2004-11-17 14:12:39 UTC (rev 8212)
+++ icecast/trunk/icecast/web/status.xsl	2004-11-17 16:02:04 UTC (rev 8213)
@@ -54,14 +54,7 @@
 <a href="auth.xsl">Click to Listen</a>
 </xsl:when>
 <xsl:otherwise>
-	<xsl:choose>
-	<xsl:when test="content-type='video/nsv'">
-	<a href="{@mount}%3Ffile%3Dstream.nsv.m3u">Click to Listen</a>
-	</xsl:when>
-	<xsl:otherwise>
-	<a href="{@mount}.m3u">Click to Listen</a>
-	</xsl:otherwise>
-	</xsl:choose>
+<a href="{@mount}.m3u">Click to Listen</a>
 </xsl:otherwise>
 </xsl:choose>
 </td></tr>



More information about the commits mailing list