In gstreamer, only one code is used to determine whether the RTP package seqnum is wraparound.

Source: Internet
Author: User
Let's look at this function: maid
Code: select all
gint
gst_rtp_buffer_compare_seqnum (guint16 seqnum1, guint16 seqnum2)
{
  return (gint16) (seqnum2 - seqnum1);
}



A simple code can be used to determine whether seqnum1 and seqnum2 have wraparound. The key point is the gint16 type conversion after return. Seqnum1, seqnum2 are all guint16, that is, unsigned short, and the return value is forcibly converted to gint16, that is, signed short. In this case, if seqnum2-seqnum1 <-32768, that is, wraparound occurs, the return value is a positive number. In other cases, if seqnum2-seqnum1> =-32768, in this case, a negative number is returned. Therefore, if the returned value is <0, seqnum2 <seqnum1 does not have wraparound. If the returned value is> 0, seqnum2> seqnum1 or wraparound occurs. In RTP, if wraparound occurs, seqnum2 is larger than seqnum1 logically even if seqnum2 is smaller than seqnum1, because seqnum2 is generated later.
As to why seqnum2-seqnum1 <-32768 is converted to gint16, it becomes a positive number. For more information, see the concept of negative numbers and supplementary codes in C.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.