diff --git a/src/audiomixerboard.cpp b/src/audiomixerboard.cpp index 8855acbd..859029dd 100755 --- a/src/audiomixerboard.cpp +++ b/src/audiomixerboard.cpp @@ -97,8 +97,9 @@ CChannelFader::CChannelFader ( QWidget* pNW, QObject::connect ( pcbMute, SIGNAL ( stateChanged ( int ) ), this, SLOT ( OnMuteStateChanged ( int ) ) ); - QObject::connect ( pcbSolo, SIGNAL ( stateChanged ( int ) ), - this, SIGNAL ( soloStateChanged ( int ) ) ); + QObject::connect ( pcbSolo, + SIGNAL ( stateChanged ( int ) ), + SIGNAL ( soloStateChanged ( int ) ) ); } void CChannelFader::SetGUIDesign ( const EGUIDesign eNewDesign ) diff --git a/src/channel.cpp b/src/channel.cpp index fc206d48..a8c1ffe6 100755 --- a/src/channel.cpp +++ b/src/channel.cpp @@ -84,11 +84,13 @@ CChannel::CChannel ( const bool bNIsServer ) : QObject::connect( &Protocol, SIGNAL ( ChangeChanName ( QString ) ), this, SLOT ( OnChangeChanName ( QString ) ) ); - QObject::connect( &Protocol, SIGNAL ( ChatTextReceived ( QString ) ), - this, SIGNAL ( ChatTextReceived ( QString ) ) ); + QObject::connect( &Protocol, + SIGNAL ( ChatTextReceived ( QString ) ), + SIGNAL ( ChatTextReceived ( QString ) ) ); - QObject::connect( &Protocol, SIGNAL ( PingReceived ( int ) ), - this, SIGNAL ( PingReceived ( int ) ) ); + QObject::connect( &Protocol, + SIGNAL ( PingReceived ( int ) ), + SIGNAL ( PingReceived ( int ) ) ); QObject::connect ( &Protocol, SIGNAL ( NetTranspPropsReceived ( CNetworkTransportProps ) ), @@ -555,4 +557,8 @@ CConnectionLessChannel::CConnectionLessChannel() QObject::connect ( &Protocol, SIGNAL ( CLMessReadyForSending ( CHostAddress, CVector ) ), SIGNAL ( CLMessReadyForSending ( CHostAddress, CVector ) ) ); + + QObject::connect( &Protocol, + SIGNAL ( CLPingReceived ( CHostAddress, int ) ), + SIGNAL ( CLPingReceived ( CHostAddress, int ) ) ); } diff --git a/src/channel.h b/src/channel.h index 6625a557..3bf8c41f 100755 --- a/src/channel.h +++ b/src/channel.h @@ -209,6 +209,9 @@ public: void CreateCLServerFullMes ( const CHostAddress& InetAddr ) { Protocol.CreateCLServerFullMes ( InetAddr ); } + void CreateCLPingMes ( const CHostAddress& InetAddr, const int iMs ) + { Protocol.CreateCLPingMes ( InetAddr, iMs ); } + protected: // network protocol CProtocol Protocol; @@ -216,6 +219,8 @@ protected: signals: void CLMessReadyForSending ( CHostAddress InetAddr, CVector vecMessage ); + + void CLPingReceived ( CHostAddress InetAddr, int iMs ); }; diff --git a/src/client.cpp b/src/client.cpp index 65d5911f..54156578 100755 --- a/src/client.cpp +++ b/src/client.cpp @@ -34,7 +34,7 @@ CClient::CClient ( const quint16 iPortNumber ) : iCeltNumCodedBytes ( CELT_NUM_BYTES_MONO_NORMAL_QUALITY ), bCeltDoHighQuality ( false ), bUseStereo ( false ), - Socket ( &Channel, iPortNumber ), + Socket ( &Channel, &ConnLessChannel, iPortNumber ), Sound ( AudioCallback, this ), iAudioInFader ( AUD_FADER_IN_MIDDLE ), bReverbOnLeftChan ( false ), @@ -89,10 +89,6 @@ CClient::CClient ( const quint16 iPortNumber ) : SIGNAL ( MessReadyForSending ( CVector ) ), this, SLOT ( OnSendProtMessage ( CVector ) ) ); - QObject::connect ( &ConnLessChannel, - SIGNAL ( CLMessReadyForSending ( CHostAddress, CVector ) ), - this, SLOT ( OnSendCLProtMessage ( CHostAddress, CVector ) ) ); - QObject::connect ( &Channel, SIGNAL ( ReqJittBufSize() ), this, SLOT ( OnReqJittBufSize() ) ); @@ -110,12 +106,20 @@ CClient::CClient ( const quint16 iPortNumber ) : QObject::connect ( &Channel, SIGNAL ( NewConnection() ), this, SLOT ( OnNewConnection() ) ); - QObject::connect ( &Channel, SIGNAL ( ChatTextReceived ( QString ) ), - this, SIGNAL ( ChatTextReceived ( QString ) ) ); + QObject::connect ( &Channel, + SIGNAL ( ChatTextReceived ( QString ) ), + SIGNAL ( ChatTextReceived ( QString ) ) ); QObject::connect ( &Channel, SIGNAL ( PingReceived ( int ) ), this, SLOT ( OnReceivePingMessage ( int ) ) ); + QObject::connect ( &ConnLessChannel, + SIGNAL ( CLMessReadyForSending ( CHostAddress, CVector ) ), + this, SLOT ( OnSendCLProtMessage ( CHostAddress, CVector ) ) ); + + QObject::connect ( &ConnLessChannel, SIGNAL ( CLPingReceived ( CHostAddress, int ) ), + this, SLOT ( OnCLPingReceived ( CHostAddress, int ) ) ); + QObject::connect ( &Sound, SIGNAL ( ReinitRequest() ), this, SLOT ( OnSndCrdReinitRequest() ) ); } @@ -162,6 +166,17 @@ void CClient::OnReceivePingMessage ( int iMs ) } } +void CClient::OnCLPingReceived ( CHostAddress InetAddr, int iMs ) +{ + // calculate difference between received time in ms and current time in ms, + // take care of wrap arounds (if wrapping, do not use result) + const int iCurDiff = PreciseTime.elapsed() - iMs; + if ( iCurDiff >= 0 ) + { + emit CLPingTimeReceived ( InetAddr, iCurDiff ); + } +} + bool CClient::SetServerAddr ( QString strNAddr ) { QHostAddress InetAddr; diff --git a/src/client.h b/src/client.h index 242aa980..4a4abef7 100755 --- a/src/client.h +++ b/src/client.h @@ -212,6 +212,9 @@ public: void SendPingMess() { Channel.CreatePingMes ( PreciseTime.elapsed() ); }; + void SendCLPingMess ( const CHostAddress& InetAddr ) + { ConnLessChannel.CreateCLPingMes ( InetAddr, PreciseTime.elapsed() ); }; + int EstimatedOverallDelay ( const int iPingTimeMs ); CChannel* GetChannel() { return &Channel; } @@ -293,17 +296,21 @@ protected: public slots: void OnSendProtMessage ( CVector vecMessage ); - void OnSendCLProtMessage ( CHostAddress InetAddr, CVector vecMessage ); void OnReqJittBufSize() { Channel.CreateJitBufMes ( Channel.GetSockBufNumFrames() ); } void OnReqChanName() { Channel.SetRemoteName ( strName ); } void OnNewConnection(); void OnReceivePingMessage ( int iMs ); + + void OnSendCLProtMessage ( CHostAddress InetAddr, CVector vecMessage ); + void OnCLPingReceived ( CHostAddress InetAddr, int iMs ); + void OnSndCrdReinitRequest(); signals: void ConClientListMesReceived ( CVector vecChanInfo ); void ChatTextReceived ( QString strChatText ); void PingTimeReceived ( int iPingTime ); + void CLPingTimeReceived ( CHostAddress InetAddr, int iPingTime ); void Disconnected(); void Stopped(); }; diff --git a/src/connectdlg.cpp b/src/connectdlg.cpp index a047be67..01666069 100755 --- a/src/connectdlg.cpp +++ b/src/connectdlg.cpp @@ -26,8 +26,9 @@ /* Implementation *************************************************************/ -CConnectDlg::CConnectDlg ( QWidget* parent, Qt::WindowFlags f ) : - QDialog ( parent, f ) +CConnectDlg::CConnectDlg ( CClient* pNCliP, QWidget* parent, + Qt::WindowFlags f ) + : QDialog ( parent, f ), pClient ( pNCliP ) { setupUi ( this ); @@ -44,7 +45,8 @@ CConnectDlg::CConnectDlg ( QWidget* parent, Qt::WindowFlags f ) : ListViewServers->setColumnWidth ( 3, 80 ); ListViewServers->clear(); - +// TEST +pListViewItem = new QTreeWidgetItem ( ListViewServers ); //TextLabelPingTime->setText ( "" ); @@ -71,12 +73,18 @@ void CConnectDlg::hideEvent ( QHideEvent* ) void CConnectDlg::OnTimerPing() { // send ping message to server -// pClient->SendPingMess(); + +// TEST +//pClient->SendCLPingMess ( pClient->GetChannel()-> +// const CHostAddress& InetAddr ); + } -void CConnectDlg::OnPingTimeResult ( int iPingTime ) +void CConnectDlg::SetPingTimeResult ( CHostAddress& InetAddr, + const int iPingTime ) { -// TODO -// TextLabelPingTime->setText ( sErrorText ); -} \ No newline at end of file +// TEST +pListViewItem->setText ( 0, QString().setNum ( iPingTime ) ); + +} diff --git a/src/connectdlg.h b/src/connectdlg.h index 96fdd25b..aafd7050 100755 --- a/src/connectdlg.h +++ b/src/connectdlg.h @@ -28,6 +28,7 @@ #include #include #include "global.h" +#include "client.h" #ifdef _WIN32 # include "../windows/moc/connectdlgbase.h" #else @@ -45,15 +46,22 @@ class CConnectDlg : public QDialog, private Ui_CConnectDlgBase Q_OBJECT public: - CConnectDlg ( QWidget* parent = 0, Qt::WindowFlags f = 0 ); + CConnectDlg ( CClient* pNCliP, QWidget* parent = 0, Qt::WindowFlags f = 0 ); + + void AddPingTime ( QString strChatText ); + void SetPingTimeResult ( CHostAddress& InetAddr, const int iPingTime ); protected: - QTimer TimerPing; - virtual void showEvent ( QShowEvent* ); virtual void hideEvent ( QHideEvent* ); - void OnPingTimeResult ( int iPingTime ); + CClient* pClient; + QTimer TimerPing; + + +// TEST +QTreeWidgetItem* pListViewItem; + public slots: void OnTimerPing(); diff --git a/src/llconclientdlg.cpp b/src/llconclientdlg.cpp index aeea67b8..052e86f0 100755 --- a/src/llconclientdlg.cpp +++ b/src/llconclientdlg.cpp @@ -46,7 +46,7 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, , Qt::WindowMinMaxButtonsHint #endif ), - ConnectDlg ( parent + ConnectDlg ( pNCliP, parent #ifdef _WIN32 // this somehow only works reliable on Windows , Qt::WindowMinMaxButtonsHint @@ -421,6 +421,9 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QObject::connect ( pClient, SIGNAL ( PingTimeReceived ( int ) ), this, SLOT ( OnPingTimeResult ( int ) ) ); + QObject::connect ( pClient, SIGNAL ( CLPingTimeReceived ( CHostAddress, int ) ), + this, SLOT ( OnCLPingTimeResult ( CHostAddress, int ) ) ); + QObject::connect ( &ClientSettingsDlg, SIGNAL ( GUIDesignChanged() ), this, SLOT ( OnGUIDesignChanged() ) ); @@ -753,6 +756,17 @@ void CLlconClientDlg::OnPingTimeResult ( int iPingTime ) LEDDelay->SetLight ( iOverallDelayLEDColor ); } +void CLlconClientDlg::OnCLPingTimeResult ( CHostAddress InetAddr, + int iPingTime ) +{ + +// TODO evaluate the background color for the ping time result in the +// table in this function (see function above, there also the LED color +// is calculated so we do the other here, too) + + ConnectDlg.SetPingTimeResult ( InetAddr, iPingTime ); +} + void CLlconClientDlg::ConnectDisconnect ( const bool bDoStart ) { // start/stop client, set button text diff --git a/src/llconclientdlg.h b/src/llconclientdlg.h index ef596a54..32b0bf8b 100755 --- a/src/llconclientdlg.h +++ b/src/llconclientdlg.h @@ -110,6 +110,7 @@ public slots: void OnTimerStatus() { UpdateDisplay(); } void OnTimerPing(); void OnPingTimeResult ( int iPingTime ); + void OnCLPingTimeResult ( CHostAddress InetAddr, int iPingTime ); void OnOpenGeneralSettings(); void OnOpenChatDialog() { ShowChatWindow(); } void OnSliderAudInFader ( int value ); diff --git a/src/server.cpp b/src/server.cpp index 52be9ddb..1f9f86d1 100755 --- a/src/server.cpp +++ b/src/server.cpp @@ -276,6 +276,10 @@ CServer::CServer ( const QString& strLoggingFileName, SIGNAL ( CLMessReadyForSending ( CHostAddress, CVector ) ), this, SLOT ( OnSendCLProtMessage ( CHostAddress, CVector ) ) ); + QObject::connect ( &ConnLessChannel, + SIGNAL ( CLPingReceived ( CHostAddress, int ) ), + this, SLOT ( OnCLPingReceived ( CHostAddress, int ) ) ); + // CODE TAG: MAX_NUM_CHANNELS_TAG // make sure we have MAX_NUM_CHANNELS connections!!! // send message diff --git a/src/server.h b/src/server.h index d7051fdb..ce739ef9 100755 --- a/src/server.h +++ b/src/server.h @@ -182,6 +182,8 @@ public slots: void OnTimer(); void OnSendProtMessage ( int iChID, CVector vecMessage ); void OnSendCLProtMessage ( CHostAddress InetAddr, CVector vecMessage ); + void OnCLPingReceived ( CHostAddress InetAddr, int iMs ) + { ConnLessChannel.CreateCLPingMes ( InetAddr, iMs ); } // CODE TAG: MAX_NUM_CHANNELS_TAG // make sure we have MAX_NUM_CHANNELS connections!!! diff --git a/src/socket.cpp b/src/socket.cpp index 73401994..f21bb222 100755 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -1,5 +1,5 @@ /******************************************************************************\ - * opyright (c) 2004-2011 + * Copyright (c) 2004-2011 * * Author(s): * Volker Fischer @@ -103,6 +103,13 @@ void CSocket::OnDataReceived() // check if packet comes from the server we want to connect if ( !( pChannel->GetAddress() == RecHostAddr ) ) { + // this is an unknown address, try to parse connection less + // message + pConnLessChannel->ParseConnectionLessMessage ( vecbyRecBuf, + iNumBytesRead, + RecHostAddr ); + + // do not perform any other action on this received packet return; } diff --git a/src/socket.h b/src/socket.h index ab52c5fe..47ef4864 100755 --- a/src/socket.h +++ b/src/socket.h @@ -46,11 +46,16 @@ class CSocket : public QObject Q_OBJECT public: - CSocket ( CChannel* pNewChannel, const quint16 iPortNumber ) : - pChannel( pNewChannel ), bIsClient ( true ) { Init ( iPortNumber ); } - CSocket ( CServer* pNServP, const quint16 iPortNumber ) : - pServer ( pNServP ), bIsClient ( false ) - { Init ( iPortNumber ); } + CSocket ( CChannel* pNewChannel, + CConnectionLessChannel* pNewCLChannel, + const quint16 iPortNumber ) + : pChannel( pNewChannel ), pConnLessChannel ( pNewCLChannel ), + bIsClient ( true ) { Init ( iPortNumber ); } + + CSocket ( CServer* pNServP, + const quint16 iPortNumber ) + : pServer ( pNServP ), bIsClient ( false ) { Init ( iPortNumber ); } + virtual ~CSocket() {} void SendPacket ( const CVector& vecbySendBuf, @@ -59,15 +64,16 @@ public: protected: void Init ( const quint16 iPortNumber = LLCON_DEFAULT_PORT_NUMBER ); - QUdpSocket SocketDevice; + QUdpSocket SocketDevice; - CVector vecbyRecBuf; - CHostAddress RecHostAddr; + CVector vecbyRecBuf; + CHostAddress RecHostAddr; - CChannel* pChannel; // for client - CServer* pServer; // for server + CChannel* pChannel; // for client + CConnectionLessChannel* pConnLessChannel; // for client + CServer* pServer; // for server - bool bIsClient; + bool bIsClient; public slots: void OnDataReceived();