added mpeg2 support, thanks to Nicholas J Humfrey

This commit is contained in:
darkeye 2006-01-25 22:47:15 +00:00
parent f9eecd27b8
commit 9ba6d64d1f
13 changed files with 209 additions and 62 deletions

View File

@ -25,4 +25,5 @@ with contributions by:
Nicholas J. Humfrey <njh@ecs.soton.ac.uk>
Joel Ebel <jbebel@ncsu.edu>
<jochen2@users.sourceforge.net>
Nicholas J Humfrey <njh@ecs.soton.ac.uk>

View File

@ -2,6 +2,9 @@ next release
o added check for bufferSecs set to 0
thanks to Toph <fangiotophia@gmail.com>
o added realtime parameter to the general section
o added MPEG2 support through the TwoLame library.
thanks to Nicholas J Humfrey <njh@ecs.soton.ac.uk>
22-10-2005 DarkIce 0.16 released

View File

@ -1,5 +1,5 @@
DarkIce live audio streamer, http://darkice.sourceforge.net
Copyright (c) 2000-2005, Tyrell Hungary, http://tyrell.hu
Copyright (c) 2000-2006, Tyrell Hungary, http://tyrell.hu
Contents

View File

@ -1,5 +1,5 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(darkice, 0.16)
AC_INIT(darkice, 0.17)
AC_CONFIG_SRCDIR(src/DarkIce.cpp)
AM_CONFIG_HEADER(src/config.h)
@ -21,11 +21,11 @@ AC_TYPE_PID_T()
AC_TYPE_SIZE_T()
AC_C_BIGENDIAN()
AC_CHECK_LIB( socket, socket)
AC_CHECK_LIB( nsl, gethostbyname)
AC_CHECK_LIB( rt, sched_getscheduler)
AC_CHECK_LIB(socket, socket)
AC_CHECK_LIB(nsl, gethostbyname)
AC_CHECK_LIB(rt, sched_getscheduler)
AC_CHECK_FUNC( getaddrinfo, AC_DEFINE(HAVE_GETADDRINFO, 1, [Does function getaddrinfo exist?] ))
AC_CHECK_FUNC(getaddrinfo, AC_DEFINE(HAVE_GETADDRINFO, 1, [Does function getaddrinfo exist?] ))
dnl-----------------------------------------------------------------------------
dnl funky posix threads checking, thanks to
@ -41,13 +41,13 @@ SYSTEM_INCLUDE=/usr/include
dnl-----------------------------------------------------------------------------
dnl link the lame library if requested
dnl-----------------------------------------------------------------------------
AC_SUBST( LAME_INCFLAGS)
AC_SUBST( LAME_LDFLAGS)
AC_SUBST(LAME_INCFLAGS)
AC_SUBST(LAME_LDFLAGS)
AC_ARG_WITH( lame,
AC_ARG_WITH(lame,
[ --with-lame use lame for encoding mp3 streams [yes] ],
USE_LAME=${withval}, USE_LAME="yes" )
AC_ARG_WITH( lame-prefix,
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],
@ -75,13 +75,13 @@ fi
dnl-----------------------------------------------------------------------------
dnl link the ogg vorbis libraries if requested
dnl-----------------------------------------------------------------------------
AC_SUBST( VORBIS_INCFLAGS)
AC_SUBST( VORBIS_LDFLAGS)
AC_SUBST(VORBIS_INCFLAGS)
AC_SUBST(VORBIS_LDFLAGS)
AC_ARG_WITH( vorbis,
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,
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],
@ -118,13 +118,13 @@ fi
dnl-----------------------------------------------------------------------------
dnl link the faac library if requested
dnl-----------------------------------------------------------------------------
AC_SUBST( FAAC_INCFLAGS)
AC_SUBST( FAAC_LDFLAGS)
AC_SUBST(FAAC_INCFLAGS)
AC_SUBST(FAAC_LDFLAGS)
AC_ARG_WITH( faac,
AC_ARG_WITH(faac,
[ --with-faac use faac for encoding AAC streams [yes] ],
USE_FAAC=${withval}, USE_FAAC="yes" )
AC_ARG_WITH( faac-prefix,
AC_ARG_WITH(faac-prefix,
[ --with-faac-prefix=DIR alternate location for faac [/usr]
look for libraries in FAAC-PREFIX/lib,
for headers in FAAC-PREFIX/include],
@ -149,26 +149,61 @@ else
fi
dnl-----------------------------------------------------------------------------
dnl link the twolame library if requested
dnl-----------------------------------------------------------------------------
AC_SUBST(TWOLAME_INCFLAGS)
AC_SUBST(TWOLAME_LDFLAGS)
AC_ARG_WITH(twolame,
[ --with-twolame use twolame for encoding MP2 streams [yes] ],
USE_TWOLAME=${withval}, USE_TWOLAME="yes" )
AC_ARG_WITH(twolame-prefix,
[ --with-twolame-prefix=DIR alternate location for twolame [/usr]
look for libraries in TWOLAME-PREFIX/lib,
for headers in TWOLAME-PREFIX/include],
CONFIG_TWOLAME_PREFIX="${withval}", CONFIG_TWOLAME_PREFIX="/usr")
if test "x${USE_TWOLAME}" = "xyes" ; then
AC_MSG_CHECKING( [for twolame library at ${CONFIG_TWOLAME_PREFIX}] )
LA_SEARCH_LIB( TWOLAME_LIB_LOC, TWOLAME_INC_LOC, libtwolame.a, twolame.h,
${CONFIG_TWOLAME_PREFIX})
if test "x${TWOLAME_LIB_LOC}" != "x" ; then
AC_DEFINE( HAVE_TWOLAME_LIB, 1, [build with twolame library] )
if test "x${TWOLAME_INC_LOC}" != "x${SYSTEM_INCLUDE}" ; then
TWOLAME_INCFLAGS="-I${TWOLAME_INC_LOC}"
fi
TWOLAME_LDFLAGS="-L${TWOLAME_LIB_LOC} -ltwolame"
AC_MSG_RESULT( [found at ${CONFIG_TWOLAME_PREFIX}] )
else
AC_MSG_WARN( [not found, building without twolame])
fi
else
AC_MSG_RESULT( [building without twolame] )
fi
dnl-----------------------------------------------------------------------------
dnl make sure at least one of lame and vorbis present
dnl-----------------------------------------------------------------------------
if test "x${LAME_LDFLAGS}" = "x"
-a "x${VORBIS_LDFLAGS}" = "x"
-a "x${FAAC_LDFLAGS}" = "x"; then
AC_MSG_ERROR([neither lame, Ogg Vorbis nor faac configured])
if test "x${LAME_LDFLAGS}" = "x" \
-a "x${VORBIS_LDFLAGS}" = "x" \
-a "x${FAAC_LDFLAGS}" = "x" \
-a "x${TWOLAME_LDFLAGS}" = "x"; then
AC_MSG_ERROR([neither lame, Ogg Vorbis, faac nor twolame configured])
fi
dnl-----------------------------------------------------------------------------
dnl link ALSA sound system if requested
dnl-----------------------------------------------------------------------------
AC_SUBST( ALSA_INCFLAGS)
AC_SUBST( ALSA_LDFLAGS)
AC_SUBST(ALSA_INCFLAGS)
AC_SUBST(ALSA_LDFLAGS)
AC_ARG_WITH( alsa,
AC_ARG_WITH(alsa,
[ --with-alsa use ALSA sound system [yes] ],
USE_ALSA=${withval}, USE_ALSA="yes" )
AC_ARG_WITH( alsa-prefix,
AC_ARG_WITH(alsa-prefix,
[ --with-alsa-prefix=DIR alternate location for ALSA [/usr]
look for libraries in ALSA-PREFIX/lib,
for headers in ALSA-PREFIX/include],
@ -200,13 +235,15 @@ dnl link JACK sound server if requested
dnl-----------------------------------------------------------------------------
AC_SUBST(JACK_CFLAGS)
AC_SUBST(JACK_LIBS)
AC_ARG_WITH( jack,
[ --with-jack use JACK audio server [yes] ],
USE_JACK=${withval}, USE_JACK="yes" )
if test "x${USE_JACK}" = "xyes" ; then
PKG_CHECK_MODULES(JACK, jack,
AC_DEFINE( HAVE_JACK_LIB, 1, [build with JACK audio server support] )
[ AC_DEFINE( HAVE_JACK_LIB, 1, [build with JACK audio server support] ) ],
[ HAVE_JACK_LIB=0 ]
)
else
AC_MSG_RESULT( [building without JACK support] )
@ -238,9 +275,9 @@ AC_CHECK_FUNCS( sched_getscheduler sched_getparam )
dnl-----------------------------------------------------------------------------
dnl enable compilation with debug flags
dnl-----------------------------------------------------------------------------
AC_SUBST( DEBUG_CXXFLAGS)
AC_SUBST(DEBUG_CXXFLAGS)
AC_ARG_WITH( debug,
AC_ARG_WITH(debug,
[ --with-debug enable debug mode [no] ],
USE_DEBUG=${withval}, USE_DEBUG="no" )

View File

@ -1,4 +1,4 @@
.TH darkice 1 "April 17, 2005" "DarkIce" "DarkIce live audio streamer"
.TH darkice 1 "January 25, 2006" "DarkIce" "DarkIce live audio streamer"
.SH NAME
darkice \- an icecast / shoutcast live audio streamer
.SH SYNOPSIS
@ -17,6 +17,7 @@ DarkIce can record from:
DarkIce can encode in the following formats:
* mp3 - using the lame library
* mp2 - using the twolame library
* Ogg Vorbis
* AAC - using the faac library
@ -97,6 +98,7 @@ Developed with contributions by
Nicholas J. Humfrey <njh@ecs.soton.ac.uk>
Joel Ebel <jbebel@ncsu.edu>
<jochen2@users.sourceforge.net>
Nicholas J Humfrey <njh@ecs.soton.ac.uk>
.SH LINKS
Project homepage:
@ -118,6 +120,10 @@ homepage:
homepage:
.I http://www.mp3dev.org/mp3/
.B TwoLame
homepage:
.I http://www.twolame.org/
.B Ogg Vorbis
homepage:
.I http://www.xiph.org/ogg/vorbis/

View File

@ -1,4 +1,4 @@
.TH darkice.cfg 5 "October 22, 2005" "DarkIce" "DarkIce live audio streamer"
.TH darkice.cfg 5 "January 25, 2006" "DarkIce" "DarkIce live audio streamer"
.SH NAME
darkice.cfg \- configuration file for darkice
.SH DESCRIPTION
@ -50,10 +50,19 @@ Time for DarkIce to run, in seconds. If 0, run forever.
Data read from the sound card is buffered before sent to
the encoder. Each buffer will be able to hold this
many seconds of samples.
.PP
Optional values:
.TP
.I reconnect
Try to reconnect to the server(s) if the connection is broken during
streaming, "yes" or "no". (optional parameter, defaults to "yes")
.TP
.I realtime
Use POSIX realtime scheduling, "yes" or "no".
(optional parameter, defaults to "yes")
.PP
.B [input]
@ -209,7 +218,7 @@ Required values:
.I format
Format of the stream sent to the
.B IceCast2
server. Supported formats are 'vorbis', 'mp3' and 'aac'.
server. Supported formats are 'vorbis', 'mp3', 'mp2' and 'aac'.
.TP
.I bitrateMode
The bit rate mode of the encoding, either "cbr", "abr" or "vbr",
@ -225,7 +234,7 @@ abr bit rate modes are specified.
The quality of encoding a value between 0.0 .. 1.0 (e.g. 0.8), with 1.0 being
the highest quality. Use a value greater than 0.0. Only used when vbr
bit rate mode is specified for Ogg Vorbis format, or in vbr and abr
modes for mp3 format.
modes for mp3 and mp2 format.
.TP
.I server
The
@ -248,11 +257,11 @@ Optional values:
.TP
.I sampleRate
The sample rate of the encoded mp3 output. If not specified, defaults
The sample rate of the encoded output. If not specified, defaults
to the value of the input sample rate.
.TP
.I channel
Number of channels for the mp3 output (e.g. 1 for mono, 2 for stereo).
Number of channels for the output (e.g. 1 for mono, 2 for stereo).
If not specified, defaults to the value of the input sample rate.
Different channels for input and output are only supported for mp3,
but not for Ogg Vorbis.
@ -291,14 +300,14 @@ Lowpass filter setting for the lame encoder, in Hz. Frequencies above
the specified value will be cut.
If not set or set to 0, the encoder's default behaviour is used.
If set to -1, the filter is disabled.
Only has effect if the mp3 format is used.
Only has effect if the mp3 or mp2 format is used.
.TP
.I highpass
Highpass filter setting for the lame encoder, in Hz. Frequencies below
the specified value will be cut.
If not set or set to 0, the encoder's default behaviour is used.
If set to -1, the filter is disabled.
Only has effect if the mp3 format is used.
Only has effect if the mp3 or mp2 format is used.
.PP
.B [shoutcast-x]

View File

@ -84,6 +84,10 @@
#include "LameLibEncoder.h"
#endif
#ifdef HAVE_TWOLAME_LIB
#include "TwoLameLibEncoder.h"
#endif
#ifdef HAVE_VORBIS_LIB
#include "VorbisLibEncoder.h"
#endif
@ -151,10 +155,14 @@ DarkIce :: init ( const Config & config ) throw ( Exception )
str = cs->get( "reconnect");
reconnect = str ? (Util::strEq( str, "yes") ? true : false) : true;
// real-time scheduling is enabled by default
str = cs->get( "realtime" );
enableRealTime = str ? (Util::strEq( str, "yes") ? true : false) : true;
// the [input] section
if ( !(cs = config.get( "input")) ) {
throw Exception( __FILE__, __LINE__, "no section [general] in config");
throw Exception( __FILE__, __LINE__, "no section [input] in config");
}
str = cs->getForSure( "sampleRate", " missing in section [input]");
@ -275,6 +283,8 @@ DarkIce :: configIceCast ( const Config & config,
throw Exception( __FILE__, __LINE__,
"invalid bitrate mode: ", str);
}
server = cs->getForSure( "server", " missing in section ", stream);
str = cs->getForSure( "port", " missing in section ", stream);
@ -334,15 +344,31 @@ DarkIce :: configIceCast ( const Config & config,
localDumpFile,
bufferSecs );
audioOuts[u].encoder = new LameLibEncoder( audioOuts[u].server.get(),
dsp.get(),
bitrateMode,
bitrate,
quality,
sampleRate,
channel,
lowpass,
highpass );
str = cs->getForSure( "format", " missing in section ", stream);
if ( Util::strEq( str, "mp3") ) {
audioOuts[u].encoder = new LameLibEncoder( audioOuts[u].server.get(),
dsp.get(),
bitrateMode,
bitrate,
quality,
sampleRate,
channel,
lowpass,
highpass );
} else if ( Util::strEq( str, "mp2") ) {
audioOuts[u].encoder = new TwoLameLibEncoder(
audioOuts[u].server.get(),
dsp.get(),
bitrateMode,
bitrate,
sampleRate,
channel );
} else {
throw Exception( __FILE__, __LINE__,
"unsupported stream format: ", str);
}
encConnector->attach( audioOuts[u].encoder.get());
#endif // HAVE_LAME_LIB
@ -405,6 +431,8 @@ DarkIce :: configIceCast2 ( const Config & config,
format = IceCast2::oggVorbis;
} else if ( Util::strEq( str, "mp3") ) {
format = IceCast2::mp3;
} else if ( Util::strEq( str, "mp2") ) {
format = IceCast2::mp2;
} else if ( Util::strEq( str, "aac") ) {
format = IceCast2::aac;
} else {
@ -533,6 +561,7 @@ DarkIce :: configIceCast2 ( const Config & config,
#endif // HAVE_LAME_LIB
break;
case IceCast2::oggVorbis:
#ifndef HAVE_VORBIS_LIB
throw Exception( __FILE__, __LINE__,
@ -552,6 +581,24 @@ DarkIce :: configIceCast2 ( const Config & config,
#endif // HAVE_VORBIS_LIB
break;
case IceCast2::mp2:
#ifndef HAVE_TWOLAME_LIB
throw Exception( __FILE__, __LINE__,
"DarkIce not compiled with TwoLame support, "
"thus can't create mp2 stream: ",
stream);
#else
audioOuts[u].encoder = new TwoLameLibEncoder(
audioOuts[u].server.get(),
dsp.get(),
bitrateMode,
bitrate,
sampleRate,
channel );
#endif // HAVE_TWOLAME_LIB
break;
case IceCast2::aac:
#ifndef HAVE_FAAC_LIB
throw Exception( __FILE__, __LINE__,
@ -791,6 +838,7 @@ DarkIce :: configFileCast ( const Config & config )
format = cs->getForSure( "format", " missing in section ", stream);
if ( !Util::strEq( format, "vorbis")
&& !Util::strEq( format, "mp3")
&& !Util::strEq( format, "mp2")
&& !Util::strEq( format, "aac") ) {
throw Exception( __FILE__, __LINE__,
"unsupported stream format: ", format);
@ -819,10 +867,6 @@ DarkIce :: configFileCast ( const Config & config )
throw Exception( __FILE__, __LINE__,
"bitrate not specified for CBR encoding");
}
if ( cs->get( "quality" ) == 0 ) {
throw Exception( __FILE__, __LINE__,
"quality not specified for CBR encoding");
}
} else if ( Util::strEq( str, "abr") ) {
bitrateMode = AudioEncoder::abr;
@ -885,7 +929,22 @@ DarkIce :: configFileCast ( const Config & config )
dsp->getChannel(),
lowpass,
highpass );
#endif // HAVE_LAME_LIB
#endif // HAVE_TWOLAME_LIB
} else if ( Util::strEq( format, "mp2") ) {
#ifndef HAVE_TWOLAME_LIB
throw Exception( __FILE__, __LINE__,
"DarkIce not compiled with TwoLAME support, "
"thus can't create MPEG Audio Layer 2 stream: ",
stream);
#else
audioOuts[u].encoder = new TwoLameLibEncoder(
audioOuts[u].server.get(),
dsp.get(),
bitrateMode,
bitrate,
sampleRate,
dsp->getChannel() );
#endif // HAVE_TWOLAME_LIB
} else if ( Util::strEq( format, "vorbis") ) {
#ifndef HAVE_VORBIS_LIB
throw Exception( __FILE__, __LINE__,
@ -898,7 +957,6 @@ DarkIce :: configFileCast ( const Config & config )
dsp.get(),
bitrateMode,
bitrate,
quality,
dsp->getSampleRate(),
dsp->getChannel() );
#endif // HAVE_VORBIS_LIB
@ -1057,9 +1115,14 @@ int
DarkIce :: run ( void ) throw ( Exception )
{
reportEvent( 3, "encoding");
setRealTimeScheduling();
if (enableRealTime) {
setRealTimeScheduling();
}
encode();
setOriginalScheduling();
if (enableRealTime) {
setOriginalScheduling();
}
reportEvent( 3, "encoding ends");
return 0;
@ -1071,6 +1134,9 @@ DarkIce :: run ( void ) throw ( Exception )
$Source$
$Log$
Revision 1.47 2006/01/25 22:47:15 darkeye
added mpeg2 support, thanks to Nicholas J Humfrey
Revision 1.46 2006/01/19 16:09:05 darkeye
added check for bufferSecs setting not to be 0

View File

@ -119,6 +119,11 @@ class DarkIce : public virtual Referable, public virtual Reporter
*/
Ref<Connector> encConnector;
/**
* Should we turn real-time scheduling on ?
*/
int enableRealTime;
/**
* Original scheduling policy
*/
@ -309,6 +314,9 @@ class DarkIce : public virtual Referable, public virtual Reporter
$Source$
$Log$
Revision 1.16 2006/01/25 22:47:15 darkeye
added mpeg2 support, thanks to Nicholas J Humfrey
Revision 1.15 2005/04/04 08:36:17 darkeye
commited changes to enable Jack support
thanks to Nicholas J. Humfrey, njh@ecs.soton.ac.uk

View File

@ -149,6 +149,7 @@ IceCast2 :: sendLogin ( void ) throw ( Exception )
sink->write( str, strlen( str));
switch ( format ) {
case mp3:
case mp2:
str = "audio/mpeg";
break;
@ -259,6 +260,9 @@ IceCast2 :: sendLogin ( void ) throw ( Exception )
$Source$
$Log$
Revision 1.13 2006/01/25 22:47:15 darkeye
added mpeg2 support, thanks to Nicholas J Humfrey
Revision 1.12 2005/04/16 21:57:34 darkeye
added AAC support through the faac codec, http://www.audiocoding.com/

View File

@ -63,7 +63,7 @@ class IceCast2 : public CastSink
/**
* Type for specifying the format of the stream.
*/
enum StreamFormat { mp3, oggVorbis, aac };
enum StreamFormat { mp3, mp2, oggVorbis, aac };
private:
@ -273,6 +273,9 @@ class IceCast2 : public CastSink
$Source$
$Log$
Revision 1.6 2006/01/25 22:47:15 darkeye
added mpeg2 support, thanks to Nicholas J Humfrey
Revision 1.5 2005/04/16 21:57:34 darkeye
added AAC support through the faac codec, http://www.audiocoding.com/

View File

@ -260,8 +260,10 @@ LameLibEncoder :: open ( void )
"lame lib initializing params error" );
}
lame_print_config( lameGlobalFlags);
if (getReportVerbosity() >= 3) {
lame_print_config( lameGlobalFlags);
}
return true;
}
@ -396,6 +398,9 @@ LameLibEncoder :: close ( void ) throw ( Exception )
$Source$
$Log$
Revision 1.20 2006/01/25 22:47:15 darkeye
added mpeg2 support, thanks to Nicholas J Humfrey
Revision 1.19 2005/04/13 19:04:55 jbebel
Distribute lame qualities better, and prevent values greater than 9 which are invalid.

View File

@ -1,8 +1,8 @@
bin_PROGRAMS = darkice
AM_CXXFLAGS = -O2 -pedantic -Wall @DEBUG_CXXFLAGS@ @PTHREAD_CFLAGS@
@JACK_CFLAGS@
INCLUDES = @LAME_INCFLAGS@ @VORBIS_INCFLAGS@ @FAAC_INCFLAGS@ @ALSA_INCFLAGS@
LDADD = @PTHREAD_LIBS@ @LAME_LDFLAGS@ @VORBIS_LDFLAGS@ @FAAC_LDFLAGS@ \
@JACK_CFLAGS@
INCLUDES = @LAME_INCFLAGS@ @VORBIS_INCFLAGS@ @FAAC_INCFLAGS@ @TWOLAME_INCFLAGS@ @ALSA_INCFLAGS@
LDADD = @PTHREAD_LIBS@ @LAME_LDFLAGS@ @VORBIS_LDFLAGS@ @FAAC_LDFLAGS@ @TWOLAME_LDFLAGS@ \
@ALSA_LDFLAGS@ @JACK_LIBS@
darkice_SOURCES = AudioEncoder.h\
@ -32,6 +32,8 @@ darkice_SOURCES = AudioEncoder.h\
FileCast.cpp\
LameLibEncoder.cpp\
LameLibEncoder.h\
TwoLameLibEncoder.cpp\
TwoLameLibEncoder.h\
VorbisLibEncoder.cpp\
VorbisLibEncoder.h\
FaacEncoder.cpp\

View File

@ -87,7 +87,7 @@ main (
std::cout << "DarkIce " << VERSION
<< " live audio streamer, http://darkice.sourceforge.net"
<< std::endl
<< "Copyright (c) 2000-2005, Tyrell Hungary, http://tyrell.hu"
<< "Copyright (c) 2000-2006, Tyrell Hungary, http://tyrell.hu"
<< std::endl << std::endl;
try {
@ -166,6 +166,9 @@ showUsage ( std::ostream & os )
$Source$
$Log$
Revision 1.16 2006/01/25 22:47:15 darkeye
added mpeg2 support, thanks to Nicholas J Humfrey
Revision 1.15 2005/04/14 11:24:42 darkeye
updated copyright notice to extend to 2005