appsrc: Update segment duration and post a duration message if the duration changes
authorSebastian Dröge <sebastian.droege@collabora.co.uk>
Tue, 9 Feb 2010 16:39:21 +0000 (17:39 +0100)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Fri, 12 Feb 2010 10:00:08 +0000 (11:00 +0100)
Fixes bug #609423.

gst-libs/gst/app/gstappsrc.c

index 32a0596..6b9512b 100644 (file)
@@ -1049,13 +1049,26 @@ gst_app_src_get_caps (GstAppSrc * appsrc)
 void
 gst_app_src_set_size (GstAppSrc * appsrc, gint64 size)
 {
+  GstSegment *segment;
+  gboolean bytes_segment;
+
   g_return_if_fail (appsrc != NULL);
   g_return_if_fail (GST_IS_APP_SRC (appsrc));
 
   GST_OBJECT_LOCK (appsrc);
   GST_DEBUG_OBJECT (appsrc, "setting size of %" G_GINT64_FORMAT, size);
   appsrc->priv->size = size;
+
+  segment = &GST_BASE_SRC_CAST (appsrc)->segment;
+  bytes_segment = (segment->format == GST_FORMAT_BYTES);
+
+  if (bytes_segment)
+    gst_segment_set_duration (segment, GST_FORMAT_BYTES, size);
   GST_OBJECT_UNLOCK (appsrc);
+
+  if (bytes_segment)
+    gst_element_post_message (GST_ELEMENT (appsrc),
+        gst_message_new_duration (GST_OBJECT (appsrc), GST_FORMAT_BYTES, size));
 }
 
 /**