[vlc-devel] [Patch] RTP reordering - dropping of old/duplicate packets
Marian Durkovic
md at bts.sk
Thu Sep 29 16:09:37 CEST 2005
Hi all,
I've added a bit of code to the UDP/RTP input, which assures that old
or duplicate RTP packets are trashed. When the network performs packet
reordering, only one discontinuity happens instead of 3 before - since
the old packet is trashed. If multiple copies of the same packet are
received, only one is used and all the others are trashed.
This is still not the full solution, since in case of packet reordering
this code is not able to restore the correct order and still creates one
discontinuity. But to avoid this, some kind of buffer needs to be
implemented, which would be able to hold the early packets until the
correct one arrives.
Please find the patch in the attachment.
With kind regards,
M.
--------------------------------------------------------------------------
---- ----
---- Marian Durkovic network manager ----
---- ----
---- Slovak Technical University Tel: +421 2 524 51 301 ----
---- Computer Centre, Nam. Slobody 17 Fax: +421 2 524 94 351 ----
---- 812 43 Bratislava, Slovak Republic E-mail/sip: md at bts.sk ----
---- ----
--------------------------------------------------------------------------
-------------- next part --------------
--- modules/access/udp.c Thu Sep 29 15:09:42 2005
+++ modules/access/udp.c.mod Thu Sep 29 15:21:01 2005
@@ -362,13 +362,23 @@
p_block->p_buffer += i_skip;
#define RTP_SEQ_NUM_SIZE 65536
+#define MAX_SEQNO_DELTA 50
+
/* Detect RTP packet loss through tracking sequence numbers.
* See RFC 1889. */
if( p_access->p_sys->i_sequence_number == -1 )
- p_access->p_sys->i_sequence_number = i_sequence_number;
+ p_access->p_sys->i_sequence_number = i_sequence_number - 1;
if( ((p_access->p_sys->i_sequence_number + 1) % RTP_SEQ_NUM_SIZE) != i_sequence_number )
{
+ if( ((p_access->p_sys->i_sequence_number - i_sequence_number + RTP_SEQ_NUM_SIZE) % RTP_SEQ_NUM_SIZE) < MAX_SEQNO_DELTA )
+ {
+ msg_Warn( p_access, "Trashing reordered/duplicate RTP packet, expected sequence number %d got %d",
+ ((p_access->p_sys->i_sequence_number + 1) % RTP_SEQ_NUM_SIZE),
+ i_sequence_number );
+ block_Release( p_block );
+ return NULL;
+ }
msg_Warn( p_access, "RTP packet(s) lost, expected sequence number %d got %d",
((p_access->p_sys->i_sequence_number + 1) % RTP_SEQ_NUM_SIZE),
i_sequence_number );
@@ -379,7 +389,10 @@
}
}
p_access->p_sys->i_sequence_number = i_sequence_number;
+
#undef RTP_SEQ_NUM_SIZE
+#undef MAX_SEQNO_DELTA
+
return p_block;
trash:
More information about the vlc-devel
mailing list