gst/rtpmanager/rtpjitterbuffer.*: Fix undefined overflow prone ts_diff handling.
authorWim Taymans <wim.taymans@gmail.com>
Tue, 21 Aug 2007 16:04:47 +0000 (16:04 +0000)
committerTim-Philipp Müller <tim.muller@collabora.co.uk>
Tue, 11 Aug 2009 01:30:28 +0000 (02:30 +0100)
Original commit message from CVS:
* gst/rtpmanager/rtpjitterbuffer.c:
(rtp_jitter_buffer_get_ts_diff):
* gst/rtpmanager/rtpjitterbuffer.h:
Fix undefined overflow prone ts_diff handling.

gst/rtpmanager/rtpjitterbuffer.c
gst/rtpmanager/rtpjitterbuffer.h

index 1ba1c8195e9f231f4a1a6c10201717a0c846829d..c36a25c5fe0a64886df510d63d16e0365431f3a6 100644 (file)
@@ -215,8 +215,9 @@ rtp_jitter_buffer_num_packets (RTPJitterBuffer * jbuf)
 guint32
 rtp_jitter_buffer_get_ts_diff (RTPJitterBuffer * jbuf)
 {
-  guint32 high_ts, low_ts;
+  guint64 high_ts, low_ts;
   GstBuffer *high_buf, *low_buf;
+  guint32 result;
 
   g_return_val_if_fail (jbuf != NULL, 0);
 
@@ -231,8 +232,9 @@ rtp_jitter_buffer_get_ts_diff (RTPJitterBuffer * jbuf)
 
   /* it needs to work if ts wraps */
   if (high_ts >= low_ts) {
-    return high_ts - low_ts;
+    result = (guint32) (high_ts - low_ts);
   } else {
-    return high_ts + G_MAXUINT32 + 1 - low_ts;
+    result = (guint32) (high_ts + G_MAXUINT32 + 1 - low_ts);
   }
+  return result;
 }
index 14b5b3f2b6969dd9a5bf31dde10b796abb18b4c6..8bff03c89bbe3f3d4595954f76de67fe1135184f 100644 (file)
@@ -62,6 +62,4 @@ void                  rtp_jitter_buffer_flush          (RTPJitterBuffer *jbuf);
 guint                 rtp_jitter_buffer_num_packets    (RTPJitterBuffer *jbuf);
 guint32               rtp_jitter_buffer_get_ts_diff    (RTPJitterBuffer *jbuf);
 
-
-
 #endif /* __RTP_JITTER_BUFFER_H__ */