capsfilter: fix refcounting problem
authorWim Taymans <wim.taymans@collabora.co.uk>
Wed, 5 Aug 2009 11:46:42 +0000 (13:46 +0200)
committerWim Taymans <wim.taymans@collabora.co.uk>
Thu, 6 Aug 2009 08:52:45 +0000 (10:52 +0200)
Make sure the metadata is writable before setting the caps on a buffer.

plugins/elements/gstcapsfilter.c

index 1a02b84..9d7a81a 100644 (file)
@@ -306,9 +306,15 @@ gst_capsfilter_prepare_buf (GstBaseTransform * trans, GstBuffer * input,
     /* FIXME : Move this behaviour to basetransform. The given caps are the ones
      * of the source pad, therefore our outgoing buffers should always have
      * those caps. */
-    gst_buffer_set_caps (input, caps);
-    gst_buffer_ref (input);
-    *buf = input;
+    if (gst_buffer_is_metadata_writable (input)) {
+      *buf = input;
+      gst_buffer_set_caps (*buf, caps);
+      gst_buffer_ref (input);
+    } else {
+      GST_DEBUG_OBJECT (trans, "Creating sub-buffer and setting caps");
+      *buf = gst_buffer_create_sub (input, 0, GST_BUFFER_SIZE (input));
+      gst_buffer_set_caps (*buf, caps);
+    }
   } else {
     /* Buffer has no caps. See if the output pad only supports fixed caps */
     GstCaps *out_caps;