jamulus/src/client.h

171 lines
4.7 KiB
C
Raw Normal View History

2006-01-28 12:29:22 +01:00
/******************************************************************************\
* Copyright (c) 2004-2006
*
* 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
*
\******************************************************************************/
#if !defined(CLIENT_HOIHGE76GEKJH98_3_43445KJIUHF1912__INCLUDED_)
#define CLIENT_HOIHGE76GEKJH98_3_43445KJIUHF1912__INCLUDED_
#include <qthread.h>
#include <qhostaddress.h>
#include <qstring.h>
2006-02-26 11:50:47 +01:00
#include <qdatetime.h>
2006-01-28 12:29:22 +01:00
#include "global.h"
#include "socket.h"
#include "resample.h"
#include "channel.h"
#include "util.h"
#ifdef _WIN32
# include "../windows/sound.h"
#else
# include "../linux/sound.h"
# include <sched.h>
#endif
/* Definitions ****************************************************************/
/* audio in fader range */
#define AUD_FADER_IN_MAX 100
/* audio reverberation range */
#define AUD_REVERB_MAX 100
/* Classes ********************************************************************/
2006-02-26 11:50:47 +01:00
class CClient : public QObject, public QThread
{
Q_OBJECT
2006-01-28 12:29:22 +01:00
public:
2006-02-26 11:50:47 +01:00
CClient();
virtual ~CClient() {}
2006-01-28 12:29:22 +01:00
void Init();
bool Stop();
bool IsRunning() { return bRun; }
2006-02-26 11:50:47 +01:00
bool SetServerAddr ( QString strNAddr );
double MicLevelL() { return SignalLevelMeterL.MicLevel(); }
double MicLevelR() { return SignalLevelMeterR.MicLevel(); }
bool IsConnected() { return Channel.IsConnected(); }
2006-01-28 12:29:22 +01:00
/* we want to return the standard deviation. For that we need to calculate
the sqaure root */
double GetTimingStdDev() { return sqrt ( RespTimeMoAvBuf.GetAverage() ); }
2006-02-26 11:50:47 +01:00
int GetAudioInFader() { return iAudioInFader; }
2006-02-26 11:50:47 +01:00
void SetAudioInFader ( const int iNV ) { iAudioInFader = iNV; }
int GetReverbLevel() { return iReverbLevel; }
2006-02-26 11:50:47 +01:00
void SetReverbLevel ( const int iNL ) { iReverbLevel = iNL; }
2006-01-28 12:29:22 +01:00
bool IsReverbOnLeftChan() { return bReverbOnLeftChan; }
2006-02-26 11:50:47 +01:00
void SetReverbOnLeftChan ( const bool bIL )
{
bReverbOnLeftChan = bIL;
AudioReverb.Clear();
2006-02-26 11:50:47 +01:00
}
2006-01-28 12:29:22 +01:00
void SetSockBufSize ( const int iNumBlocks )
2006-02-26 11:50:47 +01:00
{
// set the new socket size
Channel.SetSockBufSize ( iNumBlocks );
2006-02-26 11:50:47 +01:00
// tell the server that size has changed
Channel.CreateJitBufMes ( iNumBlocks );
}
int GetSockBufSize() { return Channel.GetSockBufSize (); }
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 )
{
// set the new socket size
Channel.SetNetwBufSizeFactOut ( iNetNetwBlSiFact );
}
int GetNetwBufSizeFactOut() { return Channel.GetNetwBufSizeFactOut(); }
2006-02-26 11:50:47 +01:00
2006-01-28 12:29:22 +01:00
CSound* GetSndInterface() { return &Sound; }
CChannel* GetChannel() { return &Channel; }
2006-01-28 12:29:22 +01:00
// settings
string strIPAddress;
protected:
2006-02-26 11:50:47 +01:00
virtual void run ();
2006-01-28 12:29:22 +01:00
/* only one channel is needed for client application */
CChannel Channel;
CSocket Socket;
CSound Sound;
CSignalLevelMeter SignalLevelMeterL;
CSignalLevelMeter SignalLevelMeterR;
bool bRun;
CVector<double> vecdNetwData;
int iAudioInFader;
bool bReverbOnLeftChan;
int iReverbLevel;
CAudioReverb AudioReverb;
int iSndCrdBlockSizeSam;
int iBlockSizeSam;
int iNetwBufSizeFactIn;
2006-01-28 12:29:22 +01:00
CVector<short> vecsAudioSndCrd;
CVector<double> vecdAudioSndCrdL;
CVector<double> vecdAudioSndCrdR;
CVector<double> vecdAudioL;
CVector<double> vecdAudioR;
CVector<short> vecsNetwork;
/* resample objects */
CAudioResample ResampleObjDownL; /* left channel */
CAudioResample ResampleObjDownR; /* right channel */
CAudioResample ResampleObjUpL; /* left channel */
CAudioResample ResampleObjUpR; /* right channel */
/* debugging, evaluating */
CMovingAv<double> RespTimeMoAvBuf;
QTime TimeLastBlock;
2006-02-26 11:50:47 +01:00
public slots:
2006-03-01 20:46:44 +01:00
void OnSendProtMessage ( CVector<uint8_t> vecMessage );
void OnReqJittBufSize();
2006-01-28 12:29:22 +01:00
};
#endif /* !defined(CLIENT_HOIHGE76GEKJH98_3_43445KJIUHF1912__INCLUDED_) */