[MOVED FROM GST-P-FARSIGHT] Improve the minimum quanta to make it impossible for...
authorOlivier CrĂȘte <olivier.crete@collabora.co.uk>
Fri, 5 Dec 2008 02:11:17 +0000 (21:11 -0500)
committerEdward Hervey <bilboed@bilboed.com>
Sat, 21 Feb 2009 16:48:07 +0000 (17:48 +0100)
gst/dtmf/gstrtpdtmfdepay.c

index 8e82865..85dac6f 100644 (file)
@@ -371,8 +371,19 @@ gst_rtp_dtmf_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
 
   /* clip to whole units of unit_time */
   if (rtpdtmfdepay->unit_time)
-    dtmf_payload.duration -= dtmf_payload.duration %
-        ((rtpdtmfdepay->unit_time * depayload->clock_rate) / 1000);
+  {
+    guint unit_time_clock =
+        (rtpdtmfdepay->unit_time * depayload->clock_rate) / 1000;
+    if (dtmf_payload.duration % unit_time_clock)
+    {
+      /* Make sure we don't overflow the duration */
+      if (dtmf_payload.duration < G_MAXUINT16 - unit_time_clock)
+        dtmf_payload.duration += unit_time_clock -
+            (dtmf_payload.duration % unit_time_clock);
+      else
+        dtmf_payload.duration -= dtmf_payload.duration % unit_time_clock;
+    }
+  }
 
   GST_DEBUG_OBJECT (depayload, "Received new RTP DTMF packet : "
       "marker=%d - timestamp=%u - event=%d - duration=%d",