some fixes for protocol

This commit is contained in:
Volker Fischer 2006-11-27 22:35:22 +00:00
parent 6729eaf7ae
commit 86dd0ecaa3
6 changed files with 90 additions and 60 deletions

View File

@ -58,12 +58,8 @@ CChannelSet::CChannelSet()
void CChannelSet::CreateAndSendChanListForAllConClients()
{
int i;
CVector<CChannelShortInfo> vecChanInfo ( 0 );
// the channel ID is defined as the order of the channels in the channel
// set where we do not care about not-connected channels
int iCurChanID = 0;
int i;
CVector<CChannelShortInfo> vecChanInfo ( 0 );
// look for free channels
for ( i = 0; i < MAX_NUM_CHANNELS; i++ )
@ -71,11 +67,10 @@ void CChannelSet::CreateAndSendChanListForAllConClients()
if ( vecChannels[i].IsConnected() )
{
// append channel ID, IP address and channel name to storing vectors
CChannelShortInfo ChannelShortInfo (
i, vecChannels[i].GetAddress().InetAddr.ip4Addr(),
vecChannels[i].GetName() );
vecChanInfo.Add ( ChannelShortInfo );
vecChanInfo.Add ( CChannelShortInfo (
i, // ID
vecChannels[i].GetAddress().InetAddr.ip4Addr(), // IP address
vecChannels[i].GetName() /* name */ ) );
}
}
@ -130,7 +125,7 @@ bool CChannelSet::PutData ( const CVector<unsigned char>& vecbyRecBuf,
const int iNumBytesRead,
const CHostAddress& HostAdr )
{
bool bRet = false;
bool bRet = false;
bool bCreateChanList = false;
Mutex.lock();
@ -160,6 +155,10 @@ bool CChannelSet::PutData ( const CVector<unsigned char>& vecbyRecBuf,
{
/* no free channel available */
bChanOK = false;
// create and send "server full" message
// TODO
}
}

View File

@ -29,7 +29,8 @@
CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent,
const char* name, bool modal, WFlags f) : pClient ( pNCliP ),
CLlconClientDlgBase ( parent, name, modal, f ),
ClientSettingsDlg ( pNCliP, 0, 0, FALSE, Qt::WStyle_MinMax )
ClientSettingsDlg ( pNCliP, 0, 0, FALSE, Qt::WStyle_MinMax ),
vecpChanFader ( 0 )
{
/* add help text to controls */
QString strInpLevH = tr("<b>Input level meter:</b> Shows the level of the "
@ -171,14 +172,10 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent,
// TEST
//new CLlconClientDlg::CChannelFader(FrameAudioFaders, FrameAudioFadersLayout);
//new CLlconClientDlg::CChannelFader(FrameAudioFaders, FrameAudioFadersLayout);
//new CLlconClientDlg::CChannelFader(FrameAudioFaders, FrameAudioFadersLayout);
//new CLlconClientDlg::CChannelFader(FrameAudioFaders, FrameAudioFadersLayout, "test");
//vecpChanFader.Init(0);
//vecpChanFader.Add(new CLlconClientDlg::CChannelFader(FrameAudioFaders, FrameAudioFadersLayout, "test"));
/*
for ( int z = 0; z < 100; z++)
@ -187,6 +184,7 @@ CLlconClientDlg::CChannelFader* pTest = new CLlconClientDlg::CChannelFader(Frame
delete pTest;
}
*/
}
@ -209,7 +207,7 @@ void CLlconClientDlg::closeEvent ( QCloseEvent * Event )
}
void CLlconClientDlg::OnConnectDisconBut ()
{
{
/* start/stop client, set button text */
if ( pClient->IsRunning () )
{
@ -292,20 +290,29 @@ void CLlconClientDlg::OnTimerSigMet ()
void CLlconClientDlg::OnConClientListMesReceived ( CVector<CChannelShortInfo> vecChanInfo )
{
int i;
// TODO
// TEST
for ( int i = 0; i < vecChanInfo.Size(); i++ )
// remove old controls
for ( i = 0; i < vecpChanFader.Size(); i++ )
{
delete vecpChanFader[i];
}
// TEST add current faders
vecpChanFader.Init ( vecChanInfo.Size() );
for ( i = 0; i < vecChanInfo.Size(); i++ )
{
QHostAddress addrTest ( vecChanInfo[i].veciIpAddr );
new CLlconClientDlg::CChannelFader ( FrameAudioFaders,
vecpChanFader[i] = new CLlconClientDlg::CChannelFader ( FrameAudioFaders,
FrameAudioFadersLayout, addrTest.toString() );
}
}
void CLlconClientDlg::UpdateDisplay()
@ -370,8 +377,10 @@ CLlconClientDlg::CChannelFader::CChannelFader ( QWidget* pNW,
pFader->setRange ( 0, AUD_MIX_FADER_MAX );
pFader->setTickInterval ( AUD_MIX_FADER_MAX / 9 );
// TEST set value
// TEST set value and make read only
pFader->setValue ( 0 );
pFader->setEnabled ( FALSE );
// add label to grid
pMainGrid->addWidget( pLabel, 1, 0 );

View File

@ -107,7 +107,7 @@ protected:
CClientSettingsDlg ClientSettingsDlg;
CVector<CChannelFader> vecpChanFader;
CVector<CChannelFader*> vecpChanFader;
public slots:
void OnConnectDisconBut();

View File

@ -49,6 +49,11 @@ MESSAGES
note: does not have any data -> n = 0
- Server full message: PROTMESSID_SERVER_FULL
note: does not have any data -> n = 0
- Network buffer block size factor PROTMESSID_NET_BLSI_FACTOR
note: size, relative to minimum block size
@ -309,6 +314,11 @@ for ( int i = 0; i < iNumBytes; i++ ) {
EvaluateReqJitBufMes ( iPos, vecData );
break;
case PROTMESSID_SERVER_FULL:
EvaluateServerFullMes ( iPos, vecData );
break;
case PROTMESSID_NET_BLSI_FACTOR:
EvaluateNetwBlSiFactMes ( iPos, vecData );
@ -348,8 +358,8 @@ for ( int i = 0; i < iNumBytes; i++ ) {
/* Access-functions for creating and parsing messages ----------------------- */
void CProtocol::CreateJitBufMes ( const int iJitBufSize )
{
CVector<uint8_t> vecData ( 2 ); // 2 bytes of data
unsigned int iPos = 0; // init position pointer
CVector<uint8_t> vecData ( 2 ); // 2 bytes of data
unsigned int iPos = 0; // init position pointer
// build data vector
PutValOnStream ( vecData, iPos, static_cast<uint32_t> ( iJitBufSize ), 2 );
@ -378,6 +388,17 @@ void CProtocol::EvaluateReqJitBufMes ( unsigned int iPos, const CVector<uint8_t>
emit ReqJittBufSize();
}
void CProtocol::CreateServerFullMes()
{
CreateAndSendMessage ( PROTMESSID_SERVER_FULL, CVector<uint8_t> ( 0 ) );
}
void CProtocol::EvaluateServerFullMes ( unsigned int iPos, const CVector<uint8_t>& vecData )
{
// invoke message action
emit ServerFull();
}
void CProtocol::CreateNetwBlSiFactMes ( const int iNetwBlSiFact )
{
CVector<uint8_t> vecData ( 2 ); // 2 bytes of data
@ -435,8 +456,8 @@ void CProtocol::CreateConClientListMes ( const CVector<CChannelShortInfo>& vecCh
const int iNumClients = vecChanInfo.Size();
// build data vector
CVector<uint8_t> vecData ( 0 );
unsigned int iPos = 0; // init position pointer
CVector<uint8_t> vecData ( 0 );
unsigned int iPos = 0; // init position pointer
for ( int i = 0; i < iNumClients; i++ )
{
@ -476,9 +497,9 @@ void CProtocol::CreateConClientListMes ( const CVector<CChannelShortInfo>& vecCh
void CProtocol:: EvaluateConClientListMes ( unsigned int iPos, const CVector<uint8_t>& vecData )
{
int iData;
const int iDataLen = vecData.Size();
CVector<CChannelShortInfo> vecChanInfo ( 0 );
int iData;
const int iDataLen = vecData.Size();
CVector<CChannelShortInfo> vecChanInfo ( 0 );
while ( iPos < iDataLen )
{
@ -583,8 +604,8 @@ bool CProtocol::ParseMessageFrame ( const CVector<uint8_t>& vecIn,
}
uint32_t CProtocol::GetValFromStream ( const CVector<uint8_t>& vecIn,
unsigned int& iPos,
const unsigned int iNumOfBytes )
unsigned int& iPos,
const unsigned int iNumOfBytes )
{
/*
note: iPos is automatically incremented in this function

View File

@ -39,10 +39,11 @@
#define PROTMESSID_ACKN 1 // acknowledge
#define PROTMESSID_JITT_BUF_SIZE 10 // jitter buffer size
#define PROTMESSID_REQ_JITT_BUF_SIZE 11 // request jitter buffer size
#define PROTMESSID_PING 12 // for measuring ping time
#define PROTMESSID_NET_BLSI_FACTOR 13 // network buffer size factor
#define PROTMESSID_CHANNEL_GAIN 14 // set channel gain for mix
#define PROTMESSID_CONN_CLIENTS_LIST 15 // connected client list
#define PROTMESSID_SERVER_FULL 12
#define PROTMESSID_PING 13 // for measuring ping time
#define PROTMESSID_NET_BLSI_FACTOR 14 // network buffer size factor
#define PROTMESSID_CHANNEL_GAIN 15 // set channel gain for mix
#define PROTMESSID_CONN_CLIENTS_LIST 16 // connected client list
// lengths of message as defined in protocol.cpp file
#define MESS_HEADER_LENGTH_BYTE 5 /* ID, cnt, length */
@ -62,6 +63,7 @@ public:
void CreateJitBufMes ( const int iJitBufSize );
void CreateReqJitBufMes();
void CreateServerFullMes();
void CreateNetwBlSiFactMes ( const int iNetwBlSiFact );
void CreateChanGainMes ( const int iChanID, const double dGain );
@ -125,10 +127,11 @@ protected:
void CreateAndSendMessage ( const int iID, const CVector<uint8_t>& vecData );
void EvaluateJitBufMes ( unsigned int iPos, const CVector<uint8_t>& vecData );
void EvaluateReqJitBufMes ( unsigned int iPos, const CVector<uint8_t>& vecData );
void EvaluateNetwBlSiFactMes ( unsigned int iPos, const CVector<uint8_t>& vecData );
void EvaluateChanGainMes ( unsigned int iPos, const CVector<uint8_t>& vecData );
void EvaluateJitBufMes ( unsigned int iPos, const CVector<uint8_t>& vecData );
void EvaluateReqJitBufMes ( unsigned int iPos, const CVector<uint8_t>& vecData );
void EvaluateServerFullMes ( unsigned int iPos, const CVector<uint8_t>& vecData );
void EvaluateNetwBlSiFactMes ( unsigned int iPos, const CVector<uint8_t>& vecData );
void EvaluateChanGainMes ( unsigned int iPos, const CVector<uint8_t>& vecData );
void EvaluateConClientListMes ( unsigned int iPos, const CVector<uint8_t>& vecData );
int iOldRecID, iOldRecCnt;
@ -153,6 +156,7 @@ signals:
void ChangeChanGain ( int iChanID, double dNewGain );
void ConClientListMesReceived ( CVector<CChannelShortInfo> vecChanInfo );
void ReqJittBufSize();
void ServerFull();
};

View File

@ -85,9 +85,9 @@ void CServer::Stop()
void CServer::OnTimer()
{
CVector<int> vecChanID;
CVector<CVector<double> > vecvecdData ( MIN_BLOCK_SIZE_SAMPLES );
CVector<double> vecdGains;
CVector<int> vecChanID;
CVector<CVector<double> > vecvecdData ( MIN_BLOCK_SIZE_SAMPLES );
CVector<double> vecdGains;
/* get data from all connected clients */
ChannelSet.GetBlockAllConC ( vecChanID, vecvecdData, vecdGains );
@ -97,15 +97,14 @@ void CServer::OnTimer()
one client is connected */
if ( iNumClients != 0 )
{
// TODO generate a sparate mix for each channel
/* actual processing of audio data -> mix */
vecsSendData = ProcessData ( vecvecdData, vecdGains );
/* send the same data to all connected clients */
for ( int i = 0; i < iNumClients; i++ )
{
// TODO generate a sparate mix for each channel
// actual processing of audio data -> mix
vecsSendData = ProcessData ( vecvecdData, vecdGains );
// send separate mix to current clients
Socket.SendPacket (
ChannelSet.PrepSendPacket ( vecChanID[i], vecsSendData ),
ChannelSet.GetAddress ( vecChanID[i] ) );
@ -139,16 +138,14 @@ void CServer::OnTimer()
}
CVector<short> CServer::ProcessData ( CVector<CVector<double> >& vecvecdData,
CVector<double>& vecdGains )
CVector<double>& vecdGains )
{
CVector<short> vecsOutData;
vecsOutData.Init ( MIN_BLOCK_SIZE_SAMPLES );
CVector<short> vecsOutData ( MIN_BLOCK_SIZE_SAMPLES );
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 );
// 3 dB offset to avoid overload if all clients are set to gain 1
const double dNorm = (double) 2.0;
/* mix all audio data from all clients together */
for ( int i = 0; i < MIN_BLOCK_SIZE_SAMPLES; i++ )