query jitter buffer size on first connection
This commit is contained in:
parent
452f7dfca3
commit
776d6b8a77
6 changed files with 101 additions and 65 deletions
|
@ -30,47 +30,31 @@
|
||||||
\******************************************************************************/
|
\******************************************************************************/
|
||||||
CChannelSet::CChannelSet()
|
CChannelSet::CChannelSet()
|
||||||
{
|
{
|
||||||
/*
|
// make sure we have MAX_NUM_CHANNELS connections!!!
|
||||||
// seems not to work...
|
// send message
|
||||||
// connect "message send"-message for each channel
|
QObject::connect(&vecChannels[0],SIGNAL(MessReadyForSending(CVector<uint8_t>)),this,SLOT(OnSendProtMessCh0(CVector<uint8_t>)));
|
||||||
for ( int i = 0; i < MAX_NUM_CHANNELS; i++ )
|
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[i],
|
QObject::connect(&vecChannels[3],SIGNAL(MessReadyForSending(CVector<uint8_t>)),this,SLOT(OnSendProtMessCh3(CVector<uint8_t>)));
|
||||||
SIGNAL ( MessReadyForSending ( CVector<uint8_t> ) ),
|
QObject::connect(&vecChannels[4],SIGNAL(MessReadyForSending(CVector<uint8_t>)),this,SLOT(OnSendProtMessCh4(CVector<uint8_t>)));
|
||||||
this, SLOT ( OnSendProtMessage ( i, 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>)));
|
||||||
// make sure we have MAX_NUM_CHANNELS connections!!!
|
QObject::connect(&vecChannels[8],SIGNAL(MessReadyForSending(CVector<uint8_t>)),this,SLOT(OnSendProtMessCh8(CVector<uint8_t>)));
|
||||||
QObject::connect(&vecChannels[0],SIGNAL(MessReadyForSending(CVector<uint8_t>)),
|
QObject::connect(&vecChannels[9],SIGNAL(MessReadyForSending(CVector<uint8_t>)),this,SLOT(OnSendProtMessCh9(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>)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
// request jitter buffer size
|
||||||
// seems not to work...
|
QObject::connect(&vecChannels[0],SIGNAL(NewConnection()),this,SLOT(OnNewConnectionCh0()));
|
||||||
void CChannelSet::OnSendProtMessage ( int iChID, CVector<uint8_t> vecMessage )
|
QObject::connect(&vecChannels[1],SIGNAL(NewConnection()),this,SLOT(OnNewConnectionCh1()));
|
||||||
{
|
QObject::connect(&vecChannels[2],SIGNAL(NewConnection()),this,SLOT(OnNewConnectionCh2()));
|
||||||
// just pass message through and add channel ID
|
QObject::connect(&vecChannels[3],SIGNAL(NewConnection()),this,SLOT(OnNewConnectionCh3()));
|
||||||
emit MessReadyForSending ( iChID,vecMessage );
|
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()
|
int CChannelSet::GetFreeChan()
|
||||||
{
|
{
|
||||||
|
@ -257,6 +241,9 @@ CChannel::CChannel ()
|
||||||
|
|
||||||
QObject::connect ( &Protocol, SIGNAL ( ChangeJittBufSize ( int ) ),
|
QObject::connect ( &Protocol, SIGNAL ( ChangeJittBufSize ( int ) ),
|
||||||
this, SLOT ( OnJittBufSizeChange ( int ) ) );
|
this, SLOT ( OnJittBufSizeChange ( int ) ) );
|
||||||
|
|
||||||
|
QObject::connect ( &Protocol, SIGNAL ( ReqJittBufSize() ),
|
||||||
|
SIGNAL ( ReqJittBufSize() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CChannel::OnSendProtMessage ( CVector<uint8_t> vecMessage )
|
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 */
|
Mutex.unlock (); /* put mutex unlock */
|
||||||
|
|
||||||
// if channel was not connected, emit signal to inform that new connection
|
// if channel was not connected, emit signal to inform that new
|
||||||
// was established
|
// connection was established
|
||||||
if ( iConTimeOut == 0 )
|
if ( iConTimeOut == 0 )
|
||||||
{
|
{
|
||||||
emit NewConnection();
|
emit NewConnection();
|
||||||
|
|
|
@ -42,7 +42,8 @@
|
||||||
#define CON_TIME_OUT_SEC_MAX 5 // seconds
|
#define CON_TIME_OUT_SEC_MAX 5 // seconds
|
||||||
#define CON_TIME_OUT_CNT_MAX ( ( CON_TIME_OUT_SEC_MAX * 1000 ) / BLOCK_DURATION_MS )
|
#define CON_TIME_OUT_CNT_MAX ( ( CON_TIME_OUT_SEC_MAX * 1000 ) / BLOCK_DURATION_MS )
|
||||||
|
|
||||||
/* maximum number of internet connections (channels) */
|
/* 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 */
|
#define MAX_NUM_CHANNELS 10 /* max number channels for server */
|
||||||
|
|
||||||
/* no valid channel number */
|
/* no valid channel number */
|
||||||
|
@ -86,10 +87,8 @@ public:
|
||||||
int GetSockBufSize() { return SockBuf.GetSize(); }
|
int GetSockBufSize() { return SockBuf.GetSize(); }
|
||||||
|
|
||||||
// network protocol interface
|
// network protocol interface
|
||||||
void CreateJitBufMes ( const int iJitBufSize )
|
void CreateJitBufMes ( const int iJitBufSize ) { Protocol.CreateJitBufMes ( iJitBufSize ); }
|
||||||
{
|
void CreateReqJitBufMes() { Protocol.CreateReqJitBufMes(); }
|
||||||
Protocol.CreateJitBufMes ( iJitBufSize );
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/* audio compression */
|
/* audio compression */
|
||||||
|
@ -129,6 +128,7 @@ public slots:
|
||||||
signals:
|
signals:
|
||||||
void MessReadyForSending ( CVector<uint8_t> vecMessage );
|
void MessReadyForSending ( CVector<uint8_t> vecMessage );
|
||||||
void NewConnection();
|
void NewConnection();
|
||||||
|
void ReqJittBufSize();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -172,21 +172,29 @@ protected:
|
||||||
QMutex Mutex;
|
QMutex Mutex;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
/*
|
// make sure we have MAX_NUM_CHANNELS connections!!!
|
||||||
// seems not to work...
|
// send message
|
||||||
void OnSendProtMessage ( int iChID, CVector<uint8_t> vecMessage );
|
void OnSendProtMessCh0(CVector<uint8_t> mess) {emit MessReadyForSending(0,mess);}
|
||||||
*/
|
void OnSendProtMessCh1(CVector<uint8_t> mess) {emit MessReadyForSending(1,mess);}
|
||||||
// make sure we have MAX_NUM_CHANNELS connections!!!
|
void OnSendProtMessCh2(CVector<uint8_t> mess) {emit MessReadyForSending(2,mess);}
|
||||||
void OnSendProtMessCh0(CVector<uint8_t> mess) {emit MessReadyForSending(0,mess);}
|
void OnSendProtMessCh3(CVector<uint8_t> mess) {emit MessReadyForSending(3,mess);}
|
||||||
void OnSendProtMessCh1(CVector<uint8_t> mess) {emit MessReadyForSending(1,mess);}
|
void OnSendProtMessCh4(CVector<uint8_t> mess) {emit MessReadyForSending(4,mess);}
|
||||||
void OnSendProtMessCh2(CVector<uint8_t> mess) {emit MessReadyForSending(2,mess);}
|
void OnSendProtMessCh5(CVector<uint8_t> mess) {emit MessReadyForSending(5,mess);}
|
||||||
void OnSendProtMessCh3(CVector<uint8_t> mess) {emit MessReadyForSending(3,mess);}
|
void OnSendProtMessCh6(CVector<uint8_t> mess) {emit MessReadyForSending(6,mess);}
|
||||||
void OnSendProtMessCh4(CVector<uint8_t> mess) {emit MessReadyForSending(4,mess);}
|
void OnSendProtMessCh7(CVector<uint8_t> mess) {emit MessReadyForSending(7,mess);}
|
||||||
void OnSendProtMessCh5(CVector<uint8_t> mess) {emit MessReadyForSending(5,mess);}
|
void OnSendProtMessCh8(CVector<uint8_t> mess) {emit MessReadyForSending(8,mess);}
|
||||||
void OnSendProtMessCh6(CVector<uint8_t> mess) {emit MessReadyForSending(6,mess);}
|
void OnSendProtMessCh9(CVector<uint8_t> mess) {emit MessReadyForSending(9,mess);}
|
||||||
void OnSendProtMessCh7(CVector<uint8_t> mess) {emit MessReadyForSending(7,mess);}
|
|
||||||
void OnSendProtMessCh8(CVector<uint8_t> mess) {emit MessReadyForSending(8,mess);}
|
void OnNewConnectionCh0(CVector<uint8_t> mess) {vecChannels[0].CreateReqJitBufMes();}
|
||||||
void OnSendProtMessCh9(CVector<uint8_t> mess) {emit MessReadyForSending(9,mess);}
|
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:
|
signals:
|
||||||
void MessReadyForSending ( int iChID, CVector<uint8_t> vecMessage );
|
void MessReadyForSending ( int iChID, CVector<uint8_t> vecMessage );
|
||||||
|
|
|
@ -34,6 +34,9 @@ CClient::CClient () : bRun ( false ), Socket ( &Channel ),
|
||||||
// connection for protocol
|
// connection for protocol
|
||||||
QObject::connect ( &Channel, SIGNAL ( MessReadyForSending ( CVector<uint8_t> ) ),
|
QObject::connect ( &Channel, SIGNAL ( MessReadyForSending ( CVector<uint8_t> ) ),
|
||||||
this, SLOT ( OnSendProtMessage ( CVector<uint8_t> ) ) );
|
this, SLOT ( OnSendProtMessage ( CVector<uint8_t> ) ) );
|
||||||
|
|
||||||
|
QObject::connect ( &Channel, SIGNAL ( ReqJittBufSize() ),
|
||||||
|
this, SLOT ( OnReqJittBufSize() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CClient::OnSendProtMessage ( CVector<uint8_t> vecMessage )
|
void CClient::OnSendProtMessage ( CVector<uint8_t> vecMessage )
|
||||||
|
|
|
@ -146,6 +146,7 @@ protected:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void OnSendProtMessage ( CVector<uint8_t> vecMessage );
|
void OnSendProtMessage ( CVector<uint8_t> vecMessage );
|
||||||
|
void OnReqJittBufSize() { Channel.CreateJitBufMes ( Channel.GetSockBufSize() ); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,9 @@ MESSAGES
|
||||||
| 2 bytes number of blocks |
|
| 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
|
// send acknowledge message
|
||||||
CreateAndSendAcknMess ( iRecID, iRecCounter );
|
CreateAndSendAcknMess ( iRecID, iRecCounter );
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PROTMESSID_REQ_JITT_BUF_SIZE:
|
||||||
|
|
||||||
|
// invoke message action
|
||||||
|
emit ReqJittBufSize();
|
||||||
|
|
||||||
|
// send acknowledge message
|
||||||
|
CreateAndSendAcknMess ( iRecID, iRecCounter );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -286,6 +299,27 @@ void CProtocol::CreateJitBufMes ( const int iJitBufSize )
|
||||||
Mutex.unlock();
|
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) *
|
* Message generation (parsing) *
|
||||||
|
|
|
@ -35,10 +35,11 @@
|
||||||
|
|
||||||
/* Definitions ****************************************************************/
|
/* Definitions ****************************************************************/
|
||||||
// protocol message IDs
|
// protocol message IDs
|
||||||
#define PROTMESSID_ILLEGAL 0 // illegal ID
|
#define PROTMESSID_ILLEGAL 0 // illegal ID
|
||||||
#define PROTMESSID_ACKN 1 // acknowledge
|
#define PROTMESSID_ACKN 1 // acknowledge
|
||||||
#define PROTMESSID_JITT_BUF_SIZE 10 // jitter buffer size
|
#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
|
// lengths of message as defined in protocol.cpp file
|
||||||
#define MESS_HEADER_LENGTH_BYTE 5 /* ID, cnt, length */
|
#define MESS_HEADER_LENGTH_BYTE 5 /* ID, cnt, length */
|
||||||
|
@ -58,6 +59,7 @@ public:
|
||||||
virtual ~CProtocol() {}
|
virtual ~CProtocol() {}
|
||||||
|
|
||||||
void CreateJitBufMes ( const int iJitBufSize );
|
void CreateJitBufMes ( const int iJitBufSize );
|
||||||
|
void CreateReqJitBufMes();
|
||||||
|
|
||||||
void CreateAndSendAcknMess ( const int& iID, const int& iCnt );
|
void CreateAndSendAcknMess ( const int& iID, const int& iCnt );
|
||||||
|
|
||||||
|
@ -131,6 +133,7 @@ signals:
|
||||||
|
|
||||||
// receiving
|
// receiving
|
||||||
void ChangeJittBufSize ( int iNewJitBufSize );
|
void ChangeJittBufSize ( int iNewJitBufSize );
|
||||||
|
void ReqJittBufSize();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue