[xiph-commits] r10533 - in icecast/trunk/libshout: . src
brendan at svn.xiph.org
brendan at svn.xiph.org
Sat Dec 3 18:49:41 PST 2005
Author: brendan
Date: 2005-12-03 18:49:34 -0800 (Sat, 03 Dec 2005)
New Revision: 10533
Added:
icecast/trunk/libshout/src/speex.c
Modified:
icecast/trunk/libshout/configure.ac
icecast/trunk/libshout/src/Makefile.am
icecast/trunk/libshout/src/ogg.c
icecast/trunk/libshout/src/shout_ogg.h
Log:
William Volkman's speex support patch.
Modified: icecast/trunk/libshout/configure.ac
===================================================================
--- icecast/trunk/libshout/configure.ac 2005-12-03 20:32:10 UTC (rev 10532)
+++ icecast/trunk/libshout/configure.ac 2005-12-04 02:49:34 UTC (rev 10533)
@@ -130,8 +130,26 @@
])
XIPH_VAR_APPEND([XIPH_CPPFLAGS],[$THEORA_CFLAGS])
XIPH_VAR_PREPEND([XIPH_LIBS],[$THEORA LDFLAGS $THEORA_LIBS])
-AM_CONDITIONAL(HAVE_THEORA, test -n "$THEORA_LIBS")
+AM_CONDITIONAL([HAVE_THEORA], [test -n "$THEORA_LIBS"])
+if test -n "$THEORA_LIBS"
+then
+ AC_DEFINE([HAVE_THEORA], 1, [Define if you want theora streams supported])
+fi
+PKG_CHECK_MODULES(SPEEX, speex, [
+ HAVE_SPEEX="yes"
+ SHOUT_REQUIRES="$SHOUT_REQUIRES, speex"
+ ], [
+ XIPH_PATH_SPEEX(, [AC_MSG_WARN([Speex library not found, disabling])])
+ ])
+XIPH_VAR_APPEND([XIPH_CPPFLAGS],[$SPEEX_CFLAGS])
+XIPH_VAR_PREPEND([XIPH_LIBS],[$SPEEX LDFLAGS $SPEEX_LIBS])
+AM_CONDITIONAL([HAVE_SPEEX], [test -n "$SPEEX_LIBS"])
+if test -n "$SPEEX_LIBS"
+then
+ AC_DEFINE([HAVE_SPEEX], 1, [Define if you want speex streams supported])
+fi
+
dnl pkgconfig/shout-config.
dnl If pkgconfig is found, use it and disable shout-config, otherwise do the
dnl opposite, unless the user overrides.
@@ -167,7 +185,7 @@
XIPH_CLEAN_CCFLAGS([$SHOUT_CPPFLAGS], [SHOUT_CPPFLAGS])
XIPH_CLEAN_CCFLAGS([$SHOUT_CFLAGS], [SHOUT_CFLAGS])
-XIPH_CLEAN_CCFLAGS([$VORBIS_LIBS $THEORA_LIBS $PTHREAD_LIBS $LIBS], [SHOUT_LIBDEPS])
+XIPH_CLEAN_CCFLAGS([$VORBIS_LIBS $THEORA_LIBS $SPEEX_LIBS $PTHREAD_LIBS $LIBS], [SHOUT_LIBDEPS])
AC_SUBST(PTHREAD_CPPFLAGS)
AC_SUBST(SHOUT_LIBDEPS)
AC_SUBST(SHOUT_REQUIRES)
Modified: icecast/trunk/libshout/src/Makefile.am
===================================================================
--- icecast/trunk/libshout/src/Makefile.am 2005-12-03 20:32:10 UTC (rev 10532)
+++ icecast/trunk/libshout/src/Makefile.am 2005-12-04 02:49:34 UTC (rev 10533)
@@ -11,14 +11,18 @@
MAYBE_THEORA = theora.c
endif
+if HAVE_SPEEX
+ MAYBE_SPEEX = speex.c
+endif
+
SUBDIRS = avl net timing httpp $(MAYBE_THREAD)
lib_LTLIBRARIES = libshout.la
libshout_la_LDFLAGS = -version-info 4:0:1
-EXTRA_DIST = theora.c
+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)
+libshout_la_SOURCES = shout.c util.c ogg.c vorbis.c mp3.c $(MAYBE_THEORA) $(MAYBE_SPEEX)
AM_CFLAGS = @XIPH_CFLAGS@
libshout_la_LIBADD = net/libicenet.la timing/libicetiming.la avl/libiceavl.la\
Modified: icecast/trunk/libshout/src/ogg.c
===================================================================
--- icecast/trunk/libshout/src/ogg.c 2005-12-03 20:32:10 UTC (rev 10532)
+++ icecast/trunk/libshout/src/ogg.c 2005-12-04 02:49:34 UTC (rev 10533)
@@ -53,6 +53,9 @@
#ifdef HAVE_THEORA
_shout_open_theora,
#endif
+#ifdef HAVE_SPEEX
+ _shout_open_speex,
+#endif
NULL
};
@@ -140,14 +143,14 @@
static int open_codec(ogg_codec_t *codec, ogg_page *page)
{
- codec_open_t open_codec;
+ codec_open_t this_codec;
int i = 0;
- while ((open_codec = codecs[i])) {
+ while ((this_codec = codecs[i])) {
ogg_stream_init(&codec->os, ogg_page_serialno(page));
ogg_stream_pagein(&codec->os, page);
- if (open_codec(codec, page) == SHOUTERR_SUCCESS)
+ if (this_codec(codec, page) == SHOUTERR_SUCCESS)
return SHOUTERR_SUCCESS;
ogg_stream_clear(&codec->os);
Modified: icecast/trunk/libshout/src/shout_ogg.h
===================================================================
--- icecast/trunk/libshout/src/shout_ogg.h 2005-12-03 20:32:10 UTC (rev 10532)
+++ icecast/trunk/libshout/src/shout_ogg.h 2005-12-04 02:49:34 UTC (rev 10533)
@@ -48,5 +48,8 @@
#ifdef HAVE_THEORA
int _shout_open_theora(ogg_codec_t *codec, ogg_page *page);
#endif
+#ifdef HAVE_SPEEX
+int _shout_open_speex(ogg_codec_t *codec, ogg_page *page);
+#endif
#endif
Added: icecast/trunk/libshout/src/speex.c
===================================================================
--- icecast/trunk/libshout/src/speex.c 2005-12-03 20:32:10 UTC (rev 10532)
+++ icecast/trunk/libshout/src/speex.c 2005-12-04 02:49:34 UTC (rev 10533)
@@ -0,0 +1,86 @@
+/* -*- c-basic-offset: 8; -*- */
+/* speex.c: Ogg Speex data handlers for libshout
+ *
+ * Copyright (C) 2005 the Icecast team <team at icecast.org>
+ *
+ * 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
+
+#include <speex/speex.h>
+#include <speex/speex_header.h>
+
+#include "shout_private.h"
+#include "shout_ogg.h"
+
+/* -- local data structures -- */
+typedef struct {
+ SpeexHeader *sh;
+} speex_data_t;
+
+/* -- local prototypes -- */
+static int read_speex_page(ogg_codec_t *codec, ogg_page *page);
+static void free_speex_data(void *codec_data);
+
+/* -- speex functions -- */
+int _shout_open_speex(ogg_codec_t *codec, ogg_page *page)
+{
+ speex_data_t *speex_data = calloc(1, sizeof(speex_data_t));
+ ogg_packet packet;
+
+ if (!speex_data)
+ return SHOUTERR_MALLOC;
+
+ ogg_stream_packetout(&codec->os, &packet);
+
+ if (!(speex_data->sh = speex_packet_to_header(packet.packet,packet.bytes))) {
+ free_speex_data(speex_data);
+
+ return SHOUTERR_UNSUPPORTED;
+ }
+
+ codec->codec_data = speex_data;
+ codec->read_page = read_speex_page;
+ codec->free_data = free_speex_data;
+
+ return SHOUTERR_SUCCESS;
+}
+
+static int read_speex_page(ogg_codec_t *codec, ogg_page *page)
+{
+ ogg_packet packet;
+ speex_data_t *speex_data = codec->codec_data;
+ uint64_t samples = 0;
+
+ while (ogg_stream_packetout (&codec->os, &packet) > 0)
+ samples += speex_data->sh->frames_per_packet * speex_data->sh->frame_size;
+
+ codec->senttime += ((samples * 1000000) / speex_data->sh->rate);
+
+ return SHOUTERR_SUCCESS;
+}
+
+static void free_speex_data(void *codec_data)
+{
+ speex_data_t *speex_data = (speex_data_t *)codec_data;
+
+ if (speex_data->sh)
+ free(speex_data->sh);
+
+ free(speex_data);
+}
Property changes on: icecast/trunk/libshout/src/speex.c
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
More information about the commits
mailing list