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 ) ) if ( Protocol.ParseMessage ( vecbyData, iNumBytes ) )
{ {
eRet = PS_PROT_OK; eRet = PS_PROT_OK;
// create message for protocol status
emit ProtocolStatus ( true );
} }
else else
{ {
eRet = PS_PROT_ERR; 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 MessReadyForSending ( CVector<uint8_t> vecMessage );
void NewConnection(); void NewConnection();
void ReqJittBufSize(); void ReqJittBufSize();
void ProtocolStatus ( bool bOk );
}; };

View file

@ -38,6 +38,9 @@ CClient::CClient () : bRun ( false ), Socket ( &Channel ),
QObject::connect ( &Channel, SIGNAL ( ReqJittBufSize() ), QObject::connect ( &Channel, SIGNAL ( ReqJittBufSize() ),
this, SLOT ( OnReqJittBufSize() ) ); this, SLOT ( OnReqJittBufSize() ) );
QObject::connect ( &Channel, SIGNAL ( ProtocolStatus ( bool ) ),
this, SLOT ( OnProtocolStatus ( bool ) ) );
} }
void CClient::OnSendProtMessage ( CVector<uint8_t> vecMessage ) void CClient::OnSendProtMessage ( CVector<uint8_t> vecMessage )
@ -81,6 +84,19 @@ bool CClient::SetServerAddr(QString strNAddr)
} }
} }
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() void CClient::Init()
{ {
/* set block sizes (in samples) */ /* set block sizes (in samples) */

View file

@ -164,6 +164,7 @@ protected:
public slots: public slots:
void OnSendProtMessage ( CVector<uint8_t> vecMessage ); void OnSendProtMessage ( CVector<uint8_t> vecMessage );
void OnReqJittBufSize(); void OnReqJittBufSize();
void OnProtocolStatus ( bool bOk );
}; };

View file

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

View file

@ -11,8 +11,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>361</width> <width>410</width>
<height>263</height> <height>249</height>
</rect> </rect>
</property> </property>
<property stdset="1"> <property stdset="1">
@ -322,6 +322,13 @@
<name>name</name> <name>name</name>
<cstring>GroupBoxSoundCardBuffers</cstring> <cstring>GroupBoxSoundCardBuffers</cstring>
</property> </property>
<property stdset="1">
<name>sizePolicy</name>
<sizepolicy>
<hsizetype>1</hsizetype>
<vsizetype>5</vsizetype>
</sizepolicy>
</property>
<property stdset="1"> <property stdset="1">
<name>title</name> <name>title</name>
<string>Sndcard Buffers</string> <string>Sndcard Buffers</string>
@ -374,7 +381,7 @@
<property stdset="1"> <property stdset="1">
<name>sizePolicy</name> <name>sizePolicy</name>
<sizepolicy> <sizepolicy>
<hsizetype>3</hsizetype> <hsizetype>1</hsizetype>
<vsizetype>1</vsizetype> <vsizetype>1</vsizetype>
</sizepolicy> </sizepolicy>
</property> </property>
@ -442,7 +449,7 @@
<property stdset="1"> <property stdset="1">
<name>sizePolicy</name> <name>sizePolicy</name>
<sizepolicy> <sizepolicy>
<hsizetype>3</hsizetype> <hsizetype>1</hsizetype>
<vsizetype>1</vsizetype> <vsizetype>1</vsizetype>
</sizepolicy> </sizepolicy>
</property> </property>
@ -573,6 +580,13 @@
<name>name</name> <name>name</name>
<cstring>GroupBoxMeasureResults</cstring> <cstring>GroupBoxMeasureResults</cstring>
</property> </property>
<property stdset="1">
<name>sizePolicy</name>
<sizepolicy>
<hsizetype>3</hsizetype>
<vsizetype>5</vsizetype>
</sizepolicy>
</property>
<property stdset="1"> <property stdset="1">
<name>title</name> <name>title</name>
<string>Debug</string> <string>Debug</string>
@ -586,6 +600,21 @@
<name>spacing</name> <name>spacing</name>
<number>6</number> <number>6</number>
</property> </property>
<widget>
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<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> <widget>
<class>QLabel</class> <class>QLabel</class>
<property stdset="1"> <property stdset="1">
@ -608,6 +637,57 @@
<string>val</string> <string>val</string>
</property> </property>
</widget> </widget>
</hbox>
</widget>
<widget>
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<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> </vbox>
</widget> </widget>
</hbox> </hbox>

