2006-12-18 15:39:33 +01:00
|
|
|
/******************************************************************************\
|
2008-07-24 18:20:25 +02:00
|
|
|
* Copyright (c) 2004-2008
|
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 ( CLIENT_HOIHGE76GEKJH98_3_43445KJIUHF1912__INCLUDED_ )
|
2006-12-18 15:39:33 +01:00
|
|
|
#define CLIENT_HOIHGE76GEKJH98_3_43445KJIUHF1912__INCLUDED_
|
|
|
|
|
2008-01-20 19:07:13 +01:00
|
|
|
#include <qthread.h>
|
|
|
|
#include <qhostaddress.h>
|
|
|
|
#include <qhostinfo.h>
|
|
|
|
#include <qstring.h>
|
|
|
|
#include <qdatetime.h>
|
2008-07-15 22:33:41 +02:00
|
|
|
#include <qmessagebox.h>
|
2006-12-18 15:39:33 +01:00
|
|
|
#include "global.h"
|
|
|
|
#include "socket.h"
|
|
|
|
#include "resample.h"
|
|
|
|
#include "channel.h"
|
2008-08-10 10:14:30 +02:00
|
|
|
#include "audiocompr.h"
|
2006-12-18 15:39:33 +01:00
|
|
|
#include "util.h"
|
|
|
|
#ifdef _WIN32
|
|
|
|
# include "../windows/sound.h"
|
|
|
|
#else
|
2006-01-28 12:29:22 +01:00
|
|
|
# include "../linux/sound.h"
|
2006-12-18 15:39:33 +01:00
|
|
|
# include <sched.h>
|
2007-02-24 10:49:52 +01:00
|
|
|
# include <socket.h>
|
|
|
|
# include <netdb.h>
|
2006-12-18 15:39:33 +01:00
|
|
|
#endif
|
|
|
|
|
2006-01-28 12:29:22 +01:00
|
|
|
|
|
|
|
/* Definitions ****************************************************************/
|
2006-11-05 12:43:25 +01:00
|
|
|
// audio in fader range
|
2006-11-25 15:46:57 +01:00
|
|
|
#define AUD_FADER_IN_MAX 100
|
2006-01-28 12:29:22 +01:00
|
|
|
|
2006-11-05 12:43:25 +01:00
|
|
|
// audio reverberation range
|
2006-11-25 15:46:57 +01:00
|
|
|
#define AUD_REVERB_MAX 100
|
2006-01-28 12:29:22 +01:00
|
|
|
|
2006-12-18 15:39:33 +01:00
|
|
|
|
|
|
|
/* Classes ********************************************************************/
|
2008-01-14 23:14:17 +01:00
|
|
|
class CClient : public QThread
|
2006-02-26 11:50:47 +01:00
|
|
|
{
|
2006-11-25 15:46:57 +01:00
|
|
|
Q_OBJECT
|
2006-12-18 15:39:33 +01:00
|
|
|
|
|
|
|
public:
|
2008-08-13 21:08:45 +02:00
|
|
|
CClient ( const quint16 iPortNumber );
|
2006-12-18 15:39:33 +01:00
|
|
|
virtual ~CClient() {}
|
|
|
|
|
|
|
|
void Init();
|
|
|
|
bool Stop();
|
|
|
|
bool IsRunning() { return bRun; }
|
|
|
|
bool SetServerAddr ( QString strNAddr );
|
|
|
|
double MicLevelL() { return SignalLevelMeterL.MicLevel(); }
|
2006-11-25 15:46:57 +01:00
|
|
|
double MicLevelR() { return SignalLevelMeterR.MicLevel(); }
|
2006-12-09 16:00:24 +01:00
|
|
|
bool IsConnected() { return Channel.IsConnected(); }
|
2006-11-25 15:46:57 +01:00
|
|
|
|
2008-04-08 20:38:55 +02:00
|
|
|
/* We want to return the standard deviation. For that we need to calculate
|
|
|
|
the sqaure root. */
|
2006-11-25 15:46:57 +01:00
|
|
|
double GetTimingStdDev() { return sqrt ( RespTimeMoAvBuf.GetAverage() ); }
|
|
|
|
|
2008-07-24 18:20:25 +02:00
|
|
|
bool GetOpenChatOnNewMessage() { return bOpenChatOnNewMessage; }
|
|
|
|
void SetOpenChatOnNewMessage ( const bool bNV ) { bOpenChatOnNewMessage = bNV; }
|
|
|
|
|
2006-11-25 15:46:57 +01:00
|
|
|
int GetAudioInFader() { return iAudioInFader; }
|
2006-12-18 15:39:33 +01:00
|
|
|
void SetAudioInFader ( const int iNV ) { iAudioInFader = iNV; }
|
2006-11-25 15:46:57 +01:00
|
|
|
|
|
|
|
int GetReverbLevel() { return iReverbLevel; }
|
|
|
|
void SetReverbLevel ( const int iNL ) { iReverbLevel = iNL; }
|
|
|
|
|
|
|
|
bool IsReverbOnLeftChan() { return bReverbOnLeftChan; }
|
|
|
|
void SetReverbOnLeftChan ( const bool bIL )
|
|
|
|
{
|
|
|
|
bReverbOnLeftChan = bIL;
|
|
|
|
AudioReverb.Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetSockBufSize ( const int iNumBlocks )
|
|
|
|
{
|
|
|
|
// set the new socket size
|
|
|
|
Channel.SetSockBufSize ( iNumBlocks );
|
|
|
|
|
|
|
|
// tell the server that size has changed
|
|
|
|
Channel.CreateJitBufMes ( iNumBlocks );
|
|
|
|
}
|
2007-09-08 12:45:14 +02:00
|
|
|
int GetSockBufSize() { return Channel.GetSockBufSize(); }
|
2006-11-25 15:46:57 +01:00
|
|
|
|
|
|
|
void SetNetwBufSizeFactIn ( const int iNewNetNetwBlSiFactIn )
|
|
|
|
{
|
|
|
|
// store value and tell the server about new value
|
|
|
|
iNetwBufSizeFactIn = iNewNetNetwBlSiFactIn;
|
|
|
|
Channel.CreateNetwBlSiFactMes ( iNewNetNetwBlSiFactIn );
|
|
|
|
}
|
|
|
|
int GetNetwBufSizeFactIn() { return iNetwBufSizeFactIn; }
|
|
|
|
|
|
|
|
void SetNetwBufSizeFactOut ( const int iNetNetwBlSiFact )
|
2008-08-10 10:14:30 +02:00
|
|
|
{ Channel.SetNetwBufSizeFactOut ( iNetNetwBlSiFact ); }
|
2006-11-25 15:46:57 +01:00
|
|
|
int GetNetwBufSizeFactOut() { return Channel.GetNetwBufSizeFactOut(); }
|
2006-02-26 11:50:47 +01:00
|
|
|
|
2008-08-10 10:14:30 +02:00
|
|
|
void SetAudioCompressionOut ( const CAudioCompression::EAudComprType eNewAudComprTypeOut )
|
|
|
|
{ Channel.SetAudioCompressionOut ( eNewAudComprTypeOut ); }
|
|
|
|
CAudioCompression::EAudComprType GetAudioCompressionOut() { return Channel.GetAudioCompressionOut(); }
|
|
|
|
|
2006-12-09 16:00:24 +01:00
|
|
|
void SetRemoteChanGain ( const int iId, const double dGain )
|
|
|
|
{ Channel.SetRemoteChanGain ( iId, dGain ); }
|
|
|
|
|
2006-12-10 12:06:14 +01:00
|
|
|
void SetRemoteName() { Channel.SetRemoteName ( strName ); }
|
2006-12-18 15:39:33 +01:00
|
|
|
|
2008-07-24 18:20:25 +02:00
|
|
|
void SendTextMess ( const QString& strChatText )
|
|
|
|
{ Channel.CreateChatTextMes ( strChatText ); }
|
|
|
|
|
2008-08-02 09:28:21 +02:00
|
|
|
void SendPingMess()
|
2008-08-11 19:21:09 +02:00
|
|
|
{ Channel.CreatePingMes ( PreciseTime.elapsed() ); };
|
2008-08-02 09:28:21 +02:00
|
|
|
|
2006-12-18 15:39:33 +01:00
|
|
|
CSound* GetSndInterface() { return &Sound; }
|
|
|
|
CChannel* GetChannel() { return &Channel; }
|
2006-01-28 12:29:22 +01:00
|
|
|
|
|
|
|
|
2006-11-25 15:46:57 +01:00
|
|
|
// settings
|
2008-01-22 22:15:04 +01:00
|
|
|
QString strIPAddress;
|
|
|
|
QString strName;
|
2006-12-18 15:39:33 +01:00
|
|
|
|
|
|
|
protected:
|
2007-09-08 12:45:14 +02:00
|
|
|
virtual void run();
|
2006-12-18 15:39:33 +01:00
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
// only one channel is needed for client application
|
2006-12-18 15:39:33 +01:00
|
|
|
CChannel Channel;
|
|
|
|
|
|
|
|
CSocket Socket;
|
|
|
|
CSound Sound;
|
|
|
|
CSignalLevelMeter SignalLevelMeterL;
|
2006-11-25 15:46:57 +01:00
|
|
|
CSignalLevelMeter SignalLevelMeterR;
|
2006-12-18 15:39:33 +01:00
|
|
|
|
|
|
|
bool bRun;
|
2006-11-25 15:46:57 +01:00
|
|
|
CVector<double> vecdNetwData;
|
2006-01-28 12:29:22 +01:00
|
|
|
|
2006-11-25 15:46:57 +01:00
|
|
|
int iAudioInFader;
|
|
|
|
bool bReverbOnLeftChan;
|
|
|
|
int iReverbLevel;
|
|
|
|
CAudioReverb AudioReverb;
|
2006-01-28 12:29:22 +01:00
|
|
|
|
2006-11-25 15:46:57 +01:00
|
|
|
int iSndCrdBlockSizeSam;
|
|
|
|
int iBlockSizeSam;
|
2006-01-28 12:29:22 +01:00
|
|
|
|
2006-11-25 15:46:57 +01:00
|
|
|
int iNetwBufSizeFactIn;
|
2006-03-13 21:23:05 +01:00
|
|
|
|
2008-07-24 18:20:25 +02:00
|
|
|
bool bOpenChatOnNewMessage;
|
|
|
|
|
2006-11-25 15:46:57 +01:00
|
|
|
CVector<short> vecsAudioSndCrd;
|
|
|
|
CVector<double> vecdAudioSndCrdL;
|
|
|
|
CVector<double> vecdAudioSndCrdR;
|
2006-01-28 12:29:22 +01:00
|
|
|
|
2006-11-25 15:46:57 +01:00
|
|
|
CVector<double> vecdAudioL;
|
|
|
|
CVector<double> vecdAudioR;
|
2006-01-28 12:29:22 +01:00
|
|
|
|
2006-11-25 15:46:57 +01:00
|
|
|
CVector<short> vecsNetwork;
|
2006-12-18 15:39:33 +01:00
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
// resample objects
|
|
|
|
CAudioResample ResampleObjDownL; // left channel
|
|
|
|
CAudioResample ResampleObjDownR; // right channel
|
|
|
|
CAudioResample ResampleObjUpL; // left channel
|
|
|
|
CAudioResample ResampleObjUpR; // right channel
|
2006-01-28 12:29:22 +01:00
|
|
|
|
2008-08-11 19:21:09 +02:00
|
|
|
// for ping measurement
|
|
|
|
CPreciseTime PreciseTime;
|
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
// debugging, evaluating
|
2006-11-25 15:46:57 +01:00
|
|
|
CMovingAv<double> RespTimeMoAvBuf;
|
|
|
|
QTime TimeLastBlock;
|
2006-02-26 11:50:47 +01:00
|
|
|
|
|
|
|
public slots:
|
2006-11-25 15:46:57 +01:00
|
|
|
void OnSendProtMessage ( CVector<uint8_t> vecMessage );
|
|
|
|
void OnReqJittBufSize();
|
|
|
|
void OnProtocolStatus ( bool bOk );
|
2006-12-10 12:06:14 +01:00
|
|
|
void OnNewConnection();
|
2008-08-10 23:56:03 +02:00
|
|
|
void OnReceivePingMessage ( int iMs );
|
2006-11-26 22:25:56 +01:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void ConClientListMesReceived ( CVector<CChannelShortInfo> vecChanInfo );
|
2008-07-24 18:20:25 +02:00
|
|
|
void ChatTextReceived ( QString strChatText );
|
2008-08-02 09:28:21 +02:00
|
|
|
void PingTimeReceived ( int iPingTime );
|
2006-12-18 15:39:33 +01:00
|
|
|
};
|
|
|
|
|
2007-09-08 12:45:14 +02:00
|
|
|
#endif /* !defined ( CLIENT_HOIHGE76GEKJH98_3_43445KJIUHF1912__INCLUDED_ ) */
|