summaryrefslogtreecommitdiff
path: root/gst/rtpmanager/rtpsource.c
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2015-05-18 17:07:23 +0300
committerSebastian Dröge <sebastian@centricular.com>2015-05-18 18:43:16 +0300
commit3386de7a8a765c4f750454888790415138c0805e (patch)
tree3b362d52ea478072644e219eb407b036caa1af8c /gst/rtpmanager/rtpsource.c
parentca110fb0b838c49d31d44c2302b948de8ab01e08 (diff)
rtpsource: Make sequence number comparison code more readable
... by using gst_rtp_buffer_compare_seqnum() and signed integers instead of implictly using effects of integer over/underflows.
Diffstat (limited to 'gst/rtpmanager/rtpsource.c')
-rw-r--r--gst/rtpmanager/rtpsource.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/gst/rtpmanager/rtpsource.c b/gst/rtpmanager/rtpsource.c
index d97adc4ea..2e984e335 100644
--- a/gst/rtpmanager/rtpsource.c
+++ b/gst/rtpmanager/rtpsource.c
@@ -997,9 +997,9 @@ do_bitrate_estimation (RTPSource * src, GstClockTime running_time,
static gboolean
update_receiver_stats (RTPSource * src, RTPPacketInfo * pinfo)
{
- guint16 seqnr, udelta;
+ guint16 seqnr, expected;
RTPSourceStats *stats;
- guint16 expected;
+ gint16 delta;
stats = &src->stats;
@@ -1013,7 +1013,7 @@ update_receiver_stats (RTPSource * src, RTPPacketInfo * pinfo)
src->curr_probation = src->probation;
}
- udelta = seqnr - stats->max_seq;
+ delta = gst_rtp_buffer_compare_seqnum (stats->max_seq, seqnr);
/* if we are still on probation, check seqnum */
if (src->curr_probation) {
@@ -1046,14 +1046,14 @@ update_receiver_stats (RTPSource * src, RTPPacketInfo * pinfo)
/* unexpected seqnum in probation */
goto probation_seqnum;
}
- } else if (udelta < RTP_MAX_DROPOUT) {
+ } else if (delta > 0 && delta < RTP_MAX_DROPOUT) {
/* in order, with permissible gap */
if (seqnr < stats->max_seq) {
/* sequence number wrapped - count another 64K cycle. */
stats->cycles += RTP_SEQ_MOD;
}
stats->max_seq = seqnr;
- } else if (udelta <= RTP_SEQ_MOD - RTP_MAX_MISORDER) {
+ } else if (delta < -RTP_MAX_MISORDER || delta >= RTP_MAX_DROPOUT) {
/* the sequence number made a very large jump */
if (seqnr == stats->bad_seq) {
/* two sequential packets -- assume that the other side
@@ -1065,9 +1065,10 @@ update_receiver_stats (RTPSource * src, RTPPacketInfo * pinfo)
stats->bad_seq = (seqnr + 1) & (RTP_SEQ_MOD - 1);
goto bad_sequence;
}
- } else {
+ } else { /* delta <= 0 && delta >= -RTP_MAX_MISORDER */
/* duplicate or reordered packet, will be filtered by jitterbuffer. */
- GST_WARNING ("duplicate or reordered packet (seqnr %d)", seqnr);
+ GST_WARNING ("duplicate or reordered packet (seqnr %d, max seq %d)", seqnr,
+ stats->max_seq);
}
src->stats.octets_received += pinfo->payload_len;