added support for low upload data rate forcing command line switch (used for server with bad internet access)

This commit is contained in:
Volker Fischer 2008-08-19 19:59:59 +00:00
parent 1e6f9f0dd9
commit 7824e1f758
5 changed files with 65 additions and 23 deletions

View file

@ -28,13 +28,15 @@
/******************************************************************************\ /******************************************************************************\
* CChannelSet * * CChannelSet *
\******************************************************************************/ \******************************************************************************/
CChannelSet::CChannelSet() : bWriteStatusHTMLFile ( false ) CChannelSet::CChannelSet ( const bool bForceLowUploadRate ) :
bWriteStatusHTMLFile ( false )
{ {
// enable all channels and set server flag // enable all channels and set server flag
for ( int i = 0; i < MAX_NUM_CHANNELS; i++ ) for ( int i = 0; i < MAX_NUM_CHANNELS; i++ )
{ {
vecChannels[i].SetEnable ( true ); vecChannels[i].SetEnable ( true );
vecChannels[i].SetIsServer ( true ); vecChannels[i].SetIsServer ( true );
vecChannels[i].SetForceLowUploadRate ( bForceLowUploadRate );
} }
// define colors for chat window identifiers // define colors for chat window identifiers
@ -527,6 +529,7 @@ void CChannelSet::WriteHTMLChannelList()
\******************************************************************************/ \******************************************************************************/
CChannel::CChannel() : sName ( "" ), CChannel::CChannel() : sName ( "" ),
vecdGains ( MAX_NUM_CHANNELS, (double) 1.0 ), bIsServer ( false ), vecdGains ( MAX_NUM_CHANNELS, (double) 1.0 ), bIsServer ( false ),
bForceLowUploadRate ( false ),
// it is important to give the following parameters meaningful initial // it is important to give the following parameters meaningful initial
// values because they are dependend on each other // values because they are dependend on each other
iCurSockBufSize ( DEF_NET_BUF_SIZE_NUM_BL ), iCurSockBufSize ( DEF_NET_BUF_SIZE_NUM_BL ),
@ -636,6 +639,19 @@ void CChannel::SetEnable ( const bool bNEnStat )
} }
} }
void CChannel::SetForceLowUploadRate ( const bool bNFoLoUpRat )
{
if ( bNFoLoUpRat )
{
// initialize with low upload rate parameters and set flag so that
// these parameters are not changed anymore
SetNetwBufSizeFactOut ( LOW_UPL_SET_BLOCK_SIZE_FACTOR_OUT );
SetAudioCompressionOut ( LOW_UPL_SET_AUDIO_COMPRESSION );
}
bForceLowUploadRate = bNFoLoUpRat;
}
void CChannel::SetNetwInBlSiFactAndCompr ( const int iNewBlockSizeFactor, void CChannel::SetNetwInBlSiFactAndCompr ( const int iNewBlockSizeFactor,
const CAudioCompression::EAudComprType eNewAudComprType ) const CAudioCompression::EAudComprType eNewAudComprType )
{ {
@ -660,26 +676,32 @@ void CChannel::SetNetwBufSizeFactOut ( const int iNewNetwBlSiFactOut )
{ {
QMutexLocker locker ( &Mutex ); QMutexLocker locker ( &Mutex );
// store new value if ( !bForceLowUploadRate )
iCurNetwOutBlSiFact = iNewNetwBlSiFactOut; {
// store new value
iCurNetwOutBlSiFact = iNewNetwBlSiFactOut;
// init audio compression and get audio compression block size // init audio compression and get audio compression block size
iAudComprSizeOut = AudioCompressionOut.Init ( iAudComprSizeOut = AudioCompressionOut.Init (
iNewNetwBlSiFactOut * MIN_BLOCK_SIZE_SAMPLES, eAudComprTypeOut ); iNewNetwBlSiFactOut * MIN_BLOCK_SIZE_SAMPLES, eAudComprTypeOut );
// init conversion buffer // init conversion buffer
ConvBuf.Init ( iNewNetwBlSiFactOut * MIN_BLOCK_SIZE_SAMPLES ); ConvBuf.Init ( iNewNetwBlSiFactOut * MIN_BLOCK_SIZE_SAMPLES );
}
} }
void CChannel::SetAudioCompressionOut ( const CAudioCompression::EAudComprType eNewAudComprTypeOut ) void CChannel::SetAudioCompressionOut ( const CAudioCompression::EAudComprType eNewAudComprTypeOut )
{ {
// store new value if ( !bForceLowUploadRate )
eAudComprTypeOut = eNewAudComprTypeOut; {
// store new value
eAudComprTypeOut = eNewAudComprTypeOut;
// call "set network buffer size factor" function because its initialization // call "set network buffer size factor" function because its initialization
// depends on the audio compression format and implicitely, the audio compression // depends on the audio compression format and implicitely, the audio compression
// is initialized // is initialized
SetNetwBufSizeFactOut ( iCurNetwOutBlSiFact ); SetNetwBufSizeFactOut ( iCurNetwOutBlSiFact );
}
} }
void CChannel::SetSockBufSize ( const int iNumBlocks ) void CChannel::SetSockBufSize ( const int iNumBlocks )

View file

@ -41,10 +41,10 @@
// Set the time-out for the input buffer until the state changes from // Set the time-out for the input buffer until the state changes from
// connected to not-connected (the actual time depends on the way the error // connected to not-connected (the actual time depends on the way the error
// correction is implemented) // correction is implemented)
#define CON_TIME_OUT_SEC_MAX 5 // seconds #define CON_TIME_OUT_SEC_MAX 5 // seconds
// no valid channel number // no valid channel number
#define INVALID_CHANNEL_ID ( MAX_NUM_CHANNELS + 1 ) #define INVALID_CHANNEL_ID ( MAX_NUM_CHANNELS + 1 )
enum EPutDataStat enum EPutDataStat
{ {
@ -63,6 +63,10 @@ enum EGetDataStat
GS_CHAN_NOT_CONNECTED GS_CHAN_NOT_CONNECTED
}; };
// low upload data rate settings
#define LOW_UPL_SET_AUDIO_COMPRESSION CAudioCompression::CT_MSADPCM
#define LOW_UPL_SET_BLOCK_SIZE_FACTOR_OUT MAX_NET_BLOCK_SIZE_FACTOR
/* Classes ********************************************************************/ /* Classes ********************************************************************/
// CChannel -------------------------------------------------------------------- // CChannel --------------------------------------------------------------------
@ -83,7 +87,8 @@ public:
bool IsConnected() const { return iConTimeOut > 0; } bool IsConnected() const { return iConTimeOut > 0; }
void SetEnable ( const bool bNEnStat ); void SetEnable ( const bool bNEnStat );
void SetIsServer ( const bool bNEnStat ) { bIsServer = bNEnStat; } void SetIsServer ( const bool bNIsServer ) { bIsServer = bNIsServer; }
void SetForceLowUploadRate ( const bool bNFoLoUpRat );
void SetAddress ( const CHostAddress NAddr ) { InetAddr = NAddr; } void SetAddress ( const CHostAddress NAddr ) { InetAddr = NAddr; }
bool GetAddress ( CHostAddress& RetAddr ); bool GetAddress ( CHostAddress& RetAddr );
@ -173,6 +178,7 @@ protected:
bool bIsEnabled; bool bIsEnabled;
bool bIsServer; bool bIsServer;
bool bForceLowUploadRate;
int iCurNetwInBlSiFact; int iCurNetwInBlSiFact;
int iCurNetwOutBlSiFact; int iCurNetwOutBlSiFact;
@ -215,7 +221,7 @@ class CChannelSet : public QObject
Q_OBJECT Q_OBJECT
public: public:
CChannelSet(); CChannelSet ( const bool bForceLowUploadRate );
virtual ~CChannelSet() {} virtual ~CChannelSet() {}
bool PutData ( const CVector<unsigned char>& vecbyRecBuf, bool PutData ( const CVector<unsigned char>& vecbyRecBuf,

View file

@ -46,6 +46,7 @@ int main ( int argc, char** argv )
bool bIsClient = true; bool bIsClient = true;
bool bUseGUI = true; bool bUseGUI = true;
bool bUseServerLogging = false; bool bUseServerLogging = false;
bool bForceLowUploadRate = false;
quint16 iPortNumber = LLCON_PORT_NUMBER; quint16 iPortNumber = LLCON_PORT_NUMBER;
std::string strIniFileName = ""; std::string strIniFileName = "";
std::string strHTMLStatusFileName = ""; std::string strHTMLStatusFileName = "";
@ -80,7 +81,15 @@ int main ( int argc, char** argv )
continue; continue;
} }
/* Port number ------------------------------------------------------------ */ /* Force low upload data rate flag ---------------------------------------- */
if ( GetFlagArgument ( argc, argv, i, "-u", "--lowuploadrate" ) )
{
bForceLowUploadRate = true;
cerr << "force low upload rate" << std::endl;
continue;
}
/* Port number ------------------------------------------------------------ */
if ( GetNumericArgument ( argc, argv, i, "-p", "--port", if ( GetNumericArgument ( argc, argv, i, "-p", "--port",
0, 65535, rDbleArgument ) ) 0, 65535, rDbleArgument ) )
{ {
@ -178,7 +187,8 @@ int main ( int argc, char** argv )
CServer Server ( bUseServerLogging, iPortNumber, CServer Server ( bUseServerLogging, iPortNumber,
strHTMLStatusFileName.c_str(), strHTMLStatusFileName.c_str(),
strServerName.c_str() ); strServerName.c_str(),
bForceLowUploadRate );
if ( bUseGUI ) if ( bUseGUI )
{ {
@ -233,6 +243,7 @@ std::string UsageArguments ( char **argv )
" -i, --inifile initialization file name (only available for client)\n" " -i, --inifile initialization file name (only available for client)\n"
" -p, --port local port number (only avaiable for server)\n" " -p, --port local port number (only avaiable for server)\n"
" -m, --htmlstatus enable HTML status file, set file name (only avaiable for server)\n" " -m, --htmlstatus enable HTML status file, set file name (only avaiable for server)\n"
" -u, --lowuploadrate force low upload rate (only avaiable for server)\n"
" -h, -?, --help this help text\n" " -h, -?, --help this help text\n"
"Example: " + std::string ( argv[0] ) + " -l -inifile myinifile.ini\n"; "Example: " + std::string ( argv[0] ) + " -l -inifile myinifile.ini\n";
} }

View file

@ -28,8 +28,10 @@
/* Implementation *************************************************************/ /* Implementation *************************************************************/
CServer::CServer ( const bool bUseLogging, const quint16 iPortNumber, CServer::CServer ( const bool bUseLogging, const quint16 iPortNumber,
const QString& strHTMLStatusFileName, const QString& strHTMLStatusFileName,
const QString& strServerNameForHTMLStatusFile ) : const QString& strServerNameForHTMLStatusFile,
Socket ( &ChannelSet, this, iPortNumber ) const bool bForceLowUploadRate ) :
Socket ( &ChannelSet, this, iPortNumber ),
ChannelSet ( bForceLowUploadRate )
{ {
vecsSendData.Init ( MIN_BLOCK_SIZE_SAMPLES ); vecsSendData.Init ( MIN_BLOCK_SIZE_SAMPLES );

View file

@ -43,7 +43,8 @@ class CServer : public QObject
public: public:
CServer ( const bool bUseLogging, const quint16 iPortNumber, CServer ( const bool bUseLogging, const quint16 iPortNumber,
const QString& strHTMLStatusFileName, const QString& strHTMLStatusFileName,
const QString& strServerNameForHTMLStatusFile ); const QString& strServerNameForHTMLStatusFile,
const bool bForceLowUploadRate );
virtual ~CServer() {} virtual ~CServer() {}
void Start(); void Start();