[Icecast-dev] [PATCH] icecast video preview

kysucix kysucix at dyne.org
Fri Nov 11 09:09:00 PST 2005


Ops! I forgot it! Here it is.
bye :)
kysucix
-------------- next part --------------
Index: conf/icecast.xml.in
===================================================================
--- conf/icecast.xml.in	(revisione 10355)
+++ conf/icecast.xml.in	(copia locale)
@@ -62,6 +62,7 @@
         <port>8001</port>
     </listen-socket>
     -->
+    <video-preview>1</video-preview>
 
     <!--<master-server>127.0.0.1</master-server>-->
     <!--<master-server-port>8001</master-server-port>-->
Index: configure.in
===================================================================
--- configure.in	(revisione 10355)
+++ configure.in	(copia locale)
@@ -50,6 +50,33 @@
 
 dnl Checks for libraries.
 
+AC_ARG_WITH(png,
+	    [  --with-png[[=path]]       Use libpng to preview files (default=yes)],
+	    if test "$withval" = "yes"; then
+		    extrapath=default
+	    elif test "$withval" = "no"; then
+		    extrapath=
+	    else
+		    extrapath=$withval
+	    fi,
+	    extrapath=default)
+
+if test -n "$extrapath"; then
+  if test "$extrapath" != default; then
+dnl    CFLAGS="$CPPFLAGS -I$extrapath/include"
+    LIBS="$LIBS -L$extrapath/lib"
+  fi
+  AC_CHECK_HEADER(png.h,
+    [AC_CHECK_LIB(png, png_libpng_ver,
+        [AC_DEFINE(WITH_PNG,
+                   1,
+                   [Define as 1 if you want to enable generation of PNGs])]
+	ICECAST_OPTIONAL="$ICECAST_OPTIONAL video_preview.o"
+         LIBS="$LIBS -lpng -lz",
+        echo "png library not found or too old -- not including PNG support",
+        -lz)])
+fi
+
 dnl Checks for header files.
 AC_HEADER_STDC
 
Index: src/format_theora.c
===================================================================
--- src/format_theora.c	(revisione 10355)
+++ src/format_theora.c	(copia locale)
@@ -12,7 +12,6 @@
 
 
 /* Ogg codec handler for theora logical streams */
-
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -28,11 +27,12 @@
 #include "format_theora.h"
 #include "client.h"
 #include "stats.h"
+#include "video_preview.h"
 
 #define CATMODULE "format-theora"
 #include "logging.h"
+#include <png.h>
 
-
 typedef struct _theora_codec_tag
 {
     theora_info     ti;
@@ -40,9 +40,14 @@
     int             granule_shift;
     ogg_int64_t     last_iframe;
     ogg_int64_t     prev_granulepos;
+#ifdef WITH_PNG
+    theora_state    td;
+    video_preview_t *video_preview;
+    yuv_buffer      yuv;
+    unsigned short int first_time;
+#endif
 } theora_codec_t;
 
-
 static void theora_codec_free (ogg_state_t *ogg_info, ogg_codec_t *codec)
 {
     theora_codec_t *theora = codec->specific;
@@ -50,8 +55,17 @@
     DEBUG0 ("freeing theora codec");
     stats_event (ogg_info->mount, "video_bitrate", NULL);
     stats_event (ogg_info->mount, "video_quality", NULL);
+#ifdef WITH_PNG
+    stats_event (ogg_info->mount, "video_preview", NULL);
+#endif 
     stats_event (ogg_info->mount, "frame_rate", NULL);
     stats_event (ogg_info->mount, "frame_size", NULL);
+
+
+#ifdef WITH_PNG
+    free_video_preview (theora -> video_preview);
+    theora_clear(&theora -> td);
+#endif
     theora_info_clear (&theora->ti);
     theora_comment_clear (&theora->tc);
     ogg_stream_clear (&codec->os);
@@ -112,8 +126,24 @@
             ERROR0 ("Not enough header packets");
             return NULL;
         }
