query jitter buffer size on first connection

This commit is contained in:
Volker Fischer 2006-03-07 21:26:40 +00:00
parent 452f7dfca3
commit 776d6b8a77
6 changed files with 101 additions and 65 deletions

View file

@ -30,47 +30,31 @@
\******************************************************************************/
CChannelSet::CChannelSet()
{
/*
// seems not to work...
// connect "message send"-message for each channel
for ( int i = 0; i < MAX_NUM_CHANNELS; i++ )
{
QObject::connect ( &vecChannels[i],
SIGNAL ( MessReadyForSending ( CVector<uint8_t> ) ),
this, SLOT ( OnSendProtMessage ( i, CVector<uint8_t> ) ) );
}
*/
// make sure we have MAX_NUM_CHANNELS connections!!!
QObject::connect(&vecChannels[0],SIGNAL(MessReadyForSending(CVector<uint8_t>)),
this,SLOT(OnSendProtMessCh0(CVector<uint8_t>)));
QObject::connect(&vecChannels[1],SIGNAL(MessReadyForSending(CVector<uint8_t>)),
this,SLOT(OnSendProtMessCh1(CVector<uint8_t>)));
QObject::connect(&vecChannels[2],SIGNAL(MessReadyForSending(CVector<uint8_t>)),
this,SLOT(OnSendProtMessCh2(CVector<uint8_t>)));
QObject::connect(&vecChannels[3],SIGNAL(MessReadyForSending(CVector<uint8_t>)),
this,SLOT(OnSendProtMessCh3(CVector<uint8_t>)));
QObject::connect(&vecChannels[4],SIGNAL(MessReadyForSending(CVector<uint8_t>)),
this,SLOT(OnSendProtMessCh4(CVector<uint8_t>)));
QObject::connect(&vecChannels[5],SIGNAL(MessReadyForSending(CVector<uint8_t>)),
this,SLOT(OnSendProtMessCh5(CVector<uint8_t>)));
QObject::connect(&vecChannels[6],SIGNAL(MessReadyForSending(CVector<uint8_t>)),
this,SLOT(OnSendProtMessCh6(CVector<uint8_t>)));
QObject::connect(&vecChannels[7],SIGNAL(MessReadyForSending(CVector<uint8_t>)),
this,SLOT(OnSendProtMessCh7(CVector<uint8_t>)));
QObject::connect(&vecChannels[8],SIGNAL(MessReadyForSending(CVector<uint8_t>)),
this,SLOT(OnSendProtMessCh8(CVector<uint8_t>)));
QObject::connect(&vecChannels[9],SIGNAL(MessReadyForSending(CVector<uint8_t>)),
this,SLOT(OnSendProtMessCh9(CVector<uint8_t>)));
}
// send message
QObject::connect(&vecChannels[0],SIGNAL(MessReadyForSending(CVector<uint8_t>)),this,SLOT(OnSendProtMessCh0(CVector<uint8_t>)));
QObject::connect(&vecChannels[1],SIGNAL(MessReadyForSending(CVector<uint8_t>)),this,SLOT(OnSendProtMessCh1(CVector<uint8_t>)));
QObject::connect(&vecChannels[2],SIGNAL(MessReadyForSending(CVector<uint8_t>)),this,SLOT(OnSendProtMessCh2(CVector<uint8_t>)));
QObject::connect(&vecChannels[3],SIGNAL(MessReadyForSending(CVector<uint8_t>)),this,SLOT(OnSendProtMessCh3(CVector<uint8_t>)));
QObject::connect(&vecChannels[4],SIGNAL(MessReadyForSending(CVector<uint8_t>)),this,SLOT(OnSendProtMessCh4(CVector<uint8_t>)));
QObject::connect(&vecChannels[5],SIGNAL(MessReadyForSending(CVector<uint8_t>)),this,SLOT(OnSendProtMessCh5(CVector<uint8_t>)));
QObject::connect(&vecChannels[6],SIGNAL(MessReadyForSending(CVector<uint8_t>)),this,SLOT(OnSendProtMessCh6(CVector<uint8_t>)));
QObject::connect(&vecChannels[7],SIGNAL(MessReadyForSending(CVector<uint8_t>)),this,SLOT(OnSendProtMessCh7(CVector<uint8_t>)));
QObject::connect(&vecChannels[8],SIGNAL(MessReadyForSending(CVector<uint8_t>)),this,SLOT(OnSendProtMessCh8(CVector<uint8_t>)));
QObject::connect(&vecChannels[9],SIGNAL(MessReadyForSending(CVector<uint8_t>)),this,SLOT(OnSendProtMessCh9(CVector<uint8_t>)));
/*
// seems not to work...
void CChannelSet::OnSendProtMessage ( int iChID, CVector<uint8_t> vecMessage )
{
// just pass message through and add channel ID
emit MessReadyForSending ( iChID,vecMessage );
// request jitter buffer size
QObject::connect(&vecChannels[0],SIGNAL(NewConnection()),this,SLOT(OnNewConnectionCh0()));
QObject::connect(&vecChannels[1],SIGNAL(NewConnection()),this,SLOT(OnNewConnectionCh1()));
QObject::connect(&vecChannels[2],SIGNAL(NewConnection()),this,SLOT(OnNewConnectionCh2()));
QObject::connect(&vecChannels[3],SIGNAL(NewConnection()),this,SLOT(OnNewConnectionCh3()));
QObject::connect(&vecChannels[4],SIGNAL(NewConnection()),this,SLOT(OnNewConnectionCh4()));
QObject::connect(&vecChannels[5],SIGNAL(NewConnection()),this,SLOT(OnNewConnectionCh5()));
QObject::connect(&vecChannels[6],SIGNAL(NewConnection()),this,SLOT(OnNewConnectionCh6()));
QObject::connect(&vecChannels[7],SIGNAL(NewConnection()),this,SLOT(OnNewConnectionCh7()));
QObject::connect(&vecChannels[8],SIGNAL(NewConnection()),this,SLOT(OnNewConnectionCh8()));
QObject::connect(&vecChannels[9],SIGNAL(NewConnection()),this,SLOT(OnNewConnectionCh9()));
}
*/
int CChannelSet::GetFreeChan()
{
@ -257,6 +241,9 @@ CChannel::CChannel ()
QObject::connect ( &Protocol, SIGNAL ( ChangeJittBufSize ( int ) ),
this, SLOT ( OnJittBufSizeChange ( int ) ) );
QObject::connect ( &Protocol, SIGNAL ( ReqJittBufSize() ),
SIGNAL ( ReqJittBufSize() ) );
}
void CChannel::OnSendProtMessage ( CVector<uint8_t> vecMessage )
@ -346,8 +333,8 @@ for (int i = 0; i < BLOCK_SIZE_SAMPLES; i++)
}
Mutex.unlock (); /* put mutex unlock */
// if channel was not connected, emit signal to inform that new connection
// was established
// if channel was not connected, emit signal to inform that new
// connection was established
if ( iConTimeOut == 0 )
{
emit NewConnection();

View file

@ -43,6 +43,7 @@
#define CON_TIME_OUT_CNT_MAX ( ( CON_TIME_OUT_SEC_MAX * 1000 ) / BLOCK_DURATION_MS )
/* maximum number of internet connections (channels) */
// if you want to change this paramter, change the connections in this class, too!
#define MAX_NUM_CHANNELS 10 /* max number channels for server */
/* no valid channel number */
@ -86,10 +87,8 @@ public:
int GetSockBufSize() { return SockBuf.GetSize(); }
// network protocol interface
void CreateJitBufMes ( const int iJitBufSize )
{
Protocol.CreateJitBufMes ( iJitBufSize );
}
void CreateJitBufMes ( const int iJitBufSize ) { Protocol.CreateJitBufMes ( iJitBufSize ); }
void CreateReqJitBufMes() { Protocol.CreateReqJitBufMes(); }
protected:
/* audio compression */
@ -129,6 +128,7 @@ public slots:
signals:
void MessReadyForSending ( CVector<uint8_t> vecMessage );
void NewConnection();
void ReqJittBufSize();
};
@ -172,11 +172,8 @@ protected:
QMutex Mutex;
public slots:
/*
// seems not to work...
void OnSendProtMessage ( int iChID, CVector<uint8_t> vecMessage );
*/
// make sure we have MAX_NUM_CHANNELS connections!!!
// send message
void OnSendProtMessCh0(CVector<uint8_t> mess) {emit MessReadyForSending(0,mess);}
void OnSendProtMessCh1(CVector<uint8_t> mess) {emit MessReadyForSending(1,mess);}
void OnSendProtMessCh2(CVector<uint8_t> mess) {emit MessReadyForSending(2,mess);}
@ -188,6 +185,17 @@ void OnSendProtMessCh7(CVector<uint8_t> mess) {emit MessReadyForSending(7,mess);
void OnSendProtMessCh8(CVector<uint8_t> mess) {emit MessReadyForSending(8,mess);}
void OnSendProtMessCh9(CVector<uint8_t> mess) {emit MessReadyForSending(9,mess);}
void OnNewConnectionCh0(CVector<uint8_t> mess) {vecChannels[0].CreateReqJitBufMes();}
void OnNewConnectionCh1(CVector<uint8_t> mess) {vecChannels[1].CreateReqJitBufMes();}
void OnNewConnectionCh2(CVector<uint8_t> mess) {vecChannels[2].CreateReqJitBufMes();}
void OnNewConnectionCh3(CVector<uint8_t> mess) {vecChannels[3].CreateReqJitBufMes();}
void OnNewConnectionCh4(CVector<uint8_t> mess) {vecChannels[4].CreateReqJitBufMes();}
void OnNewConnectionCh5(CVector<uint8_t> mess) {vecChannels[5].CreateReqJitBufMes();}
void OnNewConnectionCh6(CVector<uint8_t> mess) {vecChannels[6].CreateReqJitBufMes();}
void OnNewConnectionCh7(CVector<uint8_t> mess) {vecChannels[7].CreateReqJitBufMes();}
void OnNewConnectionCh8(CVector<uint8_t> mess) {vecChannels[8].CreateReqJitBufMes();}
void OnNewConnectionCh9(CVector<uint8_t> mess) {vecChannels[9].CreateReqJitBufMes();}
signals:
void MessReadyForSending ( int iChID, CVector<uint8_t> vecMessage );
};

