inputselector: handle gap events
authorThiago Santos <ts.santos@sisa.samsung.com>
Mon, 18 Nov 2013 21:11:56 +0000 (18:11 -0300)
committerThiago Santos <ts.santos@sisa.samsung.com>
Fri, 29 Nov 2013 18:03:44 +0000 (15:03 -0300)
Use gap events to advance the selector's pad position.

This is relevant to keep sync_streams mode working when one of the
streams doesn't have data all the time.

plugins/elements/gstinputselector.c

index 7eda5a2..84e2c7b 100644 (file)
@@ -553,6 +553,27 @@ gst_selector_pad_event (GstPad * pad, GstObject * parent, GstEvent * event)
       }
       GST_DEBUG_OBJECT (pad, "received EOS");
       break;
+    case GST_EVENT_GAP:{
+      GstClockTime ts, dur;
+
+      GST_DEBUG_OBJECT (pad, "Received gap event: %" GST_PTR_FORMAT, event);
+
+      gst_event_parse_gap (event, &ts, &dur);
+      if (GST_CLOCK_TIME_IS_VALID (ts)) {
+        if (GST_CLOCK_TIME_IS_VALID (dur))
+          ts += dur;
+
+        /* update the segment position */
+        GST_OBJECT_LOCK (pad);
+        selpad->position = ts;
+        selpad->segment.position = ts;
+        GST_OBJECT_UNLOCK (pad);
+        if (sel->sync_streams && active_sinkpad == pad)
+          GST_INPUT_SELECTOR_BROADCAST (sel);
+      }
+
+    }
+      break;
     default:
       break;
   }