preliminary implementation of protocol, in the current state we do not send any acknowledgement -> TODO
This commit is contained in:
parent
2d3c5d54ca
commit
f9e1ab348b
5 changed files with 44 additions and 13 deletions
|
@ -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 */
|
||||
|
|
|
@ -134,6 +134,9 @@ protected:
|
|||
|
||||
QMutex Mutex;
|
||||
|
||||
public slots:
|
||||
void OnJittBufSizeChange ( int iNewJitBufSize );
|
||||
|
||||
signals:
|
||||
void MessReadyForSending ();
|
||||
};
|
||||
|
|
|
@ -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]));
|
||||
|
||||
|
|
|
@ -32,6 +32,8 @@ MESSAGES
|
|||
| 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
|
||||
*/
|
||||
int iRecCounter, iRecID;
|
||||
int iRecCounter, iRecID, iData;
|
||||
unsigned int iPos;
|
||||
CVector<uint8_t> vecData;
|
||||
|
||||
|
||||
|
@ -103,6 +106,14 @@ for ( int i = 0; i < iNumBytes; 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!!!
|
||||
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<int> ( GetValFromStream ( vecData, iPos, 2 ) );
|
||||
|
||||
emit ChangeJittBufSize ( iData );
|
||||
break;
|
||||
}
|
||||
|
||||
return true; // everything was ok
|
||||
|
|
|
@ -84,10 +84,12 @@ protected:
|
|||
CVector<uint8_t> vecMessage;
|
||||
uint8_t iCounter;
|
||||
|
||||
bool bIsClient;
|
||||
|
||||
signals:
|
||||
// transmitting
|
||||
void MessReadyForSending ();
|
||||
|
||||
// receiving
|
||||
void ChangeJittBufSize ( int iNewJitBufSize );
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue