videodecoder: getters for pool and allocator
authorVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Mon, 6 Aug 2012 18:18:30 +0000 (20:18 +0200)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Tue, 14 Aug 2012 13:47:04 +0000 (15:47 +0200)
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
gst-libs/gst/video/gstvideodecoder.h

index 05c9bd0..59449c4 100644 (file)
@@ -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;
+}
index 980c42d..49e080f 100644 (file)
@@ -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 */