some more work
This commit is contained in:
parent
31efe7e92d
commit
6768e0ebf9
6 changed files with 36 additions and 45 deletions
|
@ -25,18 +25,14 @@
|
||||||
#include "channel.h"
|
#include "channel.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* Implementation *************************************************************/
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************\
|
|
||||||
* CChannel *
|
|
||||||
\******************************************************************************/
|
|
||||||
CChannel::CChannel ( const bool bNIsServer ) :
|
CChannel::CChannel ( const bool bNIsServer ) :
|
||||||
bIsServer ( bNIsServer ),
|
bIsServer ( bNIsServer ),
|
||||||
sName ( "" ),
|
sName ( "" ),
|
||||||
vecdGains ( USED_NUM_CHANNELS, (double) 1.0 ),
|
vecdGains ( USED_NUM_CHANNELS, (double) 1.0 ),
|
||||||
bIsEnabled ( false ),
|
bIsEnabled ( false ),
|
||||||
iCurNetwOutBlSiFact ( 0 )
|
iCurNetwFrameSizeFactOut ( 0 ),
|
||||||
|
iCurNetwFrameSizeOut ( 0 )
|
||||||
{
|
{
|
||||||
// init network input properties
|
// init network input properties
|
||||||
NetwBufferInProps.iAudioBlockSize = 0;
|
NetwBufferInProps.iAudioBlockSize = 0;
|
||||||
|
@ -374,6 +370,11 @@ EPutDataStat CChannel::PutData ( const CVector<uint8_t>& vecbyData,
|
||||||
{
|
{
|
||||||
Mutex.lock();
|
Mutex.lock();
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
// TODO only process data if network properties protocol message has been arrived
|
||||||
|
|
||||||
|
|
||||||
// only process audio if packet has correct size
|
// only process audio if packet has correct size
|
||||||
if ( iNumBytes == NetwBufferInProps.iNetwInBufSize )
|
if ( iNumBytes == NetwBufferInProps.iNetwInBufSize )
|
||||||
{
|
{
|
||||||
|
@ -500,8 +501,6 @@ CVector<uint8_t> CChannel::PrepSendPacket ( const CVector<short>& vecsNPacket )
|
||||||
// tell the following network send routine that nothing should be sent
|
// tell the following network send routine that nothing should be sent
|
||||||
CVector<uint8_t> vecbySendBuf ( 0 );
|
CVector<uint8_t> vecbySendBuf ( 0 );
|
||||||
|
|
||||||
if ( bIsServer )
|
|
||||||
{
|
|
||||||
// use conversion buffer to convert sound card block size in network
|
// use conversion buffer to convert sound card block size in network
|
||||||
// block size
|
// block size
|
||||||
if ( ConvBuf.Put ( vecsNPacket ) )
|
if ( ConvBuf.Put ( vecsNPacket ) )
|
||||||
|
@ -510,13 +509,6 @@ CVector<uint8_t> CChannel::PrepSendPacket ( const CVector<short>& vecsNPacket )
|
||||||
vecbySendBuf.Init ( iAudComprSizeOut );
|
vecbySendBuf.Init ( iAudComprSizeOut );
|
||||||
// vecbySendBuf = AudioCompressionOut.Encode ( ConvBuf.Get() );
|
// vecbySendBuf = AudioCompressionOut.Encode ( ConvBuf.Get() );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// a packet is ready, compress audio
|
|
||||||
vecbySendBuf.Init ( iAudComprSizeOut );
|
|
||||||
// vecbySendBuf = AudioCompressionOut.Encode ( vecsNPacket );
|
|
||||||
}
|
|
||||||
|
|
||||||
return vecbySendBuf;
|
return vecbySendBuf;
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,13 +91,16 @@ public:
|
||||||
bool SetSockBufSize ( const int iNumBlocks );
|
bool SetSockBufSize ( const int iNumBlocks );
|
||||||
int GetSockBufSize() const { return iCurSockBufSize; }
|
int GetSockBufSize() const { return iCurSockBufSize; }
|
||||||
|
|
||||||
int GetAudioBlockSizeIn() { return NetwBufferInProps.iAudioBlockSize; }
|
|
||||||
int GetUploadRateKbps();
|
int GetUploadRateKbps();
|
||||||
|
|
||||||
double GetTimingStdDev() { return CycleTimeVariance.GetStdDev(); }
|
double GetTimingStdDev() { return CycleTimeVariance.GetStdDev(); }
|
||||||
|
|
||||||
void SetNetwBufSizeFactOut ( const int iNewNetwBlSiFactOut );
|
// set/get network out buffer size and size factor
|
||||||
int GetNetwBufSizeFactOut() const { return iCurNetwOutBlSiFact; }
|
void SetNetwFrameSizeAndFactOut ( const int iNewNetwFrameSizeOut,
|
||||||
|
const int iNewNetwFrameSizeFactOut );
|
||||||
|
int GetNetwFrameSizeFactOut() const { return iCurNetwFrameSizeFactOut; }
|
||||||
|
int GetNetwFrameSizeOut() const { return iCurNetwFrameSizeOut; }
|
||||||
|
|
||||||
|
|
||||||
// network protocol interface
|
// network protocol interface
|
||||||
void CreateJitBufMes ( const int iJitBufSize )
|
void CreateJitBufMes ( const int iJitBufSize )
|
||||||
|
@ -131,9 +134,6 @@ public:
|
||||||
protected:
|
protected:
|
||||||
bool ProtocolIsEnabled();
|
bool ProtocolIsEnabled();
|
||||||
|
|
||||||
// audio compression
|
|
||||||
int iAudComprSizeOut;
|
|
||||||
|
|
||||||
// connection parameters
|
// connection parameters
|
||||||
CHostAddress InetAddr;
|
CHostAddress InetAddr;
|
||||||
|
|
||||||
|
@ -161,14 +161,15 @@ protected:
|
||||||
bool bIsEnabled;
|
bool bIsEnabled;
|
||||||
bool bIsServer;
|
bool bIsServer;
|
||||||
|
|
||||||
int iCurNetwOutBlSiFact;
|
int iCurNetwFrameSizeFactOut;
|
||||||
|
int iCurNetwFrameSizeOut;
|
||||||
|
|
||||||
QMutex Mutex;
|
QMutex Mutex;
|
||||||
|
|
||||||
struct sNetwProperties
|
struct sNetwProperties
|
||||||
{
|
{
|
||||||
int iNetwInBufSize;
|
int iNetwFrameSizeFact;
|
||||||
int iAudioBlockSize;
|
int iNetwFrameSize;
|
||||||
};
|
};
|
||||||
sNetwProperties NetwBufferInProps;
|
sNetwProperties NetwBufferInProps;
|
||||||
|
|
||||||
|
|
|
@ -301,12 +301,12 @@ void CClient::Init ( const int iPrefMonoBlockSizeSamIndexAtSndCrdSamRate )
|
||||||
vecsNetwork.Init ( iMonoBlockSizeSam );
|
vecsNetwork.Init ( iMonoBlockSizeSam );
|
||||||
vecbyNetwData.Init ( iCeltNumCodedBytes );
|
vecbyNetwData.Init ( iCeltNumCodedBytes );
|
||||||
|
|
||||||
// the channel works on the audio coded block size
|
// set the channel network properties
|
||||||
|
|
||||||
// TEST right now we only support 128 samples, later 256 and 512, too
|
// TEST right now we only support 128 samples, later 256 and 512, too
|
||||||
Channel.SetNetwBufSizeFactOut ( 1 );
|
Channel.SetNetwFrameSizeAndFactOut ( iCeltNumCodedBytes,
|
||||||
|
1 ); // TEST "1"
|
||||||
|
|
||||||
// Channel.SetNetwBufSizeOut ( iCeltNumCodedBytes );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClient::ProcessAudioData ( CVector<int16_t>& vecsStereoSndCrd )
|
void CClient::ProcessAudioData ( CVector<int16_t>& vecsStereoSndCrd )
|
||||||
|
@ -491,8 +491,7 @@ void CClient::UpdateSocketBufferSize()
|
||||||
// the block sizes do not have this relation, we require to have
|
// the block sizes do not have this relation, we require to have
|
||||||
// a minimum buffer size of the sum of both sizes
|
// a minimum buffer size of the sum of both sizes
|
||||||
const double dAudioBufferDurationMs =
|
const double dAudioBufferDurationMs =
|
||||||
( iMonoBlockSizeSam + Channel.GetAudioBlockSizeIn() ) * 1000 /
|
( 2 * iMonoBlockSizeSam ) * 1000 / SYSTEM_SAMPLE_RATE;
|
||||||
SYSTEM_SAMPLE_RATE;
|
|
||||||
|
|
||||||
// accumulate the standard deviations of input network stream and
|
// accumulate the standard deviations of input network stream and
|
||||||
// internal timer,
|
// internal timer,
|
||||||
|
|
|
@ -109,7 +109,6 @@ public:
|
||||||
}
|
}
|
||||||
int GetSockBufSize() { return Channel.GetSockBufSize(); }
|
int GetSockBufSize() { return Channel.GetSockBufSize(); }
|
||||||
|
|
||||||
int GetAudioBlockSizeIn() { return Channel.GetAudioBlockSizeIn(); }
|
|
||||||
int GetUploadRateKbps() { return Channel.GetUploadRateKbps(); }
|
int GetUploadRateKbps() { return Channel.GetUploadRateKbps(); }
|
||||||
|
|
||||||
int GetSndCrdNumDev() { return Sound.GetNumDev(); }
|
int GetSndCrdNumDev() { return Sound.GetNumDev(); }
|
||||||
|
|
|
@ -566,7 +566,7 @@ bAudioOK = true;
|
||||||
void CServer::GetConCliParam ( CVector<CHostAddress>& vecHostAddresses,
|
void CServer::GetConCliParam ( CVector<CHostAddress>& vecHostAddresses,
|
||||||
CVector<QString>& vecsName,
|
CVector<QString>& vecsName,
|
||||||
CVector<int>& veciJitBufSize,
|
CVector<int>& veciJitBufSize,
|
||||||
CVector<int>& veciNetwOutBlSiFact )
|
CVector<int>& veciNetwFrameSizeFactOut )
|
||||||
{
|
{
|
||||||
CHostAddress InetAddr;
|
CHostAddress InetAddr;
|
||||||
|
|
||||||
|
@ -574,7 +574,7 @@ void CServer::GetConCliParam ( CVector<CHostAddress>& vecHostAddresses,
|
||||||
vecHostAddresses.Init ( USED_NUM_CHANNELS );
|
vecHostAddresses.Init ( USED_NUM_CHANNELS );
|
||||||
vecsName.Init ( USED_NUM_CHANNELS );
|
vecsName.Init ( USED_NUM_CHANNELS );
|
||||||
veciJitBufSize.Init ( USED_NUM_CHANNELS );
|
veciJitBufSize.Init ( USED_NUM_CHANNELS );
|
||||||
veciNetwOutBlSiFact.Init ( USED_NUM_CHANNELS );
|
veciNetwFrameSizeFactOut.Init ( USED_NUM_CHANNELS );
|
||||||
|
|
||||||
// check all possible channels
|
// check all possible channels
|
||||||
for ( int i = 0; i < USED_NUM_CHANNELS; i++ )
|
for ( int i = 0; i < USED_NUM_CHANNELS; i++ )
|
||||||
|
@ -585,7 +585,7 @@ void CServer::GetConCliParam ( CVector<CHostAddress>& vecHostAddresses,
|
||||||
vecHostAddresses[i] = InetAddr;
|
vecHostAddresses[i] = InetAddr;
|
||||||
vecsName[i] = vecChannels[i].GetName();
|
vecsName[i] = vecChannels[i].GetName();
|
||||||
veciJitBufSize[i] = vecChannels[i].GetSockBufSize();
|
veciJitBufSize[i] = vecChannels[i].GetSockBufSize();
|
||||||
veciNetwOutBlSiFact[i] = vecChannels[i].GetNetwBufSizeFactOut();
|
veciNetwFrameSizeFactOut[i] = vecChannels[i].GetNetwFrameSizeFactOut();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ public:
|
||||||
void GetConCliParam ( CVector<CHostAddress>& vecHostAddresses,
|
void GetConCliParam ( CVector<CHostAddress>& vecHostAddresses,
|
||||||
CVector<QString>& vecsName,
|
CVector<QString>& vecsName,
|
||||||
CVector<int>& veciJitBufSize,
|
CVector<int>& veciJitBufSize,
|
||||||
CVector<int>& veciNetwOutBlSiFact );
|
CVector<int>& veciNetwFrameSizeFactOut );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// access functions for actual channels
|
// access functions for actual channels
|
||||||
|
|
Loading…
Reference in a new issue