After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 533075 - gst_rtp_buffer_compare_seqnum doesn't do what it says
gst_rtp_buffer_compare_seqnum doesn't do what it says
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
git master
Other All
: Normal normal
: 0.10.20
Assigned To: Wim Taymans
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2008-05-14 08:51 UTC by Bernard B
Modified: 2008-05-14 13:43 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Bernard B 2008-05-14 08:51:03 UTC
A recent comment change for gst_rtp_buffer_compare_seqnum says that it will return the difference in sequence numbers. In its current implementation, it does not. e.g. gst_rtp_buffer_compare_seqnum(0xFFFF, 0) returns 65535, not -1 as desired.

A much easier approach is to cast the difference into a signed gint16, then into an gint (the function's return type), then the compiler and OS takes care of the wraparound and sign extension for you. e.g.

gint
gst_rtp_buffer_compare_seqnum (guint16 seqnum1, guint16 seqnum2)
{
  return (gint16)(seqnum2-seqnum1);
}

This survives this simple test below (apologies for not making it an attachment), where as the original function (revision 1.22 of gstrtpbuffer.c) does not.

void test()
{
  int i, diff;
  uint16 a, b;
  for (diff = -100; diff < 100; diff++) {
    a = 0;
    for (i = 0; i < 0x20000; i++) {
      b = a + diff;
      assert(gst_rtp_buffer_compare_seqnum(a, b) == diff);
      a++;
    }
  }
}
Comment 1 Wim Taymans 2008-05-14 13:43:10 UTC
        Patch by: Bernard B <b-gnome at largestprime dot net>

        * gst-libs/gst/rtp/gstrtpbuffer.c: (gst_rtp_buffer_compare_seqnum):
        Fix seqnum compare function for bordercase values and fix the docs 
        again. Fixes #533075.

        * tests/check/libs/rtp.c: (GST_START_TEST), (rtp_suite):
        Add a testcase for seqnum compare function.