From f9e1ab348b082bb295b46b08ec5f2b2a382fa5b6 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Mon, 27 Feb 2006 19:45:27 +0000 Subject: [PATCH] preliminary implementation of protocol, in the current state we do not send any acknowledgement -> TODO --- src/channel.cpp | 22 +++++++++++++--------- src/channel.h | 3 +++ src/llconserverdlg.cpp | 2 +- src/protocol.cpp | 24 +++++++++++++++++++++++- src/protocol.h | 6 ++++-- 5 files changed, 44 insertions(+), 13 deletions(-) diff --git a/src/channel.cpp b/src/channel.cpp index 94623d63..d5854889 100755 --- a/src/channel.cpp +++ b/src/channel.cpp @@ -216,8 +216,11 @@ CChannel::CChannel () /* connections ---------------------------------------------------------- */ // just route message through this class - QObject::connect(&Protocol, SIGNAL(MessReadyForSending()), - SIGNAL(MessReadyForSending())); + QObject::connect ( &Protocol, SIGNAL ( MessReadyForSending () ), + SIGNAL ( MessReadyForSending () ) ); + + QObject::connect ( &Protocol, SIGNAL ( ChangeJittBufSize ( int ) ), + this, SLOT ( OnJittBufSizeChange ( int ) ) ); } void CChannel::SetSockBufSize ( const int iNewBlockSize, const int iNumBlocks ) @@ -229,6 +232,11 @@ void CChannel::SetSockBufSize ( const int iNewBlockSize, const int iNumBlocks ) Mutex.unlock (); } + +void CChannel::OnJittBufSizeChange ( int iNewJitBufSize ) +{ + SetSockBufSize ( MIN_BLOCK_SIZE_SAMPLES, iNewJitBufSize ); +} bool CChannel::GetAddress(CHostAddress& RetAddr) { @@ -280,15 +288,11 @@ for (int i = 0; i < BLOCK_SIZE_SAMPLES; i++) } else { + // this seems not to be an audio block, parse the message +// TODO: different return code for protocol - -// TODO add protocol parsing here -Protocol.ParseMessage ( vecbyData, iNumBytes ); - - - - bRet = false; /* wrong packet size */ + bRet = Protocol.ParseMessage ( vecbyData, iNumBytes ); } Mutex.unlock (); /* put mutex unlock */ diff --git a/src/channel.h b/src/channel.h index a1608ecf..31a4c914 100755 --- a/src/channel.h +++ b/src/channel.h @@ -134,6 +134,9 @@ protected: QMutex Mutex; +public slots: + void OnJittBufSizeChange ( int iNewJitBufSize ); + signals: void MessReadyForSending (); }; diff --git a/src/llconserverdlg.cpp b/src/llconserverdlg.cpp index b22f4710..502b4c23 100755 --- a/src/llconserverdlg.cpp +++ b/src/llconserverdlg.cpp @@ -123,7 +123,7 @@ void CLlconServerDlg::OnTimer() vecHostAddresses[i].InetAddr.toString().latin1(), vecHostAddresses[i].iPort) /* IP, port */); - /* jitter buffer size */ + /* jitter buffer size (polling for updates) */ vecpListViewItems[i]->setText(3, QString().setNum(veciJitBufSize[i])); diff --git a/src/protocol.cpp b/src/protocol.cpp index 7e90df2e..e6f6ff1d 100755 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -32,6 +32,8 @@ MESSAGES | 2 bytes number of blocks | +--------------------------+ + This message requires acknowledgement + @@ -93,7 +95,8 @@ bool CProtocol::ParseMessage ( const CVector& vecbyData, /* return code: true -> ok; false -> error */ - int iRecCounter, iRecID; + int iRecCounter, iRecID, iData; + unsigned int iPos; CVector vecData; @@ -103,6 +106,14 @@ for ( int i = 0; i < iNumBytes; i++ ) { vecbyDataConv[i] = static_cast ( 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!!! if ( ParseMessageFrame ( vecbyDataConv, iRecCounter, iRecID, vecData ) ) { @@ -120,6 +131,17 @@ qDebug ( "parsing successful" ); // it can be used in the server protocol, too break; + + case PROTMESSID_JITT_BUF_SIZE: + +// TODO acknowledgement + + // extract data from stream and emit signal for received value + iPos = 0; + iData = static_cast ( GetValFromStream ( vecData, iPos, 2 ) ); + + emit ChangeJittBufSize ( iData ); + break; } return true; // everything was ok diff --git a/src/protocol.h b/src/protocol.h index 39adf8bc..47a2a101 100755 --- a/src/protocol.h +++ b/src/protocol.h @@ -84,10 +84,12 @@ protected: CVector vecMessage; uint8_t iCounter; - bool bIsClient; - signals: + // transmitting void MessReadyForSending (); + + // receiving + void ChangeJittBufSize ( int iNewJitBufSize ); };