prepared everything for transmitting/receiving the first connection less ping time measurement

This commit is contained in:
Volker Fischer 2011-03-30 07:55:43 +00:00
parent 0cff6af6d8
commit 9feff9057a
13 changed files with 123 additions and 39 deletions

View File

@ -97,8 +97,9 @@ CChannelFader::CChannelFader ( QWidget* pNW,
QObject::connect ( pcbMute, SIGNAL ( stateChanged ( int ) ), QObject::connect ( pcbMute, SIGNAL ( stateChanged ( int ) ),
this, SLOT ( OnMuteStateChanged ( int ) ) ); this, SLOT ( OnMuteStateChanged ( int ) ) );
QObject::connect ( pcbSolo, SIGNAL ( stateChanged ( int ) ), QObject::connect ( pcbSolo,
this, SIGNAL ( soloStateChanged ( int ) ) ); SIGNAL ( stateChanged ( int ) ),
SIGNAL ( soloStateChanged ( int ) ) );
} }
void CChannelFader::SetGUIDesign ( const EGUIDesign eNewDesign ) void CChannelFader::SetGUIDesign ( const EGUIDesign eNewDesign )

View File

@ -84,11 +84,13 @@ CChannel::CChannel ( const bool bNIsServer ) :
QObject::connect( &Protocol, SIGNAL ( ChangeChanName ( QString ) ), QObject::connect( &Protocol, SIGNAL ( ChangeChanName ( QString ) ),
this, SLOT ( OnChangeChanName ( QString ) ) ); this, SLOT ( OnChangeChanName ( QString ) ) );
QObject::connect( &Protocol, SIGNAL ( ChatTextReceived ( QString ) ), QObject::connect( &Protocol,
this, SIGNAL ( ChatTextReceived ( QString ) ) ); SIGNAL ( ChatTextReceived ( QString ) ),
SIGNAL ( ChatTextReceived ( QString ) ) );
QObject::connect( &Protocol, SIGNAL ( PingReceived ( int ) ), QObject::connect( &Protocol,
this, SIGNAL ( PingReceived ( int ) ) ); SIGNAL ( PingReceived ( int ) ),
SIGNAL ( PingReceived ( int ) ) );
QObject::connect ( &Protocol, QObject::connect ( &Protocol,
SIGNAL ( NetTranspPropsReceived ( CNetworkTransportProps ) ), SIGNAL ( NetTranspPropsReceived ( CNetworkTransportProps ) ),
@ -555,4 +557,8 @@ CConnectionLessChannel::CConnectionLessChannel()
QObject::connect ( &Protocol, QObject::connect ( &Protocol,
SIGNAL ( CLMessReadyForSending ( CHostAddress, CVector<uint8_t> ) ), SIGNAL ( CLMessReadyForSending ( CHostAddress, CVector<uint8_t> ) ),
SIGNAL ( CLMessReadyForSending ( CHostAddress, CVector<uint8_t> ) ) ); SIGNAL ( CLMessReadyForSending ( CHostAddress, CVector<uint8_t> ) ) );
QObject::connect( &Protocol,
SIGNAL ( CLPingReceived ( CHostAddress, int ) ),
SIGNAL ( CLPingReceived ( CHostAddress, int ) ) );
} }

View File

@ -209,6 +209,9 @@ public:
void CreateCLServerFullMes ( const CHostAddress& InetAddr ) void CreateCLServerFullMes ( const CHostAddress& InetAddr )
{ Protocol.CreateCLServerFullMes ( InetAddr ); } { Protocol.CreateCLServerFullMes ( InetAddr ); }
void CreateCLPingMes ( const CHostAddress& InetAddr, const int iMs )
{ Protocol.CreateCLPingMes ( InetAddr, iMs ); }
protected: protected:
// network protocol // network protocol
CProtocol Protocol; CProtocol Protocol;
@ -216,6 +219,8 @@ protected:
signals: signals:
void CLMessReadyForSending ( CHostAddress InetAddr, void CLMessReadyForSending ( CHostAddress InetAddr,
CVector<uint8_t> vecMessage ); CVector<uint8_t> vecMessage );
void CLPingReceived ( CHostAddress InetAddr, int iMs );
}; };

