fixes for big block sizes, still not finished
This commit is contained in:
parent
2f794eeee0
commit
3f6cfbbaeb
2 changed files with 56 additions and 38 deletions
|
@ -38,6 +38,15 @@ CClient::CClient ( const quint16 iPortNumber ) :
|
||||||
bDoAutoSockBufSize ( true ),
|
bDoAutoSockBufSize ( true ),
|
||||||
iSndCrdPrefMonoFrameSizeFactor ( FRAME_SIZE_FACTOR_DEFAULT )
|
iSndCrdPrefMonoFrameSizeFactor ( FRAME_SIZE_FACTOR_DEFAULT )
|
||||||
{
|
{
|
||||||
|
// init audio endocder/decoder (mono)
|
||||||
|
CeltMode = celt_mode_create (
|
||||||
|
SYSTEM_SAMPLE_RATE, 1, SYSTEM_BLOCK_FRAME_SAMPLES, NULL );
|
||||||
|
|
||||||
|
CeltEncoder = celt_encoder_create ( CeltMode );
|
||||||
|
CeltDecoder = celt_decoder_create ( CeltMode );
|
||||||
|
|
||||||
|
|
||||||
|
// connections -------------------------------------------------------------
|
||||||
// connection for protocol
|
// connection for protocol
|
||||||
QObject::connect ( &Channel,
|
QObject::connect ( &Channel,
|
||||||
SIGNAL ( MessReadyForSending ( CVector<uint8_t> ) ),
|
SIGNAL ( MessReadyForSending ( CVector<uint8_t> ) ),
|
||||||
|
@ -152,8 +161,6 @@ void CClient::SetSndCrdPrefMonoFrameSizeFactor ( const int iNewFactor )
|
||||||
( iNewFactor == FRAME_SIZE_FACTOR_DEFAULT ) ||
|
( iNewFactor == FRAME_SIZE_FACTOR_DEFAULT ) ||
|
||||||
( iNewFactor == FRAME_SIZE_FACTOR_SAFE ) )
|
( iNewFactor == FRAME_SIZE_FACTOR_SAFE ) )
|
||||||
{
|
{
|
||||||
iSndCrdPrefMonoFrameSizeFactor = iNewFactor;
|
|
||||||
|
|
||||||
// init with new parameter, if client was running then first
|
// init with new parameter, if client was running then first
|
||||||
// stop it and restart again after new initialization
|
// stop it and restart again after new initialization
|
||||||
const bool bWasRunning = Sound.IsRunning();
|
const bool bWasRunning = Sound.IsRunning();
|
||||||
|
@ -162,6 +169,9 @@ void CClient::SetSndCrdPrefMonoFrameSizeFactor ( const int iNewFactor )
|
||||||
Sound.Stop();
|
Sound.Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set new parameter
|
||||||
|
iSndCrdPrefMonoFrameSizeFactor = iNewFactor;
|
||||||
|
|
||||||
// init with new block size index parameter
|
// init with new block size index parameter
|
||||||
Init();
|
Init();
|
||||||
|
|
||||||
|
@ -268,9 +278,9 @@ void CClient::Init()
|
||||||
iMonoBlockSizeSam = Sound.Init ( iPrefMonoFrameSize );
|
iMonoBlockSizeSam = Sound.Init ( iPrefMonoFrameSize );
|
||||||
iStereoBlockSizeSam = 2 * iMonoBlockSizeSam;
|
iStereoBlockSizeSam = 2 * iMonoBlockSizeSam;
|
||||||
|
|
||||||
|
vecsAudioSndCrdMono.Init ( iMonoBlockSizeSam );
|
||||||
vecsAudioSndCrdStereo.Init ( iStereoBlockSizeSam );
|
vecsAudioSndCrdStereo.Init ( iStereoBlockSizeSam );
|
||||||
|
vecdAudioStereo.Init ( iStereoBlockSizeSam );
|
||||||
vecdAudioStereo.Init ( iStereoBlockSizeSam );
|
|
||||||
|
|
||||||
// init response time evaluation
|
// init response time evaluation
|
||||||
CycleTimeVariance.Init ( iMonoBlockSizeSam,
|
CycleTimeVariance.Init ( iMonoBlockSizeSam,
|
||||||
|
@ -281,13 +291,6 @@ void CClient::Init()
|
||||||
// init reverberation
|
// init reverberation
|
||||||
AudioReverb.Init ( SYSTEM_SAMPLE_RATE );
|
AudioReverb.Init ( SYSTEM_SAMPLE_RATE );
|
||||||
|
|
||||||
// init audio endocder/decoder (mono)
|
|
||||||
CeltMode = celt_mode_create (
|
|
||||||
SYSTEM_SAMPLE_RATE, 1, iMonoBlockSizeSam, NULL );
|
|
||||||
|
|
||||||
CeltEncoder = celt_encoder_create ( CeltMode );
|
|
||||||
CeltDecoder = celt_decoder_create ( CeltMode );
|
|
||||||
|
|
||||||
// 22: low/normal quality 150 kbsp (128) / 108 kbps (256)
|
// 22: low/normal quality 150 kbsp (128) / 108 kbps (256)
|
||||||
// 44: high quality 216 kbps (128) / 174 kbps (256)
|
// 44: high quality 216 kbps (128) / 174 kbps (256)
|
||||||
iCeltNumCodedBytes = 22;
|
iCeltNumCodedBytes = 22;
|
||||||
|
@ -299,6 +302,9 @@ void CClient::Init()
|
||||||
vecbyNetwData.Init ( iCeltNumCodedBytes );
|
vecbyNetwData.Init ( iCeltNumCodedBytes );
|
||||||
|
|
||||||
// set the channel network properties
|
// set the channel network properties
|
||||||
|
|
||||||
|
// TODO use the actual frame size factor if possible...
|
||||||
|
|
||||||
Channel.SetNetwFrameSizeAndFact ( iCeltNumCodedBytes,
|
Channel.SetNetwFrameSizeAndFact ( iCeltNumCodedBytes,
|
||||||
iSndCrdPrefMonoFrameSizeFactor );
|
iSndCrdPrefMonoFrameSizeFactor );
|
||||||
}
|
}
|
||||||
|
@ -307,6 +313,7 @@ void CClient::ProcessAudioData ( CVector<int16_t>& vecsStereoSndCrd )
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
|
// Transmit signal ---------------------------------------------------------
|
||||||
// update stereo signal level meter
|
// update stereo signal level meter
|
||||||
SignalLevelMeter.Update ( vecsStereoSndCrd );
|
SignalLevelMeter.Update ( vecsStereoSndCrd );
|
||||||
|
|
||||||
|
@ -382,35 +389,41 @@ void CClient::ProcessAudioData ( CVector<int16_t>& vecsStereoSndCrd )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// encode current audio frame with CELT encoder
|
// TEST
|
||||||
celt_encode ( CeltEncoder,
|
// TODO use actual frame size factor, not preferred one!!!!
|
||||||
&vecsNetwork[0],
|
for ( i = 0; i < iSndCrdPrefMonoFrameSizeFactor; i++ )
|
||||||
NULL,
|
|
||||||
&vecCeltData[0],
|
|
||||||
iCeltNumCodedBytes );
|
|
||||||
|
|
||||||
// send coded audio through the network
|
|
||||||
Socket.SendPacket ( Channel.PrepSendPacket ( vecCeltData ),
|
|
||||||
Channel.GetAddress() );
|
|
||||||
|
|
||||||
|
|
||||||
// receive a new block
|
|
||||||
const bool bReceiveDataOk =
|
|
||||||
( Channel.GetData ( vecbyNetwData ) == GS_BUFFER_OK );
|
|
||||||
|
|
||||||
if ( bReceiveDataOk )
|
|
||||||
{
|
{
|
||||||
PostWinMessage ( MS_JIT_BUF_GET, MUL_COL_LED_GREEN );
|
// encode current audio frame with CELT encoder
|
||||||
}
|
celt_encode ( CeltEncoder,
|
||||||
else
|
&vecsNetwork[i * SYSTEM_BLOCK_FRAME_SAMPLES],
|
||||||
{
|
NULL,
|
||||||
PostWinMessage ( MS_JIT_BUF_GET, MUL_COL_LED_RED );
|
&vecCeltData[0],
|
||||||
|
iCeltNumCodedBytes );
|
||||||
|
|
||||||
|
// send coded audio through the network
|
||||||
|
Socket.SendPacket ( Channel.PrepSendPacket ( vecCeltData ),
|
||||||
|
Channel.GetAddress() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if channel is connected
|
|
||||||
if ( Channel.IsConnected() )
|
// Receive signal ----------------------------------------------------------
|
||||||
|
|
||||||
|
// TEST
|
||||||
|
// TODO use actual frame size factor, not preferred one!!!!
|
||||||
|
for ( i = 0; i < iSndCrdPrefMonoFrameSizeFactor; i++ )
|
||||||
{
|
{
|
||||||
CVector<short> vecsAudioSndCrdMono ( iMonoBlockSizeSam );
|
// receive a new block
|
||||||
|
const bool bReceiveDataOk =
|
||||||
|
( Channel.GetData ( vecbyNetwData ) == GS_BUFFER_OK );
|
||||||
|
|
||||||
|
if ( bReceiveDataOk )
|
||||||
|
{
|
||||||
|
PostWinMessage ( MS_JIT_BUF_GET, MUL_COL_LED_GREEN );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PostWinMessage ( MS_JIT_BUF_GET, MUL_COL_LED_RED );
|
||||||
|
}
|
||||||
|
|
||||||
// CELT decoding
|
// CELT decoding
|
||||||
if ( bReceiveDataOk )
|
if ( bReceiveDataOk )
|
||||||
|
@ -418,7 +431,7 @@ void CClient::ProcessAudioData ( CVector<int16_t>& vecsStereoSndCrd )
|
||||||
celt_decode ( CeltDecoder,
|
celt_decode ( CeltDecoder,
|
||||||
&vecbyNetwData[0],
|
&vecbyNetwData[0],
|
||||||
iCeltNumCodedBytes,
|
iCeltNumCodedBytes,
|
||||||
&vecsAudioSndCrdMono[0] );
|
&vecsAudioSndCrdMono[i * SYSTEM_BLOCK_FRAME_SAMPLES] );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -426,9 +439,13 @@ void CClient::ProcessAudioData ( CVector<int16_t>& vecsStereoSndCrd )
|
||||||
celt_decode ( CeltDecoder,
|
celt_decode ( CeltDecoder,
|
||||||
NULL,
|
NULL,
|
||||||
iCeltNumCodedBytes,
|
iCeltNumCodedBytes,
|
||||||
&vecsAudioSndCrdMono[0] );
|
&vecsAudioSndCrdMono[i * SYSTEM_BLOCK_FRAME_SAMPLES] );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if channel is connected
|
||||||
|
if ( Channel.IsConnected() )
|
||||||
|
{
|
||||||
// copy mono data in stereo sound card buffer
|
// copy mono data in stereo sound card buffer
|
||||||
for ( i = 0, j = 0; i < iMonoBlockSizeSam; i++, j += 2 )
|
for ( i = 0, j = 0; i < iMonoBlockSizeSam; i++, j += 2 )
|
||||||
{
|
{
|
||||||
|
|
|
@ -179,6 +179,7 @@ protected:
|
||||||
|
|
||||||
bool bOpenChatOnNewMessage;
|
bool bOpenChatOnNewMessage;
|
||||||
|
|
||||||
|
CVector<int16_t> vecsAudioSndCrdMono;
|
||||||
CVector<int16_t> vecsAudioSndCrdStereo;
|
CVector<int16_t> vecsAudioSndCrdStereo;
|
||||||
CVector<double> vecdAudioStereo;
|
CVector<double> vecdAudioStereo;
|
||||||
CVector<int16_t> vecsNetwork;
|
CVector<int16_t> vecsNetwork;
|
||||||
|
|
Loading…
Reference in a new issue