better sequence counting in CM17Protocol

unstable
Tom Early 4 years ago
parent bf6ed1d3a8
commit f11cb695a1

@ -54,14 +54,14 @@ CCodecStream::~CCodecStream()
} }
// display stats // display stats
if (m_RTMin >= 0.0) if (m_RTCount > 0)
{ {
double min = m_RTMin * 1000.0; double min = 1000.0 * m_RTMin;
double max = m_RTMax * 1000.0; double max = 1000.0 * m_RTMax;
double ave = (m_RTCount > 0) ? m_RTSum / m_RTCount * 1000.0 : 0.0; double ave = 1000.0 * m_RTSum / double(m_RTCount);
auto prec = std::cout.precision(); auto prec = std::cout.precision();
std::cout.precision(1); std::cout.precision(1);
std::cout << std::fixed << "Transcoder Stats (ms): " << min << "/" << ave << "/" << max << std::endl; std::cout << std::fixed << "TC round-trip time(ms): " << min << "/" << ave << "/" << max << ", " << m_RTCount << " total packets" << std::endl;
std::cout.precision(prec); std::cout.precision(prec);
} }
} }
@ -103,7 +103,7 @@ void CCodecStream::Task(void)
if (m_TCReader->Receive(&pack, 5)) if (m_TCReader->Receive(&pack, 5))
{ {
// update statistics // update statistics
double rt = pack.rt_timer.time(); double rt = pack.rt_timer.time(); // the round-trip time
if ( m_RTMin == -1 ) if ( m_RTMin == -1 )
{ {
m_RTMin = rt; m_RTMin = rt;
@ -117,7 +117,7 @@ void CCodecStream::Task(void)
} }
m_RTSum += rt; m_RTSum += rt;
m_RTCount += 1; m_RTCount++;
if ( m_LocalQueue.empty() ) if ( m_LocalQueue.empty() )
{ {

@ -68,6 +68,6 @@ protected:
double m_RTMin; double m_RTMin;
double m_RTMax; double m_RTMax;
double m_RTSum; double m_RTSum;
double m_RTCount; unsigned int m_RTCount;
uint32_t m_uiTotalPackets; uint32_t m_uiTotalPackets;
}; };

@ -236,12 +236,14 @@ void CM17Protocol::HandleQueue(void)
m_StreamsCache[module].m_dvHeader = CDvHeaderPacket((const CDvHeaderPacket &)*packet.get()); m_StreamsCache[module].m_dvHeader = CDvHeaderPacket((const CDvHeaderPacket &)*packet.get());
m_StreamsCache[module].m_iSeqCounter = 0; m_StreamsCache[module].m_iSeqCounter = 0;
} }
else if ( packet->IsDvFrame() && ((1 == m_StreamsCache[module].m_iSeqCounter++ % 2) || packet->IsLastPacket())) else if (packet->IsDvFrame())
{
if ((1 == m_StreamsCache[module].m_iSeqCounter % 2) || packet->IsLastPacket())
{ {
// encode it // encode it
SM17Frame frame; SM17Frame frame;
EncodeM17Packet(frame, m_StreamsCache[module].m_dvHeader, (CDvFramePacket *)packet.get(), m_StreamsCache[module].m_iSeqCounter-1); EncodeM17Packet(frame, m_StreamsCache[module].m_dvHeader, (CDvFramePacket *)packet.get(), m_StreamsCache[module].m_iSeqCounter);
// push it to all our clients linked to the module and who are not streaming in // push it to all our clients linked to the module and who are not streaming in
CClients *clients = g_Reflector.GetClients(); CClients *clients = g_Reflector.GetClients();
@ -263,6 +265,8 @@ void CM17Protocol::HandleQueue(void)
} }
g_Reflector.ReleaseClients(); g_Reflector.ReleaseClients();
} }
m_StreamsCache[module].m_iSeqCounter++;
}
} }
m_Queue.Unlock(); m_Queue.Unlock();
} }

Loading…
Cancel
Save

Powered by TurnKey Linux.