2006-12-18 15:39:33 +01:00
|
|
|
/******************************************************************************\
|
2009-02-22 12:07:18 +01:00
|
|
|
* Copyright (c) 2004-2009
|
2006-12-18 15:39:33 +01:00
|
|
|
*
|
|
|
|
* Author(s):
|
|
|
|
* Volker Fischer
|
|
|
|
*
|
|
|
|
******************************************************************************
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* version.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* 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.,
|
|
|
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
\******************************************************************************/
|
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
#if !defined ( SERVER_HOIHGE7LOKIH83JH8_3_43445KJIUHF1912__INCLUDED_ )
|
2006-12-18 15:39:33 +01:00
|
|
|
#define SERVER_HOIHGE7LOKIH83JH8_3_43445KJIUHF1912__INCLUDED_
|
|
|
|
|
2008-01-20 19:07:13 +01:00
|
|
|
#include <qobject.h>
|
|
|
|
#include <qtimer.h>
|
|
|
|
#include <qdatetime.h>
|
|
|
|
#include <qhostaddress.h>
|
2009-07-31 21:55:28 +02:00
|
|
|
#include "celt.h"
|
2006-12-18 15:39:33 +01:00
|
|
|
#include "global.h"
|
|
|
|
#include "socket.h"
|
|
|
|
#include "channel.h"
|
2006-01-28 12:29:22 +01:00
|
|
|
#include "util.h"
|
2009-05-24 17:25:04 +02:00
|
|
|
#include "serverlogging.h"
|
2006-01-28 12:29:22 +01:00
|
|
|
|
2006-12-18 15:39:33 +01:00
|
|
|
|
2009-07-26 22:12:22 +02:00
|
|
|
/* Definitions ****************************************************************/
|
|
|
|
// no valid channel number
|
|
|
|
#define INVALID_CHANNEL_ID ( MAX_NUM_CHANNELS + 1 )
|
|
|
|
|
2009-07-31 21:55:28 +02:00
|
|
|
// minimum timer precision
|
|
|
|
#define MIN_TIMER_RESOLUTION_MS 1 // ms
|
|
|
|
|
2009-07-26 22:12:22 +02:00
|
|
|
|
2006-12-18 15:39:33 +01:00
|
|
|
/* Classes ********************************************************************/
|
2009-08-01 11:05:14 +02:00
|
|
|
class CHighPrecisionTimer : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2009-08-01 11:21:46 +02:00
|
|
|
CHighPrecisionTimer();
|
2009-08-01 11:05:14 +02:00
|
|
|
|
|
|
|
void start();
|
|
|
|
void stop();
|
|
|
|
bool isActive() const { return Timer.isActive(); }
|
|
|
|
|
|
|
|
protected:
|
2009-08-01 11:21:46 +02:00
|
|
|
QTimer Timer;
|
|
|
|
CVector<int> veciTimeOutIntervals;
|
|
|
|
int iCurPosInVector;
|
|
|
|
int iIntervalCounter;
|
2009-08-01 11:05:14 +02:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void OnTimer();
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void timeout();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-12-18 15:39:33 +01:00
|
|
|
class CServer : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2008-12-02 19:02:40 +01:00
|
|
|
CServer ( const QString& strLoggingFileName,
|
2009-08-01 11:05:14 +02:00
|
|
|
const quint16 iPortNumber,
|
2008-08-09 09:55:27 +02:00
|
|
|
const QString& strHTMLStatusFileName,
|
2009-06-06 12:07:01 +02:00
|
|
|
const QString& strHistoryFileName,
|
2009-07-24 16:31:25 +02:00
|
|
|
const QString& strServerNameForHTMLStatusFile );
|
2007-05-06 14:27:41 +02:00
|
|
|
virtual ~CServer() {}
|
2006-12-18 15:39:33 +01:00
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
void Start();
|
|
|
|
void Stop();
|
2009-07-31 21:55:28 +02:00
|
|
|
bool IsRunning() { return HighPrecisionTimer.isActive(); }
|
2006-09-16 13:26:15 +02:00
|
|
|
|
2006-12-18 15:39:33 +01:00
|
|
|
bool GetTimingStdDev ( double& dCurTiStdDev );
|
|
|
|
|
2009-07-26 22:12:22 +02:00
|
|
|
bool PutData ( const CVector<uint8_t>& vecbyRecBuf,
|
|
|
|
const int iNumBytesRead, const CHostAddress& HostAdr );
|
|
|
|
|
|
|
|
void GetConCliParam ( CVector<CHostAddress>& vecHostAddresses,
|
|
|
|
CVector<QString>& vecsName,
|
2009-08-02 09:54:15 +02:00
|
|
|
CVector<int>& veciJitBufNumFrames,
|
2009-07-28 22:31:23 +02:00
|
|
|
CVector<int>& veciNetwFrameSizeFact );
|
2006-12-18 15:39:33 +01:00
|
|
|
|
|
|
|
protected:
|
2009-07-26 22:12:22 +02:00
|
|
|
// access functions for actual channels
|
|
|
|
bool IsConnected ( const int iChanNum )
|
|
|
|
{ return vecChannels[iChanNum].IsConnected(); }
|
|
|
|
|
|
|
|
void StartStatusHTMLFileWriting ( const QString& strNewFileName,
|
|
|
|
const QString& strNewServerNameWithPort );
|
|
|
|
|
|
|
|
int CheckAddr ( const CHostAddress& Addr );
|
|
|
|
int GetFreeChan();
|
|
|
|
CVector<CChannelShortInfo> CreateChannelList();
|
|
|
|
void CreateAndSendChanListForAllConChannels();
|
|
|
|
void CreateAndSendChanListForThisChan ( const int iCurChanID );
|
2009-09-06 16:08:53 +02:00
|
|
|
void CreateAndSendChatTextForAllConChannels ( const int iCurChanID,
|
|
|
|
const QString& strChatText );
|
2009-07-26 22:12:22 +02:00
|
|
|
void WriteHTMLChannelList();
|
|
|
|
|
2009-08-03 09:29:00 +02:00
|
|
|
CVector<int16_t> ProcessData ( CVector<CVector<int16_t> >& vecvecsData,
|
|
|
|
CVector<double>& vecdGains );
|
2006-12-18 15:39:33 +01:00
|
|
|
|
2008-01-15 21:07:55 +01:00
|
|
|
virtual void customEvent ( QEvent* Event );
|
2006-02-12 15:26:46 +01:00
|
|
|
|
2009-08-02 09:54:15 +02:00
|
|
|
// do not use the vector class since CChannel does not have appropriate
|
|
|
|
// copy constructor/operator
|
2009-07-26 22:12:22 +02:00
|
|
|
CChannel vecChannels[MAX_NUM_CHANNELS];
|
|
|
|
QMutex Mutex;
|
|
|
|
|
2009-07-31 21:55:28 +02:00
|
|
|
// audio encoder/decoder
|
2009-09-06 16:08:53 +02:00
|
|
|
CELTMode* CeltMode[MAX_NUM_CHANNELS];
|
|
|
|
CELTEncoder* CeltEncoder[MAX_NUM_CHANNELS];
|
|
|
|
CELTDecoder* CeltDecoder[MAX_NUM_CHANNELS];
|
2009-07-31 21:55:28 +02:00
|
|
|
|
2009-07-26 22:12:22 +02:00
|
|
|
CVector<QString> vstrChatColors;
|
|
|
|
|
|
|
|
// HTML file server status
|
|
|
|
bool bWriteStatusHTMLFile;
|
|
|
|
QString strServerHTMLFileListName;
|
|
|
|
QString strServerNameWithPort;
|
|
|
|
|
2009-08-01 11:05:14 +02:00
|
|
|
CHighPrecisionTimer HighPrecisionTimer;
|
2006-12-18 15:39:33 +01:00
|
|
|
CVector<short> vecsSendData;
|
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
// actual working objects
|
2006-11-25 15:46:57 +01:00
|
|
|
CSocket Socket;
|
2006-01-28 12:29:22 +01:00
|
|
|
|
2009-03-07 11:52:06 +01:00
|
|
|
CCycleTimeVariance CycleTimeVariance;
|
2006-12-18 15:39:33 +01:00
|
|
|
|
2007-05-06 14:27:41 +02:00
|
|
|
// logging
|
2009-05-24 17:25:04 +02:00
|
|
|
CServerLogging Logging;
|
2007-05-06 14:27:41 +02:00
|
|
|
|
2006-12-18 15:39:33 +01:00
|
|
|
public slots:
|
2009-08-01 11:05:14 +02:00
|
|
|
void OnTimer();
|
2006-11-25 15:46:57 +01:00
|
|
|
void OnSendProtMessage ( int iChID, CVector<uint8_t> vecMessage );
|
2009-07-26 22:12:22 +02:00
|
|
|
|
|
|
|
// CODE TAG: MAX_NUM_CHANNELS_TAG
|
|
|
|
// make sure we have MAX_NUM_CHANNELS connections!!!
|
|
|
|
// send message
|
|
|
|
void OnSendProtMessCh0 ( CVector<uint8_t> mess ) { OnSendProtMessage ( 0, mess ); }
|
|
|
|
void OnSendProtMessCh1 ( CVector<uint8_t> mess ) { OnSendProtMessage ( 1, mess ); }
|
|
|
|
void OnSendProtMessCh2 ( CVector<uint8_t> mess ) { OnSendProtMessage ( 2, mess ); }
|
|
|
|
void OnSendProtMessCh3 ( CVector<uint8_t> mess ) { OnSendProtMessage ( 3, mess ); }
|
|
|
|
void OnSendProtMessCh4 ( CVector<uint8_t> mess ) { OnSendProtMessage ( 4, mess ); }
|
|
|
|
void OnSendProtMessCh5 ( CVector<uint8_t> mess ) { OnSendProtMessage ( 5, mess ); }
|
|
|
|
void OnSendProtMessCh6 ( CVector<uint8_t> mess ) { OnSendProtMessage ( 6, mess ); }
|
|
|
|
void OnSendProtMessCh7 ( CVector<uint8_t> mess ) { OnSendProtMessage ( 7, mess ); }
|
|
|
|
void OnSendProtMessCh8 ( CVector<uint8_t> mess ) { OnSendProtMessage ( 8, mess ); }
|
|
|
|
void OnSendProtMessCh9 ( CVector<uint8_t> mess ) { OnSendProtMessage ( 9, mess ); }
|
|
|
|
|
|
|
|
void OnNewConnectionCh0() { vecChannels[0].CreateReqJitBufMes(); }
|
|
|
|
void OnNewConnectionCh1() { vecChannels[1].CreateReqJitBufMes(); }
|
|
|
|
void OnNewConnectionCh2() { vecChannels[2].CreateReqJitBufMes(); }
|
|
|
|
void OnNewConnectionCh3() { vecChannels[3].CreateReqJitBufMes(); }
|
|
|
|
void OnNewConnectionCh4() { vecChannels[4].CreateReqJitBufMes(); }
|
|
|
|
void OnNewConnectionCh5() { vecChannels[5].CreateReqJitBufMes(); }
|
|
|
|
void OnNewConnectionCh6() { vecChannels[6].CreateReqJitBufMes(); }
|
|
|
|
void OnNewConnectionCh7() { vecChannels[7].CreateReqJitBufMes(); }
|
|
|
|
void OnNewConnectionCh8() { vecChannels[8].CreateReqJitBufMes(); }
|
|
|
|
void OnNewConnectionCh9() { vecChannels[9].CreateReqJitBufMes(); }
|
|
|
|
|
|
|
|
void OnReqConnClientsListCh0() { CreateAndSendChanListForThisChan ( 0 ); }
|
|
|
|
void OnReqConnClientsListCh1() { CreateAndSendChanListForThisChan ( 1 ); }
|
|
|
|
void OnReqConnClientsListCh2() { CreateAndSendChanListForThisChan ( 2 ); }
|
|
|
|
void OnReqConnClientsListCh3() { CreateAndSendChanListForThisChan ( 3 ); }
|
|
|
|
void OnReqConnClientsListCh4() { CreateAndSendChanListForThisChan ( 4 ); }
|
|
|
|
void OnReqConnClientsListCh5() { CreateAndSendChanListForThisChan ( 5 ); }
|
|
|
|
void OnReqConnClientsListCh6() { CreateAndSendChanListForThisChan ( 6 ); }
|
|
|
|
void OnReqConnClientsListCh7() { CreateAndSendChanListForThisChan ( 7 ); }
|
|
|
|
void OnReqConnClientsListCh8() { CreateAndSendChanListForThisChan ( 8 ); }
|
|
|
|
void OnReqConnClientsListCh9() { CreateAndSendChanListForThisChan ( 9 ); }
|
|
|
|
|
|
|
|
void OnNameHasChangedCh0() { CreateAndSendChanListForAllConChannels(); }
|
|
|
|
void OnNameHasChangedCh1() { CreateAndSendChanListForAllConChannels(); }
|
|
|
|
void OnNameHasChangedCh2() { CreateAndSendChanListForAllConChannels(); }
|
|
|
|
void OnNameHasChangedCh3() { CreateAndSendChanListForAllConChannels(); }
|
|
|
|
void OnNameHasChangedCh4() { CreateAndSendChanListForAllConChannels(); }
|
|
|
|
void OnNameHasChangedCh5() { CreateAndSendChanListForAllConChannels(); }
|
|
|
|
void OnNameHasChangedCh6() { CreateAndSendChanListForAllConChannels(); }
|
|
|
|
void OnNameHasChangedCh7() { CreateAndSendChanListForAllConChannels(); }
|
|
|
|
void OnNameHasChangedCh8() { CreateAndSendChanListForAllConChannels(); }
|
|
|
|
void OnNameHasChangedCh9() { CreateAndSendChanListForAllConChannels(); }
|
|
|
|
|
|
|
|
void OnChatTextReceivedCh0 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 0, strChatText ); }
|
|
|
|
void OnChatTextReceivedCh1 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 1, strChatText ); }
|
|
|
|
void OnChatTextReceivedCh2 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 2, strChatText ); }
|
|
|
|
void OnChatTextReceivedCh3 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 3, strChatText ); }
|
|
|
|
void OnChatTextReceivedCh4 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 4, strChatText ); }
|
|
|
|
void OnChatTextReceivedCh5 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 5, strChatText ); }
|
|
|
|
void OnChatTextReceivedCh6 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 6, strChatText ); }
|
|
|
|
void OnChatTextReceivedCh7 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 7, strChatText ); }
|
|
|
|
void OnChatTextReceivedCh8 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 8, strChatText ); }
|
|
|
|
void OnChatTextReceivedCh9 ( QString strChatText ) { CreateAndSendChatTextForAllConChannels ( 9, strChatText ); }
|
|
|
|
|
|
|
|
void OnPingReceivedCh0 ( int iMs ) { vecChannels[0].CreatePingMes ( iMs ); }
|
|
|
|
void OnPingReceivedCh1 ( int iMs ) { vecChannels[1].CreatePingMes ( iMs ); }
|
|
|
|
void OnPingReceivedCh2 ( int iMs ) { vecChannels[2].CreatePingMes ( iMs ); }
|
|
|
|
void OnPingReceivedCh3 ( int iMs ) { vecChannels[3].CreatePingMes ( iMs ); }
|
|
|
|
void OnPingReceivedCh4 ( int iMs ) { vecChannels[4].CreatePingMes ( iMs ); }
|
|
|
|
void OnPingReceivedCh5 ( int iMs ) { vecChannels[5].CreatePingMes ( iMs ); }
|
|
|
|
void OnPingReceivedCh6 ( int iMs ) { vecChannels[6].CreatePingMes ( iMs ); }
|
|
|
|
void OnPingReceivedCh7 ( int iMs ) { vecChannels[7].CreatePingMes ( iMs ); }
|
|
|
|
void OnPingReceivedCh8 ( int iMs ) { vecChannels[8].CreatePingMes ( iMs ); }
|
|
|
|
void OnPingReceivedCh9 ( int iMs ) { vecChannels[9].CreatePingMes ( iMs ); }
|
2006-12-18 15:39:33 +01:00
|
|
|
};
|
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
#endif /* !defined ( SERVER_HOIHGE7LOKIH83JH8_3_43445KJIUHF1912__INCLUDED_ ) */
|