some fixes for protocol
This commit is contained in:
parent
6729eaf7ae
commit
86dd0ecaa3
6 changed files with 90 additions and 60 deletions
|
@ -61,21 +61,16 @@ void CChannelSet::CreateAndSendChanListForAllConClients()
|
||||||
int i;
|
int i;
|
||||||
CVector<CChannelShortInfo> vecChanInfo ( 0 );
|
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;
|
|
||||||
|
|
||||||
// look for free channels
|
// look for free channels
|
||||||
for ( i = 0; i < MAX_NUM_CHANNELS; i++ )
|
for ( i = 0; i < MAX_NUM_CHANNELS; i++ )
|
||||||
{
|
{
|
||||||
if ( vecChannels[i].IsConnected() )
|
if ( vecChannels[i].IsConnected() )
|
||||||
{
|
{
|
||||||
// append channel ID, IP address and channel name to storing vectors
|
// append channel ID, IP address and channel name to storing vectors
|
||||||
CChannelShortInfo ChannelShortInfo (
|
vecChanInfo.Add ( CChannelShortInfo (
|
||||||
i, vecChannels[i].GetAddress().InetAddr.ip4Addr(),
|
i, // ID
|
||||||
vecChannels[i].GetName() );
|
vecChannels[i].GetAddress().InetAddr.ip4Addr(), // IP address
|
||||||
|
vecChannels[i].GetName() /* name */ ) );
|
||||||
vecChanInfo.Add ( ChannelShortInfo );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,6 +155,10 @@ bool CChannelSet::PutData ( const CVector<unsigned char>& vecbyRecBuf,
|
||||||
{
|
{
|
||||||
/* no free channel available */
|
/* no free channel available */
|
||||||
bChanOK = false;
|
bChanOK = false;
|
||||||
|
|
||||||
|
// create and send "server full" message
|
||||||
|
// TODO
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,8 @@
|
||||||
CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent,
|
CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent,
|
||||||
const char* name, bool modal, WFlags f) : pClient ( pNCliP ),
|
const char* name, bool modal, WFlags f) : pClient ( pNCliP ),
|
||||||
CLlconClientDlgBase ( parent, name, modal, f ),
|
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 */
|
/* add help text to controls */
|
||||||
QString strInpLevH = tr("<b>Input level meter:</b> Shows the level of the "
|
QString strInpLevH = tr("<b>Input level meter:</b> Shows the level of the "
|
||||||
|
@ -171,14 +172,10 @@ CLlconClientDlg::CLlconClientDlg ( CClient* pNCliP, QWidget* parent,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TEST
|
// TEST
|
||||||
//new CLlconClientDlg::CChannelFader(FrameAudioFaders, FrameAudioFadersLayout);
|
//vecpChanFader.Init(0);
|
||||||
//new CLlconClientDlg::CChannelFader(FrameAudioFaders, FrameAudioFadersLayout);
|
//vecpChanFader.Add(new CLlconClientDlg::CChannelFader(FrameAudioFaders, FrameAudioFadersLayout, "test"));
|
||||||
//new CLlconClientDlg::CChannelFader(FrameAudioFaders, FrameAudioFadersLayout);
|
|
||||||
//new CLlconClientDlg::CChannelFader(FrameAudioFaders, FrameAudioFadersLayout, "test");
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
for ( int z = 0; z < 100; z++)
|
for ( int z = 0; z < 100; z++)
|
||||||
|
@ -188,6 +185,7 @@ delete pTest;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CLlconClientDlg::~CLlconClientDlg()
|
CLlconClientDlg::~CLlconClientDlg()
|
||||||
|
@ -292,20 +290,29 @@ void CLlconClientDlg::OnTimerSigMet ()
|
||||||
|
|
||||||
void CLlconClientDlg::OnConClientListMesReceived ( CVector<CChannelShortInfo> vecChanInfo )
|
void CLlconClientDlg::OnConClientListMesReceived ( CVector<CChannelShortInfo> vecChanInfo )
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
// TEST
|
// remove old controls
|
||||||
for ( int i = 0; i < vecChanInfo.Size(); i++ )
|
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 );
|
QHostAddress addrTest ( vecChanInfo[i].veciIpAddr );
|
||||||
|
|
||||||
new CLlconClientDlg::CChannelFader ( FrameAudioFaders,
|
vecpChanFader[i] = new CLlconClientDlg::CChannelFader ( FrameAudioFaders,
|
||||||
FrameAudioFadersLayout, addrTest.toString() );
|
FrameAudioFadersLayout, addrTest.toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLlconClientDlg::UpdateDisplay()
|
void CLlconClientDlg::UpdateDisplay()
|
||||||
|
@ -370,8 +377,10 @@ CLlconClientDlg::CChannelFader::CChannelFader ( QWidget* pNW,
|
||||||
pFader->setRange ( 0, AUD_MIX_FADER_MAX );
|
pFader->setRange ( 0, AUD_MIX_FADER_MAX );
|
||||||
pFader->setTickInterval ( AUD_MIX_FADER_MAX / 9 );
|
pFader->setTickInterval ( AUD_MIX_FADER_MAX / 9 );
|
||||||
|
|
||||||
// TEST set value
|
// TEST set value and make read only
|
||||||
pFader->setValue ( 0 );
|
pFader->setValue ( 0 );
|
||||||
|
pFader->setEnabled ( FALSE );
|
||||||
|
|
||||||
|
|
||||||
// add label to grid
|
// add label to grid
|
||||||
pMainGrid->addWidget( pLabel, 1, 0 );
|
pMainGrid->addWidget( pLabel, 1, 0 );
|
||||||
|
|
|
@ -107,7 +107,7 @@ protected:
|
||||||
|
|
||||||
CClientSettingsDlg ClientSettingsDlg;
|
CClientSettingsDlg ClientSettingsDlg;
|
||||||
|
|
||||||
CVector<CChannelFader> vecpChanFader;
|
CVector<CChannelFader*> vecpChanFader;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void OnConnectDisconBut();
|
void OnConnectDisconBut();
|
||||||
|
|
|
@ -49,6 +49,11 @@ MESSAGES
|
||||||
|
|
||||||
note: does not have any data -> n = 0
|
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
|
- Network buffer block size factor PROTMESSID_NET_BLSI_FACTOR
|
||||||
|
|
||||||
note: size, relative to minimum block size
|
note: size, relative to minimum block size
|
||||||
|
@ -309,6 +314,11 @@ for ( int i = 0; i < iNumBytes; i++ ) {
|
||||||
EvaluateReqJitBufMes ( iPos, vecData );
|
EvaluateReqJitBufMes ( iPos, vecData );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PROTMESSID_SERVER_FULL:
|
||||||
|
|
||||||
|
EvaluateServerFullMes ( iPos, vecData );
|
||||||
|
break;
|
||||||
|
|
||||||
case PROTMESSID_NET_BLSI_FACTOR:
|
case PROTMESSID_NET_BLSI_FACTOR:
|
||||||
|
|
||||||
EvaluateNetwBlSiFactMes ( iPos, vecData );
|
EvaluateNetwBlSiFactMes ( iPos, vecData );
|
||||||
|
@ -378,6 +388,17 @@ void CProtocol::EvaluateReqJitBufMes ( unsigned int iPos, const CVector<uint8_t>
|
||||||
emit ReqJittBufSize();
|
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 )
|
void CProtocol::CreateNetwBlSiFactMes ( const int iNetwBlSiFact )
|
||||||
{
|
{
|
||||||
CVector<uint8_t> vecData ( 2 ); // 2 bytes of data
|
CVector<uint8_t> vecData ( 2 ); // 2 bytes of data
|
||||||
|
|
|
@ -39,10 +39,11 @@
|
||||||
#define PROTMESSID_ACKN 1 // acknowledge
|
#define PROTMESSID_ACKN 1 // acknowledge
|
||||||
#define PROTMESSID_JITT_BUF_SIZE 10 // jitter buffer size
|
#define PROTMESSID_JITT_BUF_SIZE 10 // jitter buffer size
|
||||||
#define PROTMESSID_REQ_JITT_BUF_SIZE 11 // request jitter buffer size
|
#define PROTMESSID_REQ_JITT_BUF_SIZE 11 // request jitter buffer size
|
||||||
#define PROTMESSID_PING 12 // for measuring ping time
|
#define PROTMESSID_SERVER_FULL 12
|
||||||
#define PROTMESSID_NET_BLSI_FACTOR 13 // network buffer size factor
|
#define PROTMESSID_PING 13 // for measuring ping time
|
||||||
#define PROTMESSID_CHANNEL_GAIN 14 // set channel gain for mix
|
#define PROTMESSID_NET_BLSI_FACTOR 14 // network buffer size factor
|
||||||
#define PROTMESSID_CONN_CLIENTS_LIST 15 // connected client list
|
#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
|
// lengths of message as defined in protocol.cpp file
|
||||||
#define MESS_HEADER_LENGTH_BYTE 5 /* ID, cnt, length */
|
#define MESS_HEADER_LENGTH_BYTE 5 /* ID, cnt, length */
|
||||||
|
@ -62,6 +63,7 @@ public:
|
||||||
|
|
||||||
void CreateJitBufMes ( const int iJitBufSize );
|
void CreateJitBufMes ( const int iJitBufSize );
|
||||||
void CreateReqJitBufMes();
|
void CreateReqJitBufMes();
|
||||||
|
void CreateServerFullMes();
|
||||||
void CreateNetwBlSiFactMes ( const int iNetwBlSiFact );
|
void CreateNetwBlSiFactMes ( const int iNetwBlSiFact );
|
||||||
void CreateChanGainMes ( const int iChanID, const double dGain );
|
void CreateChanGainMes ( const int iChanID, const double dGain );
|
||||||
|
|
||||||
|
@ -127,6 +129,7 @@ protected:
|
||||||
|
|
||||||
void EvaluateJitBufMes ( 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 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 EvaluateNetwBlSiFactMes ( unsigned int iPos, const CVector<uint8_t>& vecData );
|
||||||
void EvaluateChanGainMes ( 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 );
|
void EvaluateConClientListMes ( unsigned int iPos, const CVector<uint8_t>& vecData );
|
||||||
|
@ -153,6 +156,7 @@ signals:
|
||||||
void ChangeChanGain ( int iChanID, double dNewGain );
|
void ChangeChanGain ( int iChanID, double dNewGain );
|
||||||
void ConClientListMesReceived ( CVector<CChannelShortInfo> vecChanInfo );
|
void ConClientListMesReceived ( CVector<CChannelShortInfo> vecChanInfo );
|
||||||
void ReqJittBufSize();
|
void ReqJittBufSize();
|
||||||
|
void ServerFull();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -97,15 +97,14 @@ void CServer::OnTimer()
|
||||||
one client is connected */
|
one client is connected */
|
||||||
if ( iNumClients != 0 )
|
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++ )
|
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 (
|
Socket.SendPacket (
|
||||||
ChannelSet.PrepSendPacket ( vecChanID[i], vecsSendData ),
|
ChannelSet.PrepSendPacket ( vecChanID[i], vecsSendData ),
|
||||||
ChannelSet.GetAddress ( vecChanID[i] ) );
|
ChannelSet.GetAddress ( vecChanID[i] ) );
|
||||||
|
@ -141,14 +140,12 @@ void CServer::OnTimer()
|
||||||
CVector<short> CServer::ProcessData ( CVector<CVector<double> >& vecvecdData,
|
CVector<short> CServer::ProcessData ( CVector<CVector<double> >& vecvecdData,
|
||||||
CVector<double>& vecdGains )
|
CVector<double>& vecdGains )
|
||||||
{
|
{
|
||||||
CVector<short> vecsOutData;
|
CVector<short> vecsOutData ( MIN_BLOCK_SIZE_SAMPLES );
|
||||||
vecsOutData.Init ( MIN_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
|
// 3 dB offset to avoid overload if all clients are set to gain 1
|
||||||
in case that a new client connects */
|
const double dNorm = (double) 2.0;
|
||||||
const double dNorm = sqrt ( (double) iNumClients );
|
|
||||||
|
|
||||||
/* mix all audio data from all clients together */
|
/* mix all audio data from all clients together */
|
||||||
for ( int i = 0; i < MIN_BLOCK_SIZE_SAMPLES; i++ )
|
for ( int i = 0; i < MIN_BLOCK_SIZE_SAMPLES; i++ )
|
||||||
|
|
Loading…
Reference in a new issue