added new file for protocol (just template right now), new code style

This commit is contained in:
Volker Fischer 2006-02-12 14:26:46 +00:00
parent 270725688f
commit dd914c411c
14 changed files with 351 additions and 160 deletions

View file

@ -13,7 +13,8 @@ llcon_SOURCES = ../src/buffer.cpp \
../src/llconserverdlg.cpp \
../src/server.cpp \
../src/settings.cpp \
../src/multicolorled.cpp \
../src/protocol.cpp \
../src/multicolorled.cpp \
sound.cpp \
../src/buffer.h \
../src/global.h \
@ -26,6 +27,7 @@ llcon_SOURCES = ../src/buffer.cpp \
../src/client.h \
../src/server.h \
../src/settings.h \
../src/protocol.h \
../src/multicolorled.h \
../src/llconserverdlg.h \
../src/llconclientdlg.h \

View file

@ -63,37 +63,45 @@ int CChannelSet::CheckAddr(const CHostAddress& Addr)
bool CChannelSet::PutData(const CVector<unsigned char>& vecbyRecBuf,
const int iNumBytesRead, const CHostAddress& HostAdr)
{
Mutex.lock();
Mutex.lock ();
/* get channel ID ------------------------------------------------------- */
bool bChanOK = true;
/* check address */
int iCurChanID = CheckAddr(HostAdr);
int iCurChanID = CheckAddr ( HostAdr );
if (iCurChanID == INVALID_CHANNEL_ID)
if ( iCurChanID == INVALID_CHANNEL_ID )
{
/* a new client is calling, look for free channel */
iCurChanID = GetFreeChan();
iCurChanID = GetFreeChan ();
if (iCurChanID != INVALID_CHANNEL_ID)
vecChannels[iCurChanID].SetAddress(HostAdr);
else
bChanOK = false; /* no free channel available */
if ( iCurChanID != INVALID_CHANNEL_ID )
{
vecChannels[iCurChanID].SetAddress ( HostAdr );
}
else
{
bChanOK = false; /* no free channel available */
}
}
/* put received data in jitter buffer ----------------------------------- */
if (bChanOK)
if ( bChanOK )
{
/* put packet in socket buffer */
if (vecChannels[iCurChanID].PutData(vecbyRecBuf, iNumBytesRead))
PostWinMessage(MS_JIT_BUF_PUT, MUL_COL_LED_GREEN, iCurChanID);
else
PostWinMessage(MS_JIT_BUF_PUT, MUL_COL_LED_RED, iCurChanID);
if ( vecChannels[iCurChanID].PutData ( vecbyRecBuf, iNumBytesRead ) )
{
PostWinMessage ( MS_JIT_BUF_PUT, MUL_COL_LED_GREEN, iCurChanID );
}
else
{
PostWinMessage ( MS_JIT_BUF_PUT, MUL_COL_LED_RED, iCurChanID );
}
}
Mutex.unlock();
Mutex.unlock ();
return !bChanOK; /* return 1 if error */
}
@ -213,25 +221,6 @@ void CChannel::SetSockBufSize ( const int iNewBlockSize, const int iNumBlocks )
Mutex.unlock ();
}
int CChannel::GetTimeStampIdx ()
{
/* only send time stamp index after a pre-defined number of packets */
if ( iTimeStampActCnt > 0 )
{
iTimeStampActCnt--;
return INVALID_TIME_STAMP_IDX;
}
else
{
/* reset time stamp activation counter */
iTimeStampActCnt = NUM_BL_TIME_STAMPS - 1;
/* wraps around automatically */
byTimeStampIdxCnt++;
return byTimeStampIdxCnt;
}
}
bool CChannel::GetAddress(CHostAddress& RetAddr)
{
if (IsConnected())
@ -262,9 +251,6 @@ bool CChannel::PutData(const CVector<unsigned char>& vecbyData,
/* do resampling to compensate for sample rate offsets in the
different sound cards of the clients */
// we should not do resampling here since we already have resampling
// in the client audio path, we could use this resampling for this
// sample rate correction, too
/*
for (int i = 0; i < BLOCK_SIZE_SAMPLES; i++)
vecdResInData[i] = (double) vecsData[i];
@ -338,7 +324,25 @@ CVector<unsigned char> CChannel::PrepSendPacket(const CVector<short>& vecsNPacke
return vecbySendBuf;
}
int CChannel::GetTimeStampIdx ()
{
/* only send time stamp index after a pre-defined number of packets */
if ( iTimeStampActCnt > 0 )
{
iTimeStampActCnt--;
return INVALID_TIME_STAMP_IDX;
}
else
{
/* reset time stamp activation counter */
iTimeStampActCnt = NUM_BL_TIME_STAMPS - 1;
/* wraps around automatically */
byTimeStampIdxCnt++;
return byTimeStampIdxCnt;
}
}
/******************************************************************************\
@ -395,8 +399,6 @@ fflush(pFile);
*/
/* calculate linear regression for sample rate estimation */
/* first, calculate averages */
double dTimeAv = 0;
@ -434,15 +436,10 @@ fflush(pFile);
*/
}
/*
static FILE* pFile = fopen("v.dat", "w");
fprintf(pFile, "%e\n", dSamRateEst);
fflush(pFile);
*/
}

