rtpdtmfsrc: Make sure rtpdtmfsrc timestamps don't overlap
authorOlivier Crête <olivier.crete@collabora.com>
Tue, 12 Jul 2011 00:47:23 +0000 (20:47 -0400)
committerOlivier Crête <olivier.crete@collabora.com>
Wed, 24 Aug 2011 16:24:17 +0000 (12:24 -0400)
gst/dtmf/gstrtpdtmfsrc.c

index 19acc6cae649e4a8455df21345ac6438278c289b..90e63fc6e10ddf77e09ee049e7343ec858d941a0 100644 (file)
@@ -506,7 +506,6 @@ gst_rtp_dtmf_prepare_timestamps (GstRTPDTMFSrc * dtmfsrc)
   GST_OBJECT_UNLOCK (dtmfsrc);
 
   if (GST_CLOCK_TIME_IS_VALID (last_stop)) {
-    dtmfsrc->timestamp = last_stop;
     dtmfsrc->start_timestamp = last_stop;
   } else {
     GstClock *clock = gst_element_get_clock (GST_ELEMENT (dtmfsrc));
@@ -516,10 +515,15 @@ gst_rtp_dtmf_prepare_timestamps (GstRTPDTMFSrc * dtmfsrc)
 
     dtmfsrc->start_timestamp = gst_clock_get_time (clock)
         - gst_element_get_base_time (GST_ELEMENT (dtmfsrc));
-    dtmfsrc->start_timestamp = dtmfsrc->timestamp;
     gst_object_unref (clock);
   }
 
+  /* If the last stop was in the past, then lets add the buffers together */
+  if (dtmfsrc->start_timestamp < dtmfsrc->timestamp)
+    dtmfsrc->start_timestamp = dtmfsrc->timestamp;
+
+  dtmfsrc->timestamp = dtmfsrc->start_timestamp;
+
   dtmfsrc->rtp_timestamp = dtmfsrc->ts_base +
       gst_util_uint64_scale_int (gst_segment_to_running_time (&GST_BASE_SRC
           (dtmfsrc)->segment, GST_FORMAT_TIME, dtmfsrc->timestamp),
@@ -976,6 +980,7 @@ gst_rtp_dtmf_src_ready_to_paused (GstRTPDTMFSrc * dtmfsrc)
   else
     dtmfsrc->ts_base = dtmfsrc->ts_offset;
 
+  dtmfsrc->timestamp = 0;
 }
 
 static GstStateChangeReturn