videoencoder: getter for allocator
authorVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Tue, 7 Aug 2012 15:19:05 +0000 (17:19 +0200)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Tue, 14 Aug 2012 13:47:23 +0000 (15:47 +0200)
Sometimes the encoder would need to use the allocator for something else than
just allocating output buffers, for example, querying different parameters.

This patch expose a getter accessor for the negotiated memory allocator.

gst-libs/gst/video/gstvideoencoder.c
gst-libs/gst/video/gstvideoencoder.h

index bfff440..605ebf5 100644 (file)
@@ -2039,3 +2039,30 @@ gst_video_encoder_merge_tags (GstVideoEncoder * encoder,
   encoder->priv->tags_changed = TRUE;
   GST_VIDEO_ENCODER_STREAM_UNLOCK (encoder);
 }
+
+/**
+ * gst_video_encoder_get_allocator:
+ * @encoder: a #GstVideoEncoder
+ * @allocator: (out) (allow-none) (transfer full): the #GstAllocator
+ * used
+ * @params: (out) (allow-none) (transfer full): the
+ * #GstAllocatorParams of @allocator
+ *
+ * Lets #GstVideoEncoder sub-classes to know the memory @allocator
+ * used by the base class and its @params.
+ *
+ * Unref the @allocator after use it.
+ */
+void
+gst_video_encoder_get_allocator (GstVideoEncoder * encoder,
+    GstAllocator ** allocator, GstAllocationParams * params)
+{
+  g_return_if_fail (GST_IS_VIDEO_ENCODER (encoder));
+
+  if (allocator)
+    *allocator = encoder->priv->allocator ?
+        gst_object_ref (encoder->priv->allocator) : NULL;
+
+  if (params)
+    *params = encoder->priv->params;
+}
index 933e080..ffc45db 100644 (file)
@@ -298,6 +298,10 @@ void                 gst_video_encoder_merge_tags  (GstVideoEncoder *encoder,
                                                     const GstTagList *tags,
                                                     GstTagMergeMode mode);
 
+void                 gst_video_encoder_get_allocator (GstVideoEncoder *encoder,
+                                                      GstAllocator **allocator,
+                                                      GstAllocationParams *params);
+
 G_END_DECLS
 
 #endif