first tests with protocol
This commit is contained in:
parent
070158cb33
commit
651f60b625
14 changed files with 256 additions and 129 deletions
|
@ -38,7 +38,10 @@ llcon_SOURCES = ../src/buffer.cpp \
|
|||
|
||||
# these need to be generated before the rest can be compiled
|
||||
|
||||
BUILT_SOURCES=moc/moc_server.cpp \
|
||||
BUILT_SOURCES=moc/moc_server.cpp \
|
||||
moc/moc_client.cpp \
|
||||
moc/moc_protocol.cpp \
|
||||
moc/moc_channel.cpp \
|
||||
moc/moc_socket.cpp \
|
||||
moc/moc_multicolorled.cpp \
|
||||
moc/moc_util.cpp \
|
||||
|
@ -55,8 +58,11 @@ dist-hook:
|
|||
mkdir $(distdir)/moc
|
||||
|
||||
moc/moc_server.cpp: ../src/server.h
|
||||
$(MOC) ../src/server.h -o moc/moc_server.cpp
|
||||
|
||||
$(MOC) ../src/server.h -o moc/moc_server.cpp
|
||||
|
||||
moc/moc_client.cpp: ../src/client.h
|
||||
$(MOC) ../src/client.h -o moc/moc_client.cpp
|
||||
|
||||
moc/moc_socket.cpp: ../src/socket.h
|
||||
$(MOC) ../src/socket.h -o moc/moc_socket.cpp
|
||||
|
||||
|
@ -66,6 +72,11 @@ moc/moc_multicolorled.cpp: ../src/multicolorled.h
|
|||
moc/moc_util.cpp: ../src/util.h
|
||||
$(MOC) ../src/util.h -o moc/moc_util.cpp
|
||||
|
||||
moc/moc_protocol.cpp: ../src/protocol.h
|
||||
$(MOC) ../src/protocol.h -o moc/moc_protocol.cpp
|
||||
|
||||
moc/moc_channel.cpp: ../src/channel.h
|
||||
$(MOC) ../src/channel.h -o moc/moc_channel.cpp
|
||||
|
||||
|
||||
moc/moc_aboutdlgbase.cpp: moc/aboutdlgbase.h
|
||||
|
|
|
@ -198,7 +198,7 @@ for ( int i = 0; i < MAX_NUM_CHANNELS; i++ )
|
|||
/******************************************************************************\
|
||||
* CChannel *
|
||||
\******************************************************************************/
|
||||
CChannel::CChannel()
|
||||
CChannel::CChannel ()
|
||||
{
|
||||
/* init time stamp activation counter */
|
||||
iTimeStampActCnt = NUM_BL_TIME_STAMPS;
|
||||
|
@ -220,8 +220,14 @@ CChannel::CChannel()
|
|||
iConTimeOut = 0;
|
||||
|
||||
/* init sample rate offset estimation object */
|
||||
SampleOffsetEst.Init();
|
||||
}
|
||||
SampleOffsetEst.Init();
|
||||
|
||||
|
||||
/* connections ---------------------------------------------------------- */
|
||||
// just route message through this class
|
||||
QObject::connect(&Protocol, SIGNAL(MessReadyForSending()),
|
||||
SIGNAL(MessReadyForSending()));
|
||||
}
|
||||
|
||||
void CChannel::SetSockBufSize ( const int iNewBlockSize, const int iNumBlocks )
|
||||
{
|
||||
|
@ -230,7 +236,7 @@ void CChannel::SetSockBufSize ( const int iNewBlockSize, const int iNumBlocks )
|
|||
|
||||
SockBuf.Init ( iNewBlockSize, iNumBlocks );
|
||||
|
||||
Mutex.unlock ();
|
||||
Mutex.unlock ();
|
||||
}
|
||||
|
||||
bool CChannel::GetAddress(CHostAddress& RetAddr)
|
||||
|
@ -292,7 +298,7 @@ for (int i = 0; i < BLOCK_SIZE_SAMPLES; i++)
|
|||
|
||||
|
||||
// TODO add protocol parsing here
|
||||
ClientProtocol.ParseMessage ( vecbyData, iNumBytes );
|
||||
Protocol.ParseMessage ( vecbyData, iNumBytes );
|
||||
|
||||
|
||||
|
||||
|
@ -304,27 +310,29 @@ ClientProtocol.ParseMessage ( vecbyData, iNumBytes );
|
|||
return bRet;
|
||||
}
|
||||
|
||||
bool CChannel::GetData(CVector<double>& vecdData)
|
||||
bool CChannel::GetData ( CVector<double>& vecdData )
|
||||
{
|
||||
Mutex.lock(); /* get mutex lock */
|
||||
Mutex.lock (); /* get mutex lock */
|
||||
|
||||
const bool bGetOK = SockBuf.Get(vecdData);
|
||||
const bool bGetOK = SockBuf.Get ( vecdData );
|
||||
|
||||
if (!bGetOK)
|
||||
if ( !bGetOK )
|
||||
{
|
||||
/* decrease time-out counter */
|
||||
if (iConTimeOut > 0)
|
||||
if ( iConTimeOut > 0 )
|
||||
{
|
||||
iConTimeOut--;
|
||||
|
||||
/* if time out is reached, re-init resample offset estimation
|
||||
module */
|
||||
if (iConTimeOut == 0)
|
||||
SampleOffsetEst.Init();
|
||||
if ( iConTimeOut == 0 )
|
||||
{
|
||||
SampleOffsetEst.Init ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Mutex.unlock(); /* get mutex unlock */
|
||||
Mutex.unlock (); /* get mutex unlock */
|
||||
|
||||
return bGetOK;
|
||||
}
|
||||
|
|
|
@ -74,28 +74,40 @@ protected:
|
|||
|
||||
|
||||
/* CChannel ----------------------------------------------------------------- */
|
||||
class CChannel
|
||||
{
|
||||
class CChannel : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CChannel();
|
||||
virtual ~CChannel() {}
|
||||
CChannel ();
|
||||
virtual ~CChannel () {}
|
||||
|
||||
bool PutData(const CVector<unsigned char>& vecbyData,
|
||||
int iNumBytes);
|
||||
bool GetData(CVector<double>& vecdData);
|
||||
bool PutData ( const CVector<unsigned char>& vecbyData,
|
||||
int iNumBytes );
|
||||
bool GetData ( CVector<double>& vecdData );
|
||||
|
||||
CVector<unsigned char> PrepSendPacket(const CVector<short>& vecsNPacket);
|
||||
CVector<unsigned char> PrepSendPacket ( const CVector<short>& vecsNPacket );
|
||||
CVector<unsigned char> GetSendMessage () { return Protocol.GetSendMessage (); }
|
||||
|
||||
bool IsConnected () const { return iConTimeOut > 0; }
|
||||
|
||||
int GetTimeStampIdx ();
|
||||
int GetComprAudSize () { return iAudComprSize; }
|
||||
double GetResampleOffset () { return SampleOffsetEst.GetSamRate (); }
|
||||
|
||||
void SetAddress ( const CHostAddress NAddr ) { InetAddr = NAddr; }
|
||||
bool GetAddress ( CHostAddress& RetAddr );
|
||||
CHostAddress GetAddress () { return InetAddr; }
|
||||
|
||||
bool GetAddress(CHostAddress& RetAddr);
|
||||
CHostAddress GetAddress() {return InetAddr;}
|
||||
int GetTimeStampIdx();
|
||||
void SetAddress(const CHostAddress NAddr) {InetAddr = NAddr;}
|
||||
bool IsConnected() const {return iConTimeOut > 0;}
|
||||
int GetComprAudSize() {return iAudComprSize;}
|
||||
double GetResampleOffset() {return SampleOffsetEst.GetSamRate();}
|
||||
void SetSockBufSize ( const int iNewBlockSize, const int iNumBlocks );
|
||||
int GetSockBufSize() {return SockBuf.GetSize();}
|
||||
|
||||
int GetSockBufSize () { return SockBuf.GetSize(); }
|
||||
|
||||
// network protocol interface
|
||||
void CreateJitBufMes ( const int iJitBufSize )
|
||||
{
|
||||
Protocol.CreateJitBufMes ( iJitBufSize );
|
||||
}
|
||||
|
||||
protected:
|
||||
/* audio compression */
|
||||
CAudioCompression AudioCompression;
|
||||
|
@ -118,10 +130,8 @@ protected:
|
|||
/* network output conversion buffer */
|
||||
CConvBuf ConvBuf;
|
||||
|
||||
|
||||
// TEST TODO: better implementation, now this object is created in server AND client which is not good
|
||||
CClientProtocol ClientProtocol;
|
||||
|
||||
// network protocol
|
||||
CProtocol Protocol;
|
||||
|
||||
/* time stamp index counter */
|
||||
Q_UINT8 byTimeStampIdxCnt;
|
||||
|
@ -129,7 +139,10 @@ CClientProtocol ClientProtocol;
|
|||
|
||||
int iConTimeOut;
|
||||
|
||||
QMutex Mutex;
|
||||
QMutex Mutex;
|
||||
|
||||
signals:
|
||||
void MessReadyForSending ();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -25,7 +25,30 @@
|
|||
#include "client.h"
|
||||
|
||||
|
||||
/* Implementation *************************************************************/
|
||||
/* Implementation *************************************************************/
|
||||
CClient::CClient () : bRun ( false ), Socket ( &Channel ),
|
||||
iAudioInFader ( AUD_FADER_IN_MAX / 2 ),
|
||||
iReverbLevel ( AUD_REVERB_MAX / 6 ),
|
||||
bReverbOnLeftChan ( false )
|
||||
{
|
||||
QObject::connect(&Channel, SIGNAL(MessReadyForSending()),
|
||||
this, SLOT(OnSendProtMessage()));
|
||||
}
|
||||
|
||||
void CClient::OnSendProtMessage ()
|
||||
{
|
||||
|
||||
// the protocol queries me to call the function to send the message
|
||||
// send it through the network
|
||||
Socket.SendPacket ( Channel.GetSendMessage (),
|
||||
Channel.GetAddress(), Channel.GetTimeStampIdx() );
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool CClient::SetServerAddr(QString strNAddr)
|
||||
{
|
||||
QHostAddress InetAddr;
|
||||
|
@ -88,7 +111,7 @@ void CClient::Init()
|
|||
void CClient::run()
|
||||
{
|
||||
int i, iInCnt;
|
||||
|
||||
|
||||
/* Set thread priority (The working thread should have a higher
|
||||
priority than the GUI) */
|
||||
#ifdef _WIN32
|
||||
|
@ -112,10 +135,14 @@ void CClient::run()
|
|||
while (bRun)
|
||||
{
|
||||
/* get audio from sound card (blocking function) */
|
||||
if (Sound.Read(vecsAudioSndCrd))
|
||||
PostWinMessage(MS_SOUND_IN, MUL_COL_LED_RED);
|
||||
else
|
||||
PostWinMessage(MS_SOUND_IN, MUL_COL_LED_GREEN);
|
||||
if (Sound.Read(vecsAudioSndCrd))
|
||||
{
|
||||
PostWinMessage(MS_SOUND_IN, MUL_COL_LED_RED);
|
||||
}
|
||||
else
|
||||
{
|
||||
PostWinMessage(MS_SOUND_IN, MUL_COL_LED_GREEN);
|
||||
}
|
||||
|
||||
/* copy data from one stereo buffer in two separate buffers */
|
||||
iInCnt = 0;
|
||||
|
@ -181,10 +208,14 @@ void CClient::run()
|
|||
Channel.GetAddress(), Channel.GetTimeStampIdx());
|
||||
|
||||
/* receive a new block */
|
||||
if (Channel.GetData(vecdNetwData))
|
||||
PostWinMessage(MS_JIT_BUF_GET, MUL_COL_LED_GREEN);
|
||||
else
|
||||
PostWinMessage(MS_JIT_BUF_GET, MUL_COL_LED_RED);
|
||||
if (Channel.GetData(vecdNetwData))
|
||||
{
|
||||
PostWinMessage(MS_JIT_BUF_GET, MUL_COL_LED_GREEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
PostWinMessage(MS_JIT_BUF_GET, MUL_COL_LED_RED);
|
||||
}
|
||||
|
||||
#ifdef _DEBUG_
|
||||
#if 0
|
||||
|
@ -252,14 +283,18 @@ fflush(pFileDelay);
|
|||
if (Channel.IsConnected())
|
||||
{
|
||||
/* write mono input signal in both sound-card channels */
|
||||
for (i = 0; i < iBlockSizeSam; i++)
|
||||
vecdAudioL[i] = vecdAudioR[i] = vecdNetwData[i];
|
||||
for (i = 0; i < iBlockSizeSam; i++)
|
||||
{
|
||||
vecdAudioL[i] = vecdAudioR[i] = vecdNetwData[i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* if not connected, clear data */
|
||||
for (i = 0; i < iBlockSizeSam; i++)
|
||||
vecdAudioL[i] = vecdAudioR[i] = 0.0;
|
||||
for (i = 0; i < iBlockSizeSam; i++)
|
||||
{
|
||||
vecdAudioL[i] = vecdAudioR[i] = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
/* resample data for each channel separately */
|
||||
|
@ -275,10 +310,14 @@ fflush(pFileDelay);
|
|||
}
|
||||
|
||||
/* play the new block */
|
||||
if (Sound.Write(vecsAudioSndCrd))
|
||||
PostWinMessage(MS_SOUND_OUT, MUL_COL_LED_RED);
|
||||
else
|
||||
if (Sound.Write(vecsAudioSndCrd))
|
||||
{
|
||||
PostWinMessage(MS_SOUND_OUT, MUL_COL_LED_RED);
|
||||
}
|
||||
else
|
||||
{
|
||||
PostWinMessage(MS_SOUND_OUT, MUL_COL_LED_GREEN);
|
||||
}
|
||||
|
||||
|
||||
/* update response time measurement --------------------------------- */
|
||||
|
@ -316,4 +355,4 @@ bool CClient::Stop()
|
|||
|
||||
/* give thread some time to terminate, return status */
|
||||
return wait(5000);
|
||||
}
|
||||
}
|
||||
|
|
67
src/client.h
67
src/client.h
|
@ -28,7 +28,7 @@
|
|||
#include <qthread.h>
|
||||
#include <qhostaddress.h>
|
||||
#include <qstring.h>
|
||||
#include <qdatetime.h>
|
||||
#include <qdatetime.h>
|
||||
#include "global.h"
|
||||
#include "socket.h"
|
||||
#include "resample.h"
|
||||
|
@ -51,46 +51,60 @@
|
|||
|
||||
|
||||
/* Classes ********************************************************************/
|
||||
class CClient : public QThread
|
||||
{
|
||||
class CClient : public QObject, public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CClient() : bRun ( false ), Socket ( &Channel ),
|
||||
iAudioInFader ( AUD_FADER_IN_MAX / 2 ),
|
||||
iReverbLevel ( AUD_REVERB_MAX / 6 ),
|
||||
bReverbOnLeftChan ( false ) {}
|
||||
CClient();
|
||||
virtual ~CClient () {}
|
||||
|
||||
void Init();
|
||||
bool Stop();
|
||||
bool IsRunning() {return bRun;}
|
||||
bool SetServerAddr(QString strNAddr);
|
||||
double MicLevelL() {return SignalLevelMeterL.MicLevel();}
|
||||
double MicLevelR() {return SignalLevelMeterR.MicLevel();}
|
||||
bool IsConnected() {return Channel.IsConnected();}
|
||||
void Init ();
|
||||
bool Stop ();
|
||||
bool IsRunning () { return bRun; }
|
||||
bool SetServerAddr ( QString strNAddr );
|
||||
double MicLevelL () { return SignalLevelMeterL.MicLevel (); }
|
||||
double MicLevelR () { return SignalLevelMeterR.MicLevel (); }
|
||||
bool IsConnected () { return Channel.IsConnected (); }
|
||||
|
||||
/* we want to return the standard deviation. For that we need to calculate
|
||||
the sqaure root */
|
||||
double GetTimingStdDev() {return sqrt(RespTimeMoAvBuf.GetAverage());}
|
||||
double GetTimingStdDev () { return sqrt ( RespTimeMoAvBuf.GetAverage () ); }
|
||||
|
||||
int GetAudioInFader() {return iAudioInFader;}
|
||||
void SetAudioInFader(const int iNV) {iAudioInFader = iNV;}
|
||||
int GetAudioInFader () { return iAudioInFader; }
|
||||
void SetAudioInFader ( const int iNV ) { iAudioInFader = iNV; }
|
||||
|
||||
int GetReverbLevel() {return iReverbLevel;}
|
||||
void SetReverbLevel(const int iNL) {iReverbLevel = iNL;}
|
||||
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 iNewBlockSize, const int iNumBlocks )
|
||||
{
|
||||
// set the new socket size
|
||||
Channel.SetSockBufSize ( iNewBlockSize, iNumBlocks );
|
||||
|
||||
// tell the server that size has changed
|
||||
Channel.CreateJitBufMes ( iNumBlocks );
|
||||
}
|
||||
int GetSockBufSize () { return Channel.GetSockBufSize (); }
|
||||
|
||||
bool IsReverbOnLeftChan() {return bReverbOnLeftChan;}
|
||||
void SetReverbOnLeftChan(const bool bIL)
|
||||
{bReverbOnLeftChan = bIL; AudioReverb.Clear();}
|
||||
|
||||
CSound* GetSndInterface() {return &Sound;}
|
||||
CChannel* GetChannel() {return &Channel;}
|
||||
CSound* GetSndInterface () { return &Sound; }
|
||||
CChannel* GetChannel () { return &Channel; }
|
||||
|
||||
|
||||
// settings
|
||||
string strIPAddress;
|
||||
|
||||
protected:
|
||||
virtual void run();
|
||||
virtual void run ();
|
||||
|
||||
/* only one channel is needed for client application */
|
||||
CChannel Channel;
|
||||
|
@ -129,6 +143,9 @@ protected:
|
|||
/* debugging, evaluating */
|
||||
CMovingAv<double> RespTimeMoAvBuf;
|
||||
QTime TimeLastBlock;
|
||||
|
||||
public slots:
|
||||
void OnSendProtMessage ();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
|
||||
/* version and application name */
|
||||
#ifndef VERSION
|
||||
# define VERSION "0.9.3cvs"
|
||||
# define VERSION "0.9.4cvs"
|
||||
#endif
|
||||
#define APP_NAME "llcon"
|
||||
|
||||
|
@ -125,7 +125,7 @@ typedef unsigned int _MESSAGE_IDENT;
|
|||
#define MS_SOUND_OUT 2
|
||||
#define MS_JIT_BUF_PUT 3
|
||||
#define MS_JIT_BUF_GET 4
|
||||
#define MS_PACKET_RECEIVED 5
|
||||
#define MS_PACKET_RECEIVED 5
|
||||
|
||||
#define MUL_COL_LED_RED 0
|
||||
#define MUL_COL_LED_YELLOW 1
|
||||
|
|
|
@ -98,7 +98,7 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent,
|
|||
|
||||
/* network buffer */
|
||||
SliderNetBuf->setRange(1, MAX_NET_BUF_SIZE_NUM_BL);
|
||||
const int iCurNumNetBuf = pClient->GetChannel()->GetSockBufSize();
|
||||
const int iCurNumNetBuf = pClient->GetSockBufSize();
|
||||
SliderNetBuf->setValue(iCurNumNetBuf);
|
||||
TextNetBuf->setText("Size: " + QString().setNum(iCurNumNetBuf));
|
||||
|
||||
|
@ -240,7 +240,7 @@ void CLlconClientDlg::OnSliderSndBufOutChange(int value)
|
|||
|
||||
void CLlconClientDlg::OnSliderNetBuf(int value)
|
||||
{
|
||||
pClient->GetChannel()->SetSockBufSize ( MIN_BLOCK_SIZE_SAMPLES, value );
|
||||
pClient->SetSockBufSize ( MIN_BLOCK_SIZE_SAMPLES, value );
|
||||
TextNetBuf->setText("Size: " + QString().setNum(value));
|
||||
}
|
||||
|
||||
|
|
|
@ -58,9 +58,37 @@ MESSAGES
|
|||
|
||||
|
||||
/* Implementation *************************************************************/
|
||||
CVector<unsigned char> CProtocol::GetSendMessage ()
|
||||
{
|
||||
// TEST, TODO implement protocol handling here (timers, etc.)
|
||||
|
||||
bool CClientProtocol::ParseMessage ( const CVector<unsigned char>& vecbyData,
|
||||
const int iNumBytes )
|
||||
// convert unsigned uint8_t in char, TODO convert all buffers in uint8_t
|
||||
CVector<unsigned char> vecbyDataConv ( vecMessage.Size () );
|
||||
for ( int i = 0; i < vecMessage.Size (); i++ ) {
|
||||
vecbyDataConv[i] = static_cast<unsigned char> ( vecMessage[i] );
|
||||
}
|
||||
|
||||
return vecbyDataConv;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CProtocol::EnqueueMessage ( CVector<uint8_t>& vecMessage )
|
||||
{
|
||||
/* TODO */
|
||||
|
||||
emit MessReadyForSending ();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool CProtocol::ParseMessage ( const CVector<unsigned char>& vecbyData,
|
||||
const int iNumBytes )
|
||||
{
|
||||
/*
|
||||
return code: true -> ok; false -> error
|
||||
|
@ -68,6 +96,11 @@ bool CClientProtocol::ParseMessage ( const CVector<unsigned char>& vecbyData,
|
|||
int iRecCounter, iRecID;
|
||||
CVector<uint8_t> vecData;
|
||||
|
||||
|
||||
// TEST
|
||||
qDebug ( "parser entered" );
|
||||
|
||||
|
||||
// convert unsigned char in uint8_t, TODO convert all buffers in uint8_t
|
||||
CVector<uint8_t> vecbyDataConv ( vecbyData.Size () );
|
||||
for ( int i = 0; i < vecbyData.Size (); i++ ) {
|
||||
|
@ -95,7 +128,7 @@ for ( int i = 0; i < vecbyData.Size (); i++ ) {
|
|||
}
|
||||
}
|
||||
|
||||
void CClientProtocol::CreateJitBufMes ( const int iJitBufSize )
|
||||
void CProtocol::CreateJitBufMes ( const int iJitBufSize )
|
||||
{
|
||||
CVector<uint8_t> vecData ( 2 );
|
||||
unsigned int iPos = 0;
|
||||
|
@ -105,6 +138,13 @@ void CClientProtocol::CreateJitBufMes ( const int iJitBufSize )
|
|||
|
||||
// build complete message
|
||||
GenMessageFrame ( vecMessage, iCounter, PROTMESSID_JITT_BUF_SIZE, vecData );
|
||||
|
||||
// increase counter (wraps around automatically)
|
||||
// TODO: make it thread safe!!!!!!!!!!!!
|
||||
iCounter++;
|
||||
|
||||
// enqueue message
|
||||
EnqueueMessage ( vecMessage );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#define PROTOCOL_H__3B123453_4344_BB2392354455IUHF1912__INCLUDED_
|
||||
|
||||
#include <qglobal.h>
|
||||
#include <qthread.h>
|
||||
#include "global.h"
|
||||
#include "util.h"
|
||||
|
||||
|
@ -42,13 +43,25 @@
|
|||
|
||||
|
||||
/* Classes ********************************************************************/
|
||||
class CProtocol
|
||||
class CProtocol : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CProtocol () : iCounter ( 0 ) {}
|
||||
virtual ~CProtocol () {}
|
||||
|
||||
void CreateJitBufMes ( const int iJitBufSize );
|
||||
|
||||
bool ParseMessage ( const CVector<unsigned char>& vecbyData,
|
||||
const int iNumBytes );
|
||||
|
||||
CVector<unsigned char> GetSendMessage ();
|
||||
|
||||
protected:
|
||||
void EnqueueMessage ( CVector<uint8_t>& vecMessage );
|
||||
|
||||
|
||||
bool ParseMessageFrame ( const CVector<uint8_t>& vecIn,
|
||||
int& iCnt,
|
||||
int& iID,
|
||||
|
@ -70,42 +83,12 @@ protected:
|
|||
|
||||
CVector<uint8_t> vecMessage;
|
||||
uint8_t iCounter;
|
||||
|
||||
bool bIsClient;
|
||||
|
||||
signals:
|
||||
void MessReadyForSending ();
|
||||
};
|
||||
|
||||
|
||||
class CClientProtocol : public CProtocol
|
||||
{
|
||||
public:
|
||||
CClientProtocol () {}
|
||||
virtual ~CClientProtocol () {}
|
||||
|
||||
void CreateJitBufMes ( const int iJitBufSize );
|
||||
|
||||
bool ParseMessage ( const CVector<unsigned char>& vecbyData,
|
||||
const int iNumBytes );
|
||||
|
||||
protected:
|
||||
|
||||
};
|
||||
|
||||
|
||||
class CServerProtocol : public CProtocol
|
||||
{
|
||||
public:
|
||||
CServerProtocol () {}
|
||||
virtual ~CServerProtocol () {}
|
||||
|
||||
bool ParseMessage ( const CVector<unsigned char>& vecbyData,
|
||||
const int iNumBytes );
|
||||
|
||||
protected:
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* !defined(PROTOCOL_H__3B123453_4344_BB2392354455IUHF1912__INCLUDED_) */
|
||||
|
|
|
@ -79,7 +79,7 @@ void CSettings::ReadIniFile()
|
|||
|
||||
// network jitter buffer size
|
||||
if ( GetNumericIniSet(ini, "Client", "jitbuf", 0, MAX_NET_BUF_SIZE_NUM_BL, iValue ) == TRUE ) {
|
||||
pClient->GetChannel()->SetSockBufSize ( MIN_BLOCK_SIZE_SAMPLES, iValue );
|
||||
pClient->SetSockBufSize ( MIN_BLOCK_SIZE_SAMPLES, iValue );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ void CSettings::WriteIniFile()
|
|||
SetNumericIniSet ( ini, "Client", "audoutbuf", pClient->GetSndInterface()->GetOutNumBuf () );
|
||||
|
||||
// network jitter buffer size
|
||||
SetNumericIniSet ( ini, "Client", "jitbuf", pClient->GetChannel()->GetSockBufSize () );
|
||||
SetNumericIniSet ( ini, "Client", "jitbuf", pClient->GetSockBufSize () );
|
||||
|
||||
|
||||
/* Save settings in init-file */
|
||||
|
|
|
@ -76,7 +76,7 @@ void CSocket::SendPacket( const CVector<unsigned char>& vecbySendBuf,
|
|||
{
|
||||
/* send packet through network */
|
||||
SocketDevice.writeBlock (
|
||||
(const char*) &((CVector<unsigned char>) vecbySendBuf)[0],
|
||||
(const char*) &( (CVector<unsigned char>) vecbySendBuf )[0],
|
||||
iVecSizeOut, HostAddr.InetAddr, HostAddr.iPort );
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ void CSocket::OnDataReceived ()
|
|||
{
|
||||
/* read block from network interface */
|
||||
const int iNumBytesRead = SocketDevice.readBlock( (char*) &vecbyRecBuf[0],
|
||||
MAX_SIZE_BYTES_NETW_BUF);
|
||||
MAX_SIZE_BYTES_NETW_BUF );
|
||||
|
||||
/* check if an error occurred */
|
||||
if ( iNumBytesRead < 0 )
|
||||
|
|
|
@ -69,6 +69,7 @@ protected:
|
|||
|
||||
CChannel* pChannel; /* for client */
|
||||
CChannelSet* pChannelSet; /* for server */
|
||||
|
||||
QObject* pServer;
|
||||
bool bIsClient;
|
||||
|
||||
|
|
|
@ -30,8 +30,11 @@ rem .h --------------
|
|||
%qtdir%\bin\moc.exe ..\src\multicolorled.h -o moc\moc_multicolorled.cpp
|
||||
%qtdir%\bin\moc.exe ..\src\llconclientdlg.h -o moc\moc_llconclientdlg.cpp
|
||||
%qtdir%\bin\moc.exe ..\src\llconserverdlg.h -o moc\moc_llconserverdlg.cpp
|
||||
%qtdir%\bin\moc.exe ..\src\server.h -o moc\moc_server.cpp
|
||||
%qtdir%\bin\moc.exe ..\src\server.h -o moc\moc_server.cpp
|
||||
%qtdir%\bin\moc.exe ..\src\client.h -o moc\moc_client.cpp
|
||||
%qtdir%\bin\moc.exe ..\src\socket.h -o moc\moc_socket.cpp
|
||||
%qtdir%\bin\moc.exe ..\src\protocol.h -o moc\moc_protocol.cpp
|
||||
%qtdir%\bin\moc.exe ..\src\channel.h -o moc\moc_channel.cpp
|
||||
|
||||
|
||||
rem .ui -------------
|
||||
|
|
|
@ -113,6 +113,14 @@ SOURCE=.\moc\moc_aboutdlgbase.cpp
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\moc\moc_channel.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\moc\moc_client.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\moc\moc_llconclientdlg.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -133,6 +141,10 @@ SOURCE=.\moc\moc_multicolorled.cpp
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\moc\moc_protocol.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\moc\moc_server.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
|
Loading…
Reference in a new issue