From efe9e31b345a1ca04f92114a95d698d1b34e1c7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Mon, 6 Aug 2012 20:18:30 +0200 Subject: [PATCH] videodecoder: getters for pool and allocator Sometimes the decoder would need to use the pool or the allocator for something else than just allocating output buffers. For example, the querying for different parameters, such as asking for a bigger number of buffers to allocate in the pool. This patch expose a two getters accessors: one for the buffer pool and the other for the memory allocator. --- gst-libs/gst/video/gstvideodecoder.c | 45 ++++++++++++++++++++++++++++ gst-libs/gst/video/gstvideodecoder.h | 4 +++ 2 files changed, 49 insertions(+) diff --git a/gst-libs/gst/video/gstvideodecoder.c b/gst-libs/gst/video/gstvideodecoder.c index 05c9bd0428..59449c476d 100644 --- a/gst-libs/gst/video/gstvideodecoder.c +++ b/gst-libs/gst/video/gstvideodecoder.c @@ -3141,3 +3141,48 @@ gst_video_decoder_merge_tags (GstVideoDecoder * decoder, decoder->priv->tags_changed = TRUE; GST_VIDEO_DECODER_STREAM_UNLOCK (decoder); } + +/** + * gst_video_decoder_get_buffer_pool: + * @decoder: a #GstVideoDecoder + * + * Returns: (transfer full): the instance of the #GstBufferPool used + * by the decoder; free it after use it + */ +GstBufferPool * +gst_video_decoder_get_buffer_pool (GstVideoDecoder * decoder) +{ + g_return_val_if_fail (GST_IS_VIDEO_DECODER (decoder), NULL); + + if (decoder->priv->pool) + return gst_object_ref (decoder->priv->pool); + + return NULL; +} + +/** + * gst_video_decoder_get_allocator: + * @decoder: a #GstVideoDecoder + * @allocator: (out) (allow-none) (transfer full): the #GstAllocator + * used + * @params: (out) (allow-none) (transfer full): the + * #GstAllocatorParams of @allocator + * + * Lets #GstVideoDecoder sub-classes to know the memory @allocator + * used by the base class and its @params. + * + * Unref the @allocator after use it. + */ +void +gst_video_decoder_get_allocator (GstVideoDecoder * decoder, + GstAllocator ** allocator, GstAllocationParams * params) +{ + g_return_if_fail (GST_IS_VIDEO_DECODER (decoder)); + + if (allocator) + *allocator = decoder->priv->allocator ? + gst_object_ref (decoder->priv->allocator) : NULL; + + if (params) + *params = decoder->priv->params; +} diff --git a/gst-libs/gst/video/gstvideodecoder.h b/gst-libs/gst/video/gstvideodecoder.h index 980c42d521..49e080f9fd 100644 --- a/gst-libs/gst/video/gstvideodecoder.h +++ b/gst-libs/gst/video/gstvideodecoder.h @@ -309,6 +309,10 @@ void gst_video_decoder_get_latency (GstVideoDecoder *decoder, GstClockTime *min_latency, GstClockTime *max_latency); +void gst_video_decoder_get_allocator (GstVideoDecoder *decoder, + GstAllocator **allocator, + GstAllocationParams *params); +GstBufferPool *gst_video_decoder_get_buffer_pool (GstVideoDecoder *decoder); /* Object methods */