preliminary implementation of protocol, in the current state we do not send any acknowledgement -> TODO

This commit is contained in:
Volker Fischer 2006-02-27 19:45:27 +00:00
parent 2d3c5d54ca
commit f9e1ab348b
5 changed files with 44 additions and 13 deletions

View file

@ -216,8 +216,11 @@ CChannel::CChannel ()
/* connections ---------------------------------------------------------- */ /* connections ---------------------------------------------------------- */
// just route message through this class // just route message through this class
QObject::connect(&Protocol, SIGNAL(MessReadyForSending()), QObject::connect ( &Protocol, SIGNAL ( MessReadyForSending () ),
SIGNAL(MessReadyForSending())); SIGNAL ( MessReadyForSending () ) );
QObject::connect ( &Protocol, SIGNAL ( ChangeJittBufSize ( int ) ),
this, SLOT ( OnJittBufSizeChange ( int ) ) );
} }
void CChannel::SetSockBufSize ( const int iNewBlockSize, const int iNumBlocks ) void CChannel::SetSockBufSize ( const int iNewBlockSize, const int iNumBlocks )
@ -229,6 +232,11 @@ void CChannel::SetSockBufSize ( const int iNewBlockSize, const int iNumBlocks )
Mutex.unlock (); Mutex.unlock ();
} }
void CChannel::OnJittBufSizeChange ( int iNewJitBufSize )
{
SetSockBufSize ( MIN_BLOCK_SIZE_SAMPLES, iNewJitBufSize );
}
bool CChannel::GetAddress(CHostAddress& RetAddr) bool CChannel::GetAddress(CHostAddress& RetAddr)
{ {
@ -280,15 +288,11 @@ for (int i = 0; i < BLOCK_SIZE_SAMPLES; i++)
} }
else else
{ {
// this seems not to be an audio block, parse the message
// TODO: different return code for protocol
bRet = Protocol.ParseMessage ( vecbyData, iNumBytes );
// TODO add protocol parsing here
Protocol.ParseMessage ( vecbyData, iNumBytes );
bRet = false; /* wrong packet size */
} }
Mutex.unlock (); /* put mutex unlock */ Mutex.unlock (); /* put mutex unlock */

View file

@ -134,6 +134,9 @@ protected:
QMutex Mutex; QMutex Mutex;
public slots:
void OnJittBufSizeChange ( int iNewJitBufSize );
signals: signals:
void MessReadyForSending (); void MessReadyForSending ();
}; };

View file

@ -123,7 +123,7 @@ void CLlconServerDlg::OnTimer()
vecHostAddresses[i].InetAddr.toString().latin1(), vecHostAddresses[i].InetAddr.toString().latin1(),
vecHostAddresses[i].iPort) /* IP, port */); vecHostAddresses[i].iPort) /* IP, port */);
/* jitter buffer size */ /* jitter buffer size (polling for updates) */
vecpListViewItems[i]->setText(3, vecpListViewItems[i]->setText(3,
QString().setNum(veciJitBufSize[i])); QString().setNum(veciJitBufSize[i]));

View file

@ -32,6 +32,8 @@ MESSAGES
| 2 bytes number of blocks | | 2 bytes number of blocks |
+--------------------------+ +--------------------------+
This message requires acknowledgement
@ -93,7 +95,8 @@ bool CProtocol::ParseMessage ( const CVector<unsigned char>& vecbyData,
/* /*
return code: true -> ok; false -> error return code: true -> ok; false -> error
*/ */
int iRecCounter, iRecID; int iRecCounter, iRecID, iData;
unsigned int iPos;
CVector<uint8_t> vecData; CVector<uint8_t> vecData;
@ -103,6 +106,14 @@ for ( int i = 0; i < iNumBytes; i++ ) {
vecbyDataConv[i] = static_cast<uint8_t> ( vecbyData[i] ); vecbyDataConv[i] = static_cast<uint8_t> ( vecbyData[i] );
} }
// In case we received a message and returned an answer but our answer did
// not make it to the receiver, he will resend his message. We check here
// if the message is the same as the old one, and if this is the case, just
// resend our old answer again
// TODO
// important: vecbyDataConv must have iNumBytes to get it work!!! // important: vecbyDataConv must have iNumBytes to get it work!!!
if ( ParseMessageFrame ( vecbyDataConv, iRecCounter, iRecID, vecData ) ) if ( ParseMessageFrame ( vecbyDataConv, iRecCounter, iRecID, vecData ) )
{ {
@ -120,6 +131,17 @@ qDebug ( "parsing successful" );
// it can be used in the server protocol, too // it can be used in the server protocol, too
break; break;
case PROTMESSID_JITT_BUF_SIZE:
// TODO acknowledgement
// extract data from stream and emit signal for received value
iPos = 0;
iData = static_cast<int> ( GetValFromStream ( vecData, iPos, 2 ) );
emit ChangeJittBufSize ( iData );
break;
} }
return true; // everything was ok return true; // everything was ok

View file

@ -84,10 +84,12 @@ protected:
CVector<uint8_t> vecMessage; CVector<uint8_t> vecMessage;
uint8_t iCounter; uint8_t iCounter;
bool bIsClient;
signals: signals:
// transmitting
void MessReadyForSending (); void MessReadyForSending ();
// receiving
void ChangeJittBufSize ( int iNewJitBufSize );
}; };