From 65cfafb3b90835c7aaf59c681bdc938ac7a0a16b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Tue, 7 Aug 2012 17:35:48 +0200 Subject: [PATCH] basesrc: getters for pool and allocator 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 | 45 ++++++++++++++++++++++++++++++++++++++ libs/gst/base/gstbasesrc.h | 6 +++++ 2 files changed, 51 insertions(+) diff --git a/libs/gst/base/gstbasesrc.c b/libs/gst/base/gstbasesrc.c index 56fd861503..ab0ff084bd 100644 --- a/libs/gst/base/gstbasesrc.c +++ b/libs/gst/base/gstbasesrc.c @@ -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; +} diff --git a/libs/gst/base/gstbasesrc.h b/libs/gst/base/gstbasesrc.h index 289b77a674..b0ae337c46 100644 --- a/libs/gst/base/gstbasesrc.h +++ b/libs/gst/base/gstbasesrc.h @@ -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__ */