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"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/******************************************************************************\
|
||||
* CChannel *
|
||||
\******************************************************************************/
|
||||
/* Implementation *************************************************************/
|
||||
CChannel::CChannel ( const bool bNIsServer ) :
|
||||
bIsServer ( bNIsServer ),
|
||||
sName ( "" ),
|
||||
vecdGains ( USED_NUM_CHANNELS, (double) 1.0 ),
|
||||
bIsEnabled ( false ),
|
||||
iCurNetwOutBlSiFact ( 0 )
|
||||
iCurNetwFrameSizeFactOut ( 0 ),
|
||||
iCurNetwFrameSizeOut ( 0 )
|
||||
{
|
||||
// init network input properties
|
||||
NetwBufferInProps.iAudioBlockSize = 0;
|
||||
|
@ -374,6 +370,11 @@ EPutDataStat CChannel::PutData ( const CVector<uint8_t>& vecbyData,
|
|||
{
|
||||
Mutex.lock();
|
||||
{
|
||||
|
||||
|
||||
// TODO only process data if network properties protocol message has been arrived
|
||||
|
||||
|
||||
// only process audio if packet has correct size
|
||||
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
|
||||
CVector<uint8_t> vecbySendBuf ( 0 );
|
||||
|
||||
if ( bIsServer )
|
||||
{
|
||||
// use conversion buffer to convert sound card block size in network
|
||||
// block size
|
||||
if ( ConvBuf.Put ( vecsNPacket ) )
|
||||
{
|
||||
// a packet is ready, compress audio
|
||||
vecbySendBuf.Init ( iAudComprSizeOut );
|
||||
// vecbySendBuf = AudioCompressionOut.Encode ( ConvBuf.Get() );
|
||||
}
|
||||
}
|
||||
else
|
||||
// use conversion buffer to convert sound card block size in network
|
||||
// block size
|
||||
if ( ConvBuf.Put ( vecsNPacket ) )
|
||||
{
|
||||
// a packet is ready, compress audio
|
||||
vecbySendBuf.Init ( iAudComprSizeOut );
|
||||
// vecbySendBuf = AudioCompressionOut.Encode ( vecsNPacket );
|
||||
// vecbySendBuf = AudioCompressionOut.Encode ( ConvBuf.Get() );
|
||||
}
|
||||
|
||||
return vecbySendBuf;
|
||||
|
|
|
@ -91,13 +91,16 @@ public:
|
|||
bool SetSockBufSize ( const int iNumBlocks );
|
||||
int GetSockBufSize() const { return iCurSockBufSize; }
|
||||
|
||||
int GetAudioBlockSizeIn() { return NetwBufferInProps.iAudioBlockSize; }
|
||||
int GetUploadRateKbps();
|
||||
|
||||
double GetTimingStdDev() { return CycleTimeVariance.GetStdDev(); }
|
||||
|
||||
void SetNetwBufSizeFactOut ( const int iNewNetwBlSiFactOut );
|
||||
int GetNetwBufSizeFactOut() const { return iCurNetwOutBlSiFact; }
|
||||
// set/get network out buffer size and size factor
|
||||
void SetNetwFrameSizeAndFactOut ( const int iNewNetwFrameSizeOut,
|
||||
const int iNewNetwFrameSizeFactOut );
|
||||
int GetNetwFrameSizeFactOut() const { return iCurNetwFrameSizeFactOut; }
|
||||
int GetNetwFrameSizeOut() const { return iCurNetwFrameSizeOut; }
|
||||
|
||||
|
||||
// network protocol interface
|
||||
void CreateJitBufMes ( const int iJitBufSize )
|
||||
|
@ -131,9 +134,6 @@ public:
|
|||
protected:
|
||||
bool ProtocolIsEnabled();
|
||||
|
||||
// audio compression
|
||||
int iAudComprSizeOut;
|
||||
|
||||
// connection parameters
|
||||
CHostAddress InetAddr;
|
||||
|
||||
|
@ -161,14 +161,15 @@ protected:
|
|||
bool bIsEnabled;
|
||||
bool bIsServer;
|
||||
|
||||
int iCurNetwOutBlSiFact;
|
||||
int iCurNetwFrameSizeFactOut;
|
||||
int iCurNetwFrameSizeOut;
|
||||
|
||||
QMutex Mutex;
|
||||
|
||||
struct sNetwProperties
|
||||
{
|
||||
int iNetwInBufSize;
|
||||
int iAudioBlockSize;
|
||||
int iNetwFrameSizeFact;
|
||||
int iNetwFrameSize;
|
||||
};
|
||||
sNetwProperties NetwBufferInProps;
|
||||
|
||||
|
|
|
@ -301,12 +301,12 @@ void CClient::Init ( const int iPrefMonoBlockSizeSamIndexAtSndCrdSamRate )
|
|||
vecsNetwork.Init ( iMonoBlockSizeSam );
|
||||
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
|
||||
Channel.SetNetwBufSizeFactOut ( 1 );
|
||||
Channel.SetNetwFrameSizeAndFactOut ( iCeltNumCodedBytes,
|
||||
1 ); // TEST "1"
|
||||
|
||||
// Channel.SetNetwBufSizeOut ( iCeltNumCodedBytes );
|
||||
}
|
||||
|
||||
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
|
||||
// a minimum buffer size of the sum of both sizes
|
||||
const double dAudioBufferDurationMs =
|
||||
( iMonoBlockSizeSam + Channel.GetAudioBlockSizeIn() ) * 1000 /
|
||||
SYSTEM_SAMPLE_RATE;
|
||||
( 2 * iMonoBlockSizeSam ) * 1000 / SYSTEM_SAMPLE_RATE;
|
||||
|
||||
// accumulate the standard deviations of input network stream and
|
||||
// internal timer,
|
||||
|
|
|
@ -109,7 +109,6 @@ public:
|
|||
}
|
||||
int GetSockBufSize() { return Channel.GetSockBufSize(); }
|
||||
|
||||
int GetAudioBlockSizeIn() { return Channel.GetAudioBlockSizeIn(); }
|
||||
int GetUploadRateKbps() { return Channel.GetUploadRateKbps(); }
|
||||
|
||||
int GetSndCrdNumDev() { return Sound.GetNumDev(); }
|
||||
|
|
|
@ -566,15 +566,15 @@ bAudioOK = true;
|
|||
void CServer::GetConCliParam ( CVector<CHostAddress>& vecHostAddresses,
|
||||
CVector<QString>& vecsName,
|
||||
CVector<int>& veciJitBufSize,
|
||||
CVector<int>& veciNetwOutBlSiFact )
|
||||
CVector<int>& veciNetwFrameSizeFactOut )
|
||||
{
|
||||
CHostAddress InetAddr;
|
||||
|
||||
// init return values
|
||||
vecHostAddresses.Init ( USED_NUM_CHANNELS );
|
||||
vecsName.Init ( USED_NUM_CHANNELS );
|
||||
veciJitBufSize.Init ( USED_NUM_CHANNELS );
|
||||
veciNetwOutBlSiFact.Init ( USED_NUM_CHANNELS );
|
||||
vecHostAddresses.Init ( USED_NUM_CHANNELS );
|
||||
vecsName.Init ( USED_NUM_CHANNELS );
|
||||
veciJitBufSize.Init ( USED_NUM_CHANNELS );
|
||||
veciNetwFrameSizeFactOut.Init ( USED_NUM_CHANNELS );
|
||||
|
||||
// check all possible channels
|
||||
for ( int i = 0; i < USED_NUM_CHANNELS; i++ )
|
||||
|
@ -582,10 +582,10 @@ void CServer::GetConCliParam ( CVector<CHostAddress>& vecHostAddresses,
|
|||
if ( vecChannels[i].GetAddress ( InetAddr ) )
|
||||
{
|
||||
// get requested data
|
||||
vecHostAddresses[i] = InetAddr;
|
||||
vecsName[i] = vecChannels[i].GetName();
|
||||
veciJitBufSize[i] = vecChannels[i].GetSockBufSize();
|
||||
veciNetwOutBlSiFact[i] = vecChannels[i].GetNetwBufSizeFactOut();
|
||||
vecHostAddresses[i] = InetAddr;
|
||||
vecsName[i] = vecChannels[i].GetName();
|
||||
veciJitBufSize[i] = vecChannels[i].GetSockBufSize();
|
||||
veciNetwFrameSizeFactOut[i] = vecChannels[i].GetNetwFrameSizeFactOut();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ public:
|
|||
void GetConCliParam ( CVector<CHostAddress>& vecHostAddresses,
|
||||
CVector<QString>& vecsName,
|
||||
CVector<int>& veciJitBufSize,
|
||||
CVector<int>& veciNetwOutBlSiFact );
|
||||
CVector<int>& veciNetwFrameSizeFactOut );
|
||||
|
||||
protected:
|
||||
// access functions for actual channels
|
||||
|
|
Loading…
Reference in a new issue