rndbuffersize: send SEGMENT event before pushing buffers
authorTim-Philipp Müller <tim.muller@collabora.co.uk>
Tue, 8 May 2012 17:45:34 +0000 (18:45 +0100)
committerTim-Philipp Müller <tim.muller@collabora.co.uk>
Wed, 9 May 2012 10:39:34 +0000 (11:39 +0100)
Conflicts:

gst/debugutils/rndbuffersize.c

gst/debugutils/rndbuffersize.c

index 99ffcbe..b23e687 100644 (file)
@@ -23,7 +23,7 @@
  */
 
 #ifdef HAVE_CONFIG_H
-#  include "config.h"
+#include "config.h"
 #endif
 
 #include <gst/gst.h>
@@ -51,6 +51,8 @@ struct _GstRndBufferSize
 
   GstPad *sinkpad, *srcpad;
   guint64 offset;
+
+  gboolean need_newsegment;
 };
 
 struct _GstRndBufferSizeClass
@@ -259,6 +261,7 @@ gst_rnd_buffer_size_activate_mode (GstPad * pad, GstObject * parent,
         res =
             gst_pad_start_task (pad, (GstTaskFunction) gst_rnd_buffer_size_loop,
             self);
+        self->need_newsegment = TRUE;
       } else {
         GST_INFO_OBJECT (self, "stopping pull");
         res = gst_pad_stop_task (pad);
@@ -302,6 +305,15 @@ gst_rnd_buffer_size_loop (GstRndBufferSize * self)
     GST_WARNING_OBJECT (self, "short buffer: %u bytes", size);
   }
 
+  if (self->need_newsegment) {
+    GstSegment segment;
+
+    gst_segment_init (&segment, GST_FORMAT_BYTES);
+    segment.start = self->offset;
+    gst_pad_push_event (self->srcpad, gst_event_new_segment (&segment));
+    self->need_newsegment = FALSE;
+  }
+
   self->offset += size;
 
   ret = gst_pad_push (self->srcpad, buf);