From 16baee490a0c6c58259d490cd1c8aae4fa2f8d90 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Sat, 25 Jul 2009 05:57:27 +0000 Subject: [PATCH] added version in network properties protocol message --- linux/Makefile.am | 5 ----- src/channel.cpp | 1 + src/protocol.cpp | 53 +++++++++++++++++++++++++++++++++-------------- src/util.h | 6 ++++-- 4 files changed, 43 insertions(+), 22 deletions(-) diff --git a/linux/Makefile.am b/linux/Makefile.am index c85687fe..d2abf819 100755 --- a/linux/Makefile.am +++ b/linux/Makefile.am @@ -3,8 +3,6 @@ bin_PROGRAMS = llcon llcon_SOURCES = ../src/buffer.cpp \ ../src/main.cpp \ ../src/socket.cpp \ - ../src/audiocompr.cpp \ - ../src/resample.cpp \ ../src/channel.cpp \ ../src/util.cpp \ ../src/llconclientdlg.cpp \ @@ -24,9 +22,6 @@ llcon_SOURCES = ../src/buffer.cpp \ ../src/buffer.h \ ../src/global.h \ ../src/socket.h \ - ../src/audiocompr.h \ - ../src/resample.h \ - ../src/resamplefilter.h \ ../src/channel.h \ ../src/util.h \ ../src/client.h \ diff --git a/src/channel.cpp b/src/channel.cpp index 193af4d4..ef77f030 100755 --- a/src/channel.cpp +++ b/src/channel.cpp @@ -844,6 +844,7 @@ void CChannel::CreateNetTranspPropsMessFromCurrentSettings() 1, // right now we only use mono SYSTEM_SAMPLE_RATE, // right now only one sample rate is supported CT_CELT, // always CELT coding + 0, 0 ); // send current network transport properties diff --git a/src/protocol.cpp b/src/protocol.cpp index f7ed3781..a904dc57 100755 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -15,9 +15,12 @@ Protocol message definition MAIN FRAME ---------- - +-------------+------------+------------+------------------+--------------+-------------+ - | 2 bytes TAG | 2 bytes ID | 1 byte cnt | 2 bytes length n | n bytes data | 2 bytes CRC | - +-------------+------------+------------+------------------+--------------+-------------+ + +-------------+------------+------------+------------------+ ... + | 2 bytes TAG | 2 bytes ID | 1 byte cnt | 2 bytes length n | ... + +-------------+------------+------------+------------------+ ... + ... --------------+-------------+ + ... n bytes data | 2 bytes CRC | + ... --------------+-------------+ - TAG is an all zero bit word to identify protocol messages - message ID defined by the defines PROTMESSID_x @@ -77,10 +80,12 @@ MESSAGES for each connected client append following data: - +-------------------+--------------------+------------------+----------------------+ - | 1 byte channel ID | 4 bytes IP address | 2 bytes number n | n bytes UTF-8 string | - +-------------------+--------------------+------------------+----------------------+ - + +-------------------+--------------------+------------------+ ... + | 1 byte channel ID | 4 bytes IP address | 2 bytes number n | ... + +-------------------+--------------------+------------------+ ... + ... ----------------------+ + ... n bytes UTF-8 string | + ... ----------------------+ - Request connected clients list: PROTMESSID_REQ_CONN_CLIENTS_LIST @@ -112,9 +117,15 @@ MESSAGES - 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 | - +-------------------+------------------+-----------------+------------------+-----------------------+----------------------+ + +-------------------+------------------+-----------------+ ... + | 4 bytes netw size | 4 bytes aud size | 1 byte num chan | ... + +-------------------+------------------+-----------------+ ... + ... ------------------+-----------------------+ ... + ... 4 bytes sam rate | 2 bytes audiocod type | ... + ... ------------------+-----------------------+ ... + ... -----------------+----------------------+ + ... 2 bytes version | 4 bytes audiocod arg | + ... -----------------+----------------------+ - "netw size": length of the network packet in bytes - "aud size": length of the mono audio block size in samples @@ -125,6 +136,7 @@ MESSAGES - 1: IMA-ADPCM - 2: MS-ADPCM - 3: CELT + - "version": version of the audio coder, if not used this value shall be set to 0 - "audiocod arg": argument for the audio coder, if not used this value shall be set to 0 @@ -810,8 +822,9 @@ void CProtocol::CreateNetwTranspPropsMes ( const CNetworkTransportProps& NetTrPr 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 */; + const int iEntrLen = 4 /* netw size */ + 4 /* aud size */ + + 1 /* num chan */ + 4 /* sam rate */ + 2 /* audiocod type */ + + 2 /* version */ + 4 /* audiocod arg */; // build data vector CVector vecData ( iEntrLen ); @@ -836,6 +849,10 @@ void CProtocol::CreateNetwTranspPropsMes ( const CNetworkTransportProps& NetTrPr PutValOnStream ( vecData, iPos, static_cast ( NetTrProps.eAudioCodingType ), 2 ); + // version (2 bytes) + PutValOnStream ( vecData, iPos, + static_cast ( NetTrProps.iVersion ), 2 ); + // argument for the audio coder (4 bytes) PutValOnStream ( vecData, iPos, static_cast ( NetTrProps.iAudioCodingArg ), 4 ); @@ -849,8 +866,9 @@ bool CProtocol::EvaluateNetwTranspPropsMes ( const CVector& vecData ) 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 */; + const int iEntrLen = 4 /* netw size */ + 4 /* aud size */ + + 1 /* num chan */ + 4 /* sam rate */ + 2 /* audiocod type */ + + 2 /* version */ + 4 /* audiocod arg */; // check size if ( vecData.Size() != iEntrLen ) @@ -885,7 +903,8 @@ bool CProtocol::EvaluateNetwTranspPropsMes ( const CVector& vecData ) if ( ( iRecCodingType != CT_NONE ) && ( iRecCodingType != CT_IMAADPCM ) && - ( iRecCodingType != CT_MSADPCM ) ) + ( iRecCodingType != CT_MSADPCM ) && + ( iRecCodingType != CT_CELT ) ) { return true; } @@ -893,6 +912,10 @@ bool CProtocol::EvaluateNetwTranspPropsMes ( const CVector& vecData ) ReceivedNetwTranspProps.eAudioCodingType = static_cast ( iRecCodingType ); + // version (2 bytes) + ReceivedNetwTranspProps.iVersion = + static_cast ( GetValFromStream ( vecData, iPos, 2 ) ); + // argument for the audio coder (4 bytes) ReceivedNetwTranspProps.iAudioCodingArg = static_cast ( GetValFromStream ( vecData, iPos, 4 ) ); diff --git a/src/util.h b/src/util.h index 23f31d14..909a6a00 100755 --- a/src/util.h +++ b/src/util.h @@ -430,9 +430,10 @@ public: CNetworkTransportProps ( const unsigned int iNNPS, const unsigned int iNMABS, const unsigned int iNNACH, const unsigned int iNSR, - const EAudComprType eNACT, const int iNACA ) : + const EAudComprType eNACT, const unsigned int iNVers, const int iNACA ) : iNetworkPacketSize ( iNNPS ), iMonoAudioBlockSize ( iNMABS ), - iNumAudioChannels ( iNNACH ), iSampleRate ( iNSR ), eAudioCodingType ( eNACT ), + iNumAudioChannels ( iNNACH ), iSampleRate ( iNSR ), + eAudioCodingType ( eNACT ), iVersion ( iNVers ), iAudioCodingArg ( iNACA ) {} unsigned int iNetworkPacketSize; @@ -440,6 +441,7 @@ public: unsigned int iNumAudioChannels; unsigned int iSampleRate; EAudComprType eAudioCodingType; + unsigned int iVersion; int iAudioCodingArg; };