Permalink
Browse files

Fix out-of-order RTP packet delivery.

  • Loading branch information...
daniel-kristjansson committed Mar 15, 2012
1 parent f160c64 commit c2d535fe36565a3e67462715b4ba5cd81049bf6b
Showing with 14 additions and 4 deletions.
  1. +14 −4 mythtv/libs/libmythtv/rtp/rtppacketbuffer.cpp
@@ -19,22 +19,28 @@ void RTPPacketBuffer::PushDataPacket(const UDPPacket &udp_packet)
bool large_was_seen_recently = m_large_sequence_number_seen_recently > 0;
m_large_sequence_number_seen_recently =
(key > (1U>>31)) ? 500 : m_large_sequence_number_seen_recently - 1;
(key > (1U<<15)) ? 500 : m_large_sequence_number_seen_recently - 1;
m_large_sequence_number_seen_recently =
max(m_large_sequence_number_seen_recently, 0);
if (m_large_sequence_number_seen_recently > 0)
{
if (key < (1U>>20))
key += 1ULL<<32;
if (key < 500)
key += 1ULL<<16;
}
else if (large_was_seen_recently)
{
m_current_sequence += 1ULL<<32;
m_current_sequence += 1ULL<<16;
}
key += m_current_sequence;
/*
LOG(VB_RECORD, LOG_DEBUG, QString("Pushing %1 as %2 (lr %3)")
.arg(packet.GetSequenceNumber()).arg(key)
.arg(m_large_sequence_number_seen_recently));
*/
m_unordered_packets[key] = packet;
// TODO pushing packets onto the ordered list should be based on
@@ -47,6 +53,10 @@ void RTPPacketBuffer::PushDataPacket(const UDPPacket &udp_packet)
{
QMap<uint64_t, RTPDataPacket>::iterator it =
m_unordered_packets.begin();
/*
LOG(VB_RECORD, LOG_DEBUG, QString("Popping %1 as %2")
.arg((*it).GetSequenceNumber()).arg(it.key()));
*/
m_available_packets.push_back(*it);
m_unordered_packets.erase(it);
}

0 comments on commit c2d535f

Please sign in to comment.