some cleanup of protocol implementation, cleanup main client GUI a bit, new version number

This commit is contained in:
Volker Fischer 2006-11-05 10:09:32 +00:00
parent efb83f15ac
commit bb76f4d911
12 changed files with 277 additions and 143 deletions

View file

@ -485,10 +485,16 @@ for ( int i = 0; i < iCurNetwInBlSiFact * MIN_BLOCK_SIZE_SAMPLES; i++ ) {
if ( Protocol.ParseMessage ( vecbyData, iNumBytes ) )
{
eRet = PS_PROT_OK;
// create message for protocol status
emit ProtocolStatus ( true );
}
else
{
eRet = PS_PROT_ERR;
// create message for protocol status
emit ProtocolStatus ( false );
}
}
}

View file

@ -172,6 +172,7 @@ signals:
void MessReadyForSending ( CVector<uint8_t> vecMessage );
void NewConnection();
void ReqJittBufSize();
void ProtocolStatus ( bool bOk );
};

View file

@ -38,6 +38,9 @@ CClient::CClient () : bRun ( false ), Socket ( &Channel ),
QObject::connect ( &Channel, SIGNAL ( ReqJittBufSize() ),
this, SLOT ( OnReqJittBufSize() ) );
QObject::connect ( &Channel, SIGNAL ( ProtocolStatus ( bool ) ),
this, SLOT ( OnProtocolStatus ( bool ) ) );
}
void CClient::OnSendProtMessage ( CVector<uint8_t> vecMessage )
@ -79,7 +82,20 @@ bool CClient::SetServerAddr(QString strNAddr)
{
return false; /* invalid address */
}
}
}
void CClient::OnProtocolStatus ( bool bOk )
{
// show protocol status in GUI
if ( bOk )
{
PostWinMessage ( MS_PROTOCOL, MUL_COL_LED_RED );
}
else
{
PostWinMessage ( MS_PROTOCOL, MUL_COL_LED_GREEN );
}
}
void CClient::Init()
{

View file

@ -8,16 +8,16 @@
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
\******************************************************************************/
@ -164,6 +164,7 @@ protected:
public slots:
void OnSendProtMessage ( CVector<uint8_t> vecMessage );
void OnReqJittBufSize();
void OnProtocolStatus ( bool bOk );
};

View file

@ -158,13 +158,17 @@ void CClientSettingsDlg::SetStatus ( const int iMessType, const int iStatus )
case MS_JIT_BUF_GET:
CLEDNetwGet->SetLight(iStatus);
break;
break;
case MS_PROTOCOL:
CLEDProtocolStatus->SetLight(iStatus);
case MS_RESET_ALL:
CLEDSoundIn->Reset();
CLEDSoundOut->Reset();
CLEDNetwPut->Reset();
CLEDNetwGet->Reset();
CLEDNetwGet->Reset();
CLEDProtocolStatus->Reset();
break;
}
}

View file