-        if (theora_packet_iskeyframe (&packet))
-            has_keyframe = 1;
+        if (theora_packet_iskeyframe (&packet)) {
+#ifdef WITH_PNG
+		if(config_get_config()->video_preview == 1 ) {
+			config_release_config();
+			if (theora ->  first_time == 0)
+				theora_decode_init (&theora->td, &theora-> ti);
+
+			theora_decode_packetin (&theora->td, &packet);
+			theora_decode_YUVout   (&theora->td, &theora -> yuv);
+
+			write_video_preview (&theora -> yuv, theora -> video_preview);
+			theora -> first_time++;
+
+		}
+#endif
+		has_keyframe = 1;
+	}
+
     }
     if (header_page)
     {
@@ -179,6 +209,12 @@
     codec->headers = 1;
     codec->name = "Theora";
 
+#ifdef WITH_PNG
+    theora_info *ti = &theora_codec->ti;
+    init_video_preview(ogg_info->mount, ti->width, ti->height, ti -> offset_x, ti -> offset_y , &theora_codec -> video_preview);
+    theora_codec -> first_time = 0;
+#endif
+
     format_ogg_attach_header (ogg_info, page);
     ogg_info->codec_sync = codec;
     return codec;
Index: src/cfgfile.c
===================================================================
--- src/cfgfile.c	(revisione 10355)
+++ src/cfgfile.c	(copia locale)
@@ -53,6 +53,7 @@
 #define CONFIG_DEFAULT_CHUID 0
 #define CONFIG_DEFAULT_USER NULL
 #define CONFIG_DEFAULT_GROUP NULL
+#define CONFIG_DEFAULT_VIDEO_PREVIEW 1
 #define CONFIG_MASTER_UPDATE_INTERVAL 120
 #define CONFIG_YP_URL_TIMEOUT 10
 
@@ -375,6 +376,7 @@
     configuration->relay_password = NULL;
     /* default to a typical prebuffer size used by clients */
     configuration->burst_size = CONFIG_DEFAULT_BURST_SIZE;
+    configuration->video_preview = CONFIG_DEFAULT_VIDEO_PREVIEW;
 }
 
 static void _parse_root(xmlDocPtr doc, xmlNodePtr node, 
@@ -422,6 +424,10 @@
             configuration->hostname = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
         } else if (strcmp(node->name, "listen-socket") == 0) {
             _parse_listen_socket(doc, node->xmlChildrenNode, configuration);
+        } else if (strcmp(node->name, "video-preview") == 0) {
+		tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
+		configuration->video_preview = atoi(tmp);
+            if (tmp) xmlFree(tmp);
         } else if (strcmp(node->name, "port") == 0) {
             tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
             configuration->port = atoi(tmp);
Index: src/format_theora.h
===================================================================
--- src/format_theora.h	(revisione 10355)
+++ src/format_theora.h	(copia locale)
@@ -14,6 +14,7 @@
 #ifndef __FORMAT_THEORA_H
 #define __FORMAT_THEORA_H
 
+#include <theora/theora.h>
 #include "format_ogg.h"
 
 ogg_codec_t *initial_theora_page (format_plugin_t *plugin, ogg_page *page);
Index: src/cfgfile.h
===================================================================
--- src/cfgfile.h	(revisione 10355)
+++ src/cfgfile.h	(copia locale)
@@ -118,6 +118,7 @@
     int ice_login;
     int fileserve;
     int on_demand; /* global setting for all relays */
+    unsigned int video_preview;
 
     char *shoutcast_mount;
     char *source_password;
Index: src/Makefile.am
===================================================================
--- src/Makefile.am	(revisione 10355)
+++ src/Makefile.am	(copia locale)
@@ -7,11 +7,12 @@
 bin_PROGRAMS = icecast
 
 noinst_HEADERS = admin.h cfgfile.h os.h logging.h sighandler.h connection.h \
-    global.h util.h slave.h source.h stats.h refbuf.h client.h \
+    global.h util.h slave.h source.h stats.h refbuf.h client.h format.h \
     compat.h fserve.h xslt.h yp.h event.h md5.h \
     auth.h auth_htpasswd.h auth_url.h \
     format.h format_ogg.h format_mp3.h \
-    format_vorbis.h format_theora.h format_flac.h format_speex.h format_midi.h
+    format_vorbis.h format_theora.h format_flac.h format_speex.h format_midi.h \
+    video_preview.h
 icecast_SOURCES = cfgfile.c main.c logging.c sighandler.c connection.c global.c \
     util.c slave.c source.c stats.c refbuf.c client.c \
     xslt.c fserve.c event.c admin.c md5.c \
@@ -19,7 +20,7 @@
     auth.c auth_htpasswd.c
 EXTRA_icecast_SOURCES = yp.c \
     auth_url.c \
-    format_vorbis.c format_theora.c format_speex.c
+    format_vorbis.c format_theora.c format_speex.c video_preview.c
     
 icecast_DEPENDENCIES = @ICECAST_OPTIONAL@ net/libicenet.la thread/libicethread.la \
     httpp/libicehttpp.la log/libicelog.la avl/libiceavl.la timing/libicetiming.la
Index: web/status.xsl
===================================================================
--- web/status.xsl	(revisione 10365)
+++ web/status.xsl	(copia locale)
@@ -94,6 +94,16 @@
 <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>
+<xsl:if test="video_preview">
+<xsl:choose>
+<xsl:when test="authenticator">
+<tr><td>Preview:</td><td class="videopreview"> <a href="auth.xsl"><img src="{video_preview}" border="1" align="left" alt="frame preview" title="click to start watching the video!" /></a></td></tr>
+</xsl:when>
+<xsl:otherwise>
+<tr><td>Preview:</td><td class="videopreview"> <a href="{@mount}.mp3"><img src="{video_preview}" border="1" align="left" alt="frame preview" title="click to start watching the video!" /></a></td></tr>
+</xsl:otherwise>
+</xsl:choose>
+</xsl:if>
 <tr><td>Current Song:</td><td class="streamdata"> 
 <xsl:if test="artist"><xsl:value-of select="artist" /> - </xsl:if><xsl:value-of select="title" /></td></tr>
 </table>


More information about the Icecast-dev mailing list