bug fix, some renamings of variables/functions, introduction of new signal in channel

This commit is contained in:
Volker Fischer 2009-08-02 07:54:15 +00:00
parent 35eb0fe4aa
commit 43eb897fd8
11 changed files with 106 additions and 36 deletions

View File

@ -118,6 +118,12 @@ bool CNetBuf::Get ( CVector<uint8_t>& vecbyData )
// get size of data to be get from the buffer // get size of data to be get from the buffer
const int iInSize = vecbyData.Size(); const int iInSize = vecbyData.Size();
// check size
if ( iInSize != iBlockSize )
{
return false;
}
// Check if there is not enough data available -> correct // Check if there is not enough data available -> correct
if ( GetAvailData() < iInSize ) if ( GetAvailData() < iInSize )
{ {
@ -250,7 +256,7 @@ void CNetBuf::Clear ( const EClearType eClearType )
iPutPos = 0; iPutPos = 0;
iGetPos = iMiddleOfBuffer; iGetPos = iMiddleOfBuffer;
/* check for special case */ // check for special case
if ( iPutPos == iGetPos ) if ( iPutPos == iGetPos )
{ {
eBufState = CNetBuf::BS_FULL; eBufState = CNetBuf::BS_FULL;

View File

@ -43,7 +43,7 @@ CChannel::CChannel ( const bool bNIsServer ) :
iConTimeOut = 0; iConTimeOut = 0;
// init the socket buffer // init the socket buffer
SetSockBufSize ( DEF_NET_BUF_SIZE_NUM_BL ); SetSockBufNumFrames ( DEF_NET_BUF_SIZE_NUM_BL );
// connections ------------------------------------------------------------- // connections -------------------------------------------------------------
@ -145,19 +145,20 @@ void CChannel::SetNetwFrameSizeAndFact ( const int iNewNetwFrameSize,
CreateNetTranspPropsMessFromCurrentSettings(); CreateNetTranspPropsMessFromCurrentSettings();
} }
bool CChannel::SetSockBufSize ( const int iNumBlocks ) bool CChannel::SetSockBufNumFrames ( const int iNewNumFrames )
{ {
QMutexLocker locker ( &Mutex ); // this opperation must be done with mutex QMutexLocker locker ( &Mutex ); // this opperation must be done with mutex
// first check for valid input parameter range // first check for valid input parameter range
if ( ( iNumBlocks >= MIN_NET_BUF_SIZE_NUM_BL ) && if ( ( iNewNumFrames >= MIN_NET_BUF_SIZE_NUM_BL ) &&
( iNumBlocks <= MAX_NET_BUF_SIZE_NUM_BL ) ) ( iNewNumFrames <= MAX_NET_BUF_SIZE_NUM_BL ) )
{ {
iCurSockBufSize = iNumBlocks; // store new value
iCurSockBufNumFrames = iNewNumFrames;
// the network block size is a multiple of the internal minimal // the network block size is a multiple of the minimum network
// block size // block size
SockBuf.Init ( SYSTEM_BLOCK_FRAME_SAMPLES, iNumBlocks ); SockBuf.Init ( iNetwFrameSize, iNewNumFrames );
return false; // -> no error return false; // -> no error
} }
@ -240,7 +241,7 @@ void CChannel::OnSendProtMessage ( CVector<uint8_t> vecMessage )
void CChannel::OnJittBufSizeChange ( int iNewJitBufSize ) void CChannel::OnJittBufSizeChange ( int iNewJitBufSize )
{ {
SetSockBufSize ( iNewJitBufSize ); SetSockBufNumFrames ( iNewJitBufSize );
} }
void CChannel::OnChangeChanGain ( int iChanID, double dNewGain ) void CChannel::OnChangeChanGain ( int iChanID, double dNewGain )
@ -281,6 +282,13 @@ void CChannel::OnNetTranspPropsReceived ( CNetworkTransportProps NetworkTranspor
iNetwFrameSize = iNetwFrameSize =
NetworkTransportProps.iNetworkPacketSize / NetworkTransportProps.iNetworkPacketSize /
NetworkTransportProps.iBlockSizeFact; NetworkTransportProps.iBlockSizeFact;
// update socket buffer (the network block size is a multiple of the
// minimum network frame size
SockBuf.Init ( iNetwFrameSize, iCurSockBufNumFrames );
// fire message
emit NetwFrameSizeHasChanged ( iNetwFrameSize );
} }
} }
@ -435,7 +443,7 @@ EGetDataStat CChannel::GetData ( CVector<uint8_t>& vecbyData )
// where the atomic block size is "SYSTEM_BLOCK_FRAME_SAMPLES") // where the atomic block size is "SYSTEM_BLOCK_FRAME_SAMPLES")
// TODO this code only works with the above assumption -> better // TODO this code only works with the above assumption -> better
// implementation so that we are not depending on assumptions // implementation so that we are not depending on assumptions
iConTimeOut -= SYSTEM_BLOCK_FRAME_SAMPLES; iConTimeOut -= SYSTEM_BLOCK_FRAME_SAMPLES;

View File

@ -88,8 +88,8 @@ public:
void SetRemoteChanGain ( const int iId, const double dGain ) void SetRemoteChanGain ( const int iId, const double dGain )
{ Protocol.CreateChanGainMes ( iId, dGain ); } { Protocol.CreateChanGainMes ( iId, dGain ); }
bool SetSockBufSize ( const int iNumBlocks ); bool SetSockBufNumFrames ( const int iNewNumFrames );
int GetSockBufSize() const { return iCurSockBufSize; } int GetSockBufNumFrames() const { return iCurSockBufNumFrames; }
int GetUploadRateKbps(); int GetUploadRateKbps();
@ -145,7 +145,7 @@ protected:
// network jitter-buffer // network jitter-buffer
CNetBuf SockBuf; CNetBuf SockBuf;
int iCurSockBufSize; int iCurSockBufNumFrames;
CCycleTimeVariance CycleTimeVariance; CCycleTimeVariance CycleTimeVariance;
@ -182,6 +182,7 @@ signals:
void ReqConnClientsList(); void ReqConnClientsList();
void ConClientListMesReceived ( CVector<CChannelShortInfo> vecChanInfo ); void ConClientListMesReceived ( CVector<CChannelShortInfo> vecChanInfo );
void NameHasChanged(); void NameHasChanged();
void NetwFrameSizeHasChanged ( int iNewFrameSize );
void ChatTextReceived ( QString strChatText ); void ChatTextReceived ( QString strChatText );
void PingReceived ( int iMs ); void PingReceived ( int iMs );
void ReqNetTranspProps(); void ReqNetTranspProps();

View File

@ -73,7 +73,7 @@ void CClient::OnSendProtMessage ( CVector<uint8_t> vecMessage )
void CClient::OnReqJittBufSize() void CClient::OnReqJittBufSize()
{ {
// TODO cant we implement this OnReqJjittBufSize inside the channel object? // TODO cant we implement this OnReqJjittBufSize inside the channel object?
Channel.CreateJitBufMes ( Channel.GetSockBufSize() ); Channel.CreateJitBufMes ( Channel.GetSockBufNumFrames() );
} }
void CClient::OnNewConnection() void CClient::OnNewConnection()
@ -514,8 +514,8 @@ void CClient::UpdateSocketBufferSize()
{ {
// we are in the middle of the decision region, use // we are in the middle of the decision region, use
// previous setting for determing the new decision // previous setting for determing the new decision
if ( !( ( GetSockBufSize() == iUpperHystDec ) || if ( !( ( GetSockBufNumFrames() == iUpperHystDec ) ||
( GetSockBufSize() == iLowerHystDec ) ) ) ( GetSockBufNumFrames() == iLowerHystDec ) ) )
{ {
// The old result is not near the new decision, // The old result is not near the new decision,
// use per definition the upper decision. // use per definition the upper decision.

View File

@ -93,13 +93,13 @@ public:
void SetDoAutoSockBufSize ( const bool bValue ) { bDoAutoSockBufSize = bValue; } void SetDoAutoSockBufSize ( const bool bValue ) { bDoAutoSockBufSize = bValue; }
bool GetDoAutoSockBufSize() { return bDoAutoSockBufSize; } bool GetDoAutoSockBufSize() { return bDoAutoSockBufSize; }
void SetSockBufSize ( const int iNumBlocks ) void SetSockBufNumFrames ( const int iNumBlocks )
{ {
// only change parameter if new parameter is different from current one // only change parameter if new parameter is different from current one
if ( Channel.GetSockBufSize() != iNumBlocks ) if ( Channel.GetSockBufNumFrames() != iNumBlocks )
{ {
// set the new socket size // set the new socket size (number of frames)
if ( !Channel.SetSockBufSize ( iNumBlocks ) ) if ( !Channel.SetSockBufNumFrames ( iNumBlocks ) )
{ {
// if setting of socket buffer size was successful, // if setting of socket buffer size was successful,
// tell the server that size has changed // tell the server that size has changed
@ -107,7 +107,7 @@ public:
} }
} }
} }
int GetSockBufSize() { return Channel.GetSockBufSize(); } int GetSockBufNumFrames() { return Channel.GetSockBufNumFrames(); }
int GetUploadRateKbps() { return Channel.GetUploadRateKbps(); } int GetUploadRateKbps() { return Channel.GetUploadRateKbps(); }

View File

@ -154,7 +154,7 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent,
void CClientSettingsDlg::UpdateJitterBufferFrame() void CClientSettingsDlg::UpdateJitterBufferFrame()
{ {
// update slider value and text // update slider value and text
const int iCurNumNetBuf = pClient->GetSockBufSize(); const int iCurNumNetBuf = pClient->GetSockBufNumFrames();
SliderNetBuf->setValue ( iCurNumNetBuf ); SliderNetBuf->setValue ( iCurNumNetBuf );
TextNetBuf->setText ( "Size: " + QString().setNum ( iCurNumNetBuf ) ); TextNetBuf->setText ( "Size: " + QString().setNum ( iCurNumNetBuf ) );
@ -220,7 +220,7 @@ void CClientSettingsDlg::OnDriverSetupBut()
void CClientSettingsDlg::OnSliderNetBuf ( int value ) void CClientSettingsDlg::OnSliderNetBuf ( int value )
{ {
pClient->SetSockBufSize ( value ); pClient->SetSockBufNumFrames ( value );
UpdateJitterBufferFrame(); UpdateJitterBufferFrame();
} }
@ -296,7 +296,7 @@ void CClientSettingsDlg::OnPingTimeResult ( int iPingTime )
*/ */
const int iTotalJitterBufferDelayMS = SYSTEM_BLOCK_DURATION_MS_FLOAT * const int iTotalJitterBufferDelayMS = SYSTEM_BLOCK_DURATION_MS_FLOAT *
( 2 /* buffer at client and server */ * pClient->GetSockBufSize() ) / 2; ( 2 /* buffer at client and server */ * pClient->GetSockBufNumFrames() ) / 2;
// we assume that we have two period sizes for the input and one for the // we assume that we have two period sizes for the input and one for the
// output, therefore we have "3 *" instead of "2 *" (for input and output) // output, therefore we have "3 *" instead of "2 *" (for input and output)

View File

@ -485,7 +485,7 @@ void CLlconClientDlg::customEvent ( QEvent* Event )
break; break;
case MS_SET_JIT_BUF_SIZE: case MS_SET_JIT_BUF_SIZE:
pClient->SetSockBufSize ( iStatus ); pClient->SetSockBufNumFrames ( iStatus );
break; break;
} }

View File

@ -77,13 +77,13 @@ void CLlconServerDlg::OnTimer()
{ {
CVector<CHostAddress> vecHostAddresses; CVector<CHostAddress> vecHostAddresses;
CVector<QString> vecsName; CVector<QString> vecsName;
CVector<int> veciJitBufSize; CVector<int> veciJitBufNumFrames;
CVector<int> veciNetwFrameSizeFact; CVector<int> veciNetwFrameSizeFact;
double dCurTiStdDev; double dCurTiStdDev;
ListViewMutex.lock(); ListViewMutex.lock();
pServer->GetConCliParam ( vecHostAddresses, vecsName, veciJitBufSize, pServer->GetConCliParam ( vecHostAddresses, vecsName, veciJitBufNumFrames,
veciNetwFrameSizeFact ); veciNetwFrameSizeFact );
// fill list with connected clients // fill list with connected clients
@ -101,7 +101,7 @@ void CLlconServerDlg::OnTimer()
// jitter buffer size (polling for updates) // jitter buffer size (polling for updates)
vecpListViewItems[i]->setText ( 4, vecpListViewItems[i]->setText ( 4,
QString().setNum ( veciJitBufSize[i] ) ); QString().setNum ( veciJitBufNumFrames[i] ) );
// out network block size // out network block size
vecpListViewItems[i]->setText ( 5, vecpListViewItems[i]->setText ( 5,

View File

@ -318,6 +318,29 @@ void CServer::OnTimer()
{ {
for ( int i = 0; i < iNumClients; i++ ) for ( int i = 0; i < iNumClients; i++ )
{ {
/*
// TEST CELT
CVector<short> vecsAudioSndCrdMono ( iMonoBlockSizeSam );
celt_decode ( CeltDecoder,
&vecbyNetwData[0],
iCeltNumCodedBytes,
&vecsAudioSndCrdMono[0] );
for ( i = 0, j = 0; i < iMonoBlockSizeSam; i++, j += 2 )
{
vecsStereoSndCrd[j] = vecsStereoSndCrd[j + 1] =
vecsAudioSndCrdMono[i];
}
*/
// TODO first ALL channels must be decoded before process data can
// be called!!!
// generate a sparate mix for each channel // generate a sparate mix for each channel
// actual processing of audio data -> mix // actual processing of audio data -> mix
vecsSendData = ProcessData ( vecvecdData, vecvecdGains[i] ); vecsSendData = ProcessData ( vecvecdData, vecvecdGains[i] );
@ -326,6 +349,17 @@ void CServer::OnTimer()
// Socket.SendPacket ( // Socket.SendPacket (
// PrepSendPacket ( vecChanID[i], vecsSendData ), // PrepSendPacket ( vecChanID[i], vecsSendData ),
// GetAddress ( vecChanID[i] ) ); // GetAddress ( vecChanID[i] ) );
/*
celt_encode ( CeltEncoder,
&vecsNetwork[0],
NULL,
&vecCeltData[0],
iCeltNumCodedBytes );
Socket.SendPacket ( vecCeltData, Channel.GetAddress() );
*/
} }
} }
else else
@ -363,8 +397,29 @@ void CServer::GetBlockAllConC ( CVector<int>& vecChanID,
// read out all input buffers to decrease timeout counter on // read out all input buffers to decrease timeout counter on
// disconnected channels // disconnected channels
// const EGetDataStat eGetStat = vecChannels[i].GetData ( vecdData ); // const EGetDataStat eGetStat = vecChannels[i].GetData ( vecdData );
const EGetDataStat eGetStat=GS_BUFFER_OK;//TEST const EGetDataStat eGetStat=GS_BUFFER_OK;//TEST
// TEST
/*
// TEST CELT
CVector<short> vecsAudioSndCrdMono ( iMonoBlockSizeSam );
celt_decode ( CeltDecoder,
&vecbyNetwData[0],
iCeltNumCodedBytes,
&vecsAudioSndCrdMono[0] );
for ( i = 0, j = 0; i < iMonoBlockSizeSam; i++, j += 2 )
{
vecsStereoSndCrd[j] = vecsStereoSndCrd[j + 1] =
vecsAudioSndCrdMono[i];
}
*/
// if channel was just disconnected, set flag that connected // if channel was just disconnected, set flag that connected
// client list is sent to all other clients // client list is sent to all other clients
if ( eGetStat == GS_CHAN_NOW_DISCONNECTED ) if ( eGetStat == GS_CHAN_NOW_DISCONNECTED )
@ -672,7 +727,7 @@ bAudioOK = true;
void CServer::GetConCliParam ( CVector<CHostAddress>& vecHostAddresses, void CServer::GetConCliParam ( CVector<CHostAddress>& vecHostAddresses,
CVector<QString>& vecsName, CVector<QString>& vecsName,
CVector<int>& veciJitBufSize, CVector<int>& veciJitBufNumFrames,
CVector<int>& veciNetwFrameSizeFact ) CVector<int>& veciNetwFrameSizeFact )
{ {
CHostAddress InetAddr; CHostAddress InetAddr;
@ -680,7 +735,7 @@ void CServer::GetConCliParam ( CVector<CHostAddress>& vecHostAddresses,
// init return values // init return values
vecHostAddresses.Init ( USED_NUM_CHANNELS ); vecHostAddresses.Init ( USED_NUM_CHANNELS );
vecsName.Init ( USED_NUM_CHANNELS ); vecsName.Init ( USED_NUM_CHANNELS );
veciJitBufSize.Init ( USED_NUM_CHANNELS ); veciJitBufNumFrames.Init ( USED_NUM_CHANNELS );
veciNetwFrameSizeFact.Init ( USED_NUM_CHANNELS ); veciNetwFrameSizeFact.Init ( USED_NUM_CHANNELS );
// check all possible channels // check all possible channels
@ -691,7 +746,7 @@ void CServer::GetConCliParam ( CVector<CHostAddress>& vecHostAddresses,
// get requested data // get requested data
vecHostAddresses[i] = InetAddr; vecHostAddresses[i] = InetAddr;
vecsName[i] = vecChannels[i].GetName(); vecsName[i] = vecChannels[i].GetName();
veciJitBufSize[i] = vecChannels[i].GetSockBufSize(); veciJitBufNumFrames[i] = vecChannels[i].GetSockBufNumFrames();
veciNetwFrameSizeFact[i] = vecChannels[i].GetNetwFrameSizeFact(); veciNetwFrameSizeFact[i] = vecChannels[i].GetNetwFrameSizeFact();
} }
} }

View File

@ -94,7 +94,7 @@ public:
void GetConCliParam ( CVector<CHostAddress>& vecHostAddresses, void GetConCliParam ( CVector<CHostAddress>& vecHostAddresses,
CVector<QString>& vecsName, CVector<QString>& vecsName,
CVector<int>& veciJitBufSize, CVector<int>& veciJitBufNumFrames,
CVector<int>& veciNetwFrameSizeFact ); CVector<int>& veciNetwFrameSizeFact );
protected: protected:
@ -130,8 +130,8 @@ protected:
virtual void customEvent ( QEvent* Event ); virtual void customEvent ( QEvent* Event );
/* do not use the vector class since CChannel does not have appropriate // do not use the vector class since CChannel does not have appropriate
copy constructor/operator */ // copy constructor/operator
CChannel vecChannels[MAX_NUM_CHANNELS]; CChannel vecChannels[MAX_NUM_CHANNELS];
QMutex Mutex; QMutex Mutex;

View File

@ -125,7 +125,7 @@ void CSettings::ReadIniFile ( const QString& sFileName )
if ( GetNumericIniSet ( IniXMLDocument, "client", "jitbuf", if ( GetNumericIniSet ( IniXMLDocument, "client", "jitbuf",
MIN_NET_BUF_SIZE_NUM_BL, MAX_NET_BUF_SIZE_NUM_BL, iValue ) ) MIN_NET_BUF_SIZE_NUM_BL, MAX_NET_BUF_SIZE_NUM_BL, iValue ) )
{ {
pClient->SetSockBufSize ( iValue ); pClient->SetSockBufNumFrames ( iValue );
} }
// flag whether the chat window shall be opened on a new chat message // flag whether the chat window shall be opened on a new chat message
@ -180,7 +180,7 @@ void CSettings::WriteIniFile ( const QString& sFileName )
// network jitter buffer size // network jitter buffer size
SetNumericIniSet ( IniXMLDocument, "client", "jitbuf", SetNumericIniSet ( IniXMLDocument, "client", "jitbuf",
pClient->GetSockBufSize() ); pClient->GetSockBufNumFrames() );
// flag whether the chat window shall be opened on a new chat message // flag whether the chat window shall be opened on a new chat message
SetFlagIniSet ( IniXMLDocument, "client", "openchatonnewmessage", SetFlagIniSet ( IniXMLDocument, "client", "openchatonnewmessage",