added support for low upload data rate forcing command line switch (used for server with bad internet access)
This commit is contained in:
parent
1e6f9f0dd9
commit
7824e1f758
5 changed files with 65 additions and 23 deletions
|
@ -28,13 +28,15 @@
|
|||
/******************************************************************************\
|
||||
* CChannelSet *
|
||||
\******************************************************************************/
|
||||
CChannelSet::CChannelSet() : bWriteStatusHTMLFile ( false )
|
||||
CChannelSet::CChannelSet ( const bool bForceLowUploadRate ) :
|
||||
bWriteStatusHTMLFile ( false )
|
||||
{
|
||||
// enable all channels and set server flag
|
||||
for ( int i = 0; i < MAX_NUM_CHANNELS; i++ )
|
||||
{
|
||||
vecChannels[i].SetEnable ( true );
|
||||
vecChannels[i].SetIsServer ( true );
|
||||
vecChannels[i].SetForceLowUploadRate ( bForceLowUploadRate );
|
||||
}
|
||||
|
||||
// define colors for chat window identifiers
|
||||
|
@ -527,6 +529,7 @@ void CChannelSet::WriteHTMLChannelList()
|
|||
\******************************************************************************/
|
||||
CChannel::CChannel() : sName ( "" ),
|
||||
vecdGains ( MAX_NUM_CHANNELS, (double) 1.0 ), bIsServer ( false ),
|
||||
bForceLowUploadRate ( false ),
|
||||
// it is important to give the following parameters meaningful initial
|
||||
// values because they are dependend on each other
|
||||
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,
|
||||
const CAudioCompression::EAudComprType eNewAudComprType )
|
||||
{
|
||||
|
@ -660,26 +676,32 @@ void CChannel::SetNetwBufSizeFactOut ( const int iNewNetwBlSiFactOut )
|
|||
{
|
||||
QMutexLocker locker ( &Mutex );
|
||||
|
||||
// store new value
|
||||
iCurNetwOutBlSiFact = iNewNetwBlSiFactOut;
|
||||
if ( !bForceLowUploadRate )
|
||||
{
|
||||
// store new value
|
||||
iCurNetwOutBlSiFact = iNewNetwBlSiFactOut;
|
||||
|
||||
// init audio compression and get audio compression block size
|
||||
iAudComprSizeOut = AudioCompressionOut.Init (
|
||||
iNewNetwBlSiFactOut * MIN_BLOCK_SIZE_SAMPLES, eAudComprTypeOut );
|
||||
// init audio compression and get audio compression block size
|
||||
iAudComprSizeOut = AudioCompressionOut.Init (
|
||||
iNewNetwBlSiFactOut * MIN_BLOCK_SIZE_SAMPLES, eAudComprTypeOut );
|
||||
|
||||
// init conversion buffer
|
||||
ConvBuf.Init ( iNewNetwBlSiFactOut * MIN_BLOCK_SIZE_SAMPLES );
|
||||
// init conversion buffer
|
||||
ConvBuf.Init ( iNewNetwBlSiFactOut * MIN_BLOCK_SIZE_SAMPLES );
|
||||
}
|
||||
}
|
||||
|
||||
void CChannel::SetAudioCompressionOut ( const CAudioCompression::EAudComprType eNewAudComprTypeOut )
|
||||
{
|
||||
// store new value
|
||||
eAudComprTypeOut = eNewAudComprTypeOut;
|
||||
if ( !bForceLowUploadRate )
|
||||
{
|
||||
// store new value
|
||||
eAudComprTypeOut = eNewAudComprTypeOut;
|
||||
|
||||
// call "set network buffer size factor" function because its initialization
|
||||
// depends on the audio compression format and implicitely, the audio compression
|
||||
// is initialized
|
||||
SetNetwBufSizeFactOut ( iCurNetwOutBlSiFact );
|
||||
// call "set network buffer size factor" function because its initialization
|
||||
// depends on the audio compression format and implicitely, the audio compression
|
||||
// is initialized
|
||||
SetNetwBufSizeFactOut ( iCurNetwOutBlSiFact );
|
||||
}
|
||||
}
|
||||
|
||||
void CChannel::SetSockBufSize ( const int iNumBlocks )
|
||||
|
|
|
@ -41,10 +41,10 @@
|
|||
// 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
|
||||
// correction is implemented)
|
||||
#define CON_TIME_OUT_SEC_MAX 5 // seconds
|
||||
#define CON_TIME_OUT_SEC_MAX 5 // seconds
|
||||
|
||||
// no valid channel number
|
||||
#define INVALID_CHANNEL_ID ( MAX_NUM_CHANNELS + 1 )
|
||||
#define INVALID_CHANNEL_ID ( MAX_NUM_CHANNELS + 1 )
|
||||
|
||||
enum EPutDataStat
|
||||
{
|
||||
|
@ -63,6 +63,10 @@ enum EGetDataStat
|
|||
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 ********************************************************************/
|
||||
// CChannel --------------------------------------------------------------------
|
||||
|
@ -83,7 +87,8 @@ public:
|
|||
bool IsConnected() const { return iConTimeOut > 0; }
|
||||
|
||||
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; }
|
||||
bool GetAddress ( CHostAddress& RetAddr );
|
||||
|
@ -173,6 +178,7 @@ protected:
|
|||
|
||||
bool bIsEnabled;
|
||||
bool bIsServer;
|
||||
bool bForceLowUploadRate;
|
||||
|
||||
int iCurNetwInBlSiFact;
|
||||
int iCurNetwOutBlSiFact;
|
||||
|
@ -215,7 +221,7 @@ class CChannelSet : public QObject
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CChannelSet();
|
||||
CChannelSet ( const bool bForceLowUploadRate );
|
||||
virtual ~CChannelSet() {}
|
||||
|
||||
bool PutData ( const CVector<unsigned char>& vecbyRecBuf,
|
||||
|
|
15
src/main.cpp
15
src/main.cpp
|
@ -46,6 +46,7 @@ int main ( int argc, char** argv )
|
|||
bool bIsClient = true;
|
||||
bool bUseGUI = true;
|
||||
bool bUseServerLogging = false;
|
||||
bool bForceLowUploadRate = false;
|
||||
quint16 iPortNumber = LLCON_PORT_NUMBER;
|
||||
std::string strIniFileName = "";
|
||||
std::string strHTMLStatusFileName = "";
|
||||
|
@ -80,7 +81,15 @@ int main ( int argc, char** argv )
|
|||
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",
|
||||
0, 65535, rDbleArgument ) )
|
||||
{
|
||||
|
@ -178,7 +187,8 @@ int main ( int argc, char** argv )
|
|||
|
||||
CServer Server ( bUseServerLogging, iPortNumber,
|
||||
strHTMLStatusFileName.c_str(),
|
||||
strServerName.c_str() );
|
||||
strServerName.c_str(),
|
||||
bForceLowUploadRate );
|
||||
|
||||
if ( bUseGUI )
|
||||
{
|
||||
|
@ -233,6 +243,7 @@ std::string UsageArguments ( char **argv )
|
|||
" -i, --inifile initialization file name (only available for client)\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"
|
||||
" -u, --lowuploadrate force low upload rate (only avaiable for server)\n"
|
||||
" -h, -?, --help this help text\n"
|
||||
"Example: " + std::string ( argv[0] ) + " -l -inifile myinifile.ini\n";
|
||||
}
|
||||
|
|
|
@ -28,8 +28,10 @@
|
|||
/* Implementation *************************************************************/
|
||||
CServer::CServer ( const bool bUseLogging, const quint16 iPortNumber,
|
||||
const QString& strHTMLStatusFileName,
|
||||
const QString& strServerNameForHTMLStatusFile ) :
|
||||
Socket ( &ChannelSet, this, iPortNumber )
|
||||
const QString& strServerNameForHTMLStatusFile,
|
||||
const bool bForceLowUploadRate ) :
|
||||
Socket ( &ChannelSet, this, iPortNumber ),
|
||||
ChannelSet ( bForceLowUploadRate )
|
||||
{
|
||||
vecsSendData.Init ( MIN_BLOCK_SIZE_SAMPLES );
|
||||
|
||||
|
|
|
@ -43,7 +43,8 @@ class CServer : public QObject
|
|||
public:
|
||||
CServer ( const bool bUseLogging, const quint16 iPortNumber,
|
||||
const QString& strHTMLStatusFileName,
|
||||
const QString& strServerNameForHTMLStatusFile );
|
||||
const QString& strServerNameForHTMLStatusFile,
|
||||
const bool bForceLowUploadRate );
|
||||
virtual ~CServer() {}
|
||||
|
||||
void Start();
|
||||
|
|
Loading…
Reference in a new issue