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

karl at motherfish-iii.xiph.org karl at motherfish-iii.xiph.org
Thu Apr 7 20:44:29 PDT 2005


Author: karl
Date: 2005-04-07 20:44:25 -0700 (Thu, 07 Apr 2005)
New Revision: 9125

Modified:
   icecast/branches/kh/icecast/src/auth.c
   icecast/branches/kh/icecast/src/cfgfile.c
   icecast/branches/kh/icecast/src/cfgfile.h
   icecast/branches/kh/icecast/src/source.c
   icecast/branches/kh/icecast/src/yp.c
Log:
allow for per-mount override of stream details - stream-name,
stream-description, stream-url,genre and bitrate


Modified: icecast/branches/kh/icecast/src/auth.c
===================================================================
--- icecast/branches/kh/icecast/src/auth.c	2005-04-07 17:53:28 UTC (rev 9124)
+++ icecast/branches/kh/icecast/src/auth.c	2005-04-08 03:44:25 UTC (rev 9125)
@@ -467,7 +467,8 @@
             next_option = &opt->next;
         }
         else
-            WARN1 ("unknown auth setting (%s)", current->name);
+            if (strcmp (current->name, "text") != 0)
+                WARN1 ("unknown auth setting (%s)", current->name);
     }
     auth->type = xmlGetProp (node, "type");
     get_authenticator (auth, options);

Modified: icecast/branches/kh/icecast/src/cfgfile.c
===================================================================
--- icecast/branches/kh/icecast/src/cfgfile.c	2005-04-07 17:53:28 UTC (rev 9124)
+++ icecast/branches/kh/icecast/src/cfgfile.c	2005-04-08 03:44:25 UTC (rev 9125)
@@ -642,6 +642,26 @@
             tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
             mount->cluster_password = (char *)xmlNodeListGetString(
                     doc, node->xmlChildrenNode, 1);
+        } else if (strcmp(node->name, "stream-name") == 0) {
+            tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
+            mount->stream_name = (char *)xmlNodeListGetString(
+                    doc, node->xmlChildrenNode, 1);
+        } else if (strcmp(node->name, "stream-description") == 0) {
+            tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
+            mount->stream_description = (char *)xmlNodeListGetString(
+                    doc, node->xmlChildrenNode, 1);
+        } else if (strcmp(node->name, "stream-url") == 0) {
+            tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
+            mount->stream_url = (char *)xmlNodeListGetString(
+                    doc, node->xmlChildrenNode, 1);
+        } else if (strcmp(node->name, "genre") == 0) {
+            tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
+            mount->stream_genre = (char *)xmlNodeListGetString(
+                    doc, node->xmlChildrenNode, 1);
+        } else if (strcmp(node->name, "bitrate") == 0) {
+            tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
+            mount->bitrate = (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-07 17:53:28 UTC (rev 9124)
+++ icecast/branches/kh/icecast/src/cfgfile.h	2005-04-08 03:44:25 UTC (rev 9125)
@@ -73,6 +73,12 @@
     char *on_connect;
     char *on_disconnect;
 
+    char *stream_name;
+    char *stream_description;
+    char *stream_url;
+    char *stream_genre;
+    char *bitrate;
+
     struct _mount_proxy *next;
 } mount_proxy;
 

Modified: icecast/branches/kh/icecast/src/source.c
===================================================================
--- icecast/branches/kh/icecast/src/source.c	2005-04-07 17:53:28 UTC (rev 9124)
+++ icecast/branches/kh/icecast/src/source.c	2005-04-08 03:44:25 UTC (rev 9125)
@@ -752,22 +752,8 @@
     } while (0);
     source->yp_public = atoi (str);
     stats_event (source->mount, "public", str);
+    stats_event (source->mount, "server_type", source->format->contenttype);
 