View file

@ -26,12 +26,12 @@
#define CHANNEL_HOIH9345KJH98_3_4344_BB23945IUHF1912__INCLUDED_
#include <qthread.h>
#include <qdatetime.h>
#include "global.h"
#include "buffer.h"
#include "audiocompr.h"
#include "util.h"
#include "resample.h"
#include "qdatetime.h"
/* Definitions ****************************************************************/

View file

@ -98,7 +98,7 @@
/* time interval of taps for sample rate offset estimation (time stamps) */
#define INTVL_TAPS_SAM_OFF_SET 1 /* s */
#define NUM_BL_TIME_STAMPS ( ( INTVL_TAPS_SAM_OFF_SET * 1000 ) / MIN_BLOCK_DURATION_MS )
#define NUM_BL_TIME_STAMPS ( ( INTVL_TAPS_SAM_OFF_SET * 1000 ) / BLOCK_DURATION_MS )
#define VEC_LEN_SAM_OFFS_EST ( TIME_INT_SAM_OFFS_EST / INTVL_TAPS_SAM_OFF_SET )
/* length of the moving average buffer for response time measurement */

View file

@ -68,9 +68,7 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent,
OnTimerStatus ();
/* init sample rate offset label */
// TextSamRateOffsValue->setText ( "0 Hz" );
// FIXME disable sample rate estimation result label since estimation does not work
TextSamRateOffsValue->setText ( "---" );
TextSamRateOffsValue->setText ( "0 Hz" );
/* init connection button text */
PushButtonConnect->setText ( CON_BUT_CONNECTTEXT );
@ -275,17 +273,9 @@ void CLlconClientDlg::OnTimerStatus()
TextLabelStatus->setText(tr("disconnected"));
/* update sample rate offset label */
// FIXME disable sample rate estimation result label since estimation does not work
/*
QString strSamRaOffs;
// FIXME: sample rate estimation result must be corrected since we use
// smaller buffers in client now. Actual estimation should be fixed, not here
strSamRaOffs.setNum(pClient->GetChannel()->GetResampleOffset() *
MIN_BLOCK_DURATION_MS / BLOCK_DURATION_MS, 'f', 2);
strSamRaOffs.setNum(pClient->GetChannel()->GetResampleOffset(), 'f', 2);
TextSamRateOffsValue->setText(strSamRaOffs + " Hz");
*/
/* response time */
TextLabelStdDevTimer->setText(QString().

View file

@ -107,7 +107,8 @@ CLlconServerDlg::CLlconServerDlg(QWidget* parent, const char* name, bool modal,
void CLlconServerDlg::OnTimer()
{
CVector<CHostAddress> vecHostAddresses;
CVector<double> vecdSamOffs;
CVector<double> vecdSamOffs;
double dCurTiStdDev;
ListViewMutex.lock();
@ -140,9 +141,16 @@ void CLlconServerDlg::OnTimer()
ListViewMutex.unlock();
/* response time */
TextLabelResponseTime->setText(QString().
setNum(Server.GetTimingStdDev(), 'f', 2) + " ms");
/* response time (if available) */
if ( Server.GetTimingStdDev ( dCurTiStdDev ) )
{
TextLabelResponseTime->setText(QString().
setNum(dCurTiStdDev, 'f', 2) + " ms");
}
else
{
TextLabelResponseTime->setText("---");
}
}
void CLlconServerDlg::OnSliderNetBuf(int value)

View file

@ -34,25 +34,27 @@
QApplication* pApp = NULL;
int main(int argc, char** argv)
int main ( int argc, char** argv )
{
/* Application object */
QApplication app(argc, argv);
QApplication app ( argc, argv );
/* check if server or client application shall be started */
bool bIsClient = true;
/* QT docu: argv()[0] is the program name, argv()[1] is the first
argument and argv()[argc()-1] is the last argument */
if (argc > 1)
if ( argc > 1 )
{
/* only "-s" is supported right now */
std::string strShortOpt = "-s";
if (!strShortOpt.compare(argv[1]))
bIsClient = false;
if ( !strShortOpt.compare ( argv[1] ) )
{
bIsClient = false;
}
}
if (bIsClient)
if ( bIsClient )
{
// actual client object
CClient Client;
@ -98,7 +100,8 @@ void PostWinMessage ( const _MESSAGE_IDENT MessID, const int iMessageParam,
/* In case of simulation no events should be generated */
if ( pApp != NULL )
{
CLlconEvent* LlconEv = new CLlconEvent ( MessID, iMessageParam, iChanNum );
CLlconEvent* LlconEv =
new CLlconEvent ( MessID, iMessageParam, iChanNum );
/* Qt will delete the event object when done */
QThread::postEvent ( pApp->mainWidget (), LlconEv );

31
src/protocol.cpp Executable file
View file

@ -0,0 +1,31 @@
/******************************************************************************\
* 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
*
\******************************************************************************/
#include "protocol.h"
/* Implementation *************************************************************/
// TODO

63
src/protocol.h Executable file
View file

@ -0,0 +1,63 @@
/******************************************************************************\
* 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(PROTOCOL_H__3B123453_4344_BB2392354455IUHF1912__INCLUDED_)
#define PROTOCOL_H__3B123453_4344_BB2392354455IUHF1912__INCLUDED_
#include "global.h"
/* Classes ********************************************************************/
class CProtocol
{
public:
CProtocol() {}
virtual ~CProtocol() {}
protected:
};
class CServerProtocol : public CProtocol
{
public:
CServerProtocol() {}
virtual ~CServerProtocol() {}
protected:
};
class CClientProtocol : public CProtocol
{
public:
CClientProtocol() {}
virtual ~CClientProtocol() {}
protected:
};
#endif /* !defined(PROTOCOL_H__3B123453_4344_BB2392354455IUHF1912__INCLUDED_) */

View file

@ -38,76 +38,119 @@ CServer::CServer() : Socket(&ChannelSet)
}
void CServer::Start()
{
/* start main timer */
Timer.start(BLOCK_DURATION_MS);
{
if ( !IsRunning () )
{
/* start main timer */
Timer.start(BLOCK_DURATION_MS);
/* init time for response time evaluation */
TimeLastBlock = QTime::currentTime();
}
/* init time for response time evaluation */
TimeLastBlock = QTime::currentTime();
}
}
void CServer::Stop()
{
/* stop main timer */
Timer.stop();
}
void CServer::OnTimer()
{
CVector<int> vecChanID;
CVector<CVector<double> > vecvecdData(BLOCK_SIZE_SAMPLES);
CVector<CVector<double> > vecvecdData ( BLOCK_SIZE_SAMPLES );
/* get data from all connected clients */
ChannelSet.GetBlockAllConC(vecChanID, vecvecdData);
/* actual processing of audio data -> mix */
vecsSendData = ProcessData(vecvecdData);
/* get number of connected clients from vector size */
const int iNumClients = vecvecdData.Size();
/* send the same data to all connected clients */
for (int i = 0; i < iNumClients; i++)
ChannelSet.GetBlockAllConC ( vecChanID, vecvecdData );
const int iNumClients = vecvecdData.Size ();
/* Check if at least one client is connected. If not, stop server until
one client is connected */
if ( iNumClients != 0 )
{
Socket.SendPacket(ChannelSet.PrepSendPacket(vecChanID[i], vecsSendData),
ChannelSet.GetAddress(vecChanID[i]),
ChannelSet.GetTimeStampIdx(vecChanID[i]));
}
/* actual processing of audio data -> mix */
vecsSendData = ProcessData ( vecvecdData );
/* send the same data to all connected clients */
for ( int i = 0; i < iNumClients; i++ )
{
Socket.SendPacket (
ChannelSet.PrepSendPacket ( vecChanID[i], vecsSendData ),
ChannelSet.GetAddress ( vecChanID[i] ),
ChannelSet.GetTimeStampIdx ( vecChanID[i] ) );
}
/* update response time measurement ------------------------------------- */
/* add time difference */
const QTime CurTime = QTime::currentTime();
/* update response time measurement --------------------------------- */
/* add time difference */
const QTime CurTime = QTime::currentTime ();
/* we want to calculate the standard deviation (we assume that the mean is
correct at the block period time) */
const double dCurAddVal =
((double) TimeLastBlock.msecsTo(CurTime) - BLOCK_DURATION_MS);
/* we want to calculate the standard deviation (we assume that the mean
is correct at the block period time) */
const double dCurAddVal =
( (double) TimeLastBlock.msecsTo ( CurTime ) - BLOCK_DURATION_MS );
RespTimeMoAvBuf.Add(dCurAddVal * dCurAddVal); /* add squared value */
RespTimeMoAvBuf.Add ( dCurAddVal * dCurAddVal ); /* add squared value */
/* store old time value */
TimeLastBlock = CurTime;
/* store old time value */
TimeLastBlock = CurTime;
}
else
{
/* disable server */
// TODO not yet working since the socket does not have access to the server
// object and cannot restart the server if packets arrive...
// Stop ();
}
}
CVector<short> CServer::ProcessData(CVector<CVector<double> >& vecvecdData)
CVector<short> CServer::ProcessData ( CVector<CVector<double> >& vecvecdData )
{
CVector<short> vecsOutData;
vecsOutData.Init(BLOCK_SIZE_SAMPLES);
vecsOutData.Init ( BLOCK_SIZE_SAMPLES );
const int iNumClients = vecvecdData.Size();
const int iNumClients = vecvecdData.Size ();
/* we normalize with sqrt() of N to avoid that the level drops too much
in case that a new client connects */
const double dNorm = sqrt((double) iNumClients);
const double dNorm = sqrt ( (double) iNumClients );
/* mix all audio data from all clients together */
for (int i = 0; i < BLOCK_SIZE_SAMPLES; i++)
for ( int i = 0; i < BLOCK_SIZE_SAMPLES; i++ )
{
double dMixedData = 0.0;
for (int j = 0; j < iNumClients; j++)
for ( int j = 0; j < iNumClients; j++ )
{
dMixedData += vecvecdData[j][i];
}
/* normalization and truncating to short */
vecsOutData[i] = Double2Short(dMixedData / dNorm);
vecsOutData[i] = Double2Short ( dMixedData / dNorm );
}
return vecsOutData;
}
bool CServer::GetTimingStdDev ( double& dCurTiStdDev )
{
dCurTiStdDev = 0.0; /* init return value */
/* only return value if server is active and the actual measurement is
updated */
if ( IsRunning () )
{
/* we want to return the standard deviation, for that we need to calculate
the sqaure root */
dCurTiStdDev = sqrt ( RespTimeMoAvBuf.GetAverage () );
return true;
}
else
{
return false;
}
}

View file

@ -42,23 +42,23 @@ class CServer : public QObject
Q_OBJECT
public:
CServer();
virtual ~CServer() {}
CServer ();
virtual ~CServer () {}
void Start();
void GetConCliParam(CVector<CHostAddress>& vecHostAddresses,
CVector<double>& vecdSamOffs)
{ChannelSet.GetConCliParam(vecHostAddresses, vecdSamOffs);}
void Start ();
void Stop ();
bool IsRunning() { return Timer.isActive (); }
void GetConCliParam ( CVector<CHostAddress>& vecHostAddresses,
CVector<double>& vecdSamOffs )
{ ChannelSet.GetConCliParam ( vecHostAddresses, vecdSamOffs ); }
/* we want to return the standard deviation. For that we need to calculate
the sqaure root */
double GetTimingStdDev() {return sqrt(RespTimeMoAvBuf.GetAverage());}
bool GetTimingStdDev ( double& dCurTiStdDev );
CChannelSet* GetChannelSet() {return &ChannelSet;}
CChannelSet* GetChannelSet () { return &ChannelSet; }
protected:
CVector<short> ProcessData(CVector<CVector<double> >& vecvecdData);
CVector<short> ProcessData ( CVector<CVector<double> >& vecvecdData );
QTimer Timer;
CVector<short> vecsSendData;
@ -71,7 +71,7 @@ protected:
QTime TimeLastBlock;
public slots:
void OnTimer();
void OnTimer ();
};

View file

@ -26,96 +26,104 @@
/* Implementation *************************************************************/
void CSocket::Init()
void CSocket::Init ()
{
/* allocate memory for network receive and send buffer in samples */
vecbyRecBuf.Init(MAX_SIZE_BYTES_NETW_BUF);
vecbyRecBuf.Init ( MAX_SIZE_BYTES_NETW_BUF );
/* initialize the listening socket */
bool bSuccess = SocketDevice.bind(
QHostAddress((Q_UINT32) 0) /* INADDR_ANY */, LLCON_PORT_NUMBER);
bool bSuccess = SocketDevice.bind (
QHostAddress ( (Q_UINT32) 0 ) /* INADDR_ANY */, LLCON_PORT_NUMBER );
if (bIsClient)
if ( bIsClient )
{
/* if no success, try if server is on same machine (only for client) */
if (!bSuccess)
if ( !bSuccess )
{
/* if server and client is on same machine, decrease port number by
one by definition */
bSuccess =
SocketDevice.bind(QHostAddress((Q_UINT32) 0) /* INADDR_ANY */,
LLCON_PORT_NUMBER - 1);
bSuccess = SocketDevice.bind (
QHostAddress( (Q_UINT32) 0 ) /* INADDR_ANY */,
LLCON_PORT_NUMBER - 1 );
}
}
if (!bSuccess)
if ( !bSuccess )
{
/* show error message */
QMessageBox::critical(0, "Network Error", "Cannot bind the socket.",
QMessageBox::Ok, QMessageBox::NoButton);
QMessageBox::critical ( 0, "Network Error", "Cannot bind the socket.",
QMessageBox::Ok, QMessageBox::NoButton );
/* exit application */
exit(1);
exit ( 1 );
}
QSocketNotifier* pSocketNotivRead =
new QSocketNotifier(SocketDevice.socket(), QSocketNotifier::Read);
new QSocketNotifier ( SocketDevice.socket (), QSocketNotifier::Read );
/* connect the "activated" signal */
QObject::connect(pSocketNotivRead, SIGNAL(activated(int)),
this, SLOT(OnDataReceived()));
QObject::connect ( pSocketNotivRead, SIGNAL ( activated ( int ) ),
this, SLOT ( OnDataReceived () ) );
}
void CSocket::SendPacket(const CVector<unsigned char>& vecbySendBuf,
const CHostAddress& HostAddr, const int iTimeStampIdx)
void CSocket::SendPacket( const CVector<unsigned char>& vecbySendBuf,
const CHostAddress& HostAddr,
const int iTimeStampIdx )
{
const int iVecSizeOut = vecbySendBuf.Size();
const int iVecSizeOut = vecbySendBuf.Size ();
if ( iVecSizeOut != 0 )
{
/* send packet through network */
SocketDevice.writeBlock ((const char*) &((CVector<unsigned char>) vecbySendBuf)[0],
iVecSizeOut, HostAddr.InetAddr, HostAddr.iPort);
SocketDevice.writeBlock (
(const char*) &((CVector<unsigned char>) vecbySendBuf)[0],
iVecSizeOut, HostAddr.InetAddr, HostAddr.iPort );
}
/* sent time stamp if required */
if (iTimeStampIdx != INVALID_TIME_STAMP_IDX)
if ( iTimeStampIdx != INVALID_TIME_STAMP_IDX )
{
/* Always one byte long */
SocketDevice.writeBlock((const char*) &iTimeStampIdx, 1,
HostAddr.InetAddr, HostAddr.iPort);
SocketDevice.writeBlock ( (const char*) &iTimeStampIdx, 1,
HostAddr.InetAddr, HostAddr.iPort );
}
}
void CSocket::OnDataReceived()
void CSocket::OnDataReceived ()
{
/* read block from network interface */
const int iNumBytesRead = SocketDevice.readBlock((char*) &vecbyRecBuf[0],
const int iNumBytesRead = SocketDevice.readBlock( (char*) &vecbyRecBuf[0],
MAX_SIZE_BYTES_NETW_BUF);
/* check if an error occurred */
if (iNumBytesRead < 0)
return;
if ( iNumBytesRead < 0 )
{
return;
}
/* get host address of client */
CHostAddress RecHostAddr(SocketDevice.peerAddress(),
SocketDevice.peerPort());
CHostAddress RecHostAddr ( SocketDevice.peerAddress (),
SocketDevice.peerPort () );
if (bIsClient)
if ( bIsClient )
{
/* client */
/* check if packet comes from the server we want to connect */
if (!(pChannel->GetAddress() == RecHostAddr))
if ( ! ( pChannel->GetAddress () == RecHostAddr ) )
return;
if (pChannel->PutData(vecbyRecBuf, iNumBytesRead))
PostWinMessage(MS_JIT_BUF_PUT, MUL_COL_LED_GREEN);
else
PostWinMessage(MS_JIT_BUF_PUT, MUL_COL_LED_RED);
if ( pChannel->PutData( vecbyRecBuf, iNumBytesRead ) )
{
PostWinMessage ( MS_JIT_BUF_PUT, MUL_COL_LED_GREEN );
}
else
{
PostWinMessage ( MS_JIT_BUF_PUT, MUL_COL_LED_RED );
}
}
else
{
/* server */
pChannelSet->PutData(vecbyRecBuf, iNumBytesRead, RecHostAddr);
/* server */
pChannelSet->PutData ( vecbyRecBuf, iNumBytesRead, RecHostAddr );
}
}

View file

@ -29,7 +29,8 @@
#include <qpopupmenu.h>
#include <qwhatsthis.h>
#include <qtextview.h>
#include <qlabel.h>
#include <qlabel.h>
#include <qdatetime.h>
#include <vector>
#include "global.h"
using namespace std; /* Because of the library: "vector" */
@ -376,6 +377,43 @@ protected:
double allpassCoefficient_;
double combCoefficient_[4];
};
/* Time conversion ---------------------------------------------------------- */
// needed for ping measurement
class CTimeConv
{
public:
// QTime to network time vector
static CVector<unsigned char> QTi2NetTi ( const QTime qTiIn )
{
// vector format: 1 byte hours, 1 byte min, 1 byte sec, 2 bytes ms
CVector<unsigned char> veccNetTi ( 5 );
veccNetTi[0] = static_cast<unsigned char> ( qTiIn.hour () );
veccNetTi[1] = static_cast<unsigned char> ( qTiIn.minute () );
veccNetTi[2] = static_cast<unsigned char> ( qTiIn.second () );
const int iMs = qTiIn.msec ();
veccNetTi[3] = static_cast<unsigned char> ( ( iMs >> 8 ) & 255 );
veccNetTi[4] = static_cast<unsigned char> ( iMs & 255 );
return veccNetTi;
}
// network time vector to QTime
static QTime NetTi2QTi ( const CVector<unsigned char> netTiIn )
{
// vector format: 1 byte hours, 1 byte min, 1 byte sec, 2 bytes ms
return QTime (
static_cast<int> ( netTiIn[0] ), // hour
static_cast<int> ( netTiIn[1] ), // minute
static_cast<int> ( netTiIn[2] ), // seconds
// msec
static_cast<int> ( ( netTiIn[3] << 8 ) | netTiIn[4] )
);
}
};
#endif /* !defined(UTIL_HOIH934256GEKJH98_3_43445KJIUHF1912__INCLUDED_) */

View file

@ -178,6 +178,10 @@ SOURCE=..\src\multicolorled.cpp
# End Source File
# Begin Source File
SOURCE=..\src\protocol.cpp
# End Source File
# Begin Source File
SOURCE=..\src\resample.cpp
# End Source File
# Begin Source File
@ -238,6 +242,10 @@ SOURCE=..\src\multicolorled.h
# End Source File
# Begin Source File
SOURCE=..\src\protocol.h
# End Source File
# Begin Source File
SOURCE=..\src\resample.h
# End Source File
# Begin Source File