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() {}
|
||||||
|
|
|
@ -222,6 +222,16 @@ void CChannelSet::GetConCliParam ( CVector<CHostAddress>& vecHostAddresses,
|
||||||
\******************************************************************************/
|
\******************************************************************************/
|
||||||
CChannel::CChannel()
|
CChannel::CChannel()
|
||||||
{
|
{
|
||||||
|
// 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 */
|
/* init time stamp index counter */
|
||||||
byTimeStampIdxCnt = 0;
|
byTimeStampIdxCnt = 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();
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -367,9 +373,26 @@ EPutDataStat CChannel::PutData ( const CVector<unsigned char>& vecbyData,
|
||||||
{
|
{
|
||||||
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();
|
||||||
{
|
{
|
||||||
|
@ -480,13 +503,6 @@ CVector<unsigned char> CChannel::PrepSendPacket ( const CVector<short>& vecsNPac
|
||||||
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