@ -11,8 +11,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>361</width>
<height>263</height>
<width>410</width>
<height>249</height>
</rect>
</property>
<property stdset="1">
@ -322,6 +322,13 @@
<name>name</name>
<cstring>GroupBoxSoundCardBuffers</cstring>
</property>
<property stdset="1">
<name>sizePolicy</name>
<sizepolicy>
<hsizetype>1</hsizetype>
<vsizetype>5</vsizetype>
</sizepolicy>
</property>
<property stdset="1">
<name>title</name>
<string>Sndcard Buffers</string>
@ -374,7 +381,7 @@
<property stdset="1">
<name>sizePolicy</name>
<sizepolicy>
<hsizetype>3</hsizetype>
<hsizetype>1</hsizetype>
<vsizetype>1</vsizetype>
</sizepolicy>
</property>
@ -442,7 +449,7 @@
<property stdset="1">
<name>sizePolicy</name>
<sizepolicy>
<hsizetype>3</hsizetype>
<hsizetype>1</hsizetype>
<vsizetype>1</vsizetype>
</sizepolicy>
</property>
@ -573,6 +580,13 @@
<name>name</name>
<cstring>GroupBoxMeasureResults</cstring>
</property>
<property stdset="1">
<name>sizePolicy</name>
<sizepolicy>
<hsizetype>3</hsizetype>
<vsizetype>5</vsizetype>
</sizepolicy>
</property>
<property stdset="1">
<name>title</name>
<string>Debug</string>
@ -587,26 +601,92 @@
<number>6</number>
</property>
<widget>
<class>QLabel</class>
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>TextLabelStdDevTimerLabel</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>StdDev:</string>
<cstring>Layout6</cstring>
</property>
<hbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>TextLabelStdDevTimerLabel</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>StdDev:</string>
</property>
</widget>
<widget>
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>TextLabelStdDevTimer</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>val</string>
</property>
</widget>
</hbox>
</widget>
<widget>
<class>QLabel</class>
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>TextLabelStdDevTimer</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>val</string>
<cstring>Layout8</cstring>
</property>
<hbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>TextLabel1_2</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Protocol Status:</string>
</property>
</widget>
<widget>
<class>CMultiColorLED</class>
<property stdset="1">
<name>name</name>
<cstring>CLEDProtocolStatus</cstring>
</property>
<property stdset="1">
<name>minimumSize</name>
<size>
<width>13</width>
<height>13</height>
</size>
</property>
<property stdset="1">
<name>maximumSize</name>
<size>
<width>13</width>
<height>13</height>
</size>
</property>
</widget>
</hbox>
</widget>
</vbox>
</widget>

View file

@ -42,7 +42,7 @@
/* version and application name (always use this version) */
#undef VERSION
#define VERSION "0.9.7cvs"
#define VERSION "0.9.8cvs"
#define APP_NAME "llcon"
@ -124,6 +124,7 @@ typedef unsigned int _MESSAGE_IDENT;
#define MS_JIT_BUF_PUT 3
#define MS_JIT_BUF_GET 4
#define MS_PACKET_RECEIVED 5
#define MS_PROTOCOL 6
#define MUL_COL_LED_RED 0
#define MUL_COL_LED_YELLOW 1

View file

@ -44,9 +44,6 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent,
"to be specified before. If the client is connected, pressing this "
"button will disconnect the connection."));
QWhatsThis::add(TextLabelNameVersion, tr("<b>Version:</b> Shows the "
"current version of the software."));
QWhatsThis::add(TextLabelStatus, tr("<b>Status Bar:</b> In the status bar "
"different messages are displayed. E.g., if an error ocurred or the "
"status of the connection is shown."));
@ -55,11 +52,33 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent,
"the IP address of the server can be set. If an invalid address was "
"chosen, an error message is shown in the status bar.");
QWhatsThis::add(TextLabelServerAddr, strServAddrH);
QWhatsThis::add(LineEditServerAddr, strServAddrH);
/* set text for version and application name */
TextLabelNameVersion->
setText(QString(APP_NAME) + tr(" client ") + QString(VERSION));
QWhatsThis::add(LineEditServerAddr, strServAddrH);
QString strAudFader = tr ( "<b>Audio Fader:</b> With the audio fader "
"control the level of left and right audio input channels can "
"be controlled." );
QWhatsThis::add ( TextAudInFader, strAudFader );
QWhatsThis::add ( SliderAudInFader, strAudFader );
QString strAudReverb = tr ( "<b>Reverberation Level:</b> The level of "
"reverberation effect can be set with this control. The channel to "
"which that reverberation effect shall be applied can be chosen "
"with the Reverberation Channel Selection radio buttons." );
QWhatsThis::add ( TextLabelAudReverb, strAudReverb );
QWhatsThis::add ( SliderAudReverb, strAudReverb );
QString strRevChanSel = tr ( "<b>Reverberation Channel Selection:</b> "
"With these radio buttons the audio input channel on which the "
"reverberation effect is applied can be chosen. Either the left "
"or right input channel can be selected." );
QWhatsThis::add ( TextLabelReverbSelection, strRevChanSel );
QWhatsThis::add ( RadioButtonRevSelL, strRevChanSel );
QWhatsThis::add ( RadioButtonRevSelR, strRevChanSel );
QWhatsThis::add ( CLEDOverallStatus, tr ( "<b>Overall Status:</b> "
"The overall status of the software is shown. If either the "
"network or sound interface has bad status, this LED will show "
"red color." ) );
/* init server address line edit */
LineEditServerAddr->setText ( pClient->strIPAddress.c_str () );

