new management of network block size factors

This commit is contained in:
Volker Fischer 2006-03-13 19:32:23 +00:00
parent 95389cbf7a
commit c86cbcabdb
5 changed files with 50 additions and 36 deletions

View file

@ -90,7 +90,7 @@ protected:
class CAudioCompression
{
public:
enum EAudComprType {CT_NONE, CT_IMAADPCM};
enum EAudComprType { CT_NONE, CT_IMAADPCM };
CAudioCompression() {}
virtual ~CAudioCompression() {}

View file

@ -222,6 +222,16 @@ void CChannelSet::GetConCliParam ( CVector<CHostAddress>& vecHostAddresses,
\******************************************************************************/
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 */
byTimeStampIdxCnt = 0;
@ -283,21 +293,17 @@ void CChannel::SetNetwOutBlSiFact ( const int iNewBlockSizeFactor )
void CChannel::OnSendProtMessage ( CVector<uint8_t> vecMessage )
{
// must be disabled to be able to receive network buffer size factor changes
// FIXME check, if this condition must be checked somewhere else!
// // only send messages if we are connected, otherwise delete complete queue
// if ( IsConnected() )
// {
// only send messages if we are connected, otherwise delete complete queue
if ( IsConnected() )
{
// emit message to actually send the data
emit MessReadyForSending ( vecMessage );
// }
// else
// {
// // delete send message queue
// Protocol.DeleteSendMessQueue();
// }
}
else
{
// delete send message queue
Protocol.DeleteSendMessQueue();
}
}
@ -367,9 +373,26 @@ EPutDataStat CChannel::PutData ( const CVector<unsigned char>& vecbyData,
{
EPutDataStat eRet = PS_GEN_ERROR;
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 */
if ( iNumBytes == iAudComprSizeIn )
if ( bIsAudioPacket )
{
Mutex.lock();
{
@ -480,13 +503,6 @@ CVector<unsigned char> CChannel::PrepSendPacket ( const CVector<short>& vecsNPac
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;
}

View file

@ -141,6 +141,8 @@ protected:
int iConTimeOut;
int iConTimeOutStartVal;
int vecNetwInBufSizes[NET_BLOCK_SIZE_FACTOR_MAX];
int iCurNetwInBlSiFact;
int iCurNetwBlSiFact; // TODO, will be replaced by in/out settings

View file

@ -57,10 +57,6 @@ for ( int i = 0; i < vecMessage.Size (); i++ ) {
void CClient::OnReqJittBufSize()
{
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)

View file

@ -69,7 +69,7 @@
#define NET_BLOCK_SIZE_FACTOR 3 // 3 * 2 ms = 6 ms
// 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) */
#define MAX_NET_BUF_SIZE_NUM_BL 10 /* number of blocks */