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

karl at motherfish-iii.xiph.org karl at motherfish-iii.xiph.org
Wed Oct 27 17:13:59 PDT 2004


Author: karl
Date: 2004-10-27 17:13:59 -0700 (Wed, 27 Oct 2004)
New Revision: 8126

Modified:
   icecast/branches/kh/icecast/src/format_vorbis.c
Log:
add missing stats (and YP) update when url comments supplied


Modified: icecast/branches/kh/icecast/src/format_vorbis.c
===================================================================
--- icecast/branches/kh/icecast/src/format_vorbis.c	2004-10-27 17:54:20 UTC (rev 8125)
+++ icecast/branches/kh/icecast/src/format_vorbis.c	2004-10-28 00:13:59 UTC (rev 8126)
@@ -408,12 +408,32 @@
     return 1;
 }
 
+static void update_stats (source_t *source, vorbis_comment *vc)
+{
+    char *tag;
+    /* put known comments in the stats, this could be site specific */
+    tag = vorbis_comment_query (vc, "TITLE", 0);
+    if (tag == NULL)
+        tag = "unknown";
+    else
+        INFO1 ("title set to \"%s\"", tag);
+    stats_event (source->mount, "title", tag);
 
+    tag = vorbis_comment_query (vc, "ARTIST", 0);
+    if (tag)
+    {
+        INFO1 ("artist set to \"%s\"", tag);
+        stats_event (source->mount, "artist", tag);
+    }
+    else
+        stats_event (source->mount, "artist", NULL);
+}
+
+
 /* this is called with the first page after the initial header */
 /* it processes any headers that have come in on the stream */
 static int process_vorbis_incoming_hdrs (source_t *source)
 {
-    char *tag;
     ogg_packet header;
     vstate_t *source_vorbis = source->format->_state;
 
@@ -440,21 +460,8 @@
 
     /* we have all headers */
 
-    /* put known comments in the stats, this could be site specific */
-    tag = vorbis_comment_query (&source_vorbis->vc, "TITLE", 0);
-    if (tag == NULL)
-        tag = "unknown";
-    else
-        INFO1 ("title set to \"%s\"", tag);
-    stats_event (source->mount, "title", tag);
+    update_stats (source, &source_vorbis->vc);
 
-    tag = vorbis_comment_query (&source_vorbis->vc, "ARTIST", 0);
-    if (tag == NULL)
-        tag = "unknown";
-    else
-        INFO1 ("artist set to \"%s\"", tag);
-    stats_event (source->mount, "artist", tag);
-
     stats_event_args (source->mount, "audio-samplerate", "%ld", (long)source_vorbis->vi.rate);
     stats_event_args (source->mount, "audio-channels", "%ld", (long)source_vorbis->vi.channels);
     stats_event_args (source->mount, "audio-bitrate", "%ld", (long)source_vorbis->vi.bitrate_nominal);
@@ -556,6 +563,17 @@
             change = 1;
         }
     }
+    if (strcmp (tag, "song") == 0)
+    {
+        char *p = strdup (value);
+        if (p)
+        {
+            free (source_vorbis->url_artist);
+            free (source_vorbis->url_title);
+            source_vorbis->url_title = p;
+            change = 1;
+        }
+    }
     if (change)
         source_vorbis->stream_notify = 1;
 }
@@ -577,6 +595,7 @@
         vorbis_comment_add_tag (&vc, "title", source_vorbis->url_title);
     vorbis_comment_add (&vc, "server=" ICECAST_VERSION_STRING);
     ogg_packet_clear (&source_vorbis->url_comment);
+    update_stats (source, &vc);
     vorbis_commentheader_out (&vc, &source_vorbis->url_comment);
     vorbis_comment_clear (&vc);
     header.packetno = 1;



More information about the commits mailing list