View file

@ -318,17 +318,6 @@
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>TextLabelNameVersion</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>TextLabelNameVersion</string>
</property>
</widget>
<spacer>
<property>
<name>name</name>
@ -587,7 +576,7 @@ Level</string>
</property>
<property stdset="1">
<name>text</name>
<string>Reverb Chan.
<string>Reverb Chan
Selection</string>
</property>
<property stdset="1">

View file

@ -230,11 +230,9 @@ bool CProtocol::ParseMessage ( const CVector<unsigned char>& vecbyData,
return code: true -> ok; false -> error
*/
bool bRet, bSendNextMess;
int iRecCounter, iRecID, iData, iDataLen, iStringLen, iCurID;
int iRecCounter, iRecID;
unsigned int iPos;
CVector<uint8_t> vecData;
std::string strCurString;
double dNewGain;
// convert unsigned char in uint8_t, TODO convert all buffers in uint8_t
@ -262,14 +260,13 @@ for ( int i = 0; i < iNumBytes; i++ ) {
}
else
{
// check which type of message we received and do action
switch ( iRecID )
// special treatment for acknowledge messages
if ( iRecID == PROTMESSID_ACKN )
{
case PROTMESSID_ACKN:
// extract data from stream and emit signal for received value
iPos = 0;
iData = static_cast<int> ( GetValFromStream ( vecData, iPos, 2 ) );
const int iData =
static_cast<int> ( GetValFromStream ( vecData, iPos, 2 ) );
Mutex.lock();
{
@ -294,105 +291,44 @@ for ( int i = 0; i < iNumBytes; i++ ) {
{
SendMessage();
}
break;
case PROTMESSID_JITT_BUF_SIZE:
// extract data from stream and emit signal for received value
iPos = 0;
iData = static_cast<int> ( GetValFromStream ( vecData, iPos, 2 ) );
// invoke message action
emit ChangeJittBufSize ( iData );
// send acknowledge message
CreateAndSendAcknMess ( iRecID, iRecCounter );
break;
case PROTMESSID_REQ_JITT_BUF_SIZE:
// invoke message action
emit ReqJittBufSize();
// send acknowledge message
CreateAndSendAcknMess ( iRecID, iRecCounter );
break;
case PROTMESSID_NET_BLSI_FACTOR:
// extract data from stream and emit signal for received value
iPos = 0;
iData = static_cast<int> ( GetValFromStream ( vecData, iPos, 2 ) );
// invoke message action
emit ChangeNetwBlSiFact ( iData );
// send acknowledge message
CreateAndSendAcknMess ( iRecID, iRecCounter );
break;
case PROTMESSID_CHANNEL_GAIN:
// extract data from stream and emit signal for received value
}
else
{
// init position pointer which is used for extracting data from
// received data vector
iPos = 0;
// channel ID
iCurID = static_cast<int> ( GetValFromStream ( vecData, iPos, 2 ) );
// actual gain, we convert from integer to double with range 0..1
iData = static_cast<int> ( GetValFromStream ( vecData, iPos, 2 ) );
dNewGain = (double) iData / ( 1 << 16 );
// invoke message action
emit ChangeChanGain ( iCurID, dNewGain );
// send acknowledge message
CreateAndSendAcknMess ( iRecID, iRecCounter );
break;
case PROTMESSID_CONN_CLIENTS_LIST:
// extract data from stream and emit signal for received value
iPos = 0;
iDataLen = vecData.Size();
while ( iPos < iDataLen )
// check which type of message we received and do action
switch ( iRecID )
{
case PROTMESSID_JITT_BUF_SIZE:
// IP address (4 bytes)
iData = static_cast<int> ( GetValFromStream ( vecData, iPos, 4 ) );
EvaluateJitBufMes ( iPos, vecData );
break;
// TODO do something with the received IP address "iData"
case PROTMESSID_REQ_JITT_BUF_SIZE:
// TEST
QHostAddress addrTest ( iData );
printf ( "%s ", addrTest.toString().latin1() );
EvaluateReqJitBufMes ( iPos, vecData );
break;
// number of bytes for name string (2 bytes)
iStringLen = static_cast<int> ( GetValFromStream ( vecData, iPos, 2 ) );
case PROTMESSID_NET_BLSI_FACTOR:
// name string (n bytes)
strCurString = "";
for ( int j = 0; j < iStringLen; j++ )
{
// byte-by-byte copying of the string data
iData = static_cast<int> ( GetValFromStream ( vecData, iPos, 1 ) );
strCurString += std::string ( (char*) &iData );
}
EvaluateNetwBlSiFactMes ( iPos, vecData );
break;
// TODO do something with the received name string "strCurString"
case PROTMESSID_CHANNEL_GAIN:
EvaluateChanGainMes ( iPos, vecData );
break;
case PROTMESSID_CONN_CLIENTS_LIST:
EvaluateConClientListMes ( iPos, vecData );
break;
}
// send acknowledge message
CreateAndSendAcknMess ( iRecID, iRecCounter );
break;
}
}
@ -411,7 +347,7 @@ printf ( "%s ", addrTest.toString().latin1() );
}
/* Access-functions for creating messages ----------------------------------- */
/* Access-functions for creating and parsing messages ----------------------- */
void CProtocol::CreateJitBufMes ( const int iJitBufSize )
{
CVector<uint8_t> vecData ( 2 ); // 2 bytes of data
@ -423,11 +359,27 @@ void CProtocol::CreateJitBufMes ( const int iJitBufSize )
CreateAndSendMessage ( PROTMESSID_JITT_BUF_SIZE, vecData );
}
void CProtocol::EvaluateJitBufMes ( unsigned int iPos, const CVector<uint8_t>& vecData )
{
// extract jitter buffer size
const int iData =
static_cast<int> ( GetValFromStream ( vecData, iPos, 2 ) );
// invoke message action
emit ChangeJittBufSize ( iData );
}
void CProtocol::CreateReqJitBufMes()
{
CreateAndSendMessage ( PROTMESSID_REQ_JITT_BUF_SIZE, CVector<uint8_t> ( 0 ) );
}
void CProtocol::EvaluateReqJitBufMes ( unsigned int iPos, const CVector<uint8_t>& vecData )
{
// invoke message action
emit ReqJittBufSize();
}
void CProtocol::CreateNetwBlSiFactMes ( const int iNetwBlSiFact )
{
CVector<uint8_t> vecData ( 2 ); // 2 bytes of data
@ -439,6 +391,15 @@ void CProtocol::CreateNetwBlSiFactMes ( const int iNetwBlSiFact )
CreateAndSendMessage ( PROTMESSID_NET_BLSI_FACTOR, vecData );
}
void CProtocol::EvaluateNetwBlSiFactMes ( unsigned int iPos, const CVector<uint8_t>& vecData )
{
const int iData =
static_cast<int> ( GetValFromStream ( vecData, iPos, 2 ) );
// invoke message action
emit ChangeNetwBlSiFact ( iData );
}
void CProtocol::CreateChanGainMes ( const int iChanID, const double dGain )
{
CVector<uint8_t> vecData ( 4 ); // 4 bytes of data
@ -455,6 +416,22 @@ void CProtocol::CreateChanGainMes ( const int iChanID, const double dGain )
CreateAndSendMessage ( PROTMESSID_CHANNEL_GAIN, vecData );
}
void CProtocol::EvaluateChanGainMes ( unsigned int iPos, const CVector<uint8_t>& vecData )
{
// channel ID
const int iCurID =
static_cast<int> ( GetValFromStream ( vecData, iPos, 2 ) );
// actual gain, we convert from integer to double with range 0..1
const int iData =
static_cast<int> ( GetValFromStream ( vecData, iPos, 2 ) );
const double dNewGain = (double) iData / ( 1 << 16 );
// invoke message action
emit ChangeChanGain ( iCurID, dNewGain );
}
void CProtocol::CreateConClientListMes ( const CVector<uint32_t>& veciIpAddrs,
const CVector<std::string>& vecstrNames )
{
@ -496,6 +473,41 @@ void CProtocol::CreateConClientListMes ( const CVector<uint32_t>& veciIpAddrs,
CreateAndSendMessage ( PROTMESSID_CONN_CLIENTS_LIST, vecData );
}
void CProtocol:: EvaluateConClientListMes ( unsigned int iPos, const CVector<uint8_t>& vecData )
{
int iData;
const int iDataLen = vecData.Size();
while ( iPos < iDataLen )
{
// IP address (4 bytes)
iData = static_cast<int> ( GetValFromStream ( vecData, iPos, 4 ) );
// TODO do something with the received IP address "iData"
// TEST
QHostAddress addrTest ( iData );
printf ( "%s ", addrTest.toString().latin1() );
// number of bytes for name string (2 bytes)
const int iStringLen =
static_cast<int> ( GetValFromStream ( vecData, iPos, 2 ) );
// name string (n bytes)
std::string strCurString = "";
for ( int j = 0; j < iStringLen; j++ )
{
// byte-by-byte copying of the string data
iData = static_cast<int> ( GetValFromStream ( vecData, iPos, 1 ) );
strCurString += std::string ( (char*) &iData );
}
// TODO do something with the received name string "strCurString"
}
}
/******************************************************************************\
* Message generation (parsing) *

View file

@ -45,11 +45,11 @@
#define PROTMESSID_CONN_CLIENTS_LIST 15 // connected client list
// lengths of message as defined in protocol.cpp file
#define MESS_HEADER_LENGTH_BYTE 5 /* ID, cnt, length */
#define MESS_LEN_WITHOUT_DATA_BYTE ( MESS_HEADER_LENGTH_BYTE + 2 /* CRC */ )
#define MESS_HEADER_LENGTH_BYTE 5 /* ID, cnt, length */
#define MESS_LEN_WITHOUT_DATA_BYTE ( MESS_HEADER_LENGTH_BYTE + 2 /* CRC */ )
// time out for message re-send if no acknowledgement was received
#define SEND_MESS_TIMEOUT_MS 400 // ms
#define SEND_MESS_TIMEOUT_MS 400 // ms
/* Classes ********************************************************************/
@ -59,7 +59,6 @@ class CProtocol : public QObject
public:
CProtocol();
virtual ~CProtocol() {}
void CreateJitBufMes ( const int iJitBufSize );
void CreateReqJitBufMes();
@ -127,6 +126,12 @@ protected:
void CreateAndSendMessage ( const int iID, const CVector<uint8_t>& vecData );
void EvaluateJitBufMes ( unsigned int iPos, const CVector<uint8_t>& vecData );
void EvaluateReqJitBufMes ( unsigned int iPos, const CVector<uint8_t>& vecData );
void EvaluateNetwBlSiFactMes ( unsigned int iPos, const CVector<uint8_t>& vecData );
void EvaluateChanGainMes ( unsigned int iPos, const CVector<uint8_t>& vecData );
void EvaluateConClientListMes ( unsigned int iPos, const CVector<uint8_t>& vecData );
int iOldRecID, iOldRecCnt;
// these two objects must be sequred by a mutex

View file

@ -315,7 +315,7 @@ QString CAboutDlg::GetVersionAndNameStr ( const bool bWithHtml )
strVersionText += "\n";
}
strVersionText += tr("llcon, Low-Latency (Internet) Connection");
strVersionText += tr("llcon, Low-Latency (internet) CONnection");
if ( bWithHtml )
{