From 1e6232c531a7e65da105fcdd2c7f59cd6e531acc Mon Sep 17 00:00:00 2001 From: Karl Heyes Date: Wed, 17 Nov 2004 16:02:04 +0000 Subject: [PATCH] add . drop the hardcoded mountpoint hacks for NSV svn path=/icecast/trunk/icecast/; revision=8213 --- conf/icecast.xml.in | 6 ++++++ doc/icecast2_config_file.html | 7 +++++++ src/admin.c | 27 +++++---------------------- src/cfgfile.c | 9 +++++++++ src/cfgfile.h | 1 + src/connection.c | 21 +++++++++------------ src/source.c | 11 +++-------- src/yp.c | 14 ++------------ web/status.xsl | 9 +-------- 9 files changed, 43 insertions(+), 62 deletions(-) diff --git a/conf/icecast.xml.in b/conf/icecast.xml.in index a41a501a..02f26d2e 100644 --- a/conf/icecast.xml.in +++ b/conf/icecast.xml.in @@ -99,6 +99,12 @@ 1 + + @pkgdatadir@ diff --git a/doc/icecast2_config_file.html b/doc/icecast2_config_file.html index 038654eb..ed428058 100644 --- a/doc/icecast2_config_file.html +++ b/doc/icecast2_config_file.html @@ -164,6 +164,7 @@ The URL which icecast2 uses to communicate with the Directory server. The value </listen-socket> <fileserve>1</fileserve> + <shoutcast-mount>/live.nsv</shoutcast-mount>

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.

@@ -183,6 +184,12 @@ This optional flag will indicate that this port will operate in 'shoutcast-compa
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 <paths><webroot> configuration setting.
+

shoutcast-mount

+
+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. +



diff --git a/src/admin.c b/src/admin.c index 1d8d245a..8c193ef1 100644 --- a/src/admin.c +++ b/src/admin.c @@ -299,33 +299,16 @@ void admin_handle_request(client_t *client, char *uri) 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; diff --git a/src/cfgfile.c b/src/cfgfile.c index b0d957fc..a6d3031e 100644 --- a/src/cfgfile.c +++ b/src/cfgfile.c @@ -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 @@ void config_clear(ice_config_t *c) 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 @@ static void _set_defaults(ice_config_t *configuration) 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 @@ static void _parse_root(xmlDocPtr doc, xmlNodePtr node, 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) { diff --git a/src/cfgfile.h b/src/cfgfile.h index fe67ad50..fdbb84a2 100644 --- a/src/cfgfile.h +++ b/src/cfgfile.h @@ -96,6 +96,7 @@ typedef struct ice_config_tag int ice_login; int fileserve; + char *shoutcast_mount; char *source_password; char *admin_username; char *admin_password; diff --git a/src/connection.c b/src/connection.c index 36614c7c..c5cc0880 100644 --- a/src/connection.c +++ b/src/connection.c @@ -988,9 +988,8 @@ static void _handle_get_request(connection_t *con, 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 @@ void _handle_shoutcast_compatible(connection_t *con, char *source_password) { /* 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 @@ static void *_handle_connection(void *arg) 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; } diff --git a/src/source.c b/src/source.c index 42bcde36..fa4368d2 100644 --- a/src/source.c +++ b/src/source.c @@ -485,20 +485,15 @@ static void source_init (source_t *source) 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 diff --git a/src/yp.c b/src/yp.c index 7349e6f5..a6ec0d3d 100644 --- a/src/yp.c +++ b/src/yp.c @@ -479,22 +479,12 @@ static ypdata_t *create_yp_entry (source_t *source) 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); diff --git a/web/status.xsl b/web/status.xsl index a3cfdb47..2fd3d5a2 100644 --- a/web/status.xsl +++ b/web/status.xsl @@ -54,14 +54,7 @@ Click to Listen - - - Click to Listen - - - Click to Listen - - +Click to Listen