Index: libs/gst/base/gstcollectpads.c
===================================================================
RCS file: /cvs/gstreamer/gstreamer/libs/gst/base/gstcollectpads.c,v
retrieving revision 1.52
diff -u -p -r1.52 gstcollectpads.c
--- libs/gst/base/gstcollectpads.c	3 Feb 2008 12:04:21 -0000	1.52
+++ libs/gst/base/gstcollectpads.c	14 Feb 2008 09:46:04 -0000
@@ -806,7 +806,7 @@ not_filled:
  * @size: the number of bytes to read
  *
  * Get a pointer in @bytes where @size bytes can be read from the
- * given pad data.
+ * given pad @data.
  *
  * This function should be called with @pads LOCK held, such as
  * in the callback.
@@ -841,6 +841,52 @@ gst_collect_pads_read (GstCollectPads * 
 }
 
 /**
+ * gst_collect_pads_take_buffer:
+ * @pads: the collectspads to query
+ * @data: the data to use
+ * @size: the number of bytes to read
+ *
+ * Get a subbuffer of @size bytes from the given pad @data.
+ *
+ * This function should be called with @pads LOCK held, such as
+ * in the callback.
+ *
+ * Since: 0.10.18
+ *
+ * Returns: A sub buffer. The size of the buffer can be less that requested.
+ * A return of NULL signals that the pad is end-of-stream.
+ * Unref the buffer after use.
+ *
+ * MT safe.
+ */
+GstBuffer *
+gst_collect_pads_take_buffer (GstCollectPads * pads, GstCollectData * data,
+    guint size)
+{
+  guint readsize;
+  GstBuffer *buffer, *result;
+
+  g_return_val_if_fail (pads != NULL, 0);
+  g_return_val_if_fail (GST_IS_COLLECT_PADS (pads), 0);
+  g_return_val_if_fail (data != NULL, 0);
+
+  /* no buffer, must be EOS */
+  if ((buffer = data->buffer) == NULL)
+    return NULL;
+
+  readsize = MIN (size, GST_BUFFER_SIZE (buffer) - data->pos);
+
+  result = gst_buffer_create_sub (buffer, data->pos, readsize);
+  //GST_WARNING("buffer flags %lx, %lx", 
+  //  GST_BUFFER_FLAGS (buffer)>>4, GST_BUFFER_FLAGS (result)>>4);
+
+  /* behave similar to gst_adapter_take_buffer() */
+  gst_collect_pads_flush (pads, data, readsize);
+
+  return result;
+}
+
+/**
  * gst_collect_pads_flush:
  * @pads: the collectspads to query
  * @data: the data to use
Index: libs/gst/base/gstcollectpads.h
===================================================================
RCS file: /cvs/gstreamer/gstreamer/libs/gst/base/gstcollectpads.h,v
retrieving revision 1.22
diff -u -p -r1.22 gstcollectpads.h
--- libs/gst/base/gstcollectpads.h	10 Jul 2007 20:10:16 -0000	1.22
+++ libs/gst/base/gstcollectpads.h	14 Feb 2008 09:46:04 -0000
@@ -180,6 +180,8 @@ GstBuffer*	gst_collect_pads_pop		(GstCol
 guint 		gst_collect_pads_available 	(GstCollectPads *pads);
 guint		gst_collect_pads_read		(GstCollectPads *pads, GstCollectData *data,
 						 guint8 **bytes, guint size);
+GstBuffer *      gst_collect_pads_take_buffer      (GstCollectPads * pads, GstCollectData * data,
+						 guint size);
 guint 		gst_collect_pads_flush 		(GstCollectPads *pads, GstCollectData *data,
 						 guint size);
 
