videomixer: fix timestamp problems
authorWim Taymans <wim.taymans@collabora.co.uk>
Tue, 26 Jan 2010 17:33:27 +0000 (18:33 +0100)
committerWim Taymans <wim.taymans@collabora.co.uk>
Fri, 12 Feb 2010 12:53:57 +0000 (13:53 +0100)
When the pad with the highest framerate goes EOS, instead of not timestamping
output buffers, intepollate timestamps and durations from the last seen ones.

Fixes #608026

gst/videomixer/videomixer.c
gst/videomixer/videomixer.h

index 7c6c556..c4a6633 100644 (file)
@@ -641,6 +641,7 @@ gst_videomixer_reset (GstVideoMixer * mix)
   mix->fmt = GST_VIDEO_FORMAT_UNKNOWN;
 
   mix->last_ts = 0;
+  mix->last_duration = -1;
 
   /* clean up collect data */
   walk = mix->collect->data;
@@ -1165,10 +1166,13 @@ gst_videomixer_fill_queues (GstVideoMixer * mix)
       if (buf) {
         guint64 duration;
 
-        GST_LOG_OBJECT (mix, "we have a buffer !");
-
         mixcol->buffer = buf;
         duration = GST_BUFFER_DURATION (mixcol->buffer);
+
+        GST_LOG_OBJECT (mix, "we have a buffer with duration %" GST_TIME_FORMAT
+            ", queued %" GST_TIME_FORMAT, GST_TIME_ARGS (duration),
+            GST_TIME_ARGS (mixpad->queued));
+
         /* no duration on the buffer, use the framerate */
         if (!GST_CLOCK_TIME_IS_VALID (duration)) {
           if (mixpad->fps_n == 0) {
@@ -1183,6 +1187,9 @@ gst_videomixer_fill_queues (GstVideoMixer * mix)
           mixpad->queued += duration;
         else if (!mixpad->queued)
           mixpad->queued = GST_CLOCK_TIME_NONE;
+
+        GST_LOG_OBJECT (mix, "now queued: %" GST_TIME_FORMAT,
+            GST_TIME_ARGS (mixpad->queued));
       } else {
         GST_LOG_OBJECT (mix, "pop returned a NULL buffer");
       }
@@ -1377,13 +1384,18 @@ gst_videomixer_collected (GstCollectPads * pads, GstVideoMixer * mix)
     in_ts = GST_BUFFER_TIMESTAMP (mixcol->buffer);
 
     timestamp = gst_segment_to_running_time (seg, GST_FORMAT_TIME, in_ts);
+    duration = GST_BUFFER_DURATION (mixcol->buffer);
 
     mix->last_ts = timestamp;
-    duration = GST_BUFFER_DURATION (mixcol->buffer);
-    if (GST_CLOCK_TIME_IS_VALID (duration))
-      mix->last_ts += duration;
+    mix->last_duration = duration;
+  } else {
+    timestamp = mix->last_ts;
+    duration = mix->last_duration;
   }
 
+  if (GST_CLOCK_TIME_IS_VALID (duration))
+    mix->last_ts += duration;
+
   if (!gst_videomixer_do_qos (mix, timestamp)) {
     gst_videomixer_update_queues (mix);
     GST_VIDEO_MIXER_STATE_UNLOCK (mix);
index 72b3a57..4075416 100644 (file)
@@ -82,6 +82,7 @@ struct _GstVideoMixer
   gint numpads;
 
   GstClockTime last_ts;
+  GstClockTime last_duration;
 
   /* the master pad */
   GstVideoMixerPad *master;
@@ -97,7 +98,7 @@ struct _GstVideoMixer
 
   gint fps_n;
   gint fps_d;
-  
+
   /* Next available sinkpad index */
   gint next_sinkpad;