-    str = httpp_getvar(source->parser, "ice-genre");
-    if (str == NULL)
-        str = httpp_getvar(source->parser, "icy-genre");
-    stats_event (source->mount, "genre", str);
-
-    str = httpp_getvar(source->parser, "ice-description");
-    if (str == NULL)
-        str = httpp_getvar(source->parser, "icy-description");
-    stats_event (source->mount, "server_description", str);
-
-    str = httpp_getvar(source->parser, "ice-name");
-    if (str == NULL)
-        str = httpp_getvar(source->parser, "icy-name");
-    stats_event (source->mount, "server_name", str);
-
     if (source->dumpfilename != NULL)
     {
         source->dumpfile = fopen (source->dumpfilename, "ab");
@@ -1009,6 +995,8 @@
 
 static void source_apply_mount (source_t *source, mount_proxy *mountinfo)
 {
+    char *str;
+
     if (strcmp (mountinfo->mountname, source->mount) == 0)
         INFO1 ("Applying mount information for \"%s\"", source->mount);
     else
@@ -1019,6 +1007,46 @@
     source->no_mount = mountinfo->no_mount;
     source->hidden = mountinfo->hidden;
 
+    do
+    {
+        str = mountinfo->stream_name;
+        if (str) break;
+        str = httpp_getvar(source->parser, "ice-name");
+        if (str) break;
+        str = httpp_getvar(source->parser, "icy-name");
+    } while (0);
+    stats_event (source->mount, "server_name", str);
+
+    do
+    {
+        str = mountinfo->stream_description;
+        if (str) break;
+        str = httpp_getvar(source->parser, "ice-description");
+        if (str) break;
+        str = httpp_getvar(source->parser, "icy-description");
+    } while (0);
+    stats_event (source->mount, "server_description", str);
+
+    do
+    {
+        str = mountinfo->stream_genre;
+        if (str) break;
+        str = httpp_getvar(source->parser, "ice-genre");
+        if (str) break;
+        str = httpp_getvar(source->parser, "icy-genre");
+    } while (0);
+    stats_event (source->mount, "genre", str);
+
+    do
+    {
+        str = mountinfo->bitrate;
+        if (str) break;
+        str = httpp_getvar(source->parser, "ice-bitrate");
+        if (str) break;
+        str = httpp_getvar(source->parser, "icy-br");
+    } while (0);
+    stats_event (source->mount, "bitrate", str);
+
     if (mountinfo->auth)
         stats_event (source->mount, "authenticator", mountinfo->auth->type);
     else

Modified: icecast/branches/kh/icecast/src/yp.c
===================================================================
--- icecast/branches/kh/icecast/src/yp.c	2005-04-07 17:53:28 UTC (rev 9124)
+++ icecast/branches/kh/icecast/src/yp.c	2005-04-08 03:44:25 UTC (rev 9125)
@@ -92,7 +92,7 @@
 static thread_type *yp_thread;
 
 static void *yp_update_thread(void *arg);
-static void add_yp_info (ypdata_t *yp, char *stat_name, void *info, int type);
+static void add_yp_info (ypdata_t *yp, void *info, int type);
 static unsigned do_yp_remove (ypdata_t *yp, char *s, unsigned len);
 static unsigned do_yp_add (ypdata_t *yp, char *s, unsigned len);
 static unsigned do_yp_touch (ypdata_t *yp, char *s, unsigned len);
@@ -347,7 +347,7 @@
     value = stats_get_value (yp->mount, "subtype");
     if (value)
     {
-        add_yp_info (yp, "subtype", value, YP_SUBTYPE);
+        add_yp_info (yp, value, YP_SUBTYPE);
         free (value);
     }
 
@@ -392,7 +392,8 @@
          if (song)
          {
              sprintf (song, "%s%s%s", artist, separator, title);
-             add_yp_info(yp, "yp_currently_playing", song, YP_CURRENT_SONG);
+             add_yp_info(yp, song, YP_CURRENT_SONG);
+             stats_event (yp->mount, "yp_currently_playing", song);
              free (song);
          }
     }
@@ -414,7 +415,7 @@
     val = stats_get_value (yp->mount, "subtype");
     if (val)
     {
-        add_yp_info (yp, "subtype", val, YP_SUBTYPE);
+        add_yp_info (yp, val, YP_SUBTYPE);
         free (val);
     }
 
@@ -528,8 +529,7 @@
         while (mountproxy) {
             if (strcmp (mountproxy->mountname, source->mount) == 0) {
                 if (mountproxy->cluster_password) {
-                    add_yp_info (yp, "cluster_password", 
-                            mountproxy->cluster_password, YP_CLUSTER_PASSWORD);
+                    add_yp_info (yp, mountproxy->cluster_password, YP_CLUSTER_PASSWORD);
                 }
                 break;
             }
@@ -542,37 +542,30 @@
             break;
 
         /* ice-* is icecast, icy-* is shoutcast */
-        add_yp_info (yp, "server_type", source->format->contenttype, YP_SERVER_TYPE);
-        if ((s = httpp_getvar(source->parser, "ice-name"))) {
-            add_yp_info (yp, "server_name", s, YP_SERVER_NAME);
-        }
-        if ((s = httpp_getvar(source->parser, "icy-name"))) {
-            add_yp_info (yp, "server_name", s, YP_SERVER_NAME);
-        }
-        if ((s = httpp_getvar(source->parser, "ice-url"))) {
-            add_yp_info(yp, "server_url", s, YP_SERVER_URL);
-        }
-        if ((s = httpp_getvar(source->parser, "icy-url"))) {
-            add_yp_info(yp, "server_url", s, YP_SERVER_URL);
-        }
-        if ((s = httpp_getvar(source->parser, "ice-genre"))) {
-            add_yp_info(yp, "genre", s, YP_SERVER_GENRE);
-        }
-        if ((s = httpp_getvar(source->parser, "icy-genre"))) {
-            add_yp_info(yp, "genre", s, YP_SERVER_GENRE);
-        }
-        if ((s = httpp_getvar(source->parser, "ice-bitrate"))) {
-            add_yp_info(yp, "bitrate", s, YP_BITRATE);
-        }
-        if ((s = httpp_getvar(source->parser, "icy-br"))) {
-            add_yp_info(yp, "bitrate", s, YP_BITRATE);
-        }
-        if ((s = httpp_getvar(source->parser, "ice-description"))) {
-            add_yp_info(yp, "server_description", s, YP_SERVER_DESC);
-        }
+        add_yp_info (yp, source->format->contenttype, YP_SERVER_TYPE);
+
+        s = stats_get_value (yp->mount, "server_name");
+        add_yp_info (yp, s, YP_SERVER_NAME);
+        free (s);
+
+        s = stats_get_value (yp->mount, "server_url");
+        add_yp_info (yp, s, YP_SERVER_URL);
+        free (s);
+
+        s = stats_get_value (yp->mount, "genre");
+        add_yp_info (yp, s, YP_SERVER_GENRE);
+        free (s);
+
+        s = stats_get_value (yp->mount, "bitrate");
+        add_yp_info (yp, s, YP_BITRATE);
+        free (s);
+
+        s = stats_get_value (yp->mount, "stream_description");
+        add_yp_info (yp, s, YP_SERVER_DESC);
+
         s = util_dict_urlencode (source->audio_info, '&');
         if (s)
-            add_yp_info (yp, "audio_info", s, YP_AUDIO_INFO);
+            add_yp_info (yp, s, YP_AUDIO_INFO);
         free(s);
         return yp;
     } while (0);
@@ -782,7 +775,7 @@
     }
 }
 
