regression of r503
This commit is contained in:
parent
8227296d5c
commit
6f62a31701
|
@ -61,7 +61,8 @@ CastSink :: init ( TcpSocket * socket,
|
||||||
const char * name,
|
const char * name,
|
||||||
const char * url,
|
const char * url,
|
||||||
const char * genre,
|
const char * genre,
|
||||||
bool isPublic )
|
bool isPublic,
|
||||||
|
unsigned int bufferDuration )
|
||||||
throw ( Exception )
|
throw ( Exception )
|
||||||
{
|
{
|
||||||
this->socket = socket;
|
this->socket = socket;
|
||||||
|
@ -72,6 +73,13 @@ CastSink :: init ( TcpSocket * socket,
|
||||||
this->url = url ? Util::strDup( url) : 0;
|
this->url = url ? Util::strDup( url) : 0;
|
||||||
this->genre = genre ? Util::strDup( genre) : 0;
|
this->genre = genre ? Util::strDup( genre) : 0;
|
||||||
this->isPublic = isPublic;
|
this->isPublic = isPublic;
|
||||||
|
this->bufferDuration = bufferDuration;
|
||||||
|
|
||||||
|
int bufferSize = bitRate ? (bitRate * 1024 / 8) * bufferDuration
|
||||||
|
: (128 * 1024 / 8) * bufferDuration;
|
||||||
|
|
||||||
|
bufferedSink = socket ? new BufferedSink( socket, bufferSize)
|
||||||
|
: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -110,7 +118,7 @@ CastSink :: open ( void ) throw ( Exception )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !getSink()->open() ) {
|
if ( !bufferedSink->open() ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,11 +68,21 @@ class CastSink : public Sink, public virtual Reporter
|
||||||
*/
|
*/
|
||||||
Ref<TcpSocket> socket;
|
Ref<TcpSocket> socket;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The BufferedSink encapsulating the socket connection to the server.
|
||||||
|
*/
|
||||||
|
Ref<BufferedSink> bufferedSink;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An optional Sink to enable stream dumps.
|
* An optional Sink to enable stream dumps.
|
||||||
*/
|
*/
|
||||||
Ref<Sink> streamDump;
|
Ref<Sink> streamDump;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Duration of the BufferedSink buffer in seconds.
|
||||||
|
*/
|
||||||
|
unsigned int bufferDuration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Password to the server.
|
* Password to the server.
|
||||||
*/
|
*/
|
||||||
|
@ -113,6 +123,8 @@ class CastSink : public Sink, public virtual Reporter
|
||||||
* @param genre genre of the stream.
|
* @param genre genre of the stream.
|
||||||
* @param bitRate bitrate of the stream (e.g. mp3 bitrate).
|
* @param bitRate bitrate of the stream (e.g. mp3 bitrate).
|
||||||
* @param isPublic is the stream public?
|
* @param isPublic is the stream public?
|
||||||
|
* @param bufferDuration duration of the BufferedSink buffer
|
||||||
|
* in seconds.
|
||||||
* @exception Exception
|
* @exception Exception
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
|
@ -123,7 +135,8 @@ class CastSink : public Sink, public virtual Reporter
|
||||||
const char * name,
|
const char * name,
|
||||||
const char * url,
|
const char * url,
|
||||||
const char * genre,
|
const char * genre,
|
||||||
bool isPublic)
|
bool isPublic,
|
||||||
|
unsigned int bufferDuration )
|
||||||
throw ( Exception );
|
throw ( Exception );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -165,7 +178,7 @@ class CastSink : public Sink, public virtual Reporter
|
||||||
inline Sink *
|
inline Sink *
|
||||||
getSink ( void ) const throw ()
|
getSink ( void ) const throw ()
|
||||||
{
|
{
|
||||||
return getSocket();
|
return bufferedSink.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -193,7 +206,8 @@ class CastSink : public Sink, public virtual Reporter
|
||||||
* @param bitRate bitrate of the stream (e.g. mp3 bitrate).
|
* @param bitRate bitrate of the stream (e.g. mp3 bitrate).
|
||||||
* @param isPublic is the stream public?
|
* @param isPublic is the stream public?
|
||||||
* @param streamDump a Sink to dump the streamed binary data to
|
* @param streamDump a Sink to dump the streamed binary data to
|
||||||
*
|
* @param bufferDuration duration of the BufferedSink buffer
|
||||||
|
* in seconds.
|
||||||
* @exception Exception
|
* @exception Exception
|
||||||
*/
|
*/
|
||||||
inline
|
inline
|
||||||
|
@ -204,7 +218,8 @@ class CastSink : public Sink, public virtual Reporter
|
||||||
const char * url = 0,
|
const char * url = 0,
|
||||||
const char * genre = 0,
|
const char * genre = 0,
|
||||||
bool isPublic = false,
|
bool isPublic = false,
|
||||||
Sink * streamDump = 0)
|
Sink * streamDump = 0,
|
||||||
|
unsigned int bufferDuration = 10 )
|
||||||
throw ( Exception )
|
throw ( Exception )
|
||||||
{
|
{
|
||||||
init( socket,
|
init( socket,
|
||||||
|
@ -214,7 +229,8 @@ class CastSink : public Sink, public virtual Reporter
|
||||||
name,
|
name,
|
||||||
url,
|
url,
|
||||||
genre,
|
genre,
|
||||||
isPublic );
|
isPublic,
|
||||||
|
bufferDuration );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -233,7 +249,8 @@ class CastSink : public Sink, public virtual Reporter
|
||||||
cs.name,
|
cs.name,
|
||||||
cs.url,
|
cs.url,
|
||||||
cs.genre,
|
cs.genre,
|
||||||
cs.isPublic );
|
cs.isPublic,
|
||||||
|
cs.bufferDuration );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -267,7 +284,8 @@ class CastSink : public Sink, public virtual Reporter
|
||||||
cs.name,
|
cs.name,
|
||||||
cs.url,
|
cs.url,
|
||||||
cs.genre,
|
cs.genre,
|
||||||
cs.isPublic );
|
cs.isPublic,
|
||||||
|
cs.bufferDuration );
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -290,11 +308,7 @@ class CastSink : public Sink, public virtual Reporter
|
||||||
inline virtual bool
|
inline virtual bool
|
||||||
isOpen ( void ) const throw ()
|
isOpen ( void ) const throw ()
|
||||||
{
|
{
|
||||||
Sink *s = getSink();
|
return bufferedSink != NULL ? bufferedSink->isOpen() : false;
|
||||||
if (s)
|
|
||||||
return getSink()->isOpen();
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -441,6 +455,17 @@ class CastSink : public Sink, public virtual Reporter
|
||||||
{
|
{
|
||||||
return isPublic;
|
return isPublic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the duration of the BufferedSink buffer in seconds.
|
||||||
|
*
|
||||||
|
* @return the the duration of the BufferedSink buffer in seconds.
|
||||||
|
*/
|
||||||
|
inline unsigned int
|
||||||
|
getBufferDuration ( void ) const throw ()
|
||||||
|
{
|
||||||
|
return bufferDuration;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue