|
|
|
@ -4,6 +4,7 @@
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Created by Jean-Luc Deltombe (LX3JL) on 01/11/2015.
|
|
|
|
// Created by Jean-Luc Deltombe (LX3JL) on 01/11/2015.
|
|
|
|
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
|
|
|
|
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
|
|
|
|
|
|
|
|
// Copyright © 2020 Thomas A. Early, N7TAE
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// This file is part of xlxd.
|
|
|
|
// This file is part of xlxd.
|
|
|
|
@ -36,7 +37,6 @@ CProtocol::CProtocol()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
m_bStopThread = false;
|
|
|
|
m_bStopThread = false;
|
|
|
|
m_pThread = NULL;
|
|
|
|
m_pThread = NULL;
|
|
|
|
m_Streams.reserve(NB_OF_MODULES);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -138,7 +138,12 @@ void CProtocol::OnDvFramePacketIn(CDvFramePacket *Frame, const CIp *Ip)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// find the stream
|
|
|
|
// find the stream
|
|
|
|
CPacketStream *stream = GetStream(Frame->GetStreamId(), Ip);
|
|
|
|
CPacketStream *stream = GetStream(Frame->GetStreamId(), Ip);
|
|
|
|
if ( stream != NULL )
|
|
|
|
if ( stream == NULL )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
std::cout << "Deleting orphaned Frame with ID " << Frame->GetStreamId() << " on " << Ip << std::endl;
|
|
|
|
|
|
|
|
delete Frame;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//std::cout << "DV frame" << "from " << *Ip << std::endl;
|
|
|
|
//std::cout << "DV frame" << "from " << *Ip << std::endl;
|
|
|
|
// and push
|
|
|
|
// and push
|
|
|
|
@ -152,7 +157,12 @@ void CProtocol::OnDvLastFramePacketIn(CDvLastFramePacket *Frame, const CIp *Ip)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// find the stream
|
|
|
|
// find the stream
|
|
|
|
CPacketStream *stream = GetStream(Frame->GetStreamId(), Ip);
|
|
|
|
CPacketStream *stream = GetStream(Frame->GetStreamId(), Ip);
|
|
|
|
if ( stream != NULL )
|
|
|
|
if ( stream == NULL )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
std::cout << "Deleting orphaned Last Frame with ID " << Frame->GetStreamId() << " on " << Ip << std::endl;
|
|
|
|
|
|
|
|
delete Frame;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// push
|
|
|
|
// push
|
|
|
|
stream->Lock();
|
|
|
|
stream->Lock();
|
|
|
|
@ -169,44 +179,41 @@ void CProtocol::OnDvLastFramePacketIn(CDvLastFramePacket *Frame, const CIp *Ip)
|
|
|
|
|
|
|
|
|
|
|
|
CPacketStream *CProtocol::GetStream(uint16 uiStreamId, const CIp *Ip)
|
|
|
|
CPacketStream *CProtocol::GetStream(uint16 uiStreamId, const CIp *Ip)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CPacketStream *stream = NULL;
|
|
|
|
for ( auto it=m_Streams.begin(); it!=m_Streams.end(); it++ )
|
|
|
|
|
|
|
|
|
|
|
|
// find if we have a stream with same streamid in our cache
|
|
|
|
|
|
|
|
for ( int i = 0; (i < m_Streams.size()) && (stream == NULL); i++ )
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ( m_Streams[i]->GetStreamId() == uiStreamId )
|
|
|
|
if ( (*it)->GetStreamId() == uiStreamId )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// if Ip not NULL, also check if IP match
|
|
|
|
// if Ip not NULL, also check if IP match
|
|
|
|
if ( (Ip != NULL) && (m_Streams[i]->GetOwnerIp() != NULL) )
|
|
|
|
if ( (Ip != NULL) && ((*it)->GetOwnerIp() != NULL) )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ( *Ip == *(m_Streams[i]->GetOwnerIp()) )
|
|
|
|
if ( *Ip == *((*it)->GetOwnerIp()) )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
stream = m_Streams[i];
|
|
|
|
return *it;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// done
|
|
|
|
// done
|
|
|
|
return stream;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CProtocol::CheckStreamsTimeout(void)
|
|
|
|
void CProtocol::CheckStreamsTimeout(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for ( int i = 0; i < m_Streams.size(); i++ )
|
|
|
|
for ( auto it=m_Streams.begin(); it!=m_Streams.end(); )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// time out ?
|
|
|
|
// time out ?
|
|
|
|
m_Streams[i]->Lock();
|
|
|
|
(*it)->Lock();
|
|
|
|
if ( m_Streams[i]->IsExpired() )
|
|
|
|
if ( (*it)->IsExpired() )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// yes, close it
|
|
|
|
// yes, close it
|
|
|
|
m_Streams[i]->Unlock();
|
|
|
|
(*it)->Unlock();
|
|
|
|
g_Reflector.CloseStream(m_Streams[i]);
|
|
|
|
g_Reflector.CloseStream(*it);
|
|
|
|
// and remove it
|
|
|
|
// and remove it
|
|
|
|
m_Streams.erase(m_Streams.begin()+i);
|
|
|
|
it = m_Streams.erase(it);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
m_Streams[i]->Unlock();
|
|
|
|
(*it++)->Unlock();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -256,5 +263,3 @@ uint32 CProtocol::ModuleToDmrDestId(char m) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return (uint32)(m - 'A')+1;
|
|
|
|
return (uint32)(m - 'A')+1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|