View File

@ -34,7 +34,7 @@ CClient::CClient ( const quint16 iPortNumber ) :
iCeltNumCodedBytes ( CELT_NUM_BYTES_MONO_NORMAL_QUALITY ), iCeltNumCodedBytes ( CELT_NUM_BYTES_MONO_NORMAL_QUALITY ),
bCeltDoHighQuality ( false ), bCeltDoHighQuality ( false ),
bUseStereo ( false ), bUseStereo ( false ),
Socket ( &Channel, iPortNumber ), Socket ( &Channel, &ConnLessChannel, iPortNumber ),
Sound ( AudioCallback, this ), Sound ( AudioCallback, this ),
iAudioInFader ( AUD_FADER_IN_MIDDLE ), iAudioInFader ( AUD_FADER_IN_MIDDLE ),
bReverbOnLeftChan ( false ), bReverbOnLeftChan ( false ),
@ -89,10 +89,6 @@ CClient::CClient ( const quint16 iPortNumber ) :
SIGNAL ( MessReadyForSending ( CVector<uint8_t> ) ), SIGNAL ( MessReadyForSending ( CVector<uint8_t> ) ),
this, SLOT ( OnSendProtMessage ( CVector<uint8_t> ) ) ); this, SLOT ( OnSendProtMessage ( CVector<uint8_t> ) ) );
QObject::connect ( &ConnLessChannel,
SIGNAL ( CLMessReadyForSending ( CHostAddress, CVector<uint8_t> ) ),
this, SLOT ( OnSendCLProtMessage ( CHostAddress, CVector<uint8_t> ) ) );
QObject::connect ( &Channel, SIGNAL ( ReqJittBufSize() ), QObject::connect ( &Channel, SIGNAL ( ReqJittBufSize() ),
this, SLOT ( OnReqJittBufSize() ) ); this, SLOT ( OnReqJittBufSize() ) );
@ -110,12 +106,20 @@ CClient::CClient ( const quint16 iPortNumber ) :
QObject::connect ( &Channel, SIGNAL ( NewConnection() ), QObject::connect ( &Channel, SIGNAL ( NewConnection() ),
this, SLOT ( OnNewConnection() ) ); this, SLOT ( OnNewConnection() ) );
QObject::connect ( &Channel, SIGNAL ( ChatTextReceived ( QString ) ), QObject::connect ( &Channel,
this, SIGNAL ( ChatTextReceived ( QString ) ) ); SIGNAL ( ChatTextReceived ( QString ) ),
SIGNAL ( ChatTextReceived ( QString ) ) );
QObject::connect ( &Channel, SIGNAL ( PingReceived ( int ) ), QObject::connect ( &Channel, SIGNAL ( PingReceived ( int ) ),
this, SLOT ( OnReceivePingMessage ( int ) ) ); this, SLOT ( OnReceivePingMessage ( int ) ) );
QObject::connect ( &ConnLessChannel,
SIGNAL ( CLMessReadyForSending ( CHostAddress, CVector<uint8_t> ) ),
this, SLOT ( OnSendCLProtMessage ( CHostAddress, CVector<uint8_t> ) ) );
QObject::connect ( &ConnLessChannel, SIGNAL ( CLPingReceived ( CHostAddress, int ) ),
this, SLOT ( OnCLPingReceived ( CHostAddress, int ) ) );
QObject::connect ( &Sound, SIGNAL ( ReinitRequest() ), QObject::connect ( &Sound, SIGNAL ( ReinitRequest() ),
this, SLOT ( OnSndCrdReinitRequest() ) ); 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 ) bool CClient::SetServerAddr ( QString strNAddr )
{ {
QHostAddress InetAddr; QHostAddress InetAddr;

View File

@ -212,6 +212,9 @@ public:
void SendPingMess() void SendPingMess()
{ Channel.CreatePingMes ( PreciseTime.elapsed() ); }; { Channel.CreatePingMes ( PreciseTime.elapsed() ); };
void SendCLPingMess ( const CHostAddress& InetAddr )
{ ConnLessChannel.CreateCLPingMes ( InetAddr, PreciseTime.elapsed() ); };
int EstimatedOverallDelay ( const int iPingTimeMs ); int EstimatedOverallDelay ( const int iPingTimeMs );
CChannel* GetChannel() { return &Channel; } CChannel* GetChannel() { return &Channel; }
@ -293,17 +296,21 @@ protected:
public slots: public slots:
void OnSendProtMessage ( CVector<uint8_t> vecMessage ); void OnSendProtMessage ( CVector<uint8_t> vecMessage );
void OnSendCLProtMessage ( CHostAddress InetAddr, CVector<uint8_t> vecMessage );
void OnReqJittBufSize() { Channel.CreateJitBufMes ( Channel.GetSockBufNumFrames() ); } void OnReqJittBufSize() { Channel.CreateJitBufMes ( Channel.GetSockBufNumFrames() ); }
void OnReqChanName() { Channel.SetRemoteName ( strName ); } void OnReqChanName() { Channel.SetRemoteName ( strName ); }
void OnNewConnection(); void OnNewConnection();
void OnReceivePingMessage ( int iMs ); void OnReceivePingMessage ( int iMs );
void OnSendCLProtMessage ( CHostAddress InetAddr, CVector<uint8_t> vecMessage );
void OnCLPingReceived ( CHostAddress InetAddr, int iMs );
void OnSndCrdReinitRequest(); void OnSndCrdReinitRequest();
signals: signals:
void ConClientListMesReceived ( CVector<CChannelShortInfo> vecChanInfo ); void ConClientListMesReceived ( CVector<CChannelShortInfo> vecChanInfo );
void ChatTextReceived ( QString strChatText ); void ChatTextReceived ( QString strChatText );
void PingTimeReceived ( int iPingTime ); void PingTimeReceived ( int iPingTime );
void CLPingTimeReceived ( CHostAddress InetAddr, int iPingTime );
void Disconnected(); void Disconnected();
void Stopped(); void Stopped();
}; };

