some more work for the server
This commit is contained in:
parent
5d8d6eecb2
commit
bfbda9eb73
4 changed files with 43 additions and 74 deletions
|
@ -286,9 +286,6 @@ void CChannel::OnNetTranspPropsReceived ( CNetworkTransportProps NetworkTranspor
|
||||||
// update socket buffer (the network block size is a multiple of the
|
// update socket buffer (the network block size is a multiple of the
|
||||||
// minimum network frame size
|
// minimum network frame size
|
||||||
SockBuf.Init ( iNetwFrameSize, iCurSockBufNumFrames );
|
SockBuf.Init ( iNetwFrameSize, iCurSockBufNumFrames );
|
||||||
|
|
||||||
// fire message
|
|
||||||
emit NetwFrameSizeHasChanged ( iNetwFrameSize );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -182,7 +182,6 @@ signals:
|
||||||
void ReqConnClientsList();
|
void ReqConnClientsList();
|
||||||
void ConClientListMesReceived ( CVector<CChannelShortInfo> vecChanInfo );
|
void ConClientListMesReceived ( CVector<CChannelShortInfo> vecChanInfo );
|
||||||
void NameHasChanged();
|
void NameHasChanged();
|
||||||
void NetwFrameSizeHasChanged ( int iNewFrameSize );
|
|
||||||
void ChatTextReceived ( QString strChatText );
|
void ChatTextReceived ( QString strChatText );
|
||||||
void PingReceived ( int iMs );
|
void PingReceived ( int iMs );
|
||||||
void ReqNetTranspProps();
|
void ReqNetTranspProps();
|
||||||
|
|
|
@ -305,11 +305,11 @@ void CServer::Stop()
|
||||||
void CServer::OnTimer()
|
void CServer::OnTimer()
|
||||||
{
|
{
|
||||||
CVector<int> vecChanID;
|
CVector<int> vecChanID;
|
||||||
CVector<CVector<double> > vecvecdData ( SYSTEM_BLOCK_FRAME_SAMPLES );
|
CVector<CVector<int16_t> > vecvecsData;
|
||||||
CVector<CVector<double> > vecvecdGains;
|
CVector<CVector<double> > vecvecdGains;
|
||||||
|
|
||||||
// get data from all connected clients
|
// get data from all connected clients
|
||||||
GetBlockAllConC ( vecChanID, vecvecdData, vecvecdGains );
|
GetBlockAllConC ( vecChanID, vecvecsData, vecvecdGains );
|
||||||
const int iNumClients = vecChanID.Size();
|
const int iNumClients = vecChanID.Size();
|
||||||
|
|
||||||
// Check if at least one client is connected. If not, stop server until
|
// Check if at least one client is connected. If not, stop server until
|
||||||
|
@ -318,32 +318,9 @@ void CServer::OnTimer()
|
||||||
{
|
{
|
||||||
for ( int i = 0; i < iNumClients; i++ )
|
for ( int i = 0; i < iNumClients; i++ )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
// TEST CELT
|
|
||||||
CVector<short> vecsAudioSndCrdMono ( iMonoBlockSizeSam );
|
|
||||||
|
|
||||||
celt_decode ( CeltDecoder,
|
|
||||||
&vecbyNetwData[0],
|
|
||||||
iCeltNumCodedBytes,
|
|
||||||
&vecsAudioSndCrdMono[0] );
|
|
||||||
|
|
||||||
for ( i = 0, j = 0; i < iMonoBlockSizeSam; i++, j += 2 )
|
|
||||||
{
|
|
||||||
vecsStereoSndCrd[j] = vecsStereoSndCrd[j + 1] =
|
|
||||||
vecsAudioSndCrdMono[i];
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
// TODO first ALL channels must be decoded before process data can
|
|
||||||
// be called!!!
|
|
||||||
|
|
||||||
|
|
||||||
// generate a sparate mix for each channel
|
// generate a sparate mix for each channel
|
||||||
// actual processing of audio data -> mix
|
// actual processing of audio data -> mix
|
||||||
vecsSendData = ProcessData ( vecvecdData, vecvecdGains[i] );
|
vecsSendData = ProcessData ( vecvecsData, vecvecdGains[i] );
|
||||||
|
|
||||||
// send separate mix to current clients
|
// send separate mix to current clients
|
||||||
// Socket.SendPacket (
|
// Socket.SendPacket (
|
||||||
|
@ -351,6 +328,11 @@ for ( i = 0, j = 0; i < iMonoBlockSizeSam; i++, j += 2 )
|
||||||
// GetAddress ( vecChanID[i] ) );
|
// GetAddress ( vecChanID[i] ) );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
// get current number of CELT coded bytes
|
||||||
|
const int iCeltNumCodedBytes =
|
||||||
|
vecChannels[i].GetNetwFrameSize() /
|
||||||
|
vecChannels[i].GetNetwFrameSizeFact();
|
||||||
|
|
||||||
celt_encode ( CeltEncoder,
|
celt_encode ( CeltEncoder,
|
||||||
&vecsNetwork[0],
|
&vecsNetwork[0],
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -374,17 +356,14 @@ Socket.SendPacket ( vecCeltData, Channel.GetAddress() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CServer::GetBlockAllConC ( CVector<int>& vecChanID,
|
void CServer::GetBlockAllConC ( CVector<int>& vecChanID,
|
||||||
CVector<CVector<double> >& vecvecdData,
|
CVector<CVector<int16_t> >& vecvecsData,
|
||||||
CVector<CVector<double> >& vecvecdGains )
|
CVector<CVector<double> >& vecvecdGains )
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
bool bChannelIsNowDisconnected = false;
|
bool bChannelIsNowDisconnected = false;
|
||||||
|
|
||||||
// init temporal data vector and clear input buffers
|
|
||||||
CVector<double> vecdData ( SYSTEM_BLOCK_FRAME_SAMPLES );
|
|
||||||
|
|
||||||
vecChanID.Init ( 0 );
|
vecChanID.Init ( 0 );
|
||||||
vecvecdData.Init ( 0 );
|
vecvecsData.Init ( 0 );
|
||||||
vecvecdGains.Init ( 0 );
|
vecvecdGains.Init ( 0 );
|
||||||
|
|
||||||
// make put and get calls thread safe. Do not forget to unlock mutex
|
// make put and get calls thread safe. Do not forget to unlock mutex
|
||||||
|
@ -394,31 +373,25 @@ void CServer::GetBlockAllConC ( CVector<int>& vecChanID,
|
||||||
// check all possible channels
|
// check all possible channels
|
||||||
for ( i = 0; i < USED_NUM_CHANNELS; i++ )
|
for ( i = 0; i < USED_NUM_CHANNELS; i++ )
|
||||||
{
|
{
|
||||||
|
// get current number of CELT coded bytes
|
||||||
|
const int iCeltNumCodedBytes =
|
||||||
|
vecChannels[i].GetNetwFrameSize() /
|
||||||
|
vecChannels[i].GetNetwFrameSizeFact();
|
||||||
|
|
||||||
|
// init temporal data vector and clear input buffers
|
||||||
|
CVector<uint8_t> vecbyData ( iCeltNumCodedBytes );
|
||||||
|
|
||||||
// read out all input buffers to decrease timeout counter on
|
// read out all input buffers to decrease timeout counter on
|
||||||
// disconnected channels
|
// disconnected channels
|
||||||
// const EGetDataStat eGetStat = vecChannels[i].GetData ( vecdData );
|
const EGetDataStat eGetStat = vecChannels[i].GetData ( vecbyData );
|
||||||
|
|
||||||
const EGetDataStat eGetStat=GS_BUFFER_OK;//TEST
|
// CELT decode received data stream
|
||||||
|
CVector<int16_t> vecsAudioMono ( SYSTEM_BLOCK_FRAME_SAMPLES );
|
||||||
|
|
||||||
// TEST
|
celt_decode ( CeltDecoder[i],
|
||||||
/*
|
&vecbyData[0],
|
||||||
// TEST CELT
|
|
||||||
CVector<short> vecsAudioSndCrdMono ( iMonoBlockSizeSam );
|
|
||||||
|
|
||||||
celt_decode ( CeltDecoder,
|
|
||||||
&vecbyNetwData[0],
|
|
||||||
iCeltNumCodedBytes,
|
iCeltNumCodedBytes,
|
||||||
&vecsAudioSndCrdMono[0] );
|
&vecsAudioMono[0] );
|
||||||
|
|
||||||
for ( i = 0, j = 0; i < iMonoBlockSizeSam; i++, j += 2 )
|
|
||||||
{
|
|
||||||
vecsStereoSndCrd[j] = vecsStereoSndCrd[j + 1] =
|
|
||||||
vecsAudioSndCrdMono[i];
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// if channel was just disconnected, set flag that connected
|
// if channel was just disconnected, set flag that connected
|
||||||
// client list is sent to all other clients
|
// client list is sent to all other clients
|
||||||
|
@ -432,10 +405,10 @@ for ( i = 0, j = 0; i < iMonoBlockSizeSam; i++, j += 2 )
|
||||||
// add ID and data
|
// add ID and data
|
||||||
vecChanID.Add ( i );
|
vecChanID.Add ( i );
|
||||||
|
|
||||||
const int iOldSize = vecvecdData.Size();
|
const int iOldSize = vecvecsData.Size();
|
||||||
vecvecdData.Enlarge ( 1 );
|
vecvecsData.Enlarge ( 1 );
|
||||||
vecvecdData[iOldSize].Init ( vecdData.Size() );
|
vecvecsData[iOldSize].Init ( vecsAudioMono.Size() );
|
||||||
vecvecdData[iOldSize] = vecdData;
|
vecvecsData[iOldSize] = vecsAudioMono;
|
||||||
|
|
||||||
// send message for get status (for GUI)
|
// send message for get status (for GUI)
|
||||||
if ( eGetStat == GS_BUFFER_OK )
|
if ( eGetStat == GS_BUFFER_OK )
|
||||||
|
@ -824,15 +797,15 @@ void CServer::WriteHTMLChannelList()
|
||||||
streamFileOut << "</ul>" << endl;
|
streamFileOut << "</ul>" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
CVector<short> CServer::ProcessData ( CVector<CVector<double> >& vecvecdData,
|
CVector<int16_t> CServer::ProcessData ( CVector<CVector<int16_t> >& vecvecsData,
|
||||||
CVector<double>& vecdGains )
|
CVector<double>& vecdGains )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
// init return vector with zeros since we mix all channels on that vector
|
// init return vector with zeros since we mix all channels on that vector
|
||||||
CVector<short> vecsOutData ( SYSTEM_BLOCK_FRAME_SAMPLES, 0 );
|
CVector<int16_t> vecsOutData ( SYSTEM_BLOCK_FRAME_SAMPLES, 0 );
|
||||||
|
|
||||||
const int iNumClients = vecvecdData.Size();
|
const int iNumClients = vecvecsData.Size();
|
||||||
|
|
||||||
// mix all audio data from all clients together
|
// mix all audio data from all clients together
|
||||||
for ( int j = 0; j < iNumClients; j++ )
|
for ( int j = 0; j < iNumClients; j++ )
|
||||||
|
@ -843,7 +816,7 @@ CVector<short> CServer::ProcessData ( CVector<CVector<double> >& vecvecdData,
|
||||||
for ( i = 0; i < SYSTEM_BLOCK_FRAME_SAMPLES; i++ )
|
for ( i = 0; i < SYSTEM_BLOCK_FRAME_SAMPLES; i++ )
|
||||||
{
|
{
|
||||||
vecsOutData[i] =
|
vecsOutData[i] =
|
||||||
Double2Short ( vecsOutData[i] + vecvecdData[j][i] );
|
Double2Short ( vecsOutData[i] + vecvecsData[j][i] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -852,7 +825,7 @@ CVector<short> CServer::ProcessData ( CVector<CVector<double> >& vecvecdData,
|
||||||
{
|
{
|
||||||
vecsOutData[i] =
|
vecsOutData[i] =
|
||||||
Double2Short ( vecsOutData[i] +
|
Double2Short ( vecsOutData[i] +
|
||||||
vecvecdData[j][i] * vecdGains[j] );
|
vecvecsData[j][i] * vecdGains[j] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,7 +113,7 @@ protected:
|
||||||
const QString& strNewServerNameWithPort );
|
const QString& strNewServerNameWithPort );
|
||||||
|
|
||||||
void GetBlockAllConC ( CVector<int>& vecChanID,
|
void GetBlockAllConC ( CVector<int>& vecChanID,
|
||||||
CVector<CVector<double> >& vecvecdData,
|
CVector<CVector<int16_t> >& vecvecsData,
|
||||||
CVector<CVector<double> >& vecvecdGains );
|
CVector<CVector<double> >& vecvecdGains );
|
||||||
|
|
||||||
int CheckAddr ( const CHostAddress& Addr );
|
int CheckAddr ( const CHostAddress& Addr );
|
||||||
|
@ -125,7 +125,7 @@ protected:
|
||||||
void CreateAndSendChatTextForAllConChannels ( const int iCurChanID, const QString& strChatText );
|
void CreateAndSendChatTextForAllConChannels ( const int iCurChanID, const QString& strChatText );
|
||||||
void WriteHTMLChannelList();
|
void WriteHTMLChannelList();
|
||||||
|
|
||||||
CVector<short> ProcessData ( CVector<CVector<double> >& vecvecdData,
|
CVector<int16_t> ProcessData ( CVector<CVector<int16_t> >& vecvecsData,
|
||||||
CVector<double>& vecdGains );
|
CVector<double>& vecdGains );
|
||||||
|
|
||||||
virtual void customEvent ( QEvent* Event );
|
virtual void customEvent ( QEvent* Event );
|
||||||
|
|
Loading…
Reference in a new issue