updated to work with Ogg Vorbis libs rc3 and current IceCast2 cvs

This commit is contained in:
darkeye 2002-02-20 10:40:02 +00:00
parent b4874eeb18
commit ab8efd2d31
7 changed files with 154 additions and 42 deletions

View File

@ -4,6 +4,8 @@ DarkIce 0.8
o fixed incorrect vorbis bitrate setting o fixed incorrect vorbis bitrate setting
o fix: DarkIce now reports public streams correctly o fix: DarkIce now reports public streams correctly
thanks to Tom Gray, <tomg@future-i.com> thanks to Tom Gray, <tomg@future-i.com>
o made up-to-date with Ogg Vorbis rc3 libs
o made up-to-date with current IceCast2 cvs version
19-10-2001: DarkIce 0.7 released 19-10-2001: DarkIce 0.7 released

View File

@ -36,7 +36,8 @@ public = yes # advertise this stream?
# there may be up to 8 of these sections, named [icecast2-0] ... [icecast2-7] # there may be up to 8 of these sections, named [icecast2-0] ... [icecast2-7]
# these can be mixed with [icecast-x] and [shoutcast-x] sections # these can be mixed with [icecast-x] and [shoutcast-x] sections
[icecast2-0] [icecast2-0]
bitrate = 96 # bitrate of the mp3 stream sent to the server format = vorbis # format of the stream: ogg vorbis
bitrate = 96 # bitrate of the stream sent to the server
server = yp.yourserver.com server = yp.yourserver.com
# host name of the server # host name of the server
port = 8000 # port of the IceCast2 server, usually 8000 port = 8000 # port of the IceCast2 server, usually 8000

View File

@ -158,6 +158,11 @@ The stream will be reachable at
Required values: Required values:
.TP
.I format
Format of the stream sent to the
.B IceCast2
server. Currently the only supported value here is 'vorbis'.
.TP .TP
.I bitrate .I bitrate
Bit rate to encode to in kBits / sec (e.g. 96) Bit rate to encode to in kBits / sec (e.g. 96)

View File

