[xiph-commits] r9141 - icecast/branches/kh/icecast/src

karl at motherfish-iii.xiph.org karl at motherfish-iii.xiph.org
Fri Apr 15 09:34:58 PDT 2005


Author: karl
Date: 2005-04-15 09:34:52 -0700 (Fri, 15 Apr 2005)
New Revision: 9141

Modified:
   icecast/branches/kh/icecast/src/cfgfile.c
   icecast/branches/kh/icecast/src/cfgfile.h
   icecast/branches/kh/icecast/src/connection.c
   icecast/branches/kh/icecast/src/format.c
   icecast/branches/kh/icecast/src/format.h
   icecast/branches/kh/icecast/src/format_mp3.c
   icecast/branches/kh/icecast/src/format_mp3.h
   icecast/branches/kh/icecast/src/slave.c
   icecast/branches/kh/icecast/src/source.c
   icecast/branches/kh/icecast/src/yp.c
Log:
on-demand relay related updates.  Will now add to YP before initial connection
provided enough information has been provided to the YP server


Modified: icecast/branches/kh/icecast/src/cfgfile.c
===================================================================
--- icecast/branches/kh/icecast/src/cfgfile.c	2005-04-15 10:58:47 UTC (rev 9140)
+++ icecast/branches/kh/icecast/src/cfgfile.c	2005-04-15 16:34:52 UTC (rev 9141)
@@ -195,6 +195,7 @@
         xmlFree(mount->stream_url);
         xmlFree(mount->stream_genre);
         xmlFree(mount->bitrate);
+        xmlFree(mount->type);
         if (mount->cluster_password) {
             xmlFree(mount->cluster_password);
         }
@@ -663,6 +664,14 @@
             tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
             mount->bitrate = (char *)xmlNodeListGetString(
                     doc, node->xmlChildrenNode, 1);
+        } else if (strcmp(node->name, "public") == 0) {
+            tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
+            mount->yp_public = atoi (tmp);
+            if(tmp) xmlFree(tmp);
+        } else if (strcmp(node->name, "type") == 0) {
+            tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
+            mount->type = (char *)xmlNodeListGetString(
+                    doc, node->xmlChildrenNode, 1);
         }
     } while ((node = node->next));
 }

Modified: icecast/branches/kh/icecast/src/cfgfile.h
===================================================================
--- icecast/branches/kh/icecast/src/cfgfile.h	2005-04-15 10:58:47 UTC (rev 9140)
+++ icecast/branches/kh/icecast/src/cfgfile.h	2005-04-15 16:34:52 UTC (rev 9141)
@@ -78,6 +78,8 @@
     char *stream_url;
     char *stream_genre;
     char *bitrate;
+    char *type;
+    int yp_public;
 
     struct _mount_proxy *next;
 } mount_proxy;

Modified: icecast/branches/kh/icecast/src/connection.c
===================================================================
--- icecast/branches/kh/icecast/src/connection.c	2005-04-15 10:58:47 UTC (rev 9140)
+++ icecast/branches/kh/icecast/src/connection.c	2005-04-15 16:34:52 UTC (rev 9141)
@@ -431,7 +431,7 @@
 /* Called when activating a source. Verifies that the source count is not
  * exceeded and applies any initial parameters.
  */
