basetransform: getters for pool and allocator
authorVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Tue, 7 Aug 2012 15:38:53 +0000 (17:38 +0200)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Tue, 14 Aug 2012 13:45:21 +0000 (15:45 +0200)
Sometimes a transform filter would need the buffer pool or the memory
allocator negotiated by the base class, for example, for querying different
parameters, such as a bigger number of buffers to allocate by the buffer pool.

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

libs/gst/base/gstbasetransform.c
libs/gst/base/gstbasetransform.h

index 3a8664d9093c02156a20329ca6f97f6bff250390..94396c3f36c2ccde8f9ee67076a63cec925cfd29 100644 (file)
@@ -2619,3 +2619,48 @@ gst_base_transform_reconfigure_src (GstBaseTransform * trans)
 
   gst_pad_mark_reconfigure (trans->srcpad);
 }
+
+/**
+ * gst_base_transform_get_buffer_pool:
+ * @trans: a #GstBaseTransform
+ *
+ * Returns: (transfer full): the instance of the #GstBufferPool used
+ * by @trans; free it after use it
+ */
+GstBufferPool *
+gst_base_transform_get_buffer_pool (GstBaseTransform * trans)
+{
+  g_return_val_if_fail (GST_IS_BASE_TRANSFORM (trans), NULL);
+
+  if (trans->priv->pool)
+    return gst_object_ref (trans->priv->pool);
+
+  return NULL;
+}
+
+/**
+ * gst_base_transform_get_allocator:
+ * @trans: a #GstBaseTransform
+ * @allocator: (out) (allow-none) (transfer full): the #GstAllocator
+ * used
+ * @params: (out) (allow-none) (transfer full): the
+ * #GstAllocatorParams of @allocator
+ *
+ * Lets #GstBaseTransform sub-classes to know the memory @allocator
+ * used by the base class and its @params.
+ *
+ * Unref the @allocator after use it.
+ */
+void
+gst_base_transform_get_allocator (GstBaseTransform * trans,
+    GstAllocator ** allocator, GstAllocationParams * params)
+{
+  g_return_if_fail (GST_IS_BASE_TRANSFORM (trans));
+
+  if (allocator)
+    *allocator = trans->priv->allocator ?
+        gst_object_ref (trans->priv->allocator) : NULL;
+
+  if (params)
+    *params = trans->priv->params;
+}
index da961efddc388ff31c6a918c41428fd4ab9481be..e3df619537e3319ccfaa30bd0bb66d2910e9a1ef 100644 (file)
@@ -283,6 +283,11 @@ gboolean   gst_base_transform_is_qos_enabled   (GstBaseTransform *trans);
 void            gst_base_transform_set_gap_aware    (GstBaseTransform *trans,
                                                      gboolean gap_aware);
 
+GstBufferPool * gst_base_transform_get_buffer_pool  (GstBaseTransform *trans);
+void            gst_base_transform_get_allocator    (GstBaseTransform *trans,
+                                                     GstAllocator **allocator,
+                                                     GstAllocationParams *params);
+
 void           gst_base_transform_reconfigure_sink (GstBaseTransform *trans);
 void           gst_base_transform_reconfigure_src  (GstBaseTransform *trans);
 G_END_DECLS