@ -298,15 +298,9 @@ DarkIce :: configIceCast2 ( const Config & config,
break; 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; const char * str;
IceCast2::StreamFormat format;
unsigned int bitrate = 0; unsigned int bitrate = 0;
const char * server = 0; const char * server = 0;
unsigned int port = 0; unsigned int port = 0;
@ -318,6 +312,20 @@ DarkIce :: configIceCast2 ( const Config & config,
const char * genre = 0; const char * genre = 0;
bool isPublic = false; bool isPublic = false;
str = cs->getForSure( "format", " missing in section ", stream);
if ( Util::strEq( str, "vorbis") ) {
format = IceCast2::oggVorbis;
} else if ( Util::strEq( str, "mp3") ) {
format = IceCast2::mp3;
// TODO: enable this format in the future, when icecast2
// supports it as well
throw Exception( __FILE__, __LINE__,
"unsupported stream format: ", str);
} else {
throw Exception( __FILE__, __LINE__,
"unsupported stream format: ", str);
}
str = cs->getForSure("bitrate", " missing in section ", stream); str = cs->getForSure("bitrate", " missing in section ", stream);
bitrate = Util::strToL( str); bitrate = Util::strToL( str);
server = cs->getForSure( "server", " missing in section ", stream); server = cs->getForSure( "server", " missing in section ", stream);
@ -348,6 +356,7 @@ DarkIce :: configIceCast2 ( const Config & config,
audioOuts[u].server = new IceCast2( audioOuts[u].socket.get(), audioOuts[u].server = new IceCast2( audioOuts[u].socket.get(),
password, password,
mountPoint, mountPoint,
format,
bitrate, bitrate,
name, name,
description, description,
@ -355,14 +364,45 @@ DarkIce :: configIceCast2 ( const Config & config,
genre, genre,
isPublic ); isPublic );
audioOuts[u].encoder = new VorbisLibEncoder( audioOuts[u].server.get(), switch ( format ) {
case IceCast2::mp3:
#ifndef HAVE_LAME_LIB
throw Exception( __FILE__, __LINE__,
"DarkIce not compiled with lame support, "
"thus can't create mp3 stream: ",
stream);
#else
audioOuts[u].encoder = new LameLibEncoder(
audioOuts[u].server.get(),
dsp.get(), dsp.get(),
bitrate, bitrate,
dsp->getSampleRate(), dsp->getSampleRate(),
dsp->getChannel() ); dsp->getChannel() );
#endif // HAVE_LAME_LIB
break;
case IceCast2::oggVorbis:
#ifndef HAVE_VORBIS_LIB
throw Exception( __FILE__, __LINE__,
"DarkIce not compiled with Ogg Vorbis support, "
"thus can't Ogg Vorbis stream: ",
stream);
#else
audioOuts[u].encoder = new VorbisLibEncoder(
audioOuts[u].server.get(),
dsp.get(),
bitrate,
dsp->getSampleRate(),
dsp->getChannel() );
#endif // HAVE_VORBIS_LIB
break;
default:
throw Exception( __FILE__, __LINE__,
"Illegal stream format: ", format);
}
encConnector->attach( audioOuts[u].encoder.get()); encConnector->attach( audioOuts[u].encoder.get());
#endif // HAVE_VORBIS_LIB
} }
noAudioOuts += u; noAudioOuts += u;
@ -608,6 +648,9 @@ DarkIce :: run ( void ) throw ( Exception )
$Source$ $Source$
$Log$ $Log$
Revision 1.23 2002/02/20 10:35:35 darkeye
updated to work with Ogg Vorbis libs rc3 and current IceCast2 cvs
Revision 1.22 2001/10/20 10:56:45 darkeye Revision 1.22 2001/10/20 10:56:45 darkeye
added possibility to disable highpass and lowpass filters for lame added possibility to disable highpass and lowpass filters for lame

View File

@ -79,10 +79,12 @@ static const char fileid[] = "$Id$";
* Initialize the object * Initialize the object
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
IceCast2 :: init ( const char * mountPoint, IceCast2 :: init ( StreamFormat format,
const char * mountPoint,
const char * description ) const char * description )
throw ( Exception ) throw ( Exception )
{ {
this->format = format;
this->mountPoint = Util::strDup( mountPoint); this->mountPoint = Util::strDup( mountPoint);
this->description = description ? Util::strDup( description) : 0; this->description = description ? Util::strDup( description) : 0;
} }
@ -129,7 +131,22 @@ IceCast2 :: sendLogin ( void ) throw ( Exception )
sink->write( str, strlen( str)); sink->write( str, strlen( str));
/* send the content type, Ogg Vorbis */ /* send the content type, Ogg Vorbis */
str = "\nContent-type: application/x-ogg"; str = "\nContent-type: ";
sink->write( str, strlen( str));
switch ( format ) {
case mp3:
str = "audio/mpeg";
break;
case oggVorbis:
str = "application/x-ogg";
break;
default:
throw Exception( __FILE__, __LINE__,
"unsupported stream format", format);
break;
}
sink->write( str, strlen( str)); sink->write( str, strlen( str));
/* send the ice- headers */ /* send the ice- headers */
@ -192,6 +209,9 @@ IceCast2 :: sendLogin ( void ) throw ( Exception )
$Source$ $Source$
$Log$ $Log$
Revision 1.4 2002/02/20 10:35:35 darkeye
updated to work with Ogg Vorbis libs rc3 and current IceCast2 cvs
Revision 1.3 2002/02/19 15:24:26 darkeye Revision 1.3 2002/02/19 15:24:26 darkeye
send Content-type header when logging in to icecast2 servers send Content-type header when logging in to icecast2 servers

View File

@ -58,8 +58,21 @@
*/ */
class IceCast2 : public CastSink class IceCast2 : public CastSink
{ {
public:
/**
* Type for specifying the format of the stream.
*/
enum StreamFormat { mp3, oggVorbis };
private: private:
/**
* The format of the stream.
*/
StreamFormat format;
/** /**
* Mount point of the stream on the server. * Mount point of the stream on the server.
*/ */
@ -79,7 +92,8 @@ class IceCast2 : public CastSink
* @exception Exception * @exception Exception
*/ */
void void
init ( const char * mountPoint, init ( StreamFormat format,
const char * mountPoint,
const char * description ) const char * description )
throw ( Exception ); throw ( Exception );
@ -137,6 +151,7 @@ class IceCast2 : public CastSink
IceCast2 ( TcpSocket * socket, IceCast2 ( TcpSocket * socket,
const char * password, const char * password,
const char * mountPoint, const char * mountPoint,
StreamFormat format,
unsigned int bitRate, unsigned int bitRate,
const char * name = 0, const char * name = 0,
const char * description = 0, const char * description = 0,
@ -154,7 +169,7 @@ class IceCast2 : public CastSink
isPublic, isPublic,
bufferDuration ) bufferDuration )
{ {
init( mountPoint, description); init( format, mountPoint, description);
} }
/** /**
@ -166,7 +181,8 @@ class IceCast2 : public CastSink
IceCast2( const IceCast2 & cs ) throw ( Exception ) IceCast2( const IceCast2 & cs ) throw ( Exception )
: CastSink( cs ) : CastSink( cs )
{ {
init( cs.getMountPoint(), init( cs.getFormat(),
cs.getMountPoint(),
cs.getDescription() ); cs.getDescription() );
} }
@ -194,12 +210,24 @@ class IceCast2 : public CastSink
if ( this != &cs ) { if ( this != &cs ) {
strip(); strip();
CastSink::operator=( cs ); CastSink::operator=( cs );
init( cs.getMountPoint(), init( cs.getFormat(),
cs.getMountPoint(),
cs.getDescription() ); cs.getDescription() );
} }
return *this; return *this;
} }
/**
* Get the format of the stream.
*
* @return the format of the stream.
*/
inline StreamFormat
getFormat ( void ) const throw ()
{
return format;
}
/** /**
* Get the mount point of the stream on the server. * Get the mount point of the stream on the server.
* *
@ -240,6 +268,9 @@ class IceCast2 : public CastSink
$Source$ $Source$
$Log$ $Log$
Revision 1.2 2002/02/20 10:35:35 darkeye
updated to work with Ogg Vorbis libs rc3 and current IceCast2 cvs
Revision 1.1 2001/09/14 19:31:06 darkeye Revision 1.1 2001/09/14 19:31:06 darkeye
added IceCast2 / vorbis support added IceCast2 / vorbis support

View File

@ -75,7 +75,7 @@ VorbisLibEncoder :: open ( void )
if ( (ret = vorbis_encode_init( &vorbisInfo, if ( (ret = vorbis_encode_init( &vorbisInfo,
getInChannel(), getInChannel(),
getInSampleRate(), getInSampleRate(),
-1, getOutBitrate() * 1000,
getOutBitrate() * 1000, getOutBitrate() * 1000,
-1 )) ) { -1 )) ) {
throw Exception( __FILE__, __LINE__, "vorbis encode init error", ret); throw Exception( __FILE__, __LINE__, "vorbis encode init error", ret);
@ -117,7 +117,7 @@ VorbisLibEncoder :: open ( void )
throw Exception( __FILE__, __LINE__, "vorbis header init error", ret); throw Exception( __FILE__, __LINE__, "vorbis header init error", ret);
} }
vorbis_comment_clear( &vorbisComment ); vorbis_comment_init( &vorbisComment);
ogg_stream_packetin( &oggStreamState, &header); ogg_stream_packetin( &oggStreamState, &header);
ogg_stream_packetin( &oggStreamState, &commentHeader); ogg_stream_packetin( &oggStreamState, &commentHeader);
@ -129,6 +129,8 @@ VorbisLibEncoder :: open ( void )
sink->write( oggPage.body, oggPage.body_len); sink->write( oggPage.body, oggPage.body_len);
} }
vorbis_comment_clear( &vorbisComment );
encoderOpen = true; encoderOpen = true;
return true; return true;
@ -313,6 +315,10 @@ VorbisLibEncoder :: vorbisBlocksOut ( void ) throw ()
ogg_page oggPage; ogg_page oggPage;
vorbis_analysis( &vorbisBlock, &oggPacket); vorbis_analysis( &vorbisBlock, &oggPacket);
vorbis_bitrate_addblock( &vorbisBlock);
while ( vorbis_bitrate_flushpacket( &vorbisDspState, &oggPacket) ) {
ogg_stream_packetin( &oggStreamState, &oggPacket); ogg_stream_packetin( &oggStreamState, &oggPacket);
while ( ogg_stream_pageout( &oggStreamState, &oggPage) ) { while ( ogg_stream_pageout( &oggStreamState, &oggPage) ) {
@ -330,6 +336,7 @@ VorbisLibEncoder :: vorbisBlocksOut ( void ) throw ()
} }
} }
} }
}
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
@ -359,6 +366,9 @@ VorbisLibEncoder :: close ( void ) throw ( Exception )
$Source$ $Source$
$Log$ $Log$
Revision 1.6 2002/02/20 10:35:35 darkeye
updated to work with Ogg Vorbis libs rc3 and current IceCast2 cvs
Revision 1.5 2001/10/21 13:08:18 darkeye Revision 1.5 2001/10/21 13:08:18 darkeye
fixed incorrect vorbis bitrate setting fixed incorrect vorbis bitrate setting