View file

@ -34,6 +34,9 @@ CClient::CClient () : bRun ( false ), Socket ( &Channel ),
// connection for protocol
QObject::connect ( &Channel, SIGNAL ( MessReadyForSending ( CVector<uint8_t> ) ),
this, SLOT ( OnSendProtMessage ( CVector<uint8_t> ) ) );
QObject::connect ( &Channel, SIGNAL ( ReqJittBufSize() ),
this, SLOT ( OnReqJittBufSize() ) );
}
void CClient::OnSendProtMessage ( CVector<uint8_t> vecMessage )

View file

@ -146,6 +146,7 @@ protected:
public slots:
void OnSendProtMessage ( CVector<uint8_t> vecMessage );
void OnReqJittBufSize() { Channel.CreateJitBufMes ( Channel.GetSockBufSize() ); }
};

View file

@ -45,6 +45,9 @@ MESSAGES
| 2 bytes number of blocks |
+--------------------------+
- Request jitter buffer size: PROTMESSID_REQ_JITT_BUF_SIZE
no data
@ -240,6 +243,16 @@ for ( int i = 0; i < iNumBytes; i++ ) {
// send acknowledge message
CreateAndSendAcknMess ( iRecID, iRecCounter );
break;
case PROTMESSID_REQ_JITT_BUF_SIZE:
// invoke message action
emit ReqJittBufSize();
// send acknowledge message
CreateAndSendAcknMess ( iRecID, iRecCounter );
break;
}
}
@ -286,6 +299,27 @@ void CProtocol::CreateJitBufMes ( const int iJitBufSize )
Mutex.unlock();
}
void CProtocol::CreateReqJitBufMes()
{
Mutex.lock();
{
CVector<uint8_t> vecNewMessage;
// store current counter value
const int iCurCounter = iCounter;
// increase counter (wraps around automatically)
iCounter++;
// build complete message
GenMessageFrame ( vecNewMessage, iCurCounter, PROTMESSID_REQ_JITT_BUF_SIZE, CVector<uint8_t> ( 0 ) );
// enqueue message
EnqueueMessage ( vecNewMessage, iCurCounter, PROTMESSID_REQ_JITT_BUF_SIZE );
}
Mutex.unlock();
}
/******************************************************************************\
* Message generation (parsing) *

View file

@ -38,7 +38,8 @@
#define PROTMESSID_ILLEGAL 0 // illegal ID
#define PROTMESSID_ACKN 1 // acknowledge
#define PROTMESSID_JITT_BUF_SIZE 10 // jitter buffer size
#define PROTMESSID_PING 11 // for measuring ping time
#define PROTMESSID_REQ_JITT_BUF_SIZE 11 // request jitter buffer size
#define PROTMESSID_PING 12 // for measuring ping time
// lengths of message as defined in protocol.cpp file
#define MESS_HEADER_LENGTH_BYTE 5 /* ID, cnt, length */
@ -58,6 +59,7 @@ public:
virtual ~CProtocol() {}
void CreateJitBufMes ( const int iJitBufSize );
void CreateReqJitBufMes();
void CreateAndSendAcknMess ( const int& iID, const int& iCnt );
@ -131,6 +133,7 @@ signals:
// receiving
void ChangeJittBufSize ( int iNewJitBufSize );
void ReqJittBufSize();
};