added new protocol messages for network transport properties; removed unnecessary protocol events

This commit is contained in:
Volker Fischer 2009-02-24 18:20:33 +00:00
parent 1bc8c5f84c
commit 2cd15abb8a
9 changed files with 207 additions and 60 deletions

View file

@ -858,9 +858,6 @@ EPutDataStat CChannel::PutData ( const CVector<unsigned char>& vecbyData,
// set status flags
eRet = PS_PROT_OK;
bIsProtocolPacket = true;
// create message for protocol status
emit ProtocolStatus ( true );
}
}
@ -941,9 +938,6 @@ EPutDataStat CChannel::PutData ( const CVector<unsigned char>& vecbyData,
// the protocol parsing failed and this was no audio block,
// we treat this as protocol error (unkown packet)
eRet = PS_PROT_ERR;
// create message for protocol status
emit ProtocolStatus ( false );
}
}

View file

@ -208,7 +208,6 @@ signals:
void ReqJittBufSize();
void ReqConnClientsList();
void ConClientListMesReceived ( CVector<CChannelShortInfo> vecChanInfo );
void ProtocolStatus ( bool bOk );
void NameHasChanged();
void ChatTextReceived ( QString strChatText );
void PingReceived ( int iMs );

View file

@ -47,9 +47,6 @@ CClient::CClient ( const quint16 iPortNumber ) :
QObject::connect ( &Channel, SIGNAL ( ReqJittBufSize() ),
this, SLOT ( OnReqJittBufSize() ) );
QObject::connect ( &Channel, SIGNAL ( ProtocolStatus ( bool ) ),
this, SLOT ( OnProtocolStatus ( bool ) ) );
QObject::connect ( &Channel,
SIGNAL ( ConClientListMesReceived ( CVector<CChannelShortInfo> ) ),
SIGNAL ( ConClientListMesReceived ( CVector<CChannelShortInfo> ) ) );
@ -157,19 +154,6 @@ bool CClient::SetServerAddr ( QString strNAddr )
return true;
}
void CClient::OnProtocolStatus ( bool bOk )
{
// show protocol status in GUI
if ( bOk )
{
PostWinMessage ( MS_PROTOCOL, MUL_COL_LED_RED );
}
else
{
PostWinMessage ( MS_PROTOCOL, MUL_COL_LED_GREEN );
}
}
void CClient::Start()
{
// init object

View file

@ -201,7 +201,6 @@ protected:
public slots:
void OnSendProtMessage ( CVector<uint8_t> vecMessage );
void OnReqJittBufSize();
void OnProtocolStatus ( bool bOk );
void OnNewConnection();
void OnReceivePingMessage ( int iMs );

View file

@ -93,6 +93,8 @@
// if you want to change this paramter, there has to be done code modifications
// on other places, too! The code tag "MAX_NUM_CHANNELS_TAG" shows these places
// (just search for the tag in the entire code)
// note: since in the protocol messages the channel ID is only a byte, a
// maximum of 8 channels are possible, see e.g. "PROTMESSID_CHANNEL_GAIN"!
#define MAX_NUM_CHANNELS 6 // max number channels for server
// length of the moving average buffer for response time measurement
@ -130,9 +132,8 @@ typedef unsigned int _MESSAGE_IDENT;
#define MS_JIT_BUF_PUT 3
#define MS_JIT_BUF_GET 4
#define MS_PACKET_RECEIVED 5
#define MS_PROTOCOL 6
#define MS_ERROR_IN_THREAD 7
#define MS_SET_JIT_BUF_SIZE 8
#define MS_ERROR_IN_THREAD 6
#define MS_SET_JIT_BUF_SIZE 7
#define MUL_COL_LED_RED 0
#define MUL_COL_LED_YELLOW 1

View file

@ -104,6 +104,27 @@ MESSAGES
| 4 bytes transmit time in ms |
+-----------------------------+
- Properties for network transport: PROTMESSID_NETW_TRANSPORT_PROPS
+-------------------+------------------+-----------------+------------------+-----------------------+----------------------+
| 4 bytes netw size | 4 bytes aud size | 1 byte num chan | 4 bytes sam rate | 2 bytes audiocod type | 4 bytes audiocod arg |
+-------------------+------------------+-----------------+------------------+-----------------------+----------------------+
- "netw size": length of the network packet in bytes
- "aud size": length of the mono audio block size in samples
- "num chan": number of channels of the audio signal, e.g. "2" is stereo
- "sam rate": sample rate of the audio stream
- "audiocod type": audio coding type, the following types are supported:
- 0: none, no audio coding applied
- 1: IMA-ADPCM
- 2: MS-ADPCM
- "audiocod arg": argument for the audio coder, if not used this value shall be set to 0
- Request properties for network transport: PROTMESSID_REQ_NETW_TRANSPORT_PROPS
note: does not have any data -> n = 0
******************************************************************************
*
* This program is free software; you can redistribute it and/or modify it under
@ -369,6 +390,16 @@ for ( int i = 0; i < iNumBytes; i++ ) {
bRet = EvaluatePingMes ( vecData );
break;
case PROTMESSID_NETW_TRANSPORT_PROPS:
bRet = EvaluateNetwTranspPropsMes ( vecData );
break;
case PROTMESSID_REQ_NETW_TRANSPORT_PROPS:
bRet = EvaluateReqNetwTranspPropsMes ( vecData );
break;
}
// send acknowledge message
@ -691,7 +722,7 @@ void CProtocol::CreateChatTextMes ( const QString strChatText )
unsigned int iPos = 0; // init position pointer
const int iStrLen = strChatText.size(); // get string size
// size of current list entry
// size of message body
const int iEntrLen = 2 /* string size */ + iStrLen;
// build data vector
@ -774,6 +805,109 @@ bool CProtocol::EvaluatePingMes ( const CVector<uint8_t>& vecData )
return false; // no error
}
void CProtocol::CreateNetwTranspPropsMes ( const CNetworkTransportProps& NetTrProps )
{
unsigned int iPos = 0; // init position pointer
// size of current message body
const int iEntrLen = 4 /* netw size */ + 4 /* aud size */ + 1 /* num chan */ +
4 /* sam rate */ + 2 /* audiocod type */ + 4 /* audiocod arg */;
// build data vector
CVector<uint8_t> vecData ( iEntrLen );
// length of the network packet in bytes (4 bytes)
PutValOnStream ( vecData, iPos,
static_cast<uint32_t> ( NetTrProps.iNetworkPacketSize ), 4 );
// length of the mono audio block size in samples (4 bytes)
PutValOnStream ( vecData, iPos,
static_cast<uint32_t> ( NetTrProps.iMonoAudioBlockSize ), 4 );
// number of channels of the audio signal, e.g. "2" is stereo (1 byte)
PutValOnStream ( vecData, iPos,
static_cast<uint32_t> ( NetTrProps.iNumAudioChannels ), 1 );
// sample rate of the audio stream (4 bytes)
PutValOnStream ( vecData, iPos,
static_cast<uint32_t> ( NetTrProps.iSampleRate ), 4 );
// audio coding type (2 bytes)
PutValOnStream ( vecData, iPos,
static_cast<uint32_t> ( NetTrProps.eAudioCodingType ), 2 );
// argument for the audio coder (4 bytes)
PutValOnStream ( vecData, iPos,
static_cast<uint32_t> ( NetTrProps.iAudioCodingArg ), 4 );
CreateAndSendMessage ( PROTMESSID_NETW_TRANSPORT_PROPS, vecData );
}
bool CProtocol::EvaluateNetwTranspPropsMes ( const CVector<uint8_t>& vecData )
{
unsigned int iPos = 0; // init position pointer
CNetworkTransportProps ReceivedNetwTranspProps;
// size of current message body
const int iEntrLen = 4 /* netw size */ + 4 /* aud size */ + 1 /* num chan */ +
4 /* sam rate */ + 2 /* audiocod type */ + 4 /* audiocod arg */;
// check size
if ( vecData.Size() != iEntrLen )
{
return true;
}
// length of the network packet in bytes (4 bytes)
ReceivedNetwTranspProps.iNetworkPacketSize =
static_cast<unsigned int> ( GetValFromStream ( vecData, iPos, 4 ) );
// length of the mono audio block size in samples (4 bytes)
ReceivedNetwTranspProps.iMonoAudioBlockSize =
static_cast<unsigned int> ( GetValFromStream ( vecData, iPos, 4 ) );
// number of channels of the audio signal, e.g. "2" is stereo (1 byte)
ReceivedNetwTranspProps.iNumAudioChannels =
static_cast<unsigned int> ( GetValFromStream ( vecData, iPos, 1 ) );
// sample rate of the audio stream (4 bytes)
ReceivedNetwTranspProps.iSampleRate =
static_cast<unsigned int> ( GetValFromStream ( vecData, iPos, 4 ) );
// audio coding type (2 bytes) with error check
const int iRecCodingType =
static_cast<unsigned short> ( GetValFromStream ( vecData, iPos, 2 ) );
if ( ( iRecCodingType != CNetworkTransportProps::ACT_NONE ) &&
( iRecCodingType != CNetworkTransportProps::ACT_IMA_ADPCM ) &&
( iRecCodingType != CNetworkTransportProps::ACT_MS_ADPCM ) )
{
return true;
}
// argument for the audio coder (4 bytes)
ReceivedNetwTranspProps.iAudioCodingArg =
static_cast<unsigned int> ( GetValFromStream ( vecData, iPos, 4 ) );
// invoke message action
emit NetTranspPropsReceived ( ReceivedNetwTranspProps );
return false; // no error
}
void CProtocol::CreateReqNetwTranspPropsMes()
{
CreateAndSendMessage ( PROTMESSID_REQ_NETW_TRANSPORT_PROPS, CVector<uint8_t> ( 0 ) );
}
bool CProtocol::EvaluateReqNetwTranspPropsMes ( const CVector<uint8_t>& vecData )
{
// invoke message action
emit ReqNetTranspProps();
return false; // no error
}
/******************************************************************************\

View file

@ -49,6 +49,8 @@
#define PROTMESSID_CHANNEL_NAME 18 // set channel name for fader tag
#define PROTMESSID_CHAT_TEXT 19 // contains a chat text
#define PROTMESSID_PING_MS 20 // for measuring ping time
#define PROTMESSID_NETW_TRANSPORT_PROPS 21 // properties for network transport
#define PROTMESSID_REQ_NETW_TRANSPORT_PROPS 22 // request properties for network transport
// lengths of message as defined in protocol.cpp file
#define MESS_HEADER_LENGTH_BYTE 7 // TAG (2), ID (2), cnt (1), length (2)
@ -68,15 +70,16 @@ public:
void CreateJitBufMes ( const int iJitBufSize );
void CreateReqJitBufMes();
void CreateReqConnClientsList();
void CreateServerFullMes();
void CreateNetwBlSiFactMes ( const int iNetwBlSiFact );
void CreateChanGainMes ( const int iChanID, const double dGain );
void CreateConClientListMes ( const CVector<CChannelShortInfo>& vecChanInfo );
void CreateServerFullMes();
void CreateReqConnClientsList();
void CreateChanNameMes ( const QString strName );
void CreateChatTextMes ( const QString strChatText );
void CreatePingMes ( const int iMs );
void CreateConClientListMes ( const CVector<CChannelShortInfo>& vecChanInfo );
void CreateNetwTranspPropsMes ( const CNetworkTransportProps& NetTrProps );
void CreateReqNetwTranspPropsMes();
void CreateAndSendAcknMess ( const int& iID, const int& iCnt );
@ -138,14 +141,16 @@ protected:
bool EvaluateJitBufMes ( const CVector<uint8_t>& vecData );
bool EvaluateReqJitBufMes ( const CVector<uint8_t>& vecData );
bool EvaluateReqConnClientsList ( const CVector<uint8_t>& vecData );
bool EvaluateServerFullMes ( const CVector<uint8_t>& vecData );
bool EvaluateNetwBlSiFactMes ( const CVector<uint8_t>& vecData );
bool EvaluateChanGainMes ( const CVector<uint8_t>& vecData );
bool EvaluateConClientListMes ( const CVector<uint8_t>& vecData );
bool EvaluateServerFullMes ( const CVector<uint8_t>& vecData );
bool EvaluateReqConnClientsList ( const CVector<uint8_t>& vecData );
bool EvaluateChanNameMes ( const CVector<uint8_t>& vecData );
bool EvaluateChatTextMes ( const CVector<uint8_t>& vecData );
bool EvaluateConClientListMes ( const CVector<uint8_t>& vecData );
bool EvaluatePingMes ( const CVector<uint8_t>& vecData );
bool EvaluateNetwTranspPropsMes ( const CVector<uint8_t>& vecData );
bool EvaluateReqNetwTranspPropsMes ( const CVector<uint8_t>& vecData );
int iOldRecID, iOldRecCnt;
@ -165,15 +170,17 @@ signals:
// receiving
void ChangeJittBufSize ( int iNewJitBufSize );
void ReqJittBufSize();
void ChangeNetwBlSiFact ( int iNewNetwBlSiFact );
void ChangeChanGain ( int iChanID, double dNewGain );
void ConClientListMesReceived ( CVector<CChannelShortInfo> vecChanInfo );
void ServerFull();
void ReqConnClientsList();
void ChangeChanName ( QString strName );
void ChatTextReceived ( QString strChatText );
void PingReceived ( int iMs );
void ConClientListMesReceived ( CVector<CChannelShortInfo> vecChanInfo );
void ReqJittBufSize();
void ReqConnClientsList();
void ServerFull();
void NetTranspPropsReceived ( CNetworkTransportProps NetworkTransportProps );
void ReqNetTranspProps();
};
#endif /* !defined ( PROTOCOL_H__3B123453_4344_BB2392354455IUHF1912__INCLUDED_ ) */

