added Darwin Streaming Server mount point patch, closes #29

This commit is contained in:
darkeye 2007-11-20 13:45:59 +00:00
parent 5fb33b2c45
commit dc5aaa9faf
7 changed files with 100 additions and 24 deletions

View File

@ -31,4 +31,5 @@ with contributions by:
Clyde Stubbs <clyde@htsoft.com>
Jens Maurer <Jens.Maurer@gmx.net>
Elod Horvath <elod@itfais.com>
Pierre Souchay <pierre@souchay.net>

View File

@ -1,3 +1,8 @@
Darkice 0.19 to be released
o added mount point option for Darwin Streaming Server
thanks to Pierre Souchay <pierre@souchay.net>
26-04-2007 DarkIce 0.18.1 released
o enable real-time scheduling for non-super-users, if they have

View File

@ -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 <clyde@htsoft.com>
Jens Maurer <Jens.Maurer@gmx.net>
Elod Horvath <elod@itfais.com>
Pierre Souchay <pierre@souchay.net>
.SH LINKS
Project homepage:

View File

@ -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

View File

@ -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,

View File

@ -51,6 +51,8 @@
#error need math.h
#endif
#include <sstream>
#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();

View File

@ -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.
*