new management of network block size factors
This commit is contained in:
parent
95389cbf7a
commit
c86cbcabdb
5 changed files with 50 additions and 36 deletions
|
@ -90,7 +90,7 @@ protected:
|
||||||
class CAudioCompression
|
class CAudioCompression
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum EAudComprType {CT_NONE, CT_IMAADPCM};
|
enum EAudComprType { CT_NONE, CT_IMAADPCM };
|
||||||
|
|
||||||
CAudioCompression() {}
|
CAudioCompression() {}
|
||||||
virtual ~CAudioCompression() {}
|
virtual ~CAudioCompression() {}
|
||||||
|
|
|
@ -221,19 +221,29 @@ void CChannelSet::GetConCliParam ( CVector<CHostAddress>& vecHostAddresses,
|
||||||
* CChannel *
|
* CChannel *
|
||||||
\******************************************************************************/
|
\******************************************************************************/
|
||||||
CChannel::CChannel()
|
CChannel::CChannel()
|
||||||
{
|
{
|
||||||
/* init time stamp index counter */
|
// query all possible network in buffer sizes for determining if an
|
||||||
|
// audio packet was received
|
||||||
|
for ( int i = 0; i < ( NET_BLOCK_SIZE_FACTOR_MAX - 1 ); i++ )
|
||||||
|
{
|
||||||
|
// network block size factor must start from 1 -> ( i + 1 )
|
||||||
|
vecNetwInBufSizes[i] = AudioCompressionIn.Init (
|
||||||
|
( i + 1 ) * MIN_BLOCK_SIZE_SAMPLES,
|
||||||
|
CAudioCompression::CT_IMAADPCM );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* init time stamp index counter */
|
||||||
byTimeStampIdxCnt = 0;
|
byTimeStampIdxCnt = 0;
|
||||||
|
|
||||||
iCurNetwInBlSiFact = NET_BLOCK_SIZE_FACTOR;
|
iCurNetwInBlSiFact = NET_BLOCK_SIZE_FACTOR;
|
||||||
|
|
||||||
/* init the socket buffer */
|
/* init the socket buffer */
|
||||||
SetSockBufSize ( DEF_NET_BUF_SIZE_NUM_BL );
|
SetSockBufSize ( DEF_NET_BUF_SIZE_NUM_BL );
|
||||||
|
|
||||||
// set initial input and output block size factors
|
// set initial input and output block size factors
|
||||||
SetNetwBufSizeFact ( NET_BLOCK_SIZE_FACTOR );
|
SetNetwBufSizeFact ( NET_BLOCK_SIZE_FACTOR );
|
||||||
|
|
||||||
/* init time-out for the buffer with zero -> no connection */
|
/* init time-out for the buffer with zero -> no connection */
|
||||||
iConTimeOut = 0;
|
iConTimeOut = 0;
|
||||||
|
|
||||||
|
|
||||||
|
@ -283,21 +293,17 @@ void CChannel::SetNetwOutBlSiFact ( const int iNewBlockSizeFactor )
|
||||||
|
|
||||||
void CChannel::OnSendProtMessage ( CVector<uint8_t> vecMessage )
|
void CChannel::OnSendProtMessage ( CVector<uint8_t> vecMessage )
|
||||||
{
|
{
|
||||||
|
// only send messages if we are connected, otherwise delete complete queue
|
||||||
// must be disabled to be able to receive network buffer size factor changes
|
if ( IsConnected() )
|
||||||
// FIXME check, if this condition must be checked somewhere else!
|
{
|
||||||
|
|
||||||
// // only send messages if we are connected, otherwise delete complete queue
|
|
||||||
// if ( IsConnected() )
|
|
||||||
// {
|
|
||||||
// emit message to actually send the data
|
// emit message to actually send the data
|
||||||
emit MessReadyForSending ( vecMessage );
|
emit MessReadyForSending ( vecMessage );
|
||||||
// }
|
}
|
||||||
// else
|
else
|
||||||
// {
|
{
|
||||||
// // delete send message queue
|
// delete send message queue
|
||||||
// Protocol.DeleteSendMessQueue();
|
Protocol.DeleteSendMessQueue();
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -366,10 +372,27 @@ EPutDataStat CChannel::PutData ( const CVector<unsigned char>& vecbyData,
|
||||||
int iNumBytes )
|
int iNumBytes )
|
||||||
{
|
{
|
||||||
EPutDataStat eRet = PS_GEN_ERROR;
|
EPutDataStat eRet = PS_GEN_ERROR;
|
||||||
bool bNewConnection = false;
|
bool bNewConnection = false;
|
||||||
|
bool bIsAudioPacket = false;
|
||||||
|
|
||||||
|
// check if this is an audio packet by checking all possible lengths
|
||||||
|
for ( int i = 0; i < ( NET_BLOCK_SIZE_FACTOR_MAX - 1 ); i++ )
|
||||||
|
{
|
||||||
|
if ( iNumBytes == vecNetwInBufSizes[i] )
|
||||||
|
{
|
||||||
|
bIsAudioPacket = true;
|
||||||
|
|
||||||
|
// check if we are correctly initialized
|
||||||
|
if ( iAudComprSizeIn != vecNetwInBufSizes[i] )
|
||||||
|
{
|
||||||
|
// re-initialize to new value
|
||||||
|
SetNetwBufSizeFact ( i + 1 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* only process if packet has correct size */
|
/* only process if packet has correct size */
|
||||||
if ( iNumBytes == iAudComprSizeIn )
|
if ( bIsAudioPacket )
|
||||||
{
|
{
|
||||||
Mutex.lock();
|
Mutex.lock();
|
||||||
{
|
{
|
||||||
|
@ -456,7 +479,7 @@ bool CChannel::GetData ( CVector<double>& vecdData )
|
||||||
/* decrease time-out counter */
|
/* decrease time-out counter */
|
||||||
if ( iConTimeOut > 0 )
|
if ( iConTimeOut > 0 )
|
||||||
{
|
{
|
||||||
iConTimeOut--;
|
iConTimeOut--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -479,13 +502,6 @@ CVector<unsigned char> CChannel::PrepSendPacket ( const CVector<short>& vecsNPac
|
||||||
vecbySendBuf.Init ( iAudComprSizeOut );
|
vecbySendBuf.Init ( iAudComprSizeOut );
|
||||||
vecbySendBuf = AudioCompressionOut.Encode ( ConvBuf.Get() );
|
vecbySendBuf = AudioCompressionOut.Encode ( ConvBuf.Get() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we are not connected, send network buffer size factor so that the
|
|
||||||
// server is able to process our audio packets
|
|
||||||
if ( !IsConnected() )
|
|
||||||
{
|
|
||||||
Protocol.CreateNetwBlSiFactMes ( iCurNetwBlSiFact );
|
|
||||||
}
|
|
||||||
|
|
||||||
return vecbySendBuf;
|
return vecbySendBuf;
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,6 +141,8 @@ protected:
|
||||||
int iConTimeOut;
|
int iConTimeOut;
|
||||||
int iConTimeOutStartVal;
|
int iConTimeOutStartVal;
|
||||||
|
|
||||||
|
int vecNetwInBufSizes[NET_BLOCK_SIZE_FACTOR_MAX];
|
||||||
|
|
||||||
int iCurNetwInBlSiFact;
|
int iCurNetwInBlSiFact;
|
||||||
|
|
||||||
int iCurNetwBlSiFact; // TODO, will be replaced by in/out settings
|
int iCurNetwBlSiFact; // TODO, will be replaced by in/out settings
|
||||||
|
|
|
@ -57,10 +57,6 @@ for ( int i = 0; i < vecMessage.Size (); i++ ) {
|
||||||
void CClient::OnReqJittBufSize()
|
void CClient::OnReqJittBufSize()
|
||||||
{
|
{
|
||||||
Channel.CreateJitBufMes ( Channel.GetSockBufSize() );
|
Channel.CreateJitBufMes ( Channel.GetSockBufSize() );
|
||||||
|
|
||||||
// FIXME: we set the network buffer size factor here, too -> in the
|
|
||||||
// future a separate request function for this parameter should be created
|
|
||||||
Channel.CreateNetwBlSiFactMes ( Channel.GetNetwBufSizeFact() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CClient::SetServerAddr(QString strNAddr)
|
bool CClient::SetServerAddr(QString strNAddr)
|
||||||
|
|
|
@ -69,7 +69,7 @@
|
||||||
#define NET_BLOCK_SIZE_FACTOR 3 // 3 * 2 ms = 6 ms
|
#define NET_BLOCK_SIZE_FACTOR 3 // 3 * 2 ms = 6 ms
|
||||||
|
|
||||||
// maximum value of factor for network block size
|
// maximum value of factor for network block size
|
||||||
#define NET_BLOCK_SIZE_FACTOR_MAX 10
|
#define NET_BLOCK_SIZE_FACTOR_MAX 15
|
||||||
|
|
||||||
/* maximum network buffer size (which can be chosen by slider) */
|
/* maximum network buffer size (which can be chosen by slider) */
|
||||||
#define MAX_NET_BUF_SIZE_NUM_BL 10 /* number of blocks */
|
#define MAX_NET_BUF_SIZE_NUM_BL 10 /* number of blocks */
|
||||||
|
|
Loading…
Reference in a new issue