Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Jamulus.pro
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,8 @@ HEADERS += src/plugins/audioreverb.h \
src/serverlogging.h \
src/settings.h \
src/socket.h \
src/tcpserver.h \
src/tcpconnection.h \
src/util.h \
src/recorder/jamrecorder.h \
src/recorder/creaperproject.h \
Expand Down Expand Up @@ -520,6 +522,8 @@ SOURCES += src/plugins/audioreverb.cpp \
src/settings.cpp \
src/signalhandler.cpp \
src/socket.cpp \
src/tcpserver.cpp \
src/tcpconnection.cpp \
src/util.cpp \
src/recorder/jamrecorder.cpp \
src/recorder/creaperproject.cpp \
Expand Down
217 changes: 217 additions & 0 deletions docs/TCP.md
Comment thread
pljones marked this conversation as resolved.

Large diffs are not rendered by default.

29 changes: 28 additions & 1 deletion src/channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@

// CChannel implementation *****************************************************
CChannel::CChannel ( const bool bNIsServer ) :
pTcpConnection ( nullptr ),
vecfGains ( MAX_NUM_CHANNELS, 1.0f ),
vecfPannings ( MAX_NUM_CHANNELS, 0.5f ),
iCurSockBufNumFrames ( INVALID_INDEX ),
Expand All @@ -59,6 +60,7 @@ CChannel::CChannel ( const bool bNIsServer ) :
bIsEnabled ( false ),
bIsServer ( bNIsServer ),
bIsIdentified ( false ),
iChannelToken ( 0 ),
iAudioFrameSizeSamples ( DOUBLE_SYSTEM_FRAME_SIZE_SAMPLES ),
SignalLevelMeter ( false, 0.5 ) // server mode with mono out and faster smoothing
{
Expand Down Expand Up @@ -103,7 +105,7 @@ CChannel::CChannel ( const bool bNIsServer ) :

QObject::connect ( &Protocol, &CProtocol::ChangeChanPan, this, &CChannel::OnChangeChanPan );

QObject::connect ( &Protocol, &CProtocol::ClientIDReceived, this, &CChannel::ClientIDReceived );
QObject::connect ( &Protocol, &CProtocol::ClientIDReceived, this, &CChannel::OnClientIDReceived );

QObject::connect ( &Protocol, &CProtocol::RawAudioSupported, this, &CChannel::RawAudioSupported );

Expand Down Expand Up @@ -737,3 +739,28 @@ void CChannel::UpdateSocketBufferSize()
SetSockBufNumFrames ( SockBuf.GetAutoSetting(), true );
}
}

void CChannel::OnClientIDReceived ( int iChanID ) { emit ClientIDReceived ( iChanID ); }

void CChannel::CreateConClientListMes ( const CVector<CChannelInfo>& vecChanInfo, CProtocol& ConnLessProtocol )
{
if ( pTcpConnection )
{
ConnLessProtocol.CreateCLConnClientsListMes ( InetAddr, vecChanInfo, pTcpConnection );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should make clear why the connectionless protocol is used here - I suppose since TCP handles the session, it's enough.

}
else
{
Protocol.CreateConClientListMes ( vecChanInfo );
}
}

void CChannel::SetTcpConnection ( CTcpConnection* pConnection )
{
if ( pTcpConnection )
{
// this should never happen, but handle it if it does
pTcpConnection->disconnectFromHost();
}

pTcpConnection = pConnection;
}
20 changes: 15 additions & 5 deletions src/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,15 @@ class CChannel : public QObject
void SetEnable ( const bool bNEnStat );
bool IsEnabled() { return bIsEnabled; }

void SetChannelToken ( const quint32 iNChannelToken ) { iChannelToken = iNChannelToken; }
quint32 GetChannelToken() { return iChannelToken; }

void SetAddress ( const CHostAddress& NAddr ) { InetAddr = NAddr; }
const CHostAddress& GetAddress() const { return InetAddr; }

void SetTcpConnection ( CTcpConnection* pConnection );
CTcpConnection* GetTcpConnection() { return pTcpConnection; }

void ResetInfo()
{
bIsIdentified = false;
Expand Down Expand Up @@ -185,7 +191,7 @@ class CChannel : public QObject
void CreateReqChannelLevelListMes() { Protocol.CreateReqChannelLevelListMes(); }
//### TODO: END ###//

void CreateConClientListMes ( const CVector<CChannelInfo>& vecChanInfo ) { Protocol.CreateConClientListMes ( vecChanInfo ); }
void CreateConClientListMes ( const CVector<CChannelInfo>& vecChanInfo, CProtocol& ConnLessProtocol );

void CreateRecorderStateMes ( const ERecorderState eRecorderState ) { Protocol.CreateRecorderStateMes ( eRecorderState ); }

Expand All @@ -210,7 +216,8 @@ class CChannel : public QObject
}

// connection parameters
CHostAddress InetAddr;
CHostAddress InetAddr;
CTcpConnection* pTcpConnection;

// channel info
CChannelCoreInfo ChannelInfo;
Expand Down Expand Up @@ -241,6 +248,8 @@ class CChannel : public QObject
bool bIsServer;
bool bIsIdentified;

quint32 iChannelToken;

int iNetwFrameSizeFact;
int iNetwFrameSize;
int iCeltNumCodedBytes;
Expand Down Expand Up @@ -279,11 +288,12 @@ public slots:
PutProtocolData ( iRecCounter, iRecID, vecbyMesBodyData, RecHostAddr );
}

void OnProtocolCLMessageReceived ( int iRecID, CVector<uint8_t> vecbyMesBodyData, CHostAddress RecHostAddr )
void OnProtocolCLMessageReceived ( int iRecID, CVector<uint8_t> vecbyMesBodyData, CHostAddress RecHostAddr, CTcpConnection* pTcpConnection )
{
emit DetectedCLMessage ( vecbyMesBodyData, iRecID, RecHostAddr );
emit DetectedCLMessage ( vecbyMesBodyData, iRecID, RecHostAddr, pTcpConnection );
}

void OnClientIDReceived ( int iChanID );
void OnNewConnection() { emit NewConnection(); }

signals:
Expand All @@ -307,7 +317,7 @@ public slots:
void RecorderStateReceived ( ERecorderState eRecorderState );
void Disconnected();

void DetectedCLMessage ( CVector<uint8_t> vecbyMesBodyData, int iRecID, CHostAddress RecHostAddr );
void DetectedCLMessage ( CVector<uint8_t> vecbyMesBodyData, int iRecID, CHostAddress RecHostAddr, CTcpConnection* pTcpConnection );

void ParseMessageBody ( CVector<uint8_t> vecbyMesBodyData, int iRecCounter, int iRecID );
};
Loading
Loading