From dc5aaa9faf010123dd3a3ffde0272dcc6b6f9e53 Mon Sep 17 00:00:00 2001 From: darkeye Date: Tue, 20 Nov 2007 13:45:59 +0000 Subject: [PATCH] added Darwin Streaming Server mount point patch, closes #29 --- darkice/trunk/AUTHORS | 1 + darkice/trunk/ChangeLog | 5 ++++ darkice/trunk/man/darkice.1 | 3 ++- darkice/trunk/man/darkice.cfg.5 | 4 +++ darkice/trunk/src/DarkIce.cpp | 33 ++++++++++++----------- darkice/trunk/src/ShoutCast.cpp | 46 ++++++++++++++++++++++++++++++--- darkice/trunk/src/ShoutCast.h | 32 ++++++++++++++++++++--- 7 files changed, 100 insertions(+), 24 deletions(-) diff --git a/darkice/trunk/AUTHORS b/darkice/trunk/AUTHORS index 9581819..50cc998 100644 --- a/darkice/trunk/AUTHORS +++ b/darkice/trunk/AUTHORS @@ -31,4 +31,5 @@ with contributions by: Clyde Stubbs Jens Maurer Elod Horvath + Pierre Souchay diff --git a/darkice/trunk/ChangeLog b/darkice/trunk/ChangeLog index aa6d311..52ffcfd 100644 --- a/darkice/trunk/ChangeLog +++ b/darkice/trunk/ChangeLog @@ -1,3 +1,8 @@ +Darkice 0.19 to be released + + o added mount point option for Darwin Streaming Server + thanks to Pierre Souchay + 26-04-2007 DarkIce 0.18.1 released o enable real-time scheduling for non-super-users, if they have diff --git a/darkice/trunk/man/darkice.1 b/darkice/trunk/man/darkice.1 index 66aa919..c30e625 100644 --- a/darkice/trunk/man/darkice.1 +++ b/darkice/trunk/man/darkice.1 @@ -1,4 +1,4 @@ -.TH darkice 1 "April 26, 2007" "DarkIce" "DarkIce live audio streamer" +.TH darkice 1 "November 20, 2007" "DarkIce" "DarkIce live audio streamer" .SH NAME darkice \- an icecast / shoutcast live audio streamer .SH SYNOPSIS @@ -105,6 +105,7 @@ Developed with contributions by Clyde Stubbs Jens Maurer Elod Horvath + Pierre Souchay .SH LINKS Project homepage: diff --git a/darkice/trunk/man/darkice.cfg.5 b/darkice/trunk/man/darkice.cfg.5 index 14e7263..28af76c 100644 --- a/darkice/trunk/man/darkice.cfg.5 +++ b/darkice/trunk/man/darkice.cfg.5 @@ -367,6 +367,10 @@ server .PP Optional values: +.TP +.I mountPoint +Mount point for the stream on the server. Only works on Darwin Streaming +Server, the original Shoutcast server does not support mount points .TP .I sampleRate The sample rate of the encoded mp3 output. If not specified, defaults diff --git a/darkice/trunk/src/DarkIce.cpp b/darkice/trunk/src/DarkIce.cpp index 260701b..86b39e1 100644 --- a/darkice/trunk/src/DarkIce.cpp +++ b/darkice/trunk/src/DarkIce.cpp @@ -362,26 +362,26 @@ DarkIce :: configIceCast ( const Config & config, #ifdef HAVE_LAME_LIB if ( Util::strEq( str, "mp3") ) { - audioOuts[u].encoder = new LameLibEncoder( audioOuts[u].server.get(), - dsp.get(), - bitrateMode, - bitrate, - quality, - sampleRate, - channel, - lowpass, - highpass ); + audioOuts[u].encoder = new LameLibEncoder( audioOuts[u].server.get(), + dsp.get(), + bitrateMode, + bitrate, + quality, + sampleRate, + channel, + lowpass, + highpass ); } #endif #ifdef HAVE_TWOLAME_LIB if ( Util::strEq( str, "mp2") ) { - audioOuts[u].encoder = new TwoLameLibEncoder( + audioOuts[u].encoder = new TwoLameLibEncoder( audioOuts[u].server.get(), - dsp.get(), - bitrateMode, - bitrate, - sampleRate, - channel ); + dsp.get(), + bitrateMode, + bitrate, + sampleRate, + channel ); } #endif @@ -697,6 +697,7 @@ DarkIce :: configShoutCast ( const Config & config, const char * url = 0; const char * genre = 0; bool isPublic = false; + const char * mountPoint = 0; int lowpass = 0; int highpass = 0; const char * irc = 0; @@ -755,6 +756,7 @@ DarkIce :: configShoutCast ( const Config & config, port = Util::strToL( str); password = cs->getForSure("password"," missing in section ",stream); name = cs->get( "name"); + mountPoint = cs->get( "mountPoint" ); url = cs->get( "url"); genre = cs->get( "genre"); str = cs->get( "public"); @@ -803,6 +805,7 @@ DarkIce :: configShoutCast ( const Config & config, audioOuts[u].socket = new TcpSocket( server, port); audioOuts[u].server = new ShoutCast( audioOuts[u].socket.get(), password, + mountPoint, bitrate, name, url, diff --git a/darkice/trunk/src/ShoutCast.cpp b/darkice/trunk/src/ShoutCast.cpp index 6bcc845..2e1eb2d 100644 --- a/darkice/trunk/src/ShoutCast.cpp +++ b/darkice/trunk/src/ShoutCast.cpp @@ -51,6 +51,8 @@ #error need math.h #endif +#include + #include "Exception.h" #include "Source.h" @@ -87,12 +89,14 @@ static const char fileid[] = "$Id$"; void ShoutCast :: init ( const char * irc, const char * aim, - const char * icq ) + const char * icq, + const char * mountPoint ) throw ( Exception ) { this->irc = irc ? Util::strDup( irc) : 0; this->aim = aim ? Util::strDup( aim) : 0; this->icq = icq ? Util::strDup( icq) : 0; + this->mountPoint = mountPoint ? Util::strDup( mountPoint ) : 0; } @@ -111,6 +115,9 @@ ShoutCast :: strip ( void ) throw ( Exception ) if ( icq ) { delete[] icq; } + if (mountPoint ){ + delete[] mountPoint; + } } @@ -125,6 +132,9 @@ ShoutCast :: sendLogin ( void ) throw ( Exception ) const char * str; char resp[STRBUF_SIZE]; unsigned int len; + bool needsMountPoint = false; + const char * mountPoint = getMountPoint(); + if ( !source->isOpen() ) { return false; @@ -133,10 +143,38 @@ ShoutCast :: sendLogin ( void ) throw ( Exception ) return false; } + // We will add SOURCE only if really needed: if the mountPoint is not null + // and is different of "/". This is to keep maximum compatibility with + // NullSoft Shoutcast server. + if (mountPoint != 0L + && strlen(mountPoint) > 0 && 0 != strcmp("/", mountPoint)) { + needsMountPoint = true; + } + + std::ostringstream os; + + if (needsMountPoint) { + os << "SOURCE "; + } + /* first line is the password in itself */ - str = getPassword(); - sink->write( str, strlen( str)); - str = "\n"; + os << getPassword(); + os << "\n"; + + // send the mount point + if (needsMountPoint) { + os << " "; + if (strncmp("/", mountPoint, 1) != 0) { + os << "/"; + } + os << mountPoint; + os << "\n"; + } + + str = os.str().c_str(); + + // Ok, now we send login which will be different of classical Shoutcast + // if mountPoint is not null and is different from "/" ... sink->write( str, strlen( str)); sink->flush(); diff --git a/darkice/trunk/src/ShoutCast.h b/darkice/trunk/src/ShoutCast.h index 5cf9043..5703ee1 100644 --- a/darkice/trunk/src/ShoutCast.h +++ b/darkice/trunk/src/ShoutCast.h @@ -75,18 +75,25 @@ class ShoutCast : public CastSink */ char * icq; + /** + * The optional mountPoint + */ + char * mountPoint; + /** * Initalize the object. * * @param irc IRC info string for the stream. * @param aim AIM info string for the stream. * @param icq ICQ info string for the stream. + * @param mountPoint Optional mount point information * @exception Exception */ void init ( const char * irc, const char * aim, - const char * icq ) + const char * icq, + const char * mountPoint ) throw ( Exception ); /** @@ -128,6 +135,7 @@ class ShoutCast : public CastSink * * @param socket socket connection to the server. * @param password password to the server. + * @param mountPoint Optional mount point for DSS. * @param name name of the stream. * @param url URL associated with the stream. * @param genre genre of the stream. @@ -145,6 +153,7 @@ class ShoutCast : public CastSink inline ShoutCast ( TcpSocket * socket, const char * password, + const char * mountPoint, unsigned int bitRate, const char * name = 0, const char * url = 0, @@ -166,7 +175,7 @@ class ShoutCast : public CastSink streamDump, bufferDuration ) { - init( irc, aim, icq); + init( irc, aim, icq, mountPoint ); } /** @@ -178,7 +187,7 @@ class ShoutCast : public CastSink ShoutCast( const ShoutCast & cs ) throw ( Exception ) : CastSink( cs ) { - init( cs.getIrc(), cs.getAim(), cs.getIcq()); + init( cs.getIrc(), cs.getAim(), cs.getIcq(), cs.getMountPoint()); } /** @@ -205,11 +214,26 @@ class ShoutCast : public CastSink if ( this != &cs ) { strip(); CastSink::operator=( cs ); - init( cs.getIrc(), cs.getAim(), cs.getIcq()); + init( cs.getIrc(), cs.getAim(), cs.getIcq(), getMountPoint()); } return *this; } + /** + * Get the mount point of the stream on the server. + * The mount point can be null if it has not been set + * (typical Shoutcast server) or not null (for instance + * with Darwin Streaming Server). In that case, the + * authentication process will be slightly different. + * + * @return the mount point of the stream on the server. + */ + inline const char * + getMountPoint ( void ) const throw () + { + return mountPoint; + } + /** * Get the IRC info string for the stream. *