View file

@ -407,6 +407,35 @@ public:
QString strName;
};
class CNetworkTransportProps
{
public:
enum EAudioCodingType
{
ACT_NONE = 0,
ACT_IMA_ADPCM = 1,
ACT_MS_ADPCM = 2
};
CNetworkTransportProps() : iNetworkPacketSize ( 0 ), iMonoAudioBlockSize ( 0 ),
iNumAudioChannels ( 0 ), iSampleRate ( 0 ),
eAudioCodingType ( ACT_NONE ), iAudioCodingArg ( 0 ) {}
CNetworkTransportProps ( const unsigned int iNNPS, const unsigned int iNMABS,
const unsigned int iNNACH, const unsigned int iNSR,
const EAudioCodingType eNACT, const int iNACA ) :
iNetworkPacketSize ( iNNPS ), iMonoAudioBlockSize ( iNMABS ),
iNumAudioChannels ( iNNACH ), iSampleRate ( iNSR ), eAudioCodingType ( eNACT ),
iAudioCodingArg ( iNACA ) {}
unsigned int iNetworkPacketSize;
unsigned int iMonoAudioBlockSize;
unsigned int iNumAudioChannels;
unsigned int iSampleRate;
EAudioCodingType eAudioCodingType;
int iAudioCodingArg;
};
// Audio Reverbration ----------------------------------------------------------
class CAudioReverb