View File

@ -26,8 +26,9 @@
/* Implementation *************************************************************/ /* Implementation *************************************************************/
CConnectDlg::CConnectDlg ( QWidget* parent, Qt::WindowFlags f ) : CConnectDlg::CConnectDlg ( CClient* pNCliP, QWidget* parent,
QDialog ( parent, f ) Qt::WindowFlags f )
: QDialog ( parent, f ), pClient ( pNCliP )
{ {
setupUi ( this ); setupUi ( this );
@ -44,7 +45,8 @@ CConnectDlg::CConnectDlg ( QWidget* parent, Qt::WindowFlags f ) :
ListViewServers->setColumnWidth ( 3, 80 ); ListViewServers->setColumnWidth ( 3, 80 );
ListViewServers->clear(); ListViewServers->clear();
// TEST
pListViewItem = new QTreeWidgetItem ( ListViewServers );
//TextLabelPingTime->setText ( "" ); //TextLabelPingTime->setText ( "" );
@ -71,12 +73,18 @@ void CConnectDlg::hideEvent ( QHideEvent* )
void CConnectDlg::OnTimerPing() void CConnectDlg::OnTimerPing()
{ {
// send ping message to server // 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 // TEST
// TextLabelPingTime->setText ( sErrorText ); pListViewItem->setText ( 0, QString().setNum ( iPingTime ) );
}
}

View File

@ -28,6 +28,7 @@
#include <qwhatsthis.h> #include <qwhatsthis.h>
#include <qtimer.h> #include <qtimer.h>
#include "global.h" #include "global.h"
#include "client.h"
#ifdef _WIN32 #ifdef _WIN32
# include "../windows/moc/connectdlgbase.h" # include "../windows/moc/connectdlgbase.h"
#else #else
@ -45,15 +46,22 @@ class CConnectDlg : public QDialog, private Ui_CConnectDlgBase
Q_OBJECT Q_OBJECT
public: 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: protected:
QTimer TimerPing;
virtual void showEvent ( QShowEvent* ); virtual void showEvent ( QShowEvent* );
virtual void hideEvent ( QHideEvent* ); virtual void hideEvent ( QHideEvent* );
void OnPingTimeResult ( int iPingTime ); CClient* pClient;
QTimer TimerPing;
// TEST
QTreeWidgetItem* pListViewItem;
public slots: public slots:
void OnTimerPing(); void OnTimerPing();

View File

@ -46,7 +46,7 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP,
, Qt::WindowMinMaxButtonsHint , Qt::WindowMinMaxButtonsHint
#endif #endif
), ),
ConnectDlg ( parent ConnectDlg ( pNCliP, parent
#ifdef _WIN32 #ifdef _WIN32
// this somehow only works reliable on Windows // this somehow only works reliable on Windows
, Qt::WindowMinMaxButtonsHint , Qt::WindowMinMaxButtonsHint
@ -421,6 +421,9 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP,
QObject::connect ( pClient, SIGNAL ( PingTimeReceived ( int ) ), QObject::connect ( pClient, SIGNAL ( PingTimeReceived ( int ) ),
this, SLOT ( OnPingTimeResult ( int ) ) ); this, SLOT ( OnPingTimeResult ( int ) ) );
QObject::connect ( pClient, SIGNAL ( CLPingTimeReceived ( CHostAddress, int ) ),
this, SLOT ( OnCLPingTimeResult ( CHostAddress, int ) ) );
QObject::connect ( &ClientSettingsDlg, SIGNAL ( GUIDesignChanged() ), QObject::connect ( &ClientSettingsDlg, SIGNAL ( GUIDesignChanged() ),
this, SLOT ( OnGUIDesignChanged() ) ); this, SLOT ( OnGUIDesignChanged() ) );
@ -753,6 +756,17 @@ void CLlconClientDlg::OnPingTimeResult ( int iPingTime )
LEDDelay->SetLight ( iOverallDelayLEDColor ); 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 ) void CLlconClientDlg::ConnectDisconnect ( const bool bDoStart )
{ {
// start/stop client, set button text // start/stop client, set button text

View File

@ -110,6 +110,7 @@ public slots:
void OnTimerStatus() { UpdateDisplay(); } void OnTimerStatus() { UpdateDisplay(); }
void OnTimerPing(); void OnTimerPing();
void OnPingTimeResult ( int iPingTime ); void OnPingTimeResult ( int iPingTime );
void OnCLPingTimeResult ( CHostAddress InetAddr, int iPingTime );
void OnOpenGeneralSettings(); void OnOpenGeneralSettings();
void OnOpenChatDialog() { ShowChatWindow(); } void OnOpenChatDialog() { ShowChatWindow(); }
void OnSliderAudInFader ( int value ); void OnSliderAudInFader ( int value );

View File

@ -276,6 +276,10 @@ CServer::CServer ( const QString& strLoggingFileName,
SIGNAL ( CLMessReadyForSending ( CHostAddress, CVector<uint8_t> ) ), SIGNAL ( CLMessReadyForSending ( CHostAddress, CVector<uint8_t> ) ),
this, SLOT ( OnSendCLProtMessage ( CHostAddress, CVector<uint8_t> ) ) ); this, SLOT ( OnSendCLProtMessage ( CHostAddress, CVector<uint8_t> ) ) );
QObject::connect ( &ConnLessChannel,
SIGNAL ( CLPingReceived ( CHostAddress, int ) ),
this, SLOT ( OnCLPingReceived ( CHostAddress, int ) ) );
// CODE TAG: MAX_NUM_CHANNELS_TAG // CODE TAG: MAX_NUM_CHANNELS_TAG
// make sure we have MAX_NUM_CHANNELS connections!!! // make sure we have MAX_NUM_CHANNELS connections!!!
// send message // send message

View File

@ -182,6 +182,8 @@ public slots:
void OnTimer(); void OnTimer();
void OnSendProtMessage ( int iChID, CVector<uint8_t> vecMessage ); void OnSendProtMessage ( int iChID, CVector<uint8_t> vecMessage );
void OnSendCLProtMessage ( CHostAddress InetAddr, CVector<uint8_t> vecMessage ); void OnSendCLProtMessage ( CHostAddress InetAddr, CVector<uint8_t> vecMessage );
void OnCLPingReceived ( CHostAddress InetAddr, int iMs )
{ ConnLessChannel.CreateCLPingMes ( InetAddr, iMs ); }
// CODE TAG: MAX_NUM_CHANNELS_TAG // CODE TAG: MAX_NUM_CHANNELS_TAG
// make sure we have MAX_NUM_CHANNELS connections!!! // make sure we have MAX_NUM_CHANNELS connections!!!

View File

@ -1,5 +1,5 @@
/******************************************************************************\ /******************************************************************************\
* opyright (c) 2004-2011 * Copyright (c) 2004-2011
* *
* Author(s): * Author(s):
* Volker Fischer * Volker Fischer
@ -103,6 +103,13 @@ void CSocket::OnDataReceived()
// check if packet comes from the server we want to connect // check if packet comes from the server we want to connect
if ( !( pChannel->GetAddress() == RecHostAddr ) ) 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; return;
} }

View File

@ -46,11 +46,16 @@ class CSocket : public QObject
Q_OBJECT Q_OBJECT
public: public:
CSocket ( CChannel* pNewChannel, const quint16 iPortNumber ) : CSocket ( CChannel* pNewChannel,
pChannel( pNewChannel ), bIsClient ( true ) { Init ( iPortNumber ); } CConnectionLessChannel* pNewCLChannel,
CSocket ( CServer* pNServP, const quint16 iPortNumber ) : const quint16 iPortNumber )
pServer ( pNServP ), bIsClient ( false ) : pChannel( pNewChannel ), pConnLessChannel ( pNewCLChannel ),
{ Init ( iPortNumber ); } bIsClient ( true ) { Init ( iPortNumber ); }
CSocket ( CServer* pNServP,
const quint16 iPortNumber )
: pServer ( pNServP ), bIsClient ( false ) { Init ( iPortNumber ); }
virtual ~CSocket() {} virtual ~CSocket() {}
void SendPacket ( const CVector<uint8_t>& vecbySendBuf, void SendPacket ( const CVector<uint8_t>& vecbySendBuf,
@ -59,15 +64,16 @@ public:
protected: protected:
void Init ( const quint16 iPortNumber = LLCON_DEFAULT_PORT_NUMBER ); void Init ( const quint16 iPortNumber = LLCON_DEFAULT_PORT_NUMBER );
QUdpSocket SocketDevice; QUdpSocket SocketDevice;
CVector<uint8_t> vecbyRecBuf; CVector<uint8_t> vecbyRecBuf;
CHostAddress RecHostAddr; CHostAddress RecHostAddr;
CChannel* pChannel; // for client CChannel* pChannel; // for client
CServer* pServer; // for server CConnectionLessChannel* pConnLessChannel; // for client
CServer* pServer; // for server
bool bIsClient; bool bIsClient;
public slots: public slots:
void OnDataReceived(); void OnDataReceived();