[Icecast-dev] Adding additional mount info to xsl stylesheet

Byron Young bky at bkyoung.com
Mon Dec 10 20:18:03 PST 2012


The following patch attempts to make the source client user agent and
the max listener client connection duration information available to
(icecast 2.3.2) xsl stylesheets. Will there be any memory leak issues in
the lower level functions like the acl, etc. when the source is
disconnected, when servicing queries, or otherwise?

BEGIN icecast-2.3.2-moremntinfo.patch
diff --git src/source.c src/source.c
index 02bfc74..7e90d34 100644
--- src/source.c
+++ src/source.c
@@ -614,6 +614,10 @@ static void source_init (source_t *source)
     stats_event_args (source->mount, "listeners", "%lu",
source->listeners);
     stats_event_args (source->mount, "listener_peak", "%lu",
source->peak_listeners);
     stats_event_time (source->mount, "stream_start");
+    stats_event_args (source->mount, "max_listener_duration", "%lu",
source->max_listener_duration);
+
+    const char * user_agent = httpp_getvar (source->client->parser,
"user-agent");
+    stats_event_args (source->mount, "user-agent", "%s", user_agent);
 
     DEBUG0("Source creation complete");
     source->last_read = time (NULL);
@@ -947,6 +951,8 @@ static void source_apply_mount (source_t *source,
mount_proxy *mountinfo)
         source->max_listeners = mountinfo->max_listeners;
         source->fallback_override = mountinfo->fallback_override;
         source->hidden = mountinfo->hidden;
+	source->max_listener_duration = mountinfo->max_listener_duration;
+	source->user_agent = httpp_getvar (source->client->parser,
"user-agent");
     }
 
     /* if a setting is available in the mount details then use it, else
diff --git src/source.h src/source.h
index 7a526a0..9416222 100644
--- src/source.h
+++ src/source.h
@@ -52,6 +52,9 @@ typedef struct source_tag
     unsigned long peak_listeners;
     unsigned long listeners;
     unsigned long prev_listeners;
+    unsigned long max_listener_duration;
+    const char * user_agent;
+
     long max_listeners;
     int yp_public;
     int fallback_override;
diff --git web/status.xsl web/status.xsl
index b7049a2..9a46945 100644
--- web/status.xsl
+++ web/status.xsl
@@ -92,6 +92,24 @@
 <xsl:if test="genre">
 <tr><td>Stream Genre:</td><td class="streamdata"> <xsl:value-of
select="genre" /></td></tr>
 </xsl:if>
+
+<xsl:if test="user-agent">
+<tr><td>Source:</td><td class="streamdata"> <xsl:value-of
select="user-agent" /></td></tr>
+</xsl:if>
+
+<xsl:if test="max_listener_duration">
+ <tr><td>Max Listener Connect Time:</td><td class="streamdata">
+ <xsl:choose>
+   <xsl:when test="max_listener_duration = 0">
+     Unlimited
+   </xsl:when>
+   <xsl:otherwise>
+     <xsl:value-of select="max_listener_duration" /> (seconds)
+     </xsl:otherwise>
+ </xsl:choose>
+ </td></tr>
+</xsl:if>
+
 <xsl:if test="server_url">
 <tr><td>Stream URL:</td><td class="streamdata"> <a target="_blank"
href="{server_url}"><xsl:value-of select="server_url" /></a></td></tr>
 </xsl:if>
END icecast-2.3.2-moremntinfo.patch




More information about the Icecast-dev mailing list