some more work

This commit is contained in:
Volker Fischer 2009-07-28 07:17:04 +00:00
parent 31efe7e92d
commit 6768e0ebf9
6 changed files with 36 additions and 45 deletions

View file

@ -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,22 +501,13 @@ 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
{ // block size
// use conversion buffer to convert sound card block size in network if ( ConvBuf.Put ( vecsNPacket ) )
// block size
if ( ConvBuf.Put ( vecsNPacket ) )
{
// a packet is ready, compress audio
vecbySendBuf.Init ( iAudComprSizeOut );
// vecbySendBuf = AudioCompressionOut.Encode ( ConvBuf.Get() );
}
}
else
{ {
// a packet is ready, compress audio // a packet is ready, compress audio
vecbySendBuf.Init ( iAudComprSizeOut ); vecbySendBuf.Init ( iAudComprSizeOut );
// vecbySendBuf = AudioCompressionOut.Encode ( vecsNPacket ); // vecbySendBuf = AudioCompressionOut.Encode ( ConvBuf.Get() );
} }
return vecbySendBuf; return vecbySendBuf;

View file

@ -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;

View file

@ -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,

View file

@ -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(); }

View file

@ -566,15 +566,15 @@ 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;
// init return values // init return values
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++ )
@ -582,10 +582,10 @@ void CServer::GetConCliParam ( CVector<CHostAddress>& vecHostAddresses,
if ( vecChannels[i].GetAddress ( InetAddr ) ) if ( vecChannels[i].GetAddress ( InetAddr ) )
{ {
// get requested data // get requested data
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();
} }
} }
} }

View file

@ -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