-static void add_yp_info (ypdata_t *yp, char *stat_name, void *info, int type)
+static void add_yp_info (ypdata_t *yp, void *info, int type)
 {
     char *escaped;
 
@@ -798,7 +791,6 @@
                 if (yp->server_name)
                     free (yp->server_name);
                 yp->server_name = escaped;
-                stats_event (yp->mount, stat_name, (char *)info);
             }
             break;
         case YP_SERVER_DESC:
@@ -808,7 +800,6 @@
                 if (yp->server_desc)
                     free (yp->server_desc);
                 yp->server_desc = escaped;
-                stats_event(yp->mount, stat_name, (char *)info);
             }
             break;
         case YP_SERVER_GENRE:
@@ -818,7 +809,6 @@
                 if (yp->server_genre)
                     free (yp->server_genre);
                 yp->server_genre = escaped;
-                stats_event (yp->mount, stat_name, (char *)info);
             }
             break;
         case YP_SERVER_URL:
@@ -828,7 +818,6 @@
                 if (yp->url)
                     free (yp->url);
                 yp->url = escaped;
-                stats_event (yp->mount, stat_name, (char *)info);
             }
             break;
         case YP_BITRATE:
@@ -838,7 +827,6 @@
                 if (yp->bitrate)
                     free (yp->bitrate);
                 yp->bitrate = escaped;
-                stats_event (yp->mount, stat_name, (char *)info);
             }
             break;
         case YP_AUDIO_INFO:
@@ -862,7 +850,6 @@
                 if (yp->current_song)
                     free (yp->current_song);
                 yp->current_song = escaped;
-                stats_event (yp->mount, "yp_currently_playing", (char *)info);
             }
             break;
         case YP_CLUSTER_PASSWORD:



More information about the commits mailing list