Commit 7963eb66 authored by brendan's avatar brendan
Browse files

William Volkman's speex support patch.

svn path=/icecast/trunk/libshout/; revision=10533
parent 50fbfd44
......@@ -130,7 +130,25 @@ PKG_CHECK_MODULES(THEORA, theora, [
])
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
......@@ -167,7 +185,7 @@ SHOUT_LIBS="-lshout"
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)
......
......@@ -11,14 +11,18 @@ if HAVE_THEORA
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\
......
......@@ -52,6 +52,9 @@ static codec_open_t codecs[] = {
_shout_open_vorbis,
#ifdef HAVE_THEORA
_shout_open_theora,
#endif
#ifdef HAVE_SPEEX
_shout_open_speex,
#endif
NULL
};
......@@ -140,14 +143,14 @@ static void close_ogg(shout_t *self)
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);
......
......@@ -48,5 +48,8 @@ int _shout_open_vorbis(ogg_codec_t *codec, ogg_page *page);
#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
/* -*- c-basic-offset: 8; -*- */
/* speex.c: Ogg Speex data handlers for libshout
*
* Copyright (C) 2005 the Icecast team <team@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);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment