diff --git a/src/channel.cpp b/src/channel.cpp index a6d3c558..7e914cda 100755 --- a/src/channel.cpp +++ b/src/channel.cpp @@ -419,7 +419,6 @@ EPutDataStat CChannel::PutData ( const CVector& vecbyData, // init flags bool bIsProtocolPacket = false; - bool bIsAudioPacket = false; bool bNewConnection = false; if ( bIsEnabled ) @@ -460,9 +459,6 @@ EPutDataStat CChannel::PutData ( const CVector& vecbyData, // only process audio if packet has correct size if ( iNumBytes == ( iNetwFrameSize * iNetwFrameSizeFact ) ) { - // set audio packet flag - bIsAudioPacket = true; - // store new packet in jitter buffer if ( SockBuf.Put ( vecbyData, iNumBytes ) ) { @@ -488,6 +484,8 @@ EPutDataStat CChannel::PutData ( const CVector& vecbyData, // about the audio packet properties via the protocol // check if channel was not connected, this is a new connection + // (do not fire an event directly since we are inside a mutex + // region -> to avoid a dead-lock) bNewConnection = !IsConnected(); // reset time-out counter @@ -498,23 +496,6 @@ EPutDataStat CChannel::PutData ( const CVector& vecbyData, 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 - // (this is only required for server since we defined that the - // server has to send with the same properties as sent by - // the client) - -// TODO check the conditions: !bIsProtocolPacket should always be true -// since we can only get here if bNewConnection, should we really put -// !bIsAudioPacket in here, because shouldn't we always query the audio -// properties on a new connection? - - if ( bIsServer && ( !bIsProtocolPacket ) && ( !bIsAudioPacket ) ) - { - Protocol.CreateReqNetwTranspPropsMes(); - } - // inform other objects that new connection was established emit NewConnection(); } diff --git a/src/channel.h b/src/channel.h index da01dad6..7abaf865 100755 --- a/src/channel.h +++ b/src/channel.h @@ -137,6 +137,7 @@ Protocol.CreateChanNameMes ( ChInfo.strName ); Protocol.CreateJitBufMes ( iJitBufSize ); } } + void CreateReqNetwTranspPropsMes() { Protocol.CreateReqNetwTranspPropsMes(); } void CreateReqJitBufMes() { Protocol.CreateReqJitBufMes(); } void CreateReqConnClientsList() { Protocol.CreateReqConnClientsList(); } void CreateChatTextMes ( const QString& strChatText ) { Protocol.CreateChatTextMes ( strChatText ); } diff --git a/src/server.cpp b/src/server.cpp index 94e2c945..54c56400 100755 --- a/src/server.cpp +++ b/src/server.cpp @@ -514,6 +514,21 @@ void CServer::OnSendProtMessage ( int iChID, CVector vecMessage ) Socket.SendPacket ( vecMessage, vecChannels[iChID].GetAddress() ); } +void CServer::OnNewConnection ( int iChID ) +{ + // on a new connection we query the network transport properties for the + // audio packets (to use the correct network block size and audio + // compression properties, etc.) + vecChannels[iChID].CreateReqNetwTranspPropsMes(); + + // this is a new connection, query the jitter buffer size we shall use + // for this client (note that at the same time on a new connection the + // client sends the jitter buffer size by default but maybe we have + // reached a state where this did not happen because of network trouble, + // client or server thinks that the connection was still active, etc.) + vecChannels[iChID].CreateReqJitBufMes(); +} + void CServer::OnSendCLProtMessage ( CHostAddress InetAddr, CVector vecMessage ) { diff --git a/src/server.h b/src/server.h index c36bfb7a..3f351ad8 100755 --- a/src/server.h +++ b/src/server.h @@ -262,6 +262,7 @@ signals: public slots: void OnTimer(); void OnSendProtMessage ( int iChID, CVector vecMessage ); + void OnNewConnection ( int iChID ); void OnSendCLProtMessage ( CHostAddress InetAddr, CVector vecMessage ); void OnDetCLMess ( const CVector& vecbyData, @@ -337,18 +338,18 @@ public slots: void OnDetCLMessCh10 ( CVector vData, int iNBy ) { OnDetCLMess ( vData, iNBy, vecChannels[10].GetAddress() ); } void OnDetCLMessCh11 ( CVector vData, int iNBy ) { OnDetCLMess ( vData, iNBy, vecChannels[11].GetAddress() ); } - void OnNewConnectionCh0() { vecChannels[0].CreateReqJitBufMes(); } - void OnNewConnectionCh1() { vecChannels[1].CreateReqJitBufMes(); } - void OnNewConnectionCh2() { vecChannels[2].CreateReqJitBufMes(); } - void OnNewConnectionCh3() { vecChannels[3].CreateReqJitBufMes(); } - void OnNewConnectionCh4() { vecChannels[4].CreateReqJitBufMes(); } - void OnNewConnectionCh5() { vecChannels[5].CreateReqJitBufMes(); } - void OnNewConnectionCh6() { vecChannels[6].CreateReqJitBufMes(); } - void OnNewConnectionCh7() { vecChannels[7].CreateReqJitBufMes(); } - void OnNewConnectionCh8() { vecChannels[8].CreateReqJitBufMes(); } - void OnNewConnectionCh9() { vecChannels[9].CreateReqJitBufMes(); } - void OnNewConnectionCh10() { vecChannels[10].CreateReqJitBufMes(); } - void OnNewConnectionCh11() { vecChannels[11].CreateReqJitBufMes(); } + void OnNewConnectionCh0() { OnNewConnection ( 0 ); } + void OnNewConnectionCh1() { OnNewConnection ( 1 ); } + void OnNewConnectionCh2() { OnNewConnection ( 2 ); } + void OnNewConnectionCh3() { OnNewConnection ( 3 ); } + void OnNewConnectionCh4() { OnNewConnection ( 4 ); } + void OnNewConnectionCh5() { OnNewConnection ( 5 ); } + void OnNewConnectionCh6() { OnNewConnection ( 6 ); } + void OnNewConnectionCh7() { OnNewConnection ( 7 ); } + void OnNewConnectionCh8() { OnNewConnection ( 8 ); } + void OnNewConnectionCh9() { OnNewConnection ( 9 ); } + void OnNewConnectionCh10() { OnNewConnection ( 10 ); } + void OnNewConnectionCh11() { OnNewConnection ( 11 ); } void OnReqConnClientsListCh0() { CreateAndSendChanListForThisChan ( 0 ); } void OnReqConnClientsListCh1() { CreateAndSendChanListForThisChan ( 1 ); }