From 50684028b75e2e5076ec06ba008eea9e3768c04b Mon Sep 17 00:00:00 2001 From: darkeye Date: Fri, 19 Oct 2001 12:39:42 +0000 Subject: [PATCH] created configure options to compile with or without lame / Ogg Vorbis --- darkice/trunk/ChangeLog | 2 + darkice/trunk/INSTALL | 5 +- darkice/trunk/TODO | 2 - darkice/trunk/acinclude.m4 | 44 ++++++------- darkice/trunk/configure.in | 87 +++++++++++++++++++++++--- darkice/trunk/src/DarkIce.cpp | 47 ++++++++++++-- darkice/trunk/src/LameLibEncoder.cpp | 8 +++ darkice/trunk/src/LameLibEncoder.h | 8 ++- darkice/trunk/src/Makefile.am | 2 + darkice/trunk/src/VorbisLibEncoder.cpp | 8 +++ darkice/trunk/src/VorbisLibEncoder.h | 7 ++- 11 files changed, 179 insertions(+), 41 deletions(-) diff --git a/darkice/trunk/ChangeLog b/darkice/trunk/ChangeLog index e0a036f..c41379e 100644 --- a/darkice/trunk/ChangeLog +++ b/darkice/trunk/ChangeLog @@ -4,6 +4,8 @@ DarkIce 0.7 thanks to Robin P. Blanchard, o added support for resampling mp3 streams o DarkIce config file now may contain spaces and tabs as white space + o configure script enables build with or without lame / Ogg Vorbis + also possibility to specify alternate locations for these 18-09-2001: DarkIce 0.6 released diff --git a/darkice/trunk/INSTALL b/darkice/trunk/INSTALL index c905f9b..9c330dc 100644 --- a/darkice/trunk/INSTALL +++ b/darkice/trunk/INSTALL @@ -1,9 +1,12 @@ DarkIce installation notes ========================== -DarkIce requires the following libraries (and associated header files): +DarkIce uses the following libraries (and associated header files): +for capability to stream mp3 to IceCast 1.x and Shoutcast: - libmp3lame + +for capability to stream Ogg Vorbis to IceCast 2: - libogg - libvoribs - libvorbisenc diff --git a/darkice/trunk/TODO b/darkice/trunk/TODO index 9ffa099..26c2cb8 100644 --- a/darkice/trunk/TODO +++ b/darkice/trunk/TODO @@ -7,5 +7,3 @@ o libtoolize ? o revisit real-time scheduling and one-thread-per-connection o look into performance o create proper error-reporting module -o configure options to enable / disable lame / ogg support and to - specify their location diff --git a/darkice/trunk/acinclude.m4 b/darkice/trunk/acinclude.m4 index 727690f..f905328 100644 --- a/darkice/trunk/acinclude.m4 +++ b/darkice/trunk/acinclude.m4 @@ -5,12 +5,13 @@ dnl dnl DO NOT change aclocal.m4 ! dnl -dnl * LA_SEARCH_FILE(variable, filename, PATH) -dnl * Search "filename" in the specified "PATH", "variable" will -dnl * contain the full pathname or the empty string -dnl * PATH is space-separated list of directories. -dnl * by Florian Bomers - +dnl----------------------------------------------------------------------------- +dnl LA_SEARCH_FILE(variable, filename, PATH) +dnl Search "filename" in the specified "PATH", "variable" will +dnl contain the full pathname or the empty string +dnl PATH is space-separated list of directories. +dnl by Florian Bomers +dnl----------------------------------------------------------------------------- AC_DEFUN(LA_SEARCH_FILE,[ $1= dnl hack: eliminate line feeds in $2 @@ -24,21 +25,22 @@ AC_DEFUN(LA_SEARCH_FILE,[ done ]) -dnl * LA_SEARCH_LIB(lib-variable, include-variable, lib-filename, header-filename, prefix) -dnl * looks for "lib-filename" and "header-filename" in the area of "prefix". -dnl * if found, "lib-variable" and "include-variable" are set to the -dnl * respective paths. -dnl * prefix is a single path -dnl * libs are searched in prefix, prefix/lib -dnl * headers are searched in prefix, prefix/include, -dnl * -dnl * If one of them is not found, both "lib-variable", "include-variable" are -dnl * set to the empty string. -dnl * -dnl * TODO: assert function call to verify lib -dnl * -dnl * by Florian Bomers - +dnl----------------------------------------------------------------------------- +dnl LA_SEARCH_LIB(lib-variable, include-variable, lib-filename, header-filename, prefix) +dnl looks for "lib-filename" and "header-filename" in the area of "prefix". +dnl if found, "lib-variable" and "include-variable" are set to the +dnl respective paths. +dnl prefix is a single path +dnl libs are searched in prefix, prefix/lib +dnl headers are searched in prefix, prefix/include, +dnl +dnl If one of them is not found, both "lib-variable", "include-variable" are +dnl set to the empty string. +dnl +dnl TODO: assert function call to verify lib +dnl +dnl by Florian Bomers +dnl----------------------------------------------------------------------------- AC_DEFUN(LA_SEARCH_LIB,[ dnl look for lib LA_SEARCH_FILE($1, $3, $5 $5/lib ) diff --git a/darkice/trunk/configure.in b/darkice/trunk/configure.in index 0228860..18feef3 100644 --- a/darkice/trunk/configure.in +++ b/darkice/trunk/configure.in @@ -15,19 +15,92 @@ AC_HAVE_HEADERS(sched.h) AC_HAVE_HEADERS(sys/soundcard.h sys/audio.h) AC_HEADER_SYS_WAIT() -AC_CHECK_HEADERS(lame/lame.h) -AC_CHECK_HEADERS(vorbis/vorbisenc.h) - AC_TYPE_PID_T() AC_TYPE_SIZE_T() AC_CHECK_LIB( socket, socket) AC_CHECK_LIB( nsl, gethostbyname) AC_CHECK_LIB( rt, sched_getscheduler) -AC_CHECK_LIB( ogg, ogg_stream_init) -AC_CHECK_LIB( vorbis, vorbis_info_init) -AC_CHECK_LIB( vorbisenc, vorbis_encode_init) -AC_CHECK_LIB( mp3lame, lame_init) + + +dnl----------------------------------------------------------------------------- +dnl link the lame library if requested +dnl----------------------------------------------------------------------------- +AC_SUBST( LAME_INCFLAGS) +AC_SUBST( LAME_LDFLAGS) + +AC_ARG_WITH( lame, +[ --with-lame use lame for encoding mp3 streams [yes] ], + USE_LAME=${withval}, USE_LAME="yes" ) +AC_ARG_WITH( lame-prefix, +[ --with-lame-prefix=DIR alternate location for lame [/usr] + look for libraries in LAME-PREFIX/lib, + for headers in LAME-PREFIX/include], + CONFIG_LAME_PREFIX="${withval}", CONFIG_LAME_PREFIX="/usr") + +if test "x${USE_LAME}" = "xyes" ; then + AC_MSG_CHECKING( [for lame library at ${CONFIG_LAME_PREFIX}] ) + LA_SEARCH_LIB( LAME_LIB_LOC, LAME_INC_LOC, libmp3lame.a, lame/lame.h, + ${CONFIG_LAME_PREFIX}) + if test "x${LAME_LIB_LOC}" != "x" ; then + AC_DEFINE( HAVE_LAME_LIB, 1, [build with lame library] ) + LAME_INCFLAGS="-I${LAME_INC_LOC}" + LAME_LDFLAGS="-L${LAME_LIB_LOC} -lmp3lame" + AC_MSG_RESULT( [found at ${CONFIG_LAME_PREFIX}] ) + else + AC_MSG_WARN( [not found, building without lame]) + fi +else + AC_MSG_RESULT( [building without lame] ) +fi + + +dnl----------------------------------------------------------------------------- +dnl link the ogg vorbis libraries if requested +dnl----------------------------------------------------------------------------- +AC_SUBST( VORBIS_INCFLAGS) +AC_SUBST( VORBIS_LDFLAGS) + +AC_ARG_WITH( vorbis, +[ --with-vorbis use Ogg Vorbis for encoding vorbis streams [yes] ], + USE_VORBIS=${withval}, USE_VORBIS="yes" ) +AC_ARG_WITH( vorbis-prefix, +[ --with-vorbis-prefix=DIR alternate location for vorbis [/usr] + look for libraries in VORBIS-PREFIX/lib, + for headers in VORBIS-PREFIX/include], + CONFIG_VORBIS_PREFIX="${withval}", CONFIG_VORBIS_PREFIX="/usr") + +if test "x${USE_VORBIS}" = "xyes" ; then + AC_MSG_CHECKING( [for vorbis libraries at ${CONFIG_VORBIS_PREFIX}] ) + LA_SEARCH_LIB( OGG_LIB_LOC, OGG_INC_LOC, libogg.a, ogg/ogg.h, + ${CONFIG_VORBIS_PREFIX}) + LA_SEARCH_LIB( VORBIS_LIB_LOC, VORBIS_INC_LOC, libvorbis.a, vorbis/codec.h, + ${CONFIG_VORBIS_PREFIX}) + LA_SEARCH_LIB( VORBISENC_LIB_LOC, VORBISENC_INC_LOC, + libvorbisenc.a, vorbis/vorbisenc.h, + ${CONFIG_VORBIS_PREFIX}) + + if test "x${OGG_LIB_LOC}" != "x" -a \ + "x${VORBIS_LIB_LOC}" != "x" -a \ + "x${VORBISENC_LIB_LOC}" != "x" ; then + + AC_DEFINE( HAVE_VORBIS_LIB, 1, [build with Ogg Vorbis library] ) + VORBIS_INCFLAGS="-I${OGG_INC_LOC}" + VORBIS_LDFLAGS="-L${OGG_LIB_LOC} -logg -lvorbis -lvorbisenc" + AC_MSG_RESULT( [found at ${CONFIG_VORBIS_PREFIX}] ) + else + AC_MSG_WARN( [not found, building without Ogg Vorbis]) + fi +else + AC_MSG_RESULT( [building without Ogg Vorbis] ) +fi + + +dnl make sure at least one of lame and vorbis present +if test "x${LAME_INCFLAGS}" = "x" -a "x${VORBIS_INCFLAGS}" = "x" ; then + AC_MSG_ERROR( [neither lame nor Ogg Vorbis configured]) +fi + AC_OUTPUT(Makefile src/Makefile man/Makefile) diff --git a/darkice/trunk/src/DarkIce.cpp b/darkice/trunk/src/DarkIce.cpp index 489ace8..86e873f 100644 --- a/darkice/trunk/src/DarkIce.cpp +++ b/darkice/trunk/src/DarkIce.cpp @@ -71,14 +71,21 @@ #endif + #include "Util.h" #include "IceCast.h" #include "IceCast2.h" #include "ShoutCast.h" -#include "LameLibEncoder.h" -#include "VorbisLibEncoder.h" #include "DarkIce.h" +#ifdef HAVE_LAME_LIB +#include "LameLibEncoder.h" +#endif + +#ifdef HAVE_VORBIS_LIB +#include "VorbisLibEncoder.h" +#endif + /* =================================================== local data structures */ @@ -174,7 +181,6 @@ DarkIce :: configIceCast ( const Config & config, for ( u = 0; u < maxOutput; ++u ) { const ConfigSection * cs; - const char * str; // ugly hack to change the section name to "stream0", "stream1", etc. stream[streamLen-1] = '0' + u; @@ -183,6 +189,15 @@ DarkIce :: configIceCast ( const Config & config, break; } +#ifndef HAVE_LAME_LIB + throw Exception( __FILE__, __LINE__, + "DarkIce not compiled with lame support, " + "thus can't connect to IceCast 1.x, stream: ", + stream); +#else + + const char * str; + unsigned int sampleRate = 0; unsigned int bitrate = 0; const char * server = 0; @@ -252,6 +267,7 @@ DarkIce :: configIceCast ( const Config & config, highpass ); encConnector->attach( audioOuts[u].encoder.get()); +#endif // HAVE_LAME_LIB } noAudioOuts += u; @@ -274,7 +290,6 @@ DarkIce :: configIceCast2 ( const Config & config, for ( u = 0; u < maxOutput; ++u ) { const ConfigSection * cs; - const char * str; // ugly hack to change the section name to "stream0", "stream1", etc. stream[streamLen-1] = '0' + u; @@ -283,6 +298,15 @@ DarkIce :: configIceCast2 ( const Config & config, break; } +#ifndef HAVE_VORBIS_LIB + throw Exception( __FILE__, __LINE__, + "DarkIce not compiled with Ogg Vorbis support, " + "thus can't connect to IceCast 2, stream: ", + stream); +#else + + const char * str; + unsigned int bitrate = 0; const char * server = 0; unsigned int port = 0; @@ -338,6 +362,7 @@ DarkIce :: configIceCast2 ( const Config & config, dsp->getChannel() ); encConnector->attach( audioOuts[u].encoder.get()); +#endif // HAVE_VORBIS_LIB } noAudioOuts += u; @@ -360,7 +385,6 @@ DarkIce :: configShoutCast ( const Config & config, for ( u = 0; u < maxOutput; ++u ) { const ConfigSection * cs; - const char * str; // ugly hack to change the section name to "stream0", "stream1", etc. stream[streamLen-1] = '0' + u; @@ -369,6 +393,15 @@ DarkIce :: configShoutCast ( const Config & config, break; } +#ifndef HAVE_LAME_LIB + throw Exception( __FILE__, __LINE__, + "DarkIce not compiled with lame support, " + "thus can't connect to ShoutCast, stream: ", + stream); +#else + + const char * str; + unsigned int sampleRate = 0; unsigned int bitrate = 0; const char * server = 0; @@ -436,6 +469,7 @@ DarkIce :: configShoutCast ( const Config & config, highpass ); encConnector->attach( audioOuts[u].encoder.get()); +#endif // HAVE_LAME_LIB } noAudioOuts += u; @@ -574,6 +608,9 @@ DarkIce :: run ( void ) throw ( Exception ) $Source$ $Log$ + Revision 1.21 2001/10/19 12:39:42 darkeye + created configure options to compile with or without lame / Ogg Vorbis + Revision 1.20 2001/10/19 09:03:39 darkeye added support for resampling mp3 streams diff --git a/darkice/trunk/src/LameLibEncoder.cpp b/darkice/trunk/src/LameLibEncoder.cpp index a22411f..52c946c 100644 --- a/darkice/trunk/src/LameLibEncoder.cpp +++ b/darkice/trunk/src/LameLibEncoder.cpp @@ -33,6 +33,9 @@ #include "config.h" #endif +// compile the whole file only if lame support configured in +#ifdef HAVE_LAME_LIB + #include "Exception.h" #include "Util.h" @@ -408,12 +411,17 @@ LameLibEncoder :: close ( void ) throw ( Exception ) } +#endif // HAVE_LAME_LIB + /*------------------------------------------------------------------------------ $Source$ $Log$ + Revision 1.8 2001/10/19 12:39:42 darkeye + created configure options to compile with or without lame / Ogg Vorbis + Revision 1.7 2001/09/18 14:57:19 darkeye finalized Solaris port diff --git a/darkice/trunk/src/LameLibEncoder.h b/darkice/trunk/src/LameLibEncoder.h index 17c7730..b3758de 100644 --- a/darkice/trunk/src/LameLibEncoder.h +++ b/darkice/trunk/src/LameLibEncoder.h @@ -40,10 +40,10 @@ #include "config.h" #endif -#ifdef HAVE_LAME_LAME_H +#ifdef HAVE_LAME_LIB #include #else -#error need lame/lame.h +#error configure with lame #endif @@ -448,7 +448,6 @@ class LameLibEncoder : public AudioEncoder, public virtual Reporter /* ====================================================== function prototypes */ - #endif /* LAME_LIB_ENCODER_H */ @@ -457,6 +456,9 @@ class LameLibEncoder : public AudioEncoder, public virtual Reporter $Source$ $Log$ + Revision 1.9 2001/10/19 12:39:42 darkeye + created configure options to compile with or without lame / Ogg Vorbis + Revision 1.8 2001/10/19 09:03:39 darkeye added support for resampling mp3 streams diff --git a/darkice/trunk/src/Makefile.am b/darkice/trunk/src/Makefile.am index 490777a..16818ad 100644 --- a/darkice/trunk/src/Makefile.am +++ b/darkice/trunk/src/Makefile.am @@ -1,5 +1,7 @@ bin_PROGRAMS = darkice CXXFLAGS = -O2 -Wall +INCLUDES = @LAME_INCFLAGS@ @VORBIS_INCFLAGS@ +LDADD = @LAME_LDFLAGS@ @VORBIS_LDFLAGS@ darkice_SOURCES = AudioEncoder.h\ AudioSource.h\ diff --git a/darkice/trunk/src/VorbisLibEncoder.cpp b/darkice/trunk/src/VorbisLibEncoder.cpp index e2d48a2..66ec4c6 100644 --- a/darkice/trunk/src/VorbisLibEncoder.cpp +++ b/darkice/trunk/src/VorbisLibEncoder.cpp @@ -33,6 +33,9 @@ #include "config.h" #endif +// compile only if configured for Ogg Vorbis +#ifdef HAVE_VORBIS_LIB + #include "Exception.h" #include "Util.h" @@ -348,12 +351,17 @@ VorbisLibEncoder :: close ( void ) throw ( Exception ) } +#endif // HAVE_VORBIS_LIB + /*------------------------------------------------------------------------------ $Source$ $Log$ + Revision 1.4 2001/10/19 12:39:42 darkeye + created configure options to compile with or without lame / Ogg Vorbis + Revision 1.3 2001/09/18 14:57:19 darkeye finalized Solaris port diff --git a/darkice/trunk/src/VorbisLibEncoder.h b/darkice/trunk/src/VorbisLibEncoder.h index 9f5f721..5308f30 100644 --- a/darkice/trunk/src/VorbisLibEncoder.h +++ b/darkice/trunk/src/VorbisLibEncoder.h @@ -40,10 +40,10 @@ #include "config.h" #endif -#ifdef HAVE_VORBIS_VORBISENC_H +#ifdef HAVE_VORBIS_LIB #include #else -#error need vorbis/vorbisenc.h +#error configure for Ogg Vorbis #endif @@ -442,6 +442,9 @@ class VorbisLibEncoder : public AudioEncoder, public virtual Reporter $Source$ $Log$ + Revision 1.3 2001/10/19 12:39:42 darkeye + created configure options to compile with or without lame / Ogg Vorbis + Revision 1.2 2001/09/15 11:36:22 darkeye added function vorbisBlocksOut(), finalized vorbis support