typefind: Propagate input buffer offset
authorEdward Hervey <bilboed@bilboed.com>
Tue, 4 Nov 2014 18:11:50 +0000 (19:11 +0100)
committerEdward Hervey <bilboed@bilboed.com>
Mon, 1 Dec 2014 09:47:01 +0000 (10:47 +0100)
The initial buffers might have non-default offsets, make sure they get
propagated if present.

plugins/elements/gsttypefindelement.c
plugins/elements/gsttypefindelement.h

index e8977fd..9f85582 100644 (file)
@@ -524,6 +524,7 @@ start_typefinding (GstTypeFindElement * typefind)
   GST_OBJECT_LOCK (typefind);
   if (typefind->caps)
     gst_caps_replace (&typefind->caps, NULL);
+  typefind->initial_offs = (guint64) - 1;
   GST_OBJECT_UNLOCK (typefind);
 
   typefind->mode = MODE_TYPEFIND;
@@ -559,6 +560,7 @@ stop_typefinding (GstTypeFindElement * typefind)
   buffer = gst_adapter_take_buffer (typefind->adapter, avail);
   GST_BUFFER_PTS (buffer) = pts;
   GST_BUFFER_DTS (buffer) = dts;
+  GST_BUFFER_OFFSET (buffer) = typefind->initial_offs;
   GST_OBJECT_UNLOCK (typefind);
 
   if (!push_cached_buffers) {
@@ -839,6 +841,8 @@ gst_type_find_element_chain (GstPad * pad, GstObject * parent,
     case MODE_TYPEFIND:
     {
       GST_OBJECT_LOCK (typefind);
+      if (typefind->initial_offs == GST_CLOCK_TIME_NONE)
+        typefind->initial_offs = GST_BUFFER_OFFSET (buffer);
       gst_adapter_push (typefind->adapter, buffer);
       GST_OBJECT_UNLOCK (typefind);
 
index 3551ac5..7093a82 100644 (file)
@@ -59,6 +59,8 @@ struct _GstTypeFindElement {
   GList *               cached_events;
   GstCaps *             force_caps;
 
+  guint64              initial_offs;
+  
   /* Only used when driving the pipeline */
   gboolean need_segment;
   gboolean need_stream_start;