implemented network transport properties protocol mechanism
This commit is contained in:
parent
91071384d2
commit
24ce20479e
5 changed files with 82 additions and 33 deletions
|
@ -569,16 +569,10 @@ CChannel::CChannel ( const bool bNIsServer ) : bIsServer ( bNIsServer ),
|
||||||
vecNetwBufferInProps.Init ( iNumSupportedAudComprTypes *
|
vecNetwBufferInProps.Init ( iNumSupportedAudComprTypes *
|
||||||
MAX_NET_BLOCK_SIZE_FACTOR + 1 );
|
MAX_NET_BLOCK_SIZE_FACTOR + 1 );
|
||||||
|
|
||||||
// init special mode
|
// init special mode (with invalid data)
|
||||||
|
vecNetwBufferInProps[0].iAudioBlockSize = 0;
|
||||||
// TEST -> 128
|
|
||||||
vecNetwBufferInProps[0].iAudioBlockSize = 128;
|
|
||||||
vecNetwBufferInProps[0].eAudComprType = CT_NONE;
|
vecNetwBufferInProps[0].eAudComprType = CT_NONE;
|
||||||
vecNetwBufferInProps[0].iNetwInBufSize = AudioCompressionIn.Init (
|
vecNetwBufferInProps[0].iNetwInBufSize = 0;
|
||||||
vecNetwBufferInProps[0].iAudioBlockSize,
|
|
||||||
vecNetwBufferInProps[0].eAudComprType );
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for ( int i = 0; i < MAX_NET_BLOCK_SIZE_FACTOR; i++ )
|
for ( int i = 0; i < MAX_NET_BLOCK_SIZE_FACTOR; i++ )
|
||||||
{
|
{
|
||||||
|
@ -669,6 +663,10 @@ vecNetwBufferInProps[0].iNetwInBufSize = AudioCompressionIn.Init (
|
||||||
QObject::connect ( &Protocol,
|
QObject::connect ( &Protocol,
|
||||||
SIGNAL ( NetTranspPropsReceived ( CNetworkTransportProps ) ),
|
SIGNAL ( NetTranspPropsReceived ( CNetworkTransportProps ) ),
|
||||||
this, SLOT ( OnNetTranspPropsReceived ( CNetworkTransportProps ) ) );
|
this, SLOT ( OnNetTranspPropsReceived ( CNetworkTransportProps ) ) );
|
||||||
|
|
||||||
|
QObject::connect ( &Protocol,
|
||||||
|
SIGNAL ( ReqNetTranspProps() ),
|
||||||
|
this, SLOT ( OnReqNetTranspProps() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CChannel::ProtocolIsEnabled()
|
bool CChannel::ProtocolIsEnabled()
|
||||||
|
@ -727,6 +725,9 @@ void CChannel::SetAudioBlockSizeAndComprIn ( const int iNewBlockSize,
|
||||||
AudioCompressionIn.Init ( iNewBlockSize, eNewAudComprType );
|
AudioCompressionIn.Init ( iNewBlockSize, eNewAudComprType );
|
||||||
|
|
||||||
// initial value for connection time out counter
|
// initial value for connection time out counter
|
||||||
|
|
||||||
|
// TODO FIXME this does not work correctly -> bug
|
||||||
|
// (the calculation is correct but the value is not correctly applied)
|
||||||
iConTimeOutStartVal =
|
iConTimeOutStartVal =
|
||||||
( CON_TIME_OUT_SEC_MAX * SYSTEM_SAMPLE_RATE ) / iNewBlockSize;
|
( CON_TIME_OUT_SEC_MAX * SYSTEM_SAMPLE_RATE ) / iNewBlockSize;
|
||||||
}
|
}
|
||||||
|
@ -889,26 +890,6 @@ void CChannel::OnChangeChanName ( QString strName )
|
||||||
SetName ( strName );
|
SetName ( strName );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void CChannel::OnNetTranspPropsReceived ( CNetworkTransportProps NetworkTransportProps )
|
|
||||||
{
|
|
||||||
QMutexLocker locker ( &Mutex );
|
|
||||||
|
|
||||||
// TEST
|
|
||||||
// TODO use mutex in Put function
|
|
||||||
// TODO check possiblity of received parameter -> error checking
|
|
||||||
vecNetwBufferInProps[0].iAudioBlockSize = NetworkTransportProps.iMonoAudioBlockSize;
|
|
||||||
vecNetwBufferInProps[0].eAudComprType = NetworkTransportProps.eAudioCodingType;
|
|
||||||
vecNetwBufferInProps[0].iNetwInBufSize = AudioCompressionIn.Init (
|
|
||||||
vecNetwBufferInProps[0].iAudioBlockSize,
|
|
||||||
vecNetwBufferInProps[0].eAudComprType );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool CChannel::GetAddress(CHostAddress& RetAddr)
|
bool CChannel::GetAddress(CHostAddress& RetAddr)
|
||||||
{
|
{
|
||||||
QMutexLocker locker ( &Mutex );
|
QMutexLocker locker ( &Mutex );
|
||||||
|
@ -925,6 +906,46 @@ bool CChannel::GetAddress(CHostAddress& RetAddr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void CChannel::OnNetTranspPropsReceived ( CNetworkTransportProps NetworkTransportProps )
|
||||||
|
{
|
||||||
|
QMutexLocker locker ( &Mutex );
|
||||||
|
|
||||||
|
// TEST
|
||||||
|
// TODO use mutex in Put function
|
||||||
|
// TODO check possiblity of received parameter -> error checking
|
||||||
|
// utilize, e.g., MAX_MONO_AUD_BUFF_SIZE_AT_48KHZ
|
||||||
|
vecNetwBufferInProps[0].iAudioBlockSize = NetworkTransportProps.iMonoAudioBlockSize;
|
||||||
|
vecNetwBufferInProps[0].eAudComprType = NetworkTransportProps.eAudioCodingType;
|
||||||
|
vecNetwBufferInProps[0].iNetwInBufSize = AudioCompressionIn.Init (
|
||||||
|
vecNetwBufferInProps[0].iAudioBlockSize,
|
||||||
|
vecNetwBufferInProps[0].eAudComprType );
|
||||||
|
}
|
||||||
|
|
||||||
|
void CChannel::OnReqNetTranspProps()
|
||||||
|
{
|
||||||
|
CreateNetTranspPropsMessFromCurrentSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CChannel::CreateNetTranspPropsMessFromCurrentSettings()
|
||||||
|
{
|
||||||
|
CNetworkTransportProps NetworkTransportProps (
|
||||||
|
iAudComprSizeOut,
|
||||||
|
iCurAudioBlockSizeOut,
|
||||||
|
1, // right now we only use mono
|
||||||
|
SYSTEM_SAMPLE_RATE, // right now only one sample rate is supported
|
||||||
|
AudioCompressionOut.GetType(),
|
||||||
|
0 );
|
||||||
|
|
||||||
|
// send current network transport properties
|
||||||
|
Protocol.CreateNetwTranspPropsMes ( NetworkTransportProps );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
EPutDataStat CChannel::PutData ( const CVector<unsigned char>& vecbyData,
|
EPutDataStat CChannel::PutData ( const CVector<unsigned char>& vecbyData,
|
||||||
int iNumBytes )
|
int iNumBytes )
|
||||||
{
|
{
|
||||||
|
@ -1038,9 +1059,17 @@ EPutDataStat CChannel::PutData ( const CVector<unsigned char>& vecbyData,
|
||||||
Mutex.unlock();
|
Mutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
// inform other objects that new connection was established
|
|
||||||
if ( bNewConnection )
|
if ( bNewConnection )
|
||||||
{
|
{
|
||||||
|
// if this is a new connection and the current network packet is
|
||||||
|
// neither an audio or protocol packet, we have to query the
|
||||||
|
// network transport properties for the audio packets
|
||||||
|
if ( ( !bIsProtocolPacket ) && ( !bIsAudioPacket ) )
|
||||||
|
{
|
||||||
|
Protocol.CreateReqNetwTranspPropsMes();
|
||||||
|
}
|
||||||
|
|
||||||
|
// inform other objects that new connection was established
|
||||||
emit NewConnection();
|
emit NewConnection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,6 +145,8 @@ void SetNetwBufSizeOut ( const int iNewAudioBlockSizeOut );
|
||||||
Protocol.CreateConClientListMes ( vecChanInfo );
|
Protocol.CreateConClientListMes ( vecChanInfo );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CreateNetTranspPropsMessFromCurrentSettings();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void SetAudioBlockSizeAndComprIn ( const int iNewBlockSize,
|
void SetAudioBlockSizeAndComprIn ( const int iNewBlockSize,
|
||||||
const EAudComprType eNewAudComprType );
|
const EAudComprType eNewAudComprType );
|
||||||
|
@ -205,6 +207,7 @@ public slots:
|
||||||
void OnChangeChanGain ( int iChanID, double dNewGain );
|
void OnChangeChanGain ( int iChanID, double dNewGain );
|
||||||
void OnChangeChanName ( QString strName );
|
void OnChangeChanName ( QString strName );
|
||||||
void OnNetTranspPropsReceived ( CNetworkTransportProps NetworkTransportProps );
|
void OnNetTranspPropsReceived ( CNetworkTransportProps NetworkTransportProps );
|
||||||
|
void OnReqNetTranspProps();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void MessReadyForSending ( CVector<uint8_t> vecMessage );
|
void MessReadyForSending ( CVector<uint8_t> vecMessage );
|
||||||
|
@ -215,6 +218,7 @@ signals:
|
||||||
void NameHasChanged();
|
void NameHasChanged();
|
||||||
void ChatTextReceived ( QString strChatText );
|
void ChatTextReceived ( QString strChatText );
|
||||||
void PingReceived ( int iMs );
|
void PingReceived ( int iMs );
|
||||||
|
void ReqNetTranspProps();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,9 @@ CClient::CClient ( const quint16 iPortNumber ) :
|
||||||
|
|
||||||
QObject::connect ( &Channel, SIGNAL ( PingReceived ( int ) ),
|
QObject::connect ( &Channel, SIGNAL ( PingReceived ( int ) ),
|
||||||
this, SLOT ( OnReceivePingMessage ( int ) ) );
|
this, SLOT ( OnReceivePingMessage ( int ) ) );
|
||||||
|
|
||||||
|
QObject::connect ( &Channel, SIGNAL ( ReqNetTranspProps() ),
|
||||||
|
this, SLOT ( OnReqNetTranspProps() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClient::OnSendProtMessage ( CVector<uint8_t> vecMessage )
|
void CClient::OnSendProtMessage ( CVector<uint8_t> vecMessage )
|
||||||
|
@ -77,6 +80,9 @@ for ( int i = 0; i < vecMessage.Size(); i++ ) {
|
||||||
|
|
||||||
void CClient::OnReqJittBufSize()
|
void CClient::OnReqJittBufSize()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// TODO cant we implement this OnReqJjittBufSize inside the channel object?
|
||||||
|
|
||||||
Channel.CreateJitBufMes ( Channel.GetSockBufSize() );
|
Channel.CreateJitBufMes ( Channel.GetSockBufSize() );
|
||||||
|
|
||||||
// FIXME: we set the network buffer size factor here, too -> in the
|
// FIXME: we set the network buffer size factor here, too -> in the
|
||||||
|
|
|
@ -127,7 +127,14 @@ public:
|
||||||
int GetNetwBufSizeFactOut() { return Channel.GetNetwBufSizeFactOut(); }
|
int GetNetwBufSizeFactOut() { return Channel.GetNetwBufSizeFactOut(); }
|
||||||
|
|
||||||
void SetAudioCompressionOut ( const EAudComprType eNewAudComprTypeOut )
|
void SetAudioCompressionOut ( const EAudComprType eNewAudComprTypeOut )
|
||||||
{ Channel.SetAudioCompressionOut ( eNewAudComprTypeOut ); }
|
{
|
||||||
|
Channel.SetAudioCompressionOut ( eNewAudComprTypeOut );
|
||||||
|
|
||||||
|
// tell the server that audio coding has changed (it
|
||||||
|
// is important to call this function AFTER we have applied
|
||||||
|
// the new setting to the channel!)
|
||||||
|
Channel.CreateNetTranspPropsMessFromCurrentSettings();
|
||||||
|
}
|
||||||
EAudComprType GetAudioCompressionOut() { return Channel.GetAudioCompressionOut(); }
|
EAudComprType GetAudioCompressionOut() { return Channel.GetAudioCompressionOut(); }
|
||||||
|
|
||||||
void SetRemoteChanGain ( const int iId, const double dGain )
|
void SetRemoteChanGain ( const int iId, const double dGain )
|
||||||
|
|
|
@ -880,7 +880,7 @@ bool CProtocol::EvaluateNetwTranspPropsMes ( const CVector<uint8_t>& vecData )
|
||||||
|
|
||||||
// audio coding type (2 bytes) with error check
|
// audio coding type (2 bytes) with error check
|
||||||
const int iRecCodingType =
|
const int iRecCodingType =
|
||||||
static_cast<unsigned short> ( GetValFromStream ( vecData, iPos, 2 ) );
|
static_cast<int> ( GetValFromStream ( vecData, iPos, 2 ) );
|
||||||
|
|
||||||
if ( ( iRecCodingType != CT_NONE ) &&
|
if ( ( iRecCodingType != CT_NONE ) &&
|
||||||
( iRecCodingType != CT_IMAADPCM ) &&
|
( iRecCodingType != CT_IMAADPCM ) &&
|
||||||
|
@ -889,6 +889,9 @@ bool CProtocol::EvaluateNetwTranspPropsMes ( const CVector<uint8_t>& vecData )
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ReceivedNetwTranspProps.eAudioCodingType =
|
||||||
|
static_cast<EAudComprType> ( iRecCodingType );
|
||||||
|
|
||||||
// argument for the audio coder (4 bytes)
|
// argument for the audio coder (4 bytes)
|
||||||
ReceivedNetwTranspProps.iAudioCodingArg =
|
ReceivedNetwTranspProps.iAudioCodingArg =
|
||||||
static_cast<unsigned int> ( GetValFromStream ( vecData, iPos, 4 ) );
|
static_cast<unsigned int> ( GetValFromStream ( vecData, iPos, 4 ) );
|
||||||
|
|
Loading…
Reference in a new issue