diff --git a/src/client.cpp b/src/client.cpp index 75378f8c..6e250834 100755 --- a/src/client.cpp +++ b/src/client.cpp @@ -58,6 +58,7 @@ CClient::CClient ( const quint16 iPortNumber ) : bFraSiFactSafeSupported ( false ), bOpenChatOnNewMessage ( true ), eGUIDesign ( GD_ORIGINAL ), + bJitterBufferOK ( true ), strCentralServerAddress ( "" ), bUseDefaultCentralServerAddress ( true ), iServerSockBufNumFrames ( DEF_NET_BUF_SIZE_NUM_BL ) @@ -367,6 +368,29 @@ bool CClient::SetServerAddr ( QString strNAddr ) } } +bool CClient::GetAndResetbJitterBufferOKFlag() +{ + // get the socket buffer put status flag and reset it + const bool bSocketJitBufOKFlag = Socket.GetAndResetbJitterBufferOKFlag(); + + if ( !bJitterBufferOK ) + { + // our jitter buffer get status is not OK so the overall status of the + // jitter buffer is also not OK (we do not have to consider the status + // of the socket buffer put status flag) + + // reset flag before returning the function + bJitterBufferOK = true; + return false; + } + + // the jitter buffer get (our own status flag) is OK, the final status + // now depends on the jitter buffer put status flag from the socket + // since per definition the jitter buffer status is OK if both the + // put and get status are OK + return bSocketJitBufOKFlag; +} + void CClient::SetSndCrdPrefFrameSizeFactor ( const int iNewFactor ) { // first check new input parameter @@ -659,8 +683,8 @@ void CClient::Stop() ConnLessProtocol.CreateCLDisconnection ( Channel.GetAddress() ); // reset current signal level and LEDs + bJitterBufferOK = true; SignalLevelMeter.Reset(); - PostWinMessage ( MS_RESET_ALL, 0 ); } void CClient::Init() @@ -854,7 +878,7 @@ void CClient::Init() void CClient::AudioCallback ( CVector& psData, void* arg ) { // get the pointer to the object - CClient* pMyClientObj = reinterpret_cast ( arg ); + CClient* pMyClientObj = static_cast ( arg ); // process audio data pMyClientObj->ProcessSndCrdAudioData ( psData ); @@ -1080,13 +1104,10 @@ void CClient::ProcessAudioDataIntern ( CVector& vecsStereoSndCrd ) const bool bReceiveDataOk = ( Channel.GetData ( vecbyNetwData ) == GS_BUFFER_OK ); - if ( bReceiveDataOk ) + // invalidate the buffer OK status flag if necessary + if ( !bReceiveDataOk ) { - PostWinMessage ( MS_JIT_BUF_GET, MUL_COL_LED_GREEN ); - } - else - { - PostWinMessage ( MS_JIT_BUF_GET, MUL_COL_LED_RED ); + bJitterBufferOK = false; } // CELT decoding diff --git a/src/client.h b/src/client.h index 58e4c534..ac62fc58 100755 --- a/src/client.h +++ b/src/client.h @@ -108,8 +108,12 @@ public: void Stop(); bool IsRunning() { return Sound.IsRunning(); } bool SetServerAddr ( QString strNAddr ); + double MicLevelL() { return SignalLevelMeter.MicLevelLeft(); } double MicLevelR() { return SignalLevelMeter.MicLevelRight(); } + + bool GetAndResetbJitterBufferOKFlag(); + bool IsConnected() { return Channel.IsConnected(); } bool GetOpenChatOnNewMessage() const { return bOpenChatOnNewMessage; } @@ -353,6 +357,8 @@ void SetAudoCompressiontype ( const EAudComprType eNAudCompressionType ); bool bOpenChatOnNewMessage; EGUIDesign eGUIDesign; + bool bJitterBufferOK; + QString strCentralServerAddress; bool bUseDefaultCentralServerAddress; diff --git a/src/clientdlg.cpp b/src/clientdlg.cpp index 02f6aaff..c2e13eea 100755 --- a/src/clientdlg.cpp +++ b/src/clientdlg.cpp @@ -254,10 +254,10 @@ CClientDlg::CClientDlg ( CClient* pNCliP, lbrInputLevelR->setValue ( 0 ); // init status LEDs - ledConnection->SetUpdateTime ( 2 * LED_BAR_UPDATE_TIME_MS ); - ledChat->SetUpdateTime ( 2 * LED_BAR_UPDATE_TIME_MS ); - ledDelay->SetUpdateTime ( 2 * PING_UPDATE_TIME_MS ); + ledConnection->Reset(); + ledBuffers->Reset(); ledDelay->Reset(); + ledChat->Reset(); // init slider controls --- @@ -435,6 +435,9 @@ CClientDlg::CClientDlg ( CClient* pNCliP, QObject::connect ( &TimerSigMet, SIGNAL ( timeout() ), this, SLOT ( OnTimerSigMet() ) ); + QObject::connect ( &TimerBuffersLED, SIGNAL ( timeout() ), + this, SLOT ( OnTimerBuffersLED() ) ); + QObject::connect ( &TimerStatus, SIGNAL ( timeout() ), this, SLOT ( OnTimerStatus() ) ); @@ -903,6 +906,25 @@ void CClientDlg::OnTimerSigMet() lbrInputLevelR->setValue ( (int) ceil ( dCurSigLevelR ) ); } +void CClientDlg::OnTimerBuffersLED() +{ + int iCurStatus; + + // get and reset current buffer state and set LED from that flag + if ( pClient->GetAndResetbJitterBufferOKFlag() ) + { + iCurStatus = MUL_COL_LED_GREEN; + } + else + { + iCurStatus = MUL_COL_LED_RED; + } + + // update the buffer LED and the general settings dialog, too + ledBuffers->SetLight ( iCurStatus ); + ClientSettingsDlg.SetStatus ( iCurStatus ); +} + void CClientDlg::OnTimerPing() { // send ping message to the server @@ -1005,6 +1027,7 @@ void CClientDlg::Connect ( const QString& strSelectedAddress, // start timer for level meter bar and ping time measurement TimerSigMet.start ( LEVELMETER_UPDATE_TIME_MS ); + TimerBuffersLED.start ( BUFFER_LED_UPDATE_TIME_MS ); TimerPing.start ( PING_UPDATE_TIME_MS ); } else @@ -1036,7 +1059,8 @@ void CClientDlg::Disconnect() lbrInputLevelL->setValue ( 0 ); lbrInputLevelR->setValue ( 0 ); - // stop ping time measurement timer + // stop other timers + TimerBuffersLED.stop(); TimerPing.stop(); @@ -1044,13 +1068,13 @@ void CClientDlg::Disconnect() // immediately update status bar OnTimerStatus(); -// TODO this seems not to work, LEDs are still updated afterwards... -// reset LEDs -ledConnection->Reset(); -ledBuffers->Reset(); -ledDelay->Reset(); -ledChat->Reset(); + // reset LEDs + ledConnection->Reset(); + ledBuffers->Reset(); + ledDelay->Reset(); + ledChat->Reset(); + ClientSettingsDlg.ResetStatus(); // clear mixer board (remove all faders) MainMixerBoard->HideAll(); @@ -1168,31 +1192,3 @@ rbtReverbSelR->setStyleSheet ( "" ); // also apply GUI design to child GUI controls MainMixerBoard->SetGUIDesign ( eNewDesign ); } - -void CClientDlg::customEvent ( QEvent* Event ) -{ - if ( Event->type() == QEvent::User + 11 ) - { - const int iMessType = ( (CCustomEvent*) Event )->iMessType; - const int iStatus = ( (CCustomEvent*) Event )->iStatus; - - switch ( iMessType ) - { - case MS_JIT_BUF_PUT: - case MS_JIT_BUF_GET: - // buffer status -> if any buffer goes red, this LED will go red - ledBuffers->SetLight ( iStatus ); - break; - - case MS_RESET_ALL: - ledConnection->Reset(); - ledBuffers->Reset(); - ledDelay->Reset(); - ledChat->Reset(); - break; - } - - // update general settings dialog, too - ClientSettingsDlg.SetStatus ( iMessType, iStatus ); - } -} diff --git a/src/clientdlg.h b/src/clientdlg.h index 21bb1cd0..160a5aeb 100755 --- a/src/clientdlg.h +++ b/src/clientdlg.h @@ -52,6 +52,7 @@ // update time for GUI controls #define LEVELMETER_UPDATE_TIME_MS 100 // ms +#define BUFFER_LED_UPDATE_TIME_MS 300 // ms #define LED_BAR_UPDATE_TIME_MS 1000 // ms // range for signal level meter @@ -96,10 +97,10 @@ protected: bool bConnected; bool bUnreadChatMessage; QTimer TimerSigMet; + QTimer TimerBuffersLED; QTimer TimerStatus; QTimer TimerPing; - virtual void customEvent ( QEvent* Event ); virtual void closeEvent ( QCloseEvent* Event ); void UpdateDisplay(); @@ -118,6 +119,7 @@ public slots: void OnConnectDisconBut(); void OnInstPictureBut(); void OnTimerSigMet(); + void OnTimerBuffersLED(); void OnTimerStatus() { UpdateDisplay(); } diff --git a/src/clientsettingsdlg.cpp b/src/clientsettingsdlg.cpp index 29dc1089..323c09ca 100755 --- a/src/clientsettingsdlg.cpp +++ b/src/clientsettingsdlg.cpp @@ -269,7 +269,7 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, QWidget* parent, #endif // init delay and other information controls - ledOverallDelay->SetUpdateTime ( 2 * PING_UPDATE_TIME_MS ); + ledNetw->Reset(); ledOverallDelay->Reset(); lblPingTimeValue->setText ( "---" ); lblOverallDelayValue->setText ( "---" ); @@ -750,19 +750,3 @@ void CClientSettingsDlg::UpdateDisplay() QString().setNum ( pClient->GetUploadRateKbps() ) + " kbps" ); } } - -void CClientSettingsDlg::SetStatus ( const int iMessType, const int iStatus ) -{ - switch ( iMessType ) - { - case MS_JIT_BUF_PUT: - case MS_JIT_BUF_GET: - // network LED shows combined status of put and get - ledNetw->SetLight ( iStatus ); - break; - - case MS_RESET_ALL: - ledNetw->Reset(); - break; - } -} diff --git a/src/clientsettingsdlg.h b/src/clientsettingsdlg.h index 59aee6aa..4005ef8f 100755 --- a/src/clientsettingsdlg.h +++ b/src/clientsettingsdlg.h @@ -55,7 +55,9 @@ public: QWidget* parent = 0, Qt::WindowFlags f = 0 ); - void SetStatus ( const int iMessType, const int iStatus ); + void SetStatus ( const int iStatus ) { ledNetw->SetLight ( iStatus ); } + void ResetStatus() { ledNetw->Reset(); } + void SetPingTimeResult ( const int iPingTime, const int iOverallDelayMs, const int iOverallDelayLEDColor ); diff --git a/src/global.h b/src/global.h index 83d5a01a..cf7009a5 100755 --- a/src/global.h +++ b/src/global.h @@ -260,17 +260,14 @@ typedef unsigned char uint8_t; #endif -/* Definitions for window message system ------------------------------------ */ -typedef unsigned int _MESSAGE_IDENT; -#define MS_RESET_ALL 0 // MS: Message -#define MS_JIT_BUF_PUT 1 -#define MS_JIT_BUF_GET 2 -#define MS_PACKET_RECEIVED 3 - +/* Pseudo enum definitions -------------------------------------------------- */ #define MUL_COL_LED_RED 0 #define MUL_COL_LED_YELLOW 1 #define MUL_COL_LED_GREEN 2 +// definition for custom event +#define MS_PACKET_RECEIVED 0 + /* Classes ********************************************************************/ class CGenErr @@ -337,9 +334,4 @@ bool GetNumericArgument ( QTextStream& tsConsole, double rRangeStop, double& rValue); -// posting a window message -void PostWinMessage ( const _MESSAGE_IDENT MessID, - const int iMessageParam = 0, - const int iChanNum = 0 ); - #endif /* !defined ( GLOBAL_H__3B123453_4344_BB2B_23E7A0D31912__INCLUDED_ ) */ diff --git a/src/main.cpp b/src/main.cpp index 5bb69110..f3b167dd 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -639,22 +639,3 @@ bool GetNumericArgument ( QTextStream& tsConsole, return false; } } - - -/******************************************************************************\ -* Window Message System * -\******************************************************************************/ -void PostWinMessage ( const _MESSAGE_IDENT MessID, - const int iMessageParam, - const int iChanNum ) -{ - // first check if application is initialized - if ( pApp != NULL ) - { - CCustomEvent* CustomEvent = - new CCustomEvent ( MessID, iMessageParam, iChanNum ); - - // Qt will delete the event object when done - QCoreApplication::postEvent ( pMainWindow, CustomEvent ); - } -} diff --git a/src/multicolorled.cpp b/src/multicolorled.cpp index 6e169e22..a2c734c8 100755 --- a/src/multicolorled.cpp +++ b/src/multicolorled.cpp @@ -43,25 +43,6 @@ CMultiColorLED::CMultiColorLED ( QWidget* parent, Qt::WindowFlags f ) // set init bitmap setPixmap ( BitmCubeGrey ); eColorFlag = RL_GREY; - - // init update time - SetUpdateTime ( DEFAULT_UPDATE_TIME ); - - // init timers -> we want to have single shot timers - TimerRedLight.setSingleShot ( true ); - TimerGreenLight.setSingleShot ( true ); - TimerYellowLight.setSingleShot ( true ); - - // connect timer events to the desired slots - connect ( &TimerRedLight, SIGNAL ( timeout() ), - this, SLOT ( OnTimerRedLight() ) ); - connect ( &TimerGreenLight, SIGNAL ( timeout() ), - this, SLOT ( OnTimerGreenLight() ) ); - connect ( &TimerYellowLight, SIGNAL ( timeout() ), - this, SLOT ( OnTimerYellowLight() ) ); - - connect ( this, SIGNAL ( newPixmap ( const QPixmap& ) ), - this, SLOT ( OnNewPixmap ( const QPixmap& ) ) ); } void CMultiColorLED::changeEvent ( QEvent* curEvent ) @@ -71,75 +52,56 @@ void CMultiColorLED::changeEvent ( QEvent* curEvent ) { if ( this->isEnabled() ) { - emit newPixmap ( BitmCubeGrey ); + setPixmap ( BitmCubeGrey ); eColorFlag = RL_GREY; } else { - emit newPixmap ( BitmCubeDisabled ); + setPixmap ( BitmCubeDisabled ); eColorFlag = RL_DISABLED; } } } -void CMultiColorLED::OnTimerRedLight() +void CMultiColorLED::SetColor ( const ELightColor eNewColorFlag ) { - bFlagRedLi = false; - UpdateColor(); -} - -void CMultiColorLED::OnTimerGreenLight() -{ - bFlagGreenLi = false; - UpdateColor(); -} - -void CMultiColorLED::OnTimerYellowLight() -{ - bFlagYellowLi = false; - UpdateColor(); -} - -void CMultiColorLED::UpdateColor() -{ - // Red light has highest priority, then comes yellow and at the end, we - // decide to set green light. Allways check the current color of the - // control before setting the color to prevent flickering - if ( bFlagRedLi ) + switch ( eNewColorFlag ) { + case RL_RED: + // red if ( eColorFlag != RL_RED ) { - emit newPixmap ( BitmCubeRed ); + setPixmap ( BitmCubeRed ); eColorFlag = RL_RED; } - return; - } + break; - if ( bFlagYellowLi ) - { + case RL_YELLOW: + // yellow if ( eColorFlag != RL_YELLOW ) { - emit newPixmap ( BitmCubeYellow ); + setPixmap ( BitmCubeYellow ); eColorFlag = RL_YELLOW; } - return; - } + break; - if ( bFlagGreenLi ) - { + case RL_GREEN: + // green if ( eColorFlag != RL_GREEN ) { - emit newPixmap ( BitmCubeGreen ); + setPixmap ( BitmCubeGreen ); eColorFlag = RL_GREEN; } - return; - } + break; - // if no color is active, set control to grey light - if ( eColorFlag != RL_GREY ) - { - setPixmap ( BitmCubeGrey ); - eColorFlag = RL_GREY; + default: + // if no color is active, set control to grey light + if ( eColorFlag != RL_GREY ) + { + setPixmap ( BitmCubeGrey ); + eColorFlag = RL_GREY; + } + break; } } @@ -147,12 +109,7 @@ void CMultiColorLED::Reset() { if ( this->isEnabled() ) { - // reset color flags - bFlagRedLi = false; - bFlagGreenLi = false; - bFlagYellowLi = false; - - UpdateColor(); + SetColor ( RL_GREY ); } } @@ -163,41 +120,16 @@ void CMultiColorLED::SetLight ( const int iNewStatus ) switch ( iNewStatus ) { case MUL_COL_LED_GREEN: - // green light - bFlagGreenLi = true; - TimerGreenLight.start(); + SetColor ( RL_GREEN ); break; case MUL_COL_LED_YELLOW: - // yellow light - bFlagYellowLi = true; - TimerYellowLight.start(); + SetColor ( RL_YELLOW ); break; case MUL_COL_LED_RED: - // red light - bFlagRedLi = true; - TimerRedLight.start(); + SetColor ( RL_RED ); break; } - - UpdateColor(); } } - -void CMultiColorLED::SetUpdateTime ( const int iNUTi ) -{ - // avoid too short intervals - if ( iNUTi < MIN_TIME_FOR_RED_LIGHT ) - { - iUpdateTime = MIN_TIME_FOR_RED_LIGHT; - } - else - { - iUpdateTime = iNUTi; - } - - TimerGreenLight.setInterval ( iUpdateTime ); - TimerYellowLight.setInterval ( iUpdateTime ); - TimerRedLight.setInterval ( iUpdateTime ); -} diff --git a/src/multicolorled.h b/src/multicolorled.h index 16e0d77b..c7c02c98 100755 --- a/src/multicolorled.h +++ b/src/multicolorled.h @@ -34,29 +34,17 @@ #include #include -#include -#include #include #include "global.h" -/* Definitions ****************************************************************/ -#define DEFAULT_UPDATE_TIME 300 - -// the red and yellow light should be on at least this interval -#define MIN_TIME_FOR_RED_LIGHT 100 - - /* Classes ********************************************************************/ class CMultiColorLED : public QLabel { - Q_OBJECT - public: CMultiColorLED ( QWidget* parent = 0, Qt::WindowFlags f = 0 ); void Reset(); - void SetUpdateTime ( const int iNUTi ); void SetLight ( const int iNewStatus ); protected: @@ -71,7 +59,7 @@ protected: ELightColor eColorFlag; virtual void changeEvent ( QEvent* curEvent ); - void UpdateColor(); + void SetColor ( const ELightColor eNewColorFlag ); QPixmap BitmCubeDisabled; QPixmap BitmCubeGrey; @@ -79,89 +67,11 @@ protected: QPixmap BitmCubeYellow; QPixmap BitmCubeRed; - QTimer TimerRedLight; - QTimer TimerGreenLight; - QTimer TimerYellowLight; - int iUpdateTime; bool bFlagRedLi; bool bFlagGreenLi; bool bFlagYellowLi; - -protected slots: - void OnTimerRedLight(); - void OnTimerGreenLight(); - void OnTimerYellowLight(); - virtual void OnNewPixmap ( const QPixmap& newPixmap ) { setPixmap ( newPixmap ); } - -signals: - void newPixmap ( const QPixmap& newPixmap ); -}; - - -class CMultColLEDListViewItem : public CMultiColorLED -{ - Q_OBJECT - -public: - CMultColLEDListViewItem ( const int iNewCol ) - : pListViewItem ( NULL ), iColumn ( iNewCol ) {} - - void SetListViewItemPointer ( QTreeWidgetItem* pNewListViewItem ) - { - pListViewItem = pNewListViewItem; - } - -protected slots: - virtual void OnNewPixmap ( const QPixmap& newPixmap ) - { - if ( pListViewItem != NULL ) - { - pListViewItem->setIcon ( iColumn, QIcon ( newPixmap ) ); - } - } - -protected: - QTreeWidgetItem* pListViewItem; - int iColumn; -}; - - -class CServerListViewItem : public QTreeWidgetItem -{ -public: - CServerListViewItem ( QTreeWidget* parent ) - : QTreeWidgetItem ( parent ), LED ( 2 ) - { - LED.SetListViewItemPointer ( this ); - } - - void SetLight ( int iNewStatus ) - { - LED.SetLight ( iNewStatus ); - } - -protected: - CMultColLEDListViewItem LED; -}; - - -class CConnectionServerListViewItem : public QTreeWidgetItem -{ -public: - CConnectionServerListViewItem ( QTreeWidget* parent ) - : QTreeWidgetItem ( parent ), LED ( 4 ) - { - LED.SetListViewItemPointer ( this ); - } - - void Reset() { LED.Reset(); } - void SetUpdateTime ( const int iNUTi ) { LED.SetUpdateTime ( iNUTi ); } - void SetLight ( int iNewStatus ) { LED.SetLight ( iNewStatus ); } - -protected: - CMultColLEDListViewItem LED; }; #endif // _MULTCOLORLED_H__FD6B49B5_87DF_48DD_A873_804E1606C2AC__INCLUDED_ diff --git a/src/server.cpp b/src/server.cpp index d36fe101..c54b288d 100755 --- a/src/server.cpp +++ b/src/server.cpp @@ -798,16 +798,6 @@ void CServer::OnTimer() } } } - - // send message for get status (for GUI) - if ( eGetStat == GS_BUFFER_OK ) - { - PostWinMessage ( MS_JIT_BUF_GET, MUL_COL_LED_GREEN, iCurChanID ); - } - else - { - PostWinMessage ( MS_JIT_BUF_GET, MUL_COL_LED_RED, iCurChanID ); - } } // a channel is now disconnected, take action on it @@ -1287,28 +1277,10 @@ bool CServer::PutData ( const CVector& vecbyRecBuf, if ( bChanOK ) { // put packet in socket buffer - switch ( vecChannels[iCurChanID].PutData ( vecbyRecBuf, iNumBytesRead ) ) + if ( vecChannels[iCurChanID].PutData ( vecbyRecBuf, iNumBytesRead ) == PS_PROT_OK_MESS_NOT_EVALUATED ) { - case PS_AUDIO_OK: - PostWinMessage ( MS_JIT_BUF_PUT, MUL_COL_LED_GREEN, iCurChanID ); - break; - - case PS_AUDIO_ERR: - PostWinMessage ( MS_JIT_BUF_PUT, MUL_COL_LED_RED, iCurChanID ); - break; - - case PS_PROT_ERR: - PostWinMessage ( MS_JIT_BUF_PUT, MUL_COL_LED_YELLOW, iCurChanID ); - break; - - case PS_PROT_OK_MESS_NOT_EVALUATED: - bIsNotEvaluatedProtocolMessage = true; // set flag - break; - - case PS_GEN_ERROR: - case PS_PROT_OK: - // for these cases, do nothing - break; + // set flag + bIsNotEvaluatedProtocolMessage = true; } } diff --git a/src/serverdlg.cpp b/src/serverdlg.cpp index 2bfe4afc..594c4353 100755 --- a/src/serverdlg.cpp +++ b/src/serverdlg.cpp @@ -44,8 +44,8 @@ CServerDlg::CServerDlg ( CServer* pNServP, // client list lvwClients->setWhatsThis ( tr ( "Client List: The client list " "shows all clients which are currently connected to this server. Some " - "informations about the clients like the IP address, name, buffer " - "state are given for each connected client." ) ); + "informations about the clients like the IP address and name are given " + "for each connected client." ) ); lvwClients->setAccessibleName ( tr ( "Connected clients list view" ) ); @@ -161,7 +161,6 @@ CServerDlg::CServerDlg ( CServer* pNServP, // set up list view for connected clients lvwClients->setColumnWidth ( 0, 170 ); lvwClients->setColumnWidth ( 1, 130 ); - lvwClients->setColumnWidth ( 2, 60 ); lvwClients->clear(); @@ -175,7 +174,7 @@ lvwClients->setMinimumHeight ( 140 ); vecpListViewItems.Init ( MAX_NUM_CHANNELS ); for ( int i = MAX_NUM_CHANNELS - 1; i >= 0; i-- ) { - vecpListViewItems[i] = new CServerListViewItem ( lvwClients ); + vecpListViewItems[i] = new QTreeWidgetItem ( lvwClients ); vecpListViewItems[i]->setHidden ( true ); } @@ -461,11 +460,11 @@ void CServerDlg::OnTimer() vecpListViewItems[i]->setText ( 1, vecsName[i] ); // jitter buffer size (polling for updates) - vecpListViewItems[i]->setText ( 3, + vecpListViewItems[i]->setText ( 2, QString().setNum ( veciJitBufNumFrames[i] ) ); // out network block size - vecpListViewItems[i]->setText ( 4, + vecpListViewItems[i]->setText ( 3, QString().setNum ( static_cast ( veciNetwFrameSizeFact[i] * SYSTEM_BLOCK_DURATION_MS_FLOAT ), 'f', 2 ) ); @@ -582,25 +581,3 @@ void CServerDlg::changeEvent ( QEvent* pEvent ) } } } - -void CServerDlg::customEvent ( QEvent* pEvent ) -{ - if ( pEvent->type() == QEvent::User + 11 ) - { - ListViewMutex.lock(); - { - const int iMessType = ( (CCustomEvent*) pEvent )->iMessType; - const int iStatus = ( (CCustomEvent*) pEvent )->iStatus; - const int iChanNum = ( (CCustomEvent*) pEvent )->iChanNum; - - switch(iMessType) - { - case MS_JIT_BUF_PUT: - case MS_JIT_BUF_GET: - vecpListViewItems[iChanNum]->SetLight ( iStatus ); - break; - } - } - ListViewMutex.unlock(); - } -} diff --git a/src/serverdlg.h b/src/serverdlg.h index c0926b7b..59f5a3e8 100755 --- a/src/serverdlg.h +++ b/src/serverdlg.h @@ -36,7 +36,6 @@ #include "global.h" #include "server.h" #include "settings.h" -#include "multicolorled.h" #include "ui_serverdlgbase.h" @@ -58,7 +57,6 @@ public: Qt::WindowFlags f = 0 ); protected: - virtual void customEvent ( QEvent* pEvent ); virtual void changeEvent ( QEvent* pEvent ); virtual void closeEvent ( QCloseEvent* Event ); @@ -71,7 +69,7 @@ protected: CServer* pServer; CSettings* pSettings; - CVector vecpListViewItems; + CVector vecpListViewItems; QMutex ListViewMutex; QMenuBar* pMenu; diff --git a/src/serverdlgbase.ui b/src/serverdlgbase.ui index a99190bd..6b80b951 100755 --- a/src/serverdlgbase.ui +++ b/src/serverdlgbase.ui @@ -34,11 +34,6 @@ Name - - - Buffers - - Jitter Buffer Size diff --git a/src/socket.cpp b/src/socket.cpp index e3b7db25..3063f2ad 100755 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -117,6 +117,21 @@ void CSocket::SendPacket ( const CVector& vecbySendBuf, } } +bool CSocket::GetAndResetbJitterBufferOKFlag() +{ + // check jitter buffer status + if ( !bJitterBufferOK ) + { + // reset flag and return "not OK" status + bJitterBufferOK = true; + return false; + } + + // the buffer was OK, we do not have to reset anything and just return the + // OK status + return true; +} + void CSocket::OnDataReceived() { while ( SocketDevice.hasPendingDatagrams() ) @@ -152,21 +167,9 @@ void CSocket::OnDataReceived() // this network packet is valid, put it in the channel switch ( pChannel->PutData ( vecbyRecBuf, iNumBytesRead ) ) { - case PS_AUDIO_OK: - PostWinMessage ( MS_JIT_BUF_PUT, MUL_COL_LED_GREEN ); - break; - case PS_AUDIO_ERR: case PS_GEN_ERROR: - PostWinMessage ( MS_JIT_BUF_PUT, MUL_COL_LED_RED ); - break; - - case PS_PROT_ERR: - PostWinMessage ( MS_JIT_BUF_PUT, MUL_COL_LED_YELLOW ); - break; - - default: - // other put data states need not to be considered here + bJitterBufferOK = false; break; } } diff --git a/src/socket.h b/src/socket.h index 9f4ff142..1e0b9879 100755 --- a/src/socket.h +++ b/src/socket.h @@ -57,15 +57,21 @@ class CSocket : public QObject public: CSocket ( CChannel* pNewChannel, const quint16 iPortNumber ) - : pChannel( pNewChannel ), bIsClient ( true ) { Init ( iPortNumber ); } + : pChannel ( pNewChannel ), + bIsClient ( true ), + bJitterBufferOK ( true ) { Init ( iPortNumber ); } CSocket ( CServer* pNServP, const quint16 iPortNumber ) - : pServer ( pNServP ), bIsClient ( false ) { Init ( iPortNumber ); } + : pServer ( pNServP ), + bIsClient ( false ), + bJitterBufferOK ( true ) { Init ( iPortNumber ); } void SendPacket ( const CVector& vecbySendBuf, const CHostAddress& HostAddr ); + bool GetAndResetbJitterBufferOKFlag(); + protected: void Init ( const quint16 iPortNumber = LLCON_DEFAULT_PORT_NUMBER ); @@ -80,6 +86,8 @@ protected: bool bIsClient; + bool bJitterBufferOK; + public slots: void OnDataReceived();