View file

@ -42,7 +42,7 @@
/* version and application name (always use this version) */ /* version and application name (always use this version) */
#undef VERSION #undef VERSION
#define VERSION "0.9.7cvs" #define VERSION "0.9.8cvs"
#define APP_NAME "llcon" #define APP_NAME "llcon"
@ -124,6 +124,7 @@ typedef unsigned int _MESSAGE_IDENT;
#define MS_JIT_BUF_PUT 3 #define MS_JIT_BUF_PUT 3
#define MS_JIT_BUF_GET 4 #define MS_JIT_BUF_GET 4
#define MS_PACKET_RECEIVED 5 #define MS_PACKET_RECEIVED 5
#define MS_PROTOCOL 6
#define MUL_COL_LED_RED 0 #define MUL_COL_LED_RED 0
#define MUL_COL_LED_YELLOW 1 #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 " "to be specified before. If the client is connected, pressing this "
"button will disconnect the connection.")); "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 " QWhatsThis::add(TextLabelStatus, tr("<b>Status Bar:</b> In the status bar "
"different messages are displayed. E.g., if an error ocurred or the " "different messages are displayed. E.g., if an error ocurred or the "
"status of the connection is shown.")); "status of the connection is shown."));
@ -57,9 +54,31 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent,
QWhatsThis::add(TextLabelServerAddr, strServAddrH); QWhatsThis::add(TextLabelServerAddr, strServAddrH);
QWhatsThis::add(LineEditServerAddr, strServAddrH); QWhatsThis::add(LineEditServerAddr, strServAddrH);
/* set text for version and application name */ QString strAudFader = tr ( "<b>Audio Fader:</b> With the audio fader "
TextLabelNameVersion-> "control the level of left and right audio input channels can "
setText(QString(APP_NAME) + tr(" client ") + QString(VERSION)); "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 */ /* init server address line edit */
LineEditServerAddr->setText ( pClient->strIPAddress.c_str () ); LineEditServerAddr->setText ( pClient->strIPAddress.c_str () );

View file

@ -318,17 +318,6 @@
<name>spacing</name> <name>spacing</name>
<number>6</number> <number>6</number>
</property> </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> <spacer>
<property> <property>
<name>name</name> <name>name</name>
@ -587,7 +576,7 @@ Level</string>
</property> </property>
<property stdset="1"> <property stdset="1">
<name>text</name> <name>text</name>
<string>Reverb Chan. <string>Reverb Chan
Selection</string> Selection</string>
</property> </property>
<property stdset="1"> <property stdset="1">

View file

@ -230,11 +230,9 @@ bool CProtocol::ParseMessage ( const CVector<unsigned char>& vecbyData,
return code: true -> ok; false -> error return code: true -> ok; false -> error
*/ */
bool bRet, bSendNextMess; bool bRet, bSendNextMess;
int iRecCounter, iRecID, iData, iDataLen, iStringLen, iCurID; int iRecCounter, iRecID;
unsigned int iPos; unsigned int iPos;
CVector<uint8_t> vecData; CVector<uint8_t> vecData;
std::string strCurString;
double dNewGain;
// convert unsigned char in uint8_t, TODO convert all buffers in uint8_t // 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 else
{ {
// check which type of message we received and do action // special treatment for acknowledge messages
switch ( iRecID ) if ( iRecID == PROTMESSID_ACKN )
{ {
case PROTMESSID_ACKN:
// extract data from stream and emit signal for received value // extract data from stream and emit signal for received value
iPos = 0; iPos = 0;
iData = static_cast<int> ( GetValFromStream ( vecData, iPos, 2 ) ); const int iData =
static_cast<int> ( GetValFromStream ( vecData, iPos, 2 ) );
Mutex.lock(); Mutex.lock();
{ {
@ -294,105 +291,44 @@ for ( int i = 0; i < iNumBytes; i++ ) {
{ {
SendMessage(); SendMessage();
} }
}
else
{
// init position pointer which is used for extracting data from
// received data vector
iPos = 0;
break; // check which type of message we received and do action
switch ( iRecID )
{
case PROTMESSID_JITT_BUF_SIZE: case PROTMESSID_JITT_BUF_SIZE:
// extract data from stream and emit signal for received value EvaluateJitBufMes ( iPos, vecData );
iPos = 0;
iData = static_cast<int> ( GetValFromStream ( vecData, iPos, 2 ) );
// invoke message action
emit ChangeJittBufSize ( iData );
// send acknowledge message
CreateAndSendAcknMess ( iRecID, iRecCounter );
break; break;
case PROTMESSID_REQ_JITT_BUF_SIZE: case PROTMESSID_REQ_JITT_BUF_SIZE:
// invoke message action EvaluateReqJitBufMes ( iPos, vecData );
emit ReqJittBufSize();
// send acknowledge message
CreateAndSendAcknMess ( iRecID, iRecCounter );
break; break;
case PROTMESSID_NET_BLSI_FACTOR: case PROTMESSID_NET_BLSI_FACTOR:
// extract data from stream and emit signal for received value EvaluateNetwBlSiFactMes ( iPos, vecData );
iPos = 0;
iData = static_cast<int> ( GetValFromStream ( vecData, iPos, 2 ) );
// invoke message action
emit ChangeNetwBlSiFact ( iData );
// send acknowledge message
CreateAndSendAcknMess ( iRecID, iRecCounter );
break; break;
case PROTMESSID_CHANNEL_GAIN: case PROTMESSID_CHANNEL_GAIN:
// extract data from stream and emit signal for received value EvaluateChanGainMes ( iPos, vecData );
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; break;
case PROTMESSID_CONN_CLIENTS_LIST: case PROTMESSID_CONN_CLIENTS_LIST:
// extract data from stream and emit signal for received value EvaluateConClientListMes ( iPos, vecData );
iPos = 0; break;
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)
iStringLen = static_cast<int> ( GetValFromStream ( vecData, iPos, 2 ) );
// 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 );
}
// TODO do something with the received name string "strCurString"
} }
// send acknowledge message // send acknowledge message
CreateAndSendAcknMess ( iRecID, iRecCounter ); 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 ) void CProtocol::CreateJitBufMes ( const int iJitBufSize )
{ {
CVector<uint8_t> vecData ( 2 ); // 2 bytes of data 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 ); 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() void CProtocol::CreateReqJitBufMes()
{ {
CreateAndSendMessage ( PROTMESSID_REQ_JITT_BUF_SIZE, CVector<uint8_t> ( 0 ) ); 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 ) void CProtocol::CreateNetwBlSiFactMes ( const int iNetwBlSiFact )
{ {
CVector<uint8_t> vecData ( 2 ); // 2 bytes of data 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 ); 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 ) void CProtocol::CreateChanGainMes ( const int iChanID, const double dGain )
{ {
CVector<uint8_t> vecData ( 4 ); // 4 bytes of data 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 ); 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, void CProtocol::CreateConClientListMes ( const CVector<uint32_t>& veciIpAddrs,
const CVector<std::string>& vecstrNames ) const CVector<std::string>& vecstrNames )
{ {
@ -496,6 +473,41 @@ void CProtocol::CreateConClientListMes ( const CVector<uint32_t>& veciIpAddrs,
CreateAndSendMessage ( PROTMESSID_CONN_CLIENTS_LIST, vecData ); 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) * * Message generation (parsing) *

View file

@ -59,7 +59,6 @@ class CProtocol : public QObject
public: public:
CProtocol(); CProtocol();
virtual ~CProtocol() {}
void CreateJitBufMes ( const int iJitBufSize ); void CreateJitBufMes ( const int iJitBufSize );
void CreateReqJitBufMes(); void CreateReqJitBufMes();
@ -127,6 +126,12 @@ protected:
void CreateAndSendMessage ( const int iID, const CVector<uint8_t>& vecData ); 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; int iOldRecID, iOldRecCnt;
// these two objects must be sequred by a mutex // these two objects must be sequred by a mutex

View file

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