basesrc: getters for pool and allocator
authorVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Tue, 7 Aug 2012 15:35:48 +0000 (17:35 +0200)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Tue, 14 Aug 2012 13:45:14 +0000 (15:45 +0200)
Sometimes the sources would use the buffer pool or the memory allocator for
something else than just allocating output buffers; for example, querying for
different parameters, such as a bigger number of buffers to allocate by the
pool.

This patch expose a two getters accessors: one for the buffer pool and the
other for the memory allocator.

libs/gst/base/gstbasesrc.c
libs/gst/base/gstbasesrc.h

index 56fd861..ab0ff08 100644 (file)
@@ -3626,3 +3626,48 @@ failure:
     return result;
   }
 }
+
+/**
+ * gst_base_src_get_buffer_pool:
+ * @src: a #GstBaseSrc
+ *
+ * Returns: (transfer full): the instance of the #GstBufferPool used
+ * by the src; free it after use it
+ */
+GstBufferPool *
+gst_base_src_get_buffer_pool (GstBaseSrc * src)
+{
+  g_return_val_if_fail (GST_IS_BASE_SRC (src), NULL);
+
+  if (src->priv->pool)
+    return gst_object_ref (src->priv->pool);
+
+  return NULL;
+}
+
+/**
+ * gst_base_src_get_allocator:
+ * @src: a #GstBaseSrc
+ * @allocator: (out) (allow-none) (transfer full): the #GstAllocator
+ * used
+ * @params: (out) (allow-none) (transfer full): the
+ * #GstAllocatorParams of @allocator
+ *
+ * Lets #GstBaseSrc sub-classes to know the memory @allocator
+ * used by the base class and its @params.
+ *
+ * Unref the @allocator after use it.
+ */
+void
+gst_base_src_get_allocator (GstBaseSrc * src,
+    GstAllocator ** allocator, GstAllocationParams * params)
+{
+  g_return_if_fail (GST_IS_BASE_SRC (src));
+
+  if (allocator)
+    *allocator = src->priv->allocator ?
+        gst_object_ref (src->priv->allocator) : NULL;
+
+  if (params)
+    *params = src->priv->params;
+}
index 289b77a..b0ae337 100644 (file)
@@ -259,6 +259,12 @@ gboolean        gst_base_src_new_seamless_segment (GstBaseSrc *src, gint64 start
 
 gboolean        gst_base_src_set_caps         (GstBaseSrc *src, GstCaps *caps);
 
+GstBufferPool * gst_base_src_get_buffer_pool  (GstBaseSrc *src);
+void            gst_base_src_get_allocator    (GstBaseSrc *src,
+                                               GstAllocator **allocator,
+                                               GstAllocationParams *params);
+
+
 G_END_DECLS
 
 #endif /* __GST_BASE_SRC_H__ */