-int connection_complete_source (source_t *source, connection_t *con, http_parser_t *parser)
+int connection_complete_source (source_t *source, connection_t *con, http_parser_t *in_parser)
 {
     ice_config_t *config = config_get_config();
 
@@ -442,13 +442,13 @@
     {
         char *contenttype;
         format_type_t format_type;
+        http_parser_t *parser = in_parser;
 
         /* setup format handler */
-        if (parser || source->client == NULL)
-            contenttype = httpp_getvar (parser, "content-type");
-        else
-            contenttype = httpp_getvar (source->client->parser, "content-type");
+        if (source->client)
+            parser = source->client->parser;
 
+        contenttype = httpp_getvar (parser, "content-type");
         if (contenttype != NULL)
         {
             format_type = format_get_type (contenttype);
@@ -470,13 +470,14 @@
             format_type = FORMAT_TYPE_GENERIC;
         }
 
-        if (format_get_plugin (format_type, source) < 0)
+        if (format_get_plugin (format_type, source, parser) < 0)
         {
             global_unlock();
             config_release_config();
             if (source->client)
                 client_send_404 (source->client, "internal format allocation problem");
             WARN1 ("plugin format failed for \"%s\"", source->mount);
+            source->client = NULL;
             return -1;
         }
 
@@ -493,6 +494,7 @@
             source->client = client_create (con, parser);
             if (source->client == NULL)
             {
+                global_unlock();
                 config_release_config();
                 return -1;
             }

Modified: icecast/branches/kh/icecast/src/format.c
===================================================================
--- icecast/branches/kh/icecast/src/format.c	2005-04-15 10:58:47 UTC (rev 9140)
+++ icecast/branches/kh/icecast/src/format.c	2005-04-15 16:34:52 UTC (rev 9141)
@@ -64,7 +64,7 @@
         return FORMAT_TYPE_GENERIC;
 }
 
-int format_get_plugin(format_type_t type, source_t *source)
+int format_get_plugin (format_type_t type, source_t *source, http_parser_t *parser)
 {
     int ret = -1;
 
@@ -73,7 +73,7 @@
         ret = format_ogg_get_plugin (source);
         break;
     case FORMAT_TYPE_GENERIC:
-        ret = format_mp3_get_plugin (source);
+        ret = format_mp3_get_plugin (source, parser);
         break;
     default:
         break;

Modified: icecast/branches/kh/icecast/src/format.h
===================================================================
--- icecast/branches/kh/icecast/src/format.h	2005-04-15 10:58:47 UTC (rev 9140)
+++ icecast/branches/kh/icecast/src/format.h	2005-04-15 16:34:52 UTC (rev 9141)
@@ -54,7 +54,7 @@
 } format_plugin_t;
 
 format_type_t format_get_type(char *contenttype);
-int format_get_plugin(format_type_t type, struct source_tag *source);
+int format_get_plugin(format_type_t type, struct source_tag *source, http_parser_t *p);
 
 int format_generic_write_to_client (struct source_tag *source, client_t *client);
 void format_send_general_headers(format_plugin_t *format, 

Modified: icecast/branches/kh/icecast/src/format_mp3.c
===================================================================
--- icecast/branches/kh/icecast/src/format_mp3.c	2005-04-15 10:58:47 UTC (rev 9140)
+++ icecast/branches/kh/icecast/src/format_mp3.c	2005-04-15 16:34:52 UTC (rev 9141)
@@ -73,7 +73,7 @@
    refbuf_t *associated;
 } mp3_client_data;
 
-int format_mp3_get_plugin (source_t *source)
+int format_mp3_get_plugin (source_t *source, http_parser_t *parser)
 {
     char *metadata;
     format_plugin_t *plugin;
@@ -91,7 +91,7 @@
     plugin->set_tag = mp3_set_tag;
     plugin->apply_settings = format_mp3_apply_settings;
 
-    plugin->contenttype = httpp_getvar (source->client->parser, "content-type");
+    plugin->contenttype = httpp_getvar (parser, "content-type");
     if (plugin->contenttype == NULL) {
         /* We default to MP3 audio for old clients without content types */
         plugin->contenttype = "audio/mpeg";
@@ -107,7 +107,7 @@
     state->metadata = meta;
     state->interval = -1;
 
-    metadata = httpp_getvar (source->client->parser, "icy-metaint");
+    metadata = httpp_getvar (parser, "icy-metaint");
     if (metadata)
     {
         state->inline_metadata_interval = atoi (metadata);

Modified: icecast/branches/kh/icecast/src/format_mp3.h
===================================================================
--- icecast/branches/kh/icecast/src/format_mp3.h	2005-04-15 10:58:47 UTC (rev 9140)
+++ icecast/branches/kh/icecast/src/format_mp3.h	2005-04-15 16:34:52 UTC (rev 9141)
@@ -35,6 +35,6 @@
     char build_metadata[4081];
 } mp3_state;
 
-int format_mp3_get_plugin(struct source_tag *src);
+int format_mp3_get_plugin(struct source_tag *src, http_parser_t *p);
 
 #endif  /* __FORMAT_MP3_H__ */

Modified: icecast/branches/kh/icecast/src/slave.c
===================================================================
--- icecast/branches/kh/icecast/src/slave.c	2005-04-15 10:58:47 UTC (rev 9140)
+++ icecast/branches/kh/icecast/src/slave.c	2005-04-15 16:34:52 UTC (rev 9141)
@@ -371,6 +371,8 @@
             {
                 ice_config_t *config = config_get_config ();
                 source_update_settings (config, relay->source);
+                if (relay->source->yp_public)
+                    yp_add (relay->source);
                 config_release_config ();
                 stats_event (relay->localmount, "listeners", "0");
                 DEBUG0 ("setting on_demand");

Modified: icecast/branches/kh/icecast/src/source.c
===================================================================
--- icecast/branches/kh/icecast/src/source.c	2005-04-15 10:58:47 UTC (rev 9140)
+++ icecast/branches/kh/icecast/src/source.c	2005-04-15 16:34:52 UTC (rev 9141)
@@ -813,7 +813,7 @@
     }
     slave_rebuild ();
     thread_mutex_lock (&source->lock);
-    if (source->yp_public)
+    if (source->on_demand == 0 && source->yp_public)
         yp_add (source);
 }
 
@@ -1013,6 +1013,12 @@
     if (mountinfo->bitrate)
         stats_event (source->mount, "bitrate", mountinfo->bitrate);
 
+    if (mountinfo->type)
+        stats_event (source->mount, "server_type", mountinfo->type);
+
+    if (mountinfo->yp_public)
+        source->yp_public = mountinfo->yp_public;
+
     if (mountinfo->auth)
         stats_event (source->mount, "authenticator", mountinfo->auth->type);
     else
@@ -1082,7 +1088,6 @@
 {
     mount_proxy *mountinfo = config_find_mount (config, source->mount);
     char *str;
-    http_parser_t *parser = source->client->parser;
 
     /* set global settings first */
     source->queue_size_limit = config->queue_size_limit;
@@ -1090,50 +1095,54 @@
     source->burst_size = config->burst_size;
     source->dumpfilename = NULL;
     
-    do {
-        str = httpp_getvar(parser, "ice-name");
-        if (str) break;
-        str = httpp_getvar(parser, "icy-name");
-        if (str) break;
-        str = httpp_getvar(parser, "x-audiocast-name");
-    } while (0);
-    stats_event (source->mount, "server_name", str);
+    if  (source->client)
+    {
+        http_parser_t *parser = source->client->parser;
+        do {
+            str = httpp_getvar(parser, "ice-name");
+            if (str) break;
+            str = httpp_getvar(parser, "icy-name");
+            if (str) break;
+            str = httpp_getvar(parser, "x-audiocast-name");
+        } while (0);
+        stats_event (source->mount, "server_name", str);
 
-    do {
-        str = httpp_getvar(parser, "ice-description");
-        if (str) break;
-        str = httpp_getvar(parser, "icy-description");
-        if (str) break;
-        str = httpp_getvar(parser, "x-audiocast-description");
-    } while (0);
-    stats_event (source->mount, "server_description", str);
+        do {
+            str = httpp_getvar(parser, "ice-description");
+            if (str) break;
+            str = httpp_getvar(parser, "icy-description");
+            if (str) break;
+            str = httpp_getvar(parser, "x-audiocast-description");
+        } while (0);
+        stats_event (source->mount, "server_description", str);
 
-    do {
-        str = httpp_getvar(parser, "ice-genre");
-        if (str) break;
-        str = httpp_getvar(parser, "icy-genre");
-        if (str) break;
-        str = httpp_getvar(parser, "x-audiocast-genre");
-    } while (0);
-    stats_event (source->mount, "genre", str);
+        do {
+            str = httpp_getvar(parser, "ice-genre");
+            if (str) break;
+            str = httpp_getvar(parser, "icy-genre");
+            if (str) break;
+            str = httpp_getvar(parser, "x-audiocast-genre");
+        } while (0);
+        stats_event (source->mount, "genre", str);
 
-    do {
-        str = httpp_getvar(parser, "ice-url");
-        if (str) break;
-        str = httpp_getvar(parser, "icy-url");
-        if (str) break;
-        str = httpp_getvar(parser, "x-audiocast-url");
-    } while (0);
-    stats_event (source->mount, "server_url", str);
+        do {
+            str = httpp_getvar(parser, "ice-url");
+            if (str) break;
+            str = httpp_getvar(parser, "icy-url");
+            if (str) break;
+            str = httpp_getvar(parser, "x-audiocast-url");
+        } while (0);
+        stats_event (source->mount, "server_url", str);
 
-    do {
-        str = httpp_getvar(parser, "ice-bitrate");
-        if (str) break;
-        str = httpp_getvar(parser, "icy-br");
-        if (str) break;
-        str = httpp_getvar(parser, "x-audiocast-bitrate");
-    } while (0);
-    stats_event (source->mount, "bitrate", str);
+        do {
+            str = httpp_getvar(parser, "ice-bitrate");
+            if (str) break;
+            str = httpp_getvar(parser, "icy-br");
+            if (str) break;
+            str = httpp_getvar(parser, "x-audiocast-bitrate");
+        } while (0);
+        stats_event (source->mount, "bitrate", str);
+    }
 
     if (mountinfo && source->file_only == 0)
         source_apply_mount (source, mountinfo);

Modified: icecast/branches/kh/icecast/src/yp.c
===================================================================
--- icecast/branches/kh/icecast/src/yp.c	2005-04-15 10:58:47 UTC (rev 9140)
+++ icecast/branches/kh/icecast/src/yp.c	2005-04-15 16:34:52 UTC (rev 9141)
@@ -499,7 +499,7 @@
     ypdata_t *yp;
     char *s;
 
-    if (source->running == 0 || source->yp_public == 0)
+    if ((source->running == 0  && source->on_demand == 0) || source->yp_public == 0)
         return NULL;
     yp = calloc (1, sizeof (ypdata_t));
     do



More information about the commits mailing list