|
View:
New views
1 Messages
—
Rating Filter:
Alert me
|
|
|
[PATCH] libshout - updated patch for kate and skeletonHi,
this is mostly the same as the one I posted previously, but with a modified check for the Kate stream magic to match a proposed common requirement for Ogg codecs. Thanks [libshout-svn-with-kate.diff] diff -x .svn -x '*.o' -x '*.la' -x '*.lo' -x '*.Po' -x .deps -x .libs -x autom4te.cache -x Makefile -x Makefile.in -x configure -x config.log -x config.status -x aclocal.m4 -x config.guess -x config.sub -x libtool -x config.h -x examples -x stamp-h1 -x shout-config -x shout.pc -x depcomp -x missing -x compile -x ltmain.sh -x libtool -x install-sh -x shout.h -x shout-config.in -x config.h.in -urN libshout-svn/configure.ac libshout-svn-with-kate/configure.ac --- libshout-svn/configure.ac 2008-03-10 17:23:45.000000000 +0000 +++ libshout-svn-with-kate/configure.ac 2008-03-18 22:15:15.000000000 +0000 @@ -160,6 +160,25 @@ AC_DEFINE([HAVE_SPEEX], 1, [Define if you want speex streams supported]) fi +AC_ARG_ENABLE([kate], + AC_HELP_STRING([--disable-kate],[do not build with Kate support])) + +if test "x$enable_kate" != "xno"; then + PKG_CHECK_MODULES(KATE, kate oggkate, , + AC_CHECK_LIB(kate, kate_decode_init,[have_kate=yes],[have_kate=no],-logg) + if test "x$have_kate" == "xyes" + then + AC_CHECK_LIB(oggkate, kate_ogg_decode_headerin,[have_kate=yes],[have_kate=no],-lkate -logg) + if test "x$have_kate" == "xyes" + then + KATE_LIBS="-loggkate -lkate -logg" + AC_DEFINE([HAVE_KATE],[1],[Define if you want kate streams supported]) + fi + fi + ) +fi +AM_CONDITIONAL([HAVE_KATE], [test -n "$KATE_LIBS"]) + dnl pkgconfig/shout-config. dnl If pkgconfig is found, use it and disable shout-config, otherwise do the dnl opposite, unless the user overrides. @@ -214,6 +233,8 @@ AC_SUBST(PROFILE) AC_SUBST(XIPH_CFLAGS) AC_SUBST(XIPH_CPPFLAGS) +AC_SUBST(HAVE_KATE) +AC_SUBST(KATE_LIBS) AC_OUTPUT([Makefile debian/Makefile include/Makefile include/shout/Makefile include/shout/shout.h src/Makefile src/net/Makefile src/timing/Makefile diff -x .svn -x '*.o' -x '*.la' -x '*.lo' -x '*.Po' -x .deps -x .libs -x autom4te.cache -x Makefile -x Makefile.in -x configure -x config.log -x config.status -x aclocal.m4 -x config.guess -x config.sub -x libtool -x config.h -x examples -x stamp-h1 -x shout-config -x shout.pc -x depcomp -x missing -x compile -x ltmain.sh -x libtool -x install-sh -x shout.h -x shout-config.in -x config.h.in -urN libshout-svn/src/Makefile.am libshout-svn-with-kate/src/Makefile.am --- libshout-svn/src/Makefile.am 2008-03-10 17:23:46.000000000 +0000 +++ libshout-svn-with-kate/src/Makefile.am 2008-04-09 21:33:29.000000000 +0100 @@ -22,11 +22,11 @@ EXTRA_DIST = theora.c speex.c noinst_HEADERS = shout_ogg.h shout_private.h util.h -libshout_la_SOURCES = shout.c util.c ogg.c vorbis.c mp3.c $(MAYBE_THEORA) $(MAYBE_SPEEX) +libshout_la_SOURCES = shout.c util.c ogg.c vorbis.c kate.c skeleton.c mp3.c $(MAYBE_THEORA) $(MAYBE_SPEEX) AM_CFLAGS = @XIPH_CFLAGS@ libshout_la_LIBADD = net/libicenet.la timing/libicetiming.la avl/libiceavl.la\ - httpp/libicehttpp.la $(MAYBE_THREAD_LIB) $(THEORA_LIBS) $(VORBIS_LIBS) $(SPEEX_LIBS) + httpp/libicehttpp.la $(MAYBE_THREAD_LIB) $(THEORA_LIBS) $(VORBIS_LIBS) $(SPEEX_LIBS) $(KATE_LIBS) INCLUDES = -I$(top_builddir)/include diff -x .svn -x '*.o' -x '*.la' -x '*.lo' -x '*.Po' -x .deps -x .libs -x autom4te.cache -x Makefile -x Makefile.in -x configure -x config.log -x config.status -x aclocal.m4 -x config.guess -x config.sub -x libtool -x config.h -x examples -x stamp-h1 -x shout-config -x shout.pc -x depcomp -x missing -x compile -x ltmain.sh -x libtool -x install-sh -x shout.h -x shout-config.in -x config.h.in -urN libshout-svn/src/kate.c libshout-svn-with-kate/src/kate.c --- libshout-svn/src/kate.c 1970-01-01 01:00:00.000000000 +0100 +++ libshout-svn-with-kate/src/kate.c 2008-06-14 15:53:47.000000000 +0100 @@ -0,0 +1,182 @@ +/* -*- c-basic-offset: 8; -*- */ +/* kate.c: Ogg Kate data handlers for libshout + * $Id: kate.c 11416 2006-05-22 00:32:49Z brendan $ + * + * Copyright (C) 2004 the Icecast team <team@...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#ifdef HAVE_INTTYPES_H +# include <inttypes.h> +#endif + +#include <string.h> + +#ifdef HAVE_KATE +#include <kate/oggkate.h> +#endif + +#include "shout_private.h" +#include "shout_ogg.h" + +/* -- local data structures -- */ +typedef struct { + int headers_done; +#ifdef HAVE_KATE + kate_info ki; + kate_comment kc; +#else + int num_headers; + int granule_shift; + ogg_int32_t num; + ogg_int32_t den; +#endif +} kate_data_t; + +/* -- local prototypes -- */ +static int read_kate_page(ogg_codec_t *codec, ogg_page *page); +static void free_kate_data(void *codec_data); + +/* -- kate functions -- */ +static ogg_int32_t read32le(unsigned char *buffer) +{ + ogg_int32_t v = 0; + v |= buffer[0]; + v |= buffer[1]<<8; + v |= buffer[2]<<16; + v |= buffer[3]<<24; + return v; +} + +int _shout_open_kate(ogg_codec_t *codec, ogg_page *page) +{ + ogg_packet packet; + + kate_data_t *kate_data = calloc(1, sizeof(kate_data_t)); + if (! kate_data) + return SHOUTERR_MALLOC; + + ogg_stream_packetout(&codec->os, &packet); + +#ifdef HAVE_KATE + kate_info_init(&kate_data->ki); + kate_comment_init(&kate_data->kc); + + if (kate_ogg_decode_headerin(&kate_data->ki, &kate_data->kc, &packet) < 0) { + kate_comment_clear(&kate_data->kc); + kate_info_clear(&kate_data->ki); + free_kate_data(kate_data); + + return SHOUTERR_UNSUPPORTED; + } +#else + if (packet.bytes<8 || memcmp(packet.packet, "\x80kate\0\0\0", 8)) { + free_kate_data(kate_data); + + return SHOUTERR_UNSUPPORTED; + } + kate_data->num_headers = packet.packet[11]; +#endif + + codec->codec_data = kate_data; + codec->read_page = read_kate_page; + codec->free_data = free_kate_data; + codec->headers = 1; + + return SHOUTERR_SUCCESS; +} + +static int read_kate_page(ogg_codec_t *codec, ogg_page *page) +{ + kate_data_t *kate_data = codec->codec_data; + ogg_packet packet; + ogg_int64_t granulepos; + + granulepos = ogg_page_granulepos(page); + + if (granulepos == 0) + { + while (ogg_stream_packetout(&codec->os, &packet) > 0) { +#ifdef HAVE_KATE + int ret = kate_ogg_decode_headerin(&kate_data->ki, &kate_data->kc, &packet); + if (ret < 0) + return SHOUTERR_INSANE; + if (ret > 0) + { + kate_data->headers_done = 1; + break; + } +#else + if (packet.bytes<8) + return SHOUTERR_INSANE; + if (memcmp(packet.packet+1, "kate\0\0\0", 7)) + return SHOUTERR_INSANE; + + if (packet.packet[0]==0x80) { + if (packet.bytes<32) + return SHOUTERR_INSANE; + /* retrieve granule encoding information from the BOS packet */ + kate_data->granule_shift = packet.packet[15]; + kate_data->num = read32le(packet.packet+24); + kate_data->den = read32le(packet.packet+28); + } + if (packet.packetno == kate_data->num_headers-1) + { + kate_data->headers_done = 1; + break; + } + +#endif + codec->headers++; + } + + return SHOUTERR_SUCCESS; + } + + while (ogg_stream_packetout(&codec->os, &packet) > 0) + { + /* Kate is a packet per page, so I don't need to do the start frame stuff theora does - I think */ + } + if (granulepos > 0 && kate_data->headers_done) + { +#ifdef HAVE_KATE + double t = kate_granule_time(&kate_data->ki, granulepos); +#else + ogg_int64_t g_base=granulepos>>kate_data->granule_shift; + ogg_int64_t g_offset=granulepos-(g_base<<kate_data->granule_shift); + double t = (g_base+g_offset)*(double)kate_data->den/kate_data->num; +#endif + codec->senttime = (uint64_t)(t * 1000000); + } + + return SHOUTERR_SUCCESS; +} + +static void free_kate_data(void *codec_data) +{ + kate_data_t *kate_data = (kate_data_t *)codec_data; + +#ifdef HAVE_KATE + kate_info_clear(&kate_data->ki); + kate_comment_clear(&kate_data->kc); +#endif + free(kate_data); +} + diff -x .svn -x '*.o' -x '*.la' -x '*.lo' -x '*.Po' -x .deps -x .libs -x autom4te.cache -x Makefile -x Makefile.in -x configure -x config.log -x config.status -x aclocal.m4 -x config.guess -x config.sub -x libtool -x config.h -x examples -x stamp-h1 -x shout-config -x shout.pc -x depcomp -x missing -x compile -x ltmain.sh -x libtool -x install-sh -x shout.h -x shout-config.in -x config.h.in -urN libshout-svn/src/mp3.c libshout-svn-with-kate/src/mp3.c --- libshout-svn/src/mp3.c 2008-03-10 17:23:46.000000000 +0000 +++ libshout-svn-with-kate/src/mp3.c 2008-03-18 22:18:26.000000000 +0000 @@ -204,7 +204,7 @@ end = pos - 1; count = end - start + 1; if (count > 0) - ret = shout_send_raw(self, (char *)&buff[start], count); + ret = shout_send_raw(self, (const unsigned char *)&buff[start], count); else ret = 0; @@ -235,7 +235,7 @@ /* if there's no errors, lets send the frames */ count = end - start + 1; if (count > 0) - ret = shout_send_raw(self, (char *)&buff[start], count); + ret = shout_send_raw(self, (const unsigned char *)&buff[start], count); else ret = 0; diff -x .svn -x '*.o' -x '*.la' -x '*.lo' -x '*.Po' -x .deps -x .libs -x autom4te.cache -x Makefile -x Makefile.in -x configure -x config.log -x config.status -x aclocal.m4 -x config.guess -x config.sub -x libtool -x config.h -x examples -x stamp-h1 -x shout-config -x shout.pc -x depcomp -x missing -x compile -x ltmain.sh -x libtool -x install-sh -x shout.h -x shout-config.in -x config.h.in -urN libshout-svn/src/ogg.c libshout-svn-with-kate/src/ogg.c --- libshout-svn/src/ogg.c 2008-03-10 17:23:46.000000000 +0000 +++ libshout-svn-with-kate/src/ogg.c 2008-04-09 21:26:36.000000000 +0100 @@ -54,6 +54,8 @@ typedef int (*codec_open_t)(ogg_codec_t *codec, ogg_page *page); static codec_open_t codecs[] = { _shout_open_vorbis, + _shout_open_kate, + _shout_open_skeleton, #ifdef HAVE_THEORA _shout_open_theora, #endif diff -x .svn -x '*.o' -x '*.la' -x '*.lo' -x '*.Po' -x .deps -x .libs -x autom4te.cache -x Makefile -x Makefile.in -x configure -x config.log -x config.status -x aclocal.m4 -x config.guess -x config.sub -x libtool -x config.h -x examples -x stamp-h1 -x shout-config -x shout.pc -x depcomp -x missing -x compile -x ltmain.sh -x libtool -x install-sh -x shout.h -x shout-config.in -x config.h.in -urN libshout-svn/src/shout.c libshout-svn-with-kate/src/shout.c --- libshout-svn/src/shout.c 2008-03-10 17:23:46.000000000 +0000 +++ libshout-svn-with-kate/src/shout.c 2008-03-23 15:11:01.000000000 +0000 @@ -1200,7 +1200,7 @@ char *header = NULL; int hlen = 0; int code; - char *retcode; + const char *retcode; #if 0 char *realm; #endif diff -x .svn -x '*.o' -x '*.la' -x '*.lo' -x '*.Po' -x .deps -x .libs -x autom4te.cache -x Makefile -x Makefile.in -x configure -x config.log -x config.status -x aclocal.m4 -x config.guess -x config.sub -x libtool -x config.h -x examples -x stamp-h1 -x shout-config -x shout.pc -x depcomp -x missing -x compile -x ltmain.sh -x libtool -x install-sh -x shout.h -x shout-config.in -x config.h.in -urN libshout-svn/src/shout_ogg.h libshout-svn-with-kate/src/shout_ogg.h --- libshout-svn/src/shout_ogg.h 2008-03-10 17:23:46.000000000 +0000 +++ libshout-svn-with-kate/src/shout_ogg.h 2008-04-09 21:26:49.000000000 +0100 @@ -45,6 +45,8 @@ /* codec hooks */ int _shout_open_vorbis(ogg_codec_t *codec, ogg_page *page); +int _shout_open_kate(ogg_codec_t *codec, ogg_page *page); +int _shout_open_skeleton(ogg_codec_t *codec, ogg_page *page); #ifdef HAVE_THEORA int _shout_open_theora(ogg_codec_t *codec, ogg_page *page); #endif diff -x .svn -x '*.o' -x '*.la' -x '*.lo' -x '*.Po' -x .deps -x .libs -x autom4te.cache -x Makefile -x Makefile.in -x configure -x config.log -x config.status -x aclocal.m4 -x config.guess -x config.sub -x libtool -x config.h -x examples -x stamp-h1 -x shout-config -x shout.pc -x depcomp -x missing -x compile -x ltmain.sh -x libtool -x install-sh -x shout.h -x shout-config.in -x config.h.in -urN libshout-svn/src/skeleton.c libshout-svn-with-kate/src/skeleton.c --- libshout-svn/src/skeleton.c 1970-01-01 01:00:00.000000000 +0100 +++ libshout-svn-with-kate/src/skeleton.c 2008-04-09 21:37:17.000000000 +0100 @@ -0,0 +1,105 @@ +/* -*- c-basic-offset: 8; -*- */ +/* skeleton.c: Ogg Skeleton data handlers for libshout + * $Id: skeleton.c 11416 2006-05-22 00:32:49Z brendan $ + * + * Copyright (C) 2004 the Icecast team <team@...> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#ifdef HAVE_INTTYPES_H +# include <inttypes.h> +#endif + +#include <string.h> + +#include "shout_private.h" +#include "shout_ogg.h" + +/* -- local data structures -- */ +typedef struct { +} skeleton_data_t; + +/* -- local prototypes -- */ +static int read_skeleton_page(ogg_codec_t *codec, ogg_page *page); +static void free_skeleton_data(void *codec_data); + +/* -- skeleton functions -- */ +int _shout_open_skeleton(ogg_codec_t *codec, ogg_page *page) +{ + ogg_packet packet; + + skeleton_data_t *skeleton_data = calloc(1, sizeof(skeleton_data_t)); + if (! skeleton_data) + return SHOUTERR_MALLOC; + + ogg_stream_packetout(&codec->os, &packet); + + if (packet.bytes<8 || memcmp(packet.packet, "fishead\0", 8)) { + free_skeleton_data(skeleton_data); + + return SHOUTERR_UNSUPPORTED; + } + //skeleton_data->num_headers = packet.packet[11]; + + codec->codec_data = skeleton_data; + codec->read_page = read_skeleton_page; + codec->free_data = free_skeleton_data; + codec->headers = 1; + + return SHOUTERR_SUCCESS; +} + +static int read_skeleton_page(ogg_codec_t *codec, ogg_page *page) +{ + skeleton_data_t *skeleton_data = codec->codec_data; + ogg_packet packet; + ogg_int64_t granulepos; + + granulepos = ogg_page_granulepos(page); + + if (granulepos == 0) + { + while (ogg_stream_packetout(&codec->os, &packet) > 0) { + if (packet.bytes==0) + { + // eos + break; + } + if (packet.bytes<8) + return SHOUTERR_INSANE; + if (memcmp(packet.packet+1, "fisbone\0", 8)) + return SHOUTERR_INSANE; + + codec->headers++; + } + + return SHOUTERR_SUCCESS; + } + + return SHOUTERR_SUCCESS; +} + +static void free_skeleton_data(void *codec_data) +{ + skeleton_data_t *skeleton_data = (skeleton_data_t *)codec_data; + + free(skeleton_data); +} + _______________________________________________ Icecast-dev mailing list Icecast-dev@... http://lists.xiph.org/mailman/listinfo/icecast-dev |
| Free Forum Powered by